diff --git a/btcOperator.js b/btcOperator.js index ed967b9..ff86fb9 100644 --- a/btcOperator.js +++ b/btcOperator.js @@ -1,4 +1,4 @@ -(function (EXPORTS) { //btcOperator v1.1.2 +(function (EXPORTS) { //btcOperator v1.1.2a /* BTC Crypto and API Operator */ const btcOperator = EXPORTS; @@ -703,12 +703,15 @@ btcOperator.checkIfSameTx = function (tx1, tx2) { tx1 = deserializeTx(tx1); tx2 = deserializeTx(tx2); + //compare input and output length if (tx1.ins.length !== tx2.ins.length || tx1.outs.length !== tx2.outs.length) return false; + //compare inputs for (let i = 0; i < tx1.ins.length; i++) if (tx1.ins[i].outpoint.hash !== tx2.ins[i].outpoint.hash || tx1.ins[i].outpoint.index !== tx2.ins[i].outpoint.index) return false; - for (let i = 0; i < tx2.ins.length; i++) + //compare outputs + for (let i = 0; i < tx1.outs.length; i++) if (tx1.outs[i].value !== tx2.outs[i].value || Crypto.util.bytesToHex(tx1.outs[i].script.buffer) !== Crypto.util.bytesToHex(tx2.outs[i].script.buffer)) return false; return true;