mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 16:06:26 +00:00
Create 17_3_sendtx.js
This commit is contained in:
parent
b5dd11dc5c
commit
25a9316f25
22
src/17_3_sendtx.js
Normal file
22
src/17_3_sendtx.js
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user