From 52bffd0fc3bd482895fe82f1eecfe868a0367133 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Wed, 17 Jul 2019 18:31:43 +0530 Subject: [PATCH] fixed miner fee issue in sendTransaction --- supernode/index.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/supernode/index.html b/supernode/index.html index 5e20efd..d62ce83 100644 --- a/supernode/index.html +++ b/supernode/index.html @@ -14614,7 +14614,7 @@ var obj = utxo_list[key]; sum += obj.amount; - if (btc_eq_receiving_amount <= sum - miners_fee) { + if (btc_eq_receiving_amount <= sum) { trx.addinput(obj.txid, obj.vout, obj.scriptPubKey); break; } else { @@ -14623,12 +14623,14 @@ } } + btc_eq_receiving_amount = btc_eq_receiving_amount - miners_fee; + trx.addoutput(receiver_address, btc_eq_receiving_amount); + let change_amount = 0; - if (sum - btc_eq_receiving_amount - miners_fee>0) { + if (sum - btc_eq_receiving_amount - miners_fee > 0) { change_amount = sum - btc_eq_receiving_amount - miners_fee; } - trx.addoutput(receiver_address, btc_eq_receiving_amount); if (change_amount>0) { trx.addoutput(change_adress, change_amount); } @@ -14644,6 +14646,7 @@ let signedTxHash = trx.sign(utxo_addr_wif, 1); //SIGHASH_ALL DEFAULT 1 showMessage(`Signed Transaction Hash: ${signedTxHash}`); console.log(signedTxHash); + return; var http = new XMLHttpRequest(); var tx_send_url = `${blockchain_explorer}/api/tx/send`;