From 25a9316f2521781f336df87b9319bb242012fbb1 Mon Sep 17 00:00:00 2001 From: Shannon Appelcline Date: Wed, 2 Sep 2020 14:44:14 -1000 Subject: [PATCH] Create 17_3_sendtx.js --- src/17_3_sendtx.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/17_3_sendtx.js diff --git a/src/17_3_sendtx.js b/src/17_3_sendtx.js new file mode 100644 index 0000000..fdda4ae --- /dev/null +++ b/src/17_3_sendtx.js @@ -0,0 +1,22 @@ +const RpcAgent = require('bcrpc'); +agent = new RpcAgent({port: 18332, user: 'StandUp', pass: '6305f1b2dbb3bc5a16cd0 +f4aac7e1eba'}); + +agent.getNewAddress('-addresstype', 'legacy', function (err, newAddress) { + if (err) + throw Error(JSON.stringify(err)); + console.log("Recipient: " + newAddress.result); + + agent.sendToAddress(newAddress.result, 0.00001, function(err, txid) { + if (err) + throw Error(JSON.stringify(err)); + console.log("TXID: " + txid.result); + + agent.getTransaction(txid.result, function (err, transaction) { + if (err) + throw Error(JSON.stringify(err)); + console.log(transaction.result); + }); + }); + +});