diff --git a/README.md b/README.md index bfc03bd..5b2ae4d 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,18 @@ Please note that the initial transaction was at 1% fees which are now 0.78% as s We will follow this transaction for our examples, the previous transaction was [d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206](https://btgexp.com/tx/d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206) +### The easy way + +Once you know this module (if not please read what follows), most likely you will do: + + node tx.js BTG create prevtx= prevaddr= prevamount= previndex= privkey= addr= fees= + + node tx.js BTG send + +The module will calculate the amount to be spent according to the fees and advise if the numbers are not coherent: + + amount+dev fees+network fees=prevamount + ### Important - Understanding transactions In our example we are going to spend output 31 of transaction d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206 with a prevamount of 0.00998277 that belongs to us since GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo is one of our addresses, with 0.00001001 network fees diff --git a/example-2.js b/example-2.js index 4bfa816..7bd0e1e 100644 --- a/example-2.js +++ b/example-2.js @@ -1,208 +1,208 @@ -https://btgexp.com/tx/cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 - -node tx.js BTG testamount prevamount=0.00998277 fees=0.00001001 amount=0.005 - -/* ---- Previous amount is: 0.00998277 ---- Amount to spend is: 0.00500000 ---- Network fees are: 0.00001001 ---- Dev fees are: 0.00008500 ---- Refunded amount to spending address is: 0.00488776 -*/ - -node tx.js BTG create prevtx=d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206 prevaddr=GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo prevamount=0.00998277 previndex=31 privkey=privkey addr=GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB amount=0.005 fees=0.00001001 - -/* -Version BTG -create -Creating transaction to send 0.005 (without fees) to GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB from output number 31 with amount 0.00998277 owned by GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo in transaction d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206 ---- Previous amount is: 0.00998277 ---- Amount to spend is: 0.00500000 ---- Network fees are: 0.00001001 ---- Dev fees are: 0.00008500 ---- Refunded amount to spending address is: 0.00488776 -Address corresponding to private key is GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo ------ Transaction hash: cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 -Transaction body: -020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 -Complete transaction: -e1476d4474780000000000000000000003010000d42bb13a020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 -Size 283 bytes -Network Fees: 1002 - 3.54 satoshis/byte -Dev Fees: 8500 -------------- Check - deserialize -{ input: - [ { hash: 'd5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206', - n: 31, - scriptSigLen: , - scriptSig: [Object], - data: null, - nSequence: } ], - output: - [ { nValue: 500000, - scriptPubkeyLen: , - scriptPubkey: , - address: 'GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB', - type: 'p2pkh' }, - { nValue: 488775, - scriptPubkeyLen: , - scriptPubkey: , - address: 'GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo', - type: 'p2pkh' }, - { nValue: 8500, - scriptPubkeyLen: , - scriptPubkey: , - address: 'GSBbeuKPu4d6HKJhtPgk7XayMcaXyQy8TS', - type: 'p2pkh' } ], - s: 0, - nVersion: , - nbinput: 1, - nboutput: 3, - nLockTime: } -------------- End Check - deserialize -------------- Check - verify ------ Transaction hash: cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 -signature: 3044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f075 -message to be signed: 020000004ee41cbd7a9495aeff29b1827648a8855b64105bc2c10e83bf9280c73076d8a53bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e7066504406e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac853b0f0000000000ffffffff8ea3b70975d956ba80b33d58cc1dcadceb5eb4cda36eb66e1a183db25069043100000000414f0000 ------ Transaction verified ------ Transaction hash: cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 -------------- End Check - verify -*/ - -node tx.js BTG decode 020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 - -/* -Version BTG -decode -{ input: - [ { hash: 'd5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206', - n: 31, - scriptSigLen: , - scriptSig: [Object], - data: null, - nSequence: } ], - output: - [ { nValue: 500000, - scriptPubkeyLen: , - scriptPubkey: , - address: 'GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB', - type: 'p2pkh' }, - { nValue: 488775, - scriptPubkeyLen: , - scriptPubkey: , - address: 'GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo', - type: 'p2pkh' }, - { nValue: 8500, - scriptPubkeyLen: , - scriptPubkey: , - address: 'GSBbeuKPu4d6HKJhtPgk7XayMcaXyQy8TS', - type: 'p2pkh' } ], - s: 0, - nVersion: , - nbinput: 1, - nboutput: 3, - nLockTime: } -*/ - -node tx.js BTG testconnect A.B.47.27 - -/* -Version BTG -testconnect -Sending to A.B.47.27 -Connected to : A.B.47.27:8338 -Sent version to A.B.47.27 ------- Answer receiced from A.B.47.27 -version ------- Answer receiced from A.B.47.27 -verack --------- Verack received - completing handshake with A.B.47.27 ------- Answer receiced from A.B.47.27 -sendheaders ------- Answer receiced from A.B.47.27 -ping -addr -getheaders -feefilter -End connection with A.B.47.27:8338 -*/ - -node tx.js BTG send e1476d4474780000000000000000000003010000d42bb13a020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 A.B.47.27 - -/* -Version BTG -send -Sending to A.B.47.27 -Connected to : A.B.47.27:8338 -Sent version to A.B.47.27 ------- Answer receiced from A.B.47.27 -version ------- Answer receiced from A.B.47.27 -verack --------- Verack received - completing handshake with A.B.47.27 ------- Sending transaction to A.B.47.27 -Sent e1476d4474780000000000000000000003010000d42bb13a020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 to A.B.47.27 ------- Answer receiced from A.B.47.27 -sendheaders ------- Answer receiced from A.B.47.27 -ping -addr -getheaders -feefilter -End connection with A.B.47.27:8338 -*/ -//Check with cli if you can -bgold-cli gettransaction cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 - -/* -{ - "amount": 0.00000000, - "fee": -0.00001002, - "confirmations": 0, - "trusted": true, - "txid": "cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4", - "walletconflicts": [ - ], - "time": 1511873524, - "timereceived": 1511873524, - "bip125-replaceable": "no", - "details": [ - { - "account": "", - "address": "GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB", - "category": "send", - "amount": -0.00500000, - "label": "", - "vout": 0, - "fee": -0.00001002, - "abandoned": false - }, - { - "account": "", - "address": "GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo", - "category": "send", - "amount": -0.00488775, - "label": "", - "vout": 1, - "fee": -0.00001002, - "abandoned": false - }, - { - "account": "", - "address": "GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB", - "category": "receive", - "amount": 0.00500000, - "label": "", - "vout": 0 - }, - { - "account": "", - "address": "GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo", - "category": "receive", - "amount": 0.00488775, - "label": "", - "vout": 1 - } - ], - "hex": "020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000" - */ +https://btgexp.com/tx/cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 + +node tx.js BTG testamount prevamount=0.00998277 fees=0.00001001 amount=0.005 + +/* +--- Previous amount is: 0.00998277 +--- Amount to spend is: 0.00500000 +--- Network fees are: 0.00001001 +--- Dev fees are: 0.00008500 +--- Refunded amount to spending address is: 0.00488776 +*/ + +node tx.js BTG create prevtx=d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206 prevaddr=GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo prevamount=0.00998277 previndex=31 privkey=privkey addr=GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB fees=0.00001001 amount=0.005 + +/* +Version BTG +create +Creating transaction to send 0.005 (without fees) to GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB from output number 31 with amount 0.00998277 owned by GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo in transaction d5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206 +--- Previous amount is: 0.00998277 +--- Amount to spend is: 0.00500000 +--- Network fees are: 0.00001001 +--- Dev fees are: 0.00008500 +--- Refunded amount to spending address is: 0.00488776 +Address corresponding to private key is GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo +----- Transaction hash: cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 +Transaction body: +020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 +Complete transaction: +e1476d4474780000000000000000000003010000d42bb13a020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 +Size 283 bytes +Network Fees: 1002 - 3.54 satoshis/byte +Dev Fees: 8500 +------------- Check - deserialize +{ input: + [ { hash: 'd5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206', + n: 31, + scriptSigLen: , + scriptSig: [Object], + data: null, + nSequence: } ], + output: + [ { nValue: 500000, + scriptPubkeyLen: , + scriptPubkey: , + address: 'GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB', + type: 'p2pkh' }, + { nValue: 488775, + scriptPubkeyLen: , + scriptPubkey: , + address: 'GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo', + type: 'p2pkh' }, + { nValue: 8500, + scriptPubkeyLen: , + scriptPubkey: , + address: 'GSBbeuKPu4d6HKJhtPgk7XayMcaXyQy8TS', + type: 'p2pkh' } ], + s: 0, + nVersion: , + nbinput: 1, + nboutput: 3, + nLockTime: } +------------- End Check - deserialize +------------- Check - verify +----- Transaction hash: cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 +signature: 3044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f075 +message to be signed: 020000004ee41cbd7a9495aeff29b1827648a8855b64105bc2c10e83bf9280c73076d8a53bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e7066504406e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac853b0f0000000000ffffffff8ea3b70975d956ba80b33d58cc1dcadceb5eb4cda36eb66e1a183db25069043100000000414f0000 +----- Transaction verified +----- Transaction hash: cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 +------------- End Check - verify +*/ + +node tx.js BTG decode 020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 + +/* +Version BTG +decode +{ input: + [ { hash: 'd5a80b216e5966790617dd3828bc13152bad82f121b16208496e9d718664e206', + n: 31, + scriptSigLen: , + scriptSig: [Object], + data: null, + nSequence: } ], + output: + [ { nValue: 500000, + scriptPubkeyLen: , + scriptPubkey: , + address: 'GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB', + type: 'p2pkh' }, + { nValue: 488775, + scriptPubkeyLen: , + scriptPubkey: , + address: 'GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo', + type: 'p2pkh' }, + { nValue: 8500, + scriptPubkeyLen: , + scriptPubkey: , + address: 'GSBbeuKPu4d6HKJhtPgk7XayMcaXyQy8TS', + type: 'p2pkh' } ], + s: 0, + nVersion: , + nbinput: 1, + nboutput: 3, + nLockTime: } +*/ + +node tx.js BTG testconnect A.B.47.27 + +/* +Version BTG +testconnect +Sending to A.B.47.27 +Connected to : A.B.47.27:8338 +Sent version to A.B.47.27 +------ Answer receiced from A.B.47.27 +version +------ Answer receiced from A.B.47.27 +verack +-------- Verack received - completing handshake with A.B.47.27 +------ Answer receiced from A.B.47.27 +sendheaders +------ Answer receiced from A.B.47.27 +ping +addr +getheaders +feefilter +End connection with A.B.47.27:8338 +*/ + +node tx.js BTG send e1476d4474780000000000000000000003010000d42bb13a020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 A.B.47.27 + +/* +Version BTG +send +Sending to A.B.47.27 +Connected to : A.B.47.27:8338 +Sent version to A.B.47.27 +------ Answer receiced from A.B.47.27 +version +------ Answer receiced from A.B.47.27 +verack +-------- Verack received - completing handshake with A.B.47.27 +------ Sending transaction to A.B.47.27 +Sent e1476d4474780000000000000000000003010000d42bb13a020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000 to A.B.47.27 +------ Answer receiced from A.B.47.27 +sendheaders +------ Answer receiced from A.B.47.27 +ping +addr +getheaders +feefilter +End connection with A.B.47.27:8338 +*/ +//Check with cli if you can +bgold-cli gettransaction cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4 + +/* +{ + "amount": 0.00000000, + "fee": -0.00001002, + "confirmations": 0, + "trusted": true, + "txid": "cc9684a4243999d1a1fc21c7ad7dbd1b3462bb1fb29614ed16b4d2763ab12bd4", + "walletconflicts": [ + ], + "time": 1511873524, + "timereceived": 1511873524, + "bip125-replaceable": "no", + "details": [ + { + "account": "", + "address": "GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB", + "category": "send", + "amount": -0.00500000, + "label": "", + "vout": 0, + "fee": -0.00001002, + "abandoned": false + }, + { + "account": "", + "address": "GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo", + "category": "send", + "amount": -0.00488775, + "label": "", + "vout": 1, + "fee": -0.00001002, + "abandoned": false + }, + { + "account": "", + "address": "GKz5ii8tWQG9hd196vNkwkLKsWHqaeKSoB", + "category": "receive", + "amount": 0.00500000, + "label": "", + "vout": 0 + }, + { + "account": "", + "address": "GSjwHAAYmFfQ4WPArc2ErtjQGr3Q2nkjvo", + "category": "receive", + "amount": 0.00488775, + "label": "", + "vout": 1 + } + ], + "hex": "020000000106e26486719d6e490862b121f182ad2b1513bc2838dd17067966596e210ba8d51f0000006a473044022039e2eee9a14fd18665eceeaac8af87888704ef2bfa14afe850b850e6fc7fdea702201d3c4340cc6998738295176320dc2597b3b6fcb93abc01add17b57b9ea70f0754121039f1e160a02079a6d6b7be0334cc4d76a125cd13a6f8d7131b11c263bc20bf918ffffffff0320a10700000000001976a914177b585b5401ad21b60b78b1b3c91996f250296d88ac47750700000000001976a91461975b3a4b9d5059e3db3e301e394d6d13275b3688ac34210000000000001976a9145b79a9d29a34f2f284ecdd33009ffa5e0252b68988ac00000000" + */ diff --git a/tx.js b/tx.js index 34eacfe..5c821d3 100644 --- a/tx.js +++ b/tx.js @@ -951,25 +951,26 @@ var testamount=function(args) { tmp=prevamount-s-fees; if (tmp<0) { console.log('--- Prevamount is too small to allow fees'); + amount=null; } else { console.log('--- Prevamount is small, min dev fees of '+SATO_+' apply - amount should be '+big_satoshis(tmp)); + amount=tmp; }; } else { s=prevamount-fees-advised; if (!amount) { console.log('--- With your network fees the advised amount is: '+big_satoshis(advised)); + amount=advised; } else { console.log('--- Amount too high - With your network fees the advised amount is: '+big_satoshis(advised)); + amount=null; }; - write(prevamount,advised,fees,s); }; if (fees