From daec31c1ac16c33372bc9020a1f2131f0269e8b6 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Thu, 23 Feb 2023 23:24:55 +0530 Subject: [PATCH] btcOperator v1.1.2a: bug fix - Fixed: checkIfSameTx loop in comparing outputs using incorrect length --- btcOperator.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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;