From 7d84ded4260c82cb02419e0cfcfc5d39ee242923 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Fri, 30 Sep 2022 05:11:09 +0530 Subject: [PATCH] btcOperator v1.0.10a: broadcastTx resolves txid - When broadcast is successful, txid is resolved - sendTx also resolves txid due to the above change --- btcOperator.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/btcOperator.js b/btcOperator.js index 1d0147a..7406ba2 100644 --- a/btcOperator.js +++ b/btcOperator.js @@ -1,4 +1,4 @@ -(function(EXPORTS) { //btcOperator v1.0.10 +(function(EXPORTS) { //btcOperator v1.0.10a /* BTC Crypto and API Operator */ const btcOperator = EXPORTS; @@ -31,16 +31,16 @@ }) } - const broadcast = btcOperator.broadcast = rawtx => new Promise((resolve, reject) => { + const broadcastTx = btcOperator.broadcastTx = rawTxHex => new Promise((resolve, reject) => { $.ajax({ type: "POST", url: URL + "send_tx/BTC/", data: { - "tx_hex": rawtx + "tx_hex": rawTxHex }, dataType: "json", error: e => reject(e.responseJSON), - success: r => r.status === "success" ? resolve(r.data) : reject(r) + success: r => r.status === "success" ? resolve(r.data.txid) : reject(r) }) }); @@ -485,8 +485,8 @@ new Set(wif_keys).forEach(key => console.debug("Signing key:", key, tx.sign(key, 1 /*sighashtype*/ ))); //Sign the tx using private key WIF console.debug("Signed:", tx.serialize()); debugger; - broadcast(tx.serialize()) - .then(result => resolve(result)) + broadcastTx(tx.serialize()) + .then(txid => resolve(txid)) .catch(error => reject(error)); }).catch(error => reject(error)); })