diff --git a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs index 7cb6609c23..27b01929a0 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -198,9 +198,9 @@ impl wallet_server::Wallet for WalletGrpcServer { async fn identify(&self, _: Request) -> Result, Status> { let identity = self.wallet.comms.node_identity(); Ok(Response::new(GetIdentityResponse { - public_key: identity.public_key().to_string().into_bytes(), + public_key: identity.public_key().to_vec(), public_address: identity.public_address().to_string(), - node_id: identity.node_id().to_string().into_bytes(), + node_id: identity.node_id().to_vec(), })) } diff --git a/integration_tests/features/support/ffi_steps.js b/integration_tests/features/support/ffi_steps.js index 14ba852583..3c2b58a636 100644 --- a/integration_tests/features/support/ffi_steps.js +++ b/integration_tests/features/support/ffi_steps.js @@ -646,7 +646,7 @@ Then("I want to get public key of ffi wallet {word}", function (name) { let wallet = this.getWallet(name); let public_key = wallet.identify(); expect(public_key.length).to.be.equal( - 64, + 32, `Public key has wrong length : ${public_key}` ); }); @@ -723,7 +723,8 @@ Then( () => { let publicKeys = wallet.listConnectedPublicKeys(); return ( - publicKeys && publicKeys.some((p) => p === nodeIdentity.public_key) + publicKeys && + publicKeys.some((p) => p === nodeIdentity.public_key.toString("hex")) ); }, true, diff --git a/integration_tests/features/support/steps.js b/integration_tests/features/support/steps.js index 44ae055d78..3d2867c3a5 100644 --- a/integration_tests/features/support/steps.js +++ b/integration_tests/features/support/steps.js @@ -508,7 +508,9 @@ When( await waitForPredicate(async () => { let peers = await firstNodeClient.listConnectedPeers(); - return peers.some((p) => secondNodeIdentity.public_key === p.public_key); + return peers.some( + (p) => secondNodeIdentity.public_key.toString("hex") === p.public_key + ); }, 50 * 1000); } ); @@ -519,7 +521,11 @@ Then(/(.*) is connected to (.*)/, async function (firstNode, secondNode) { const secondNodeIdentity = await secondNodeClient.identify(); let peers = await firstNodeClient.listConnectedPeers(); expect( - peers.some((p) => secondNodeIdentity.public_key === p.public_key) + peers.some( + (p) => + secondNodeIdentity.public_key.toString("hex") === + p.public_key.toString("hex") + ) ).to.be.true; }); diff --git a/integration_tests/features/support/wallet_steps.js b/integration_tests/features/support/wallet_steps.js index 95646c2f59..b94a60c931 100644 --- a/integration_tests/features/support/wallet_steps.js +++ b/integration_tests/features/support/wallet_steps.js @@ -95,7 +95,7 @@ Given( this.addWallet(walletName, wallet); let walletClient = await this.getWallet(walletName).connectClient(); let walletInfo = await walletClient.identify(); - this.addWalletPubkey(walletName, walletInfo.public_key); + this.addWalletPubkey(walletName, walletInfo.public_key.toString("hex")); } ); @@ -114,7 +114,7 @@ Given( this.addWallet(name, wallet); let walletClient = await this.getWallet(name).connectClient(); let walletInfo = await walletClient.identify(); - this.addWalletPubkey(name, walletInfo.public_key); + this.addWalletPubkey(name, walletInfo.public_key.toString("hex")); } ); @@ -197,7 +197,7 @@ Given( this.addWallet(name, wallet); let walletClient = await this.getWallet(name).connectClient(); let walletInfo = await walletClient.identify(); - this.addWalletPubkey(name, walletInfo.public_key); + this.addWalletPubkey(name, walletInfo.public_key.toString("hex")); } ); @@ -245,7 +245,7 @@ Given( this.addWallet(walletNameB, walletB); let walletClient = await this.getWallet(walletNameB).connectClient(); let walletInfo = await walletClient.identify(); - this.addWalletPubkey(walletNameB, walletInfo.public_key); + this.addWalletPubkey(walletNameB, walletInfo.public_key.toString("hex")); } ); @@ -280,7 +280,10 @@ Given( recoveredWalletName ).connectClient(); let walletInfo = await walletClient.identify(); - this.addWalletPubkey(recoveredWalletName, walletInfo.public_key); + this.addWalletPubkey( + recoveredWalletName, + walletInfo.public_key.toString("hex") + ); } } ); @@ -312,7 +315,7 @@ Given( this.addWallet(i, wallet); let walletClient = await this.getWallet(i.toString()).connectClient(); let walletInfo = await walletClient.identify(); - this.addWalletPubkey(wallet, walletInfo.public_key); + this.addWalletPubkey(wallet, walletInfo.public_key.toString("hex")); } } ); @@ -528,7 +531,7 @@ When( try { this.lastResult = await sourceClient.sendHtlc({ recipient: { - address: destInfo.public_key, + address: destInfo.public_key.toString("hex"), amount: tariAmount, fee_per_gram: feePerGram, message: "msg", @@ -566,10 +569,13 @@ When( } if (success) { this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), + this.lastResult.transaction_id + ); + this.addTransaction( + destInfo.public_key.toString("hex"), this.lastResult.transaction_id ); - this.addTransaction(destInfo.public_key, this.lastResult.transaction_id); } expect(success).to.equal(true); //lets now wait for this transaction to be at least broadcast before we continue. @@ -643,7 +649,7 @@ When( if (success) { this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), this.lastResult.results.transaction_id ); } @@ -721,7 +727,7 @@ When( if (success) { this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), this.lastResult.results.transaction_id ); } @@ -754,7 +760,7 @@ When( const sourceClient = await sourceWallet.connectClient(); const sourceInfo = await sourceClient.identify(); - const destPublicKey = this.getWalletPubkey(dest); + const destPublicKey = this.getWalletPubkey(dest).toString("hex"); this.lastResult = await this.send_tari( sourceWallet, @@ -796,7 +802,7 @@ When( this.lastResult = await this.send_tari( this.getWallet(source), destInfo.name, - destInfo.public_key, + destInfo.public_key.toString("hex"), tariAmount, fee ); @@ -848,18 +854,18 @@ When( this.lastResult = await this.send_tari( this.getWallet(source), destInfo.name, - destInfo.public_key, + destInfo.public_key.toString("hex"), tariAmount, fee ); expect(this.lastResult.results[0].is_success).to.equal(true); tx_ids.push(this.lastResult.results[0].transaction_id); this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), this.lastResult.results[0].transaction_id ); this.addTransaction( - destInfo.public_key, + destInfo.public_key.toString("hex"), this.lastResult.results[0].transaction_id ); // console.log(" Transaction '" + this.lastResult.results[0]["transaction_id"] + "' is_success(" + @@ -914,13 +920,13 @@ When( lastResult = await sourceClient.transfer({ recipients: [ { - address: dest1Info.public_key, + address: dest1Info.public_key.toString("hex"), amount: tariAmount, fee_per_gram: feePerGram, message: "msg", }, { - address: dest2Info.public_key, + address: dest2Info.public_key.toString("hex"), amount: tariAmount, fee_per_gram: feePerGram, message: "msg", @@ -960,19 +966,19 @@ When( } if (success) { this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), lastResult.results[0].transaction_id ); this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), lastResult.results[1].transaction_id ); this.addTransaction( - dest1Info.public_key, + dest1Info.public_key.toString("hex"), lastResult.results[0].transaction_id ); this.addTransaction( - dest2Info.public_key, + dest2Info.public_key.toString("hex"), lastResult.results[1].transaction_id ); } @@ -989,14 +995,14 @@ When( this.lastResult = await this.send_tari( this.getWallet(source), sourceInfo.name, - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), tariAmount, feePerGram ); expect(this.lastResult.results[0].is_success).to.equal(true); this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), this.lastResult.results[0].transaction_id ); console.log( @@ -1040,7 +1046,7 @@ When( async () => { try { const recipients = destWallets.map((w) => ({ - address: w.public_key, + address: w.public_key.toString("hex"), amount: amount, fee_per_gram: feePerGram, message: "msg", @@ -1076,7 +1082,7 @@ When( const lastResult = await this.send_tari( sourceWallet, dest, - destPublicKey, + destPublicKey.toString("hex"), amount, feePerGram, PaymentType.ONE_SIDED @@ -1084,7 +1090,7 @@ When( expect(lastResult.results[0].is_success).to.equal(true); this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), lastResult.results[0].transaction_id ); //lets now wait for this transaction to be at least broadcast before we continue. @@ -1118,7 +1124,7 @@ When( const lastResult = await this.send_tari( sourceWallet, dest, - destPublicKey, + destPublicKey.toString("hex"), amount, feePerGram, PaymentType.ONE_SIDED_TO_STEALTH_ADDRESS @@ -1126,7 +1132,7 @@ When( expect(lastResult.results[0].is_success).to.equal(true); this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), lastResult.results[0].transaction_id ); //lets now wait for this transaction to be at least broadcast before we continue. @@ -1158,7 +1164,10 @@ When( const lastResult = await this.burn_tari(sourceWallet, amount, feePerGram); expect(lastResult.is_success).to.equal(true); - this.addTransaction(sourceInfo.public_key, lastResult.transaction_id); + this.addTransaction( + sourceInfo.public_key.toString("hex"), + lastResult.transaction_id + ); //lets now wait for this transaction to be at least broadcast before we continue. await waitFor( async () => @@ -1262,7 +1271,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1312,7 +1323,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1420,7 +1433,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1469,7 +1484,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1518,7 +1535,7 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - let txIds = this.transactionsMap.get(walletInfo.public_key); + let txIds = this.transactionsMap.get(walletInfo.public_key.toString("hex")); console.log(walletName, txIds); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); @@ -1568,7 +1585,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1617,7 +1636,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1665,7 +1686,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1713,7 +1736,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1761,7 +1786,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1809,7 +1836,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -1855,7 +1884,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); const nodeClient = this.getClient(nodeName); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); throw new Error("No transactions for " + walletName + "!"); @@ -1916,7 +1947,9 @@ Then( const walletClient = await wallet.connectClient(); const walletInfo = await walletClient.identify(); - const txIds = this.transactionsMap.get(walletInfo.public_key); + const txIds = this.transactionsMap.get( + walletInfo.public_key.toString("hex") + ); if (txIds === undefined) { console.log("\nNo transactions for " + walletName + "!"); expect(false).to.equal(true); @@ -2295,7 +2328,7 @@ When( " completed with TxId: ", result ); - this.addTransaction(walletInfo.public_key, result.tx_id); + this.addTransaction(walletInfo.public_key.toString("hex"), result.tx_id); this.lastResult = result; } } @@ -2318,7 +2351,6 @@ When( const sourceInfo = await sourceWalletClient.identify(); const destWalletClient = await this.getWallet(destWallet).connectClient(); const destInfo = await destWalletClient.identify(); - console.log( "Sending", numTransactions, @@ -2330,11 +2362,12 @@ When( let batch = 1; let tx_ids = []; + for (let i = 0; i < numTransactions; i++) { const result = await this.send_tari( this.getWallet(sourceWallet), destInfo.name, - destInfo.public_key, + destInfo.public_key.toString("hex"), amount, feePerGram, false, @@ -2344,11 +2377,11 @@ When( expect(result.results[0].is_success).to.equal(true); tx_ids.push(result.results[0].transaction_id); this.addTransaction( - sourceInfo.public_key, + sourceInfo.public_key.toString("hex"), result.results[0].transaction_id ); this.addTransaction( - destInfo.public_key, + destInfo.public_key.toString("hex"), result.results[0].transaction_id ); diff --git a/integration_tests/features/support/world.js b/integration_tests/features/support/world.js index 37db97cfa8..3ca31fc4ca 100644 --- a/integration_tests/features/support/world.js +++ b/integration_tests/features/support/world.js @@ -147,7 +147,7 @@ class CustomWorld { this.addWallet(name, wallet); let walletClient = await wallet.connectClient(); let walletInfo = await walletClient.identify(); - this.walletPubkeys[name] = walletInfo.public_key; + this.walletPubkeys[name] = walletInfo.public_key.toString("hex"); } async createAndAddFFIWallet(name, seed_words = null, passphrase = null) { @@ -608,7 +608,7 @@ class CustomWorld { const sourceClient = await sourceWallet.connectClient(); const sourceInfo = await sourceClient.identify(); - const destPublicKey = this.getWalletPubkey(dest); + const destPublicKey = this.getWalletPubkey(dest).toString("hex"); this.lastResult = await this.send_tari( sourceWallet, diff --git a/integration_tests/helpers/walletClient.js b/integration_tests/helpers/walletClient.js index 962a24114e..55a957a08e 100644 --- a/integration_tests/helpers/walletClient.js +++ b/integration_tests/helpers/walletClient.js @@ -180,9 +180,9 @@ class WalletClient { async identify() { const info = await this.client.identify(); return { - public_key: info.public_key.toString("utf8"), + public_key: info.public_key, public_address: info.public_address, - node_id: info.node_id.toString("utf8"), + node_id: info.node_id, }; }