diff --git a/lib/http/rpc.js b/lib/http/rpc.js index a9166591..ff1e5090 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -862,7 +862,8 @@ RPC.prototype.getTXOutProof = async function getTXOutProof(args, help) { throw new RPCError(errs.INVALID_PARAMETER, 'Invalid TXIDs.'); const items = new Validator([txids]); - const hashes = new Set(); + const set = new Set(); + const hashes = []; let last = null; @@ -872,10 +873,11 @@ RPC.prototype.getTXOutProof = async function getTXOutProof(args, help) { if (!hash) throw new RPCError(errs.TYPE_ERROR, 'Invalid TXID.'); - if (hashes.has(hash)) + if (set.has(hash)) throw new RPCError(errs.INVALID_PARAMETER, 'Duplicate txid.'); - hashes.add(hash); + set.add(hash); + hashes.push(hash); last = hash; } @@ -897,14 +899,14 @@ RPC.prototype.getTXOutProof = async function getTXOutProof(args, help) { if (!block) throw new RPCError(errs.MISC_ERROR, 'Block not found.'); - for (const txid of hashes) { - if (!block.hasTX(txid)) { + for (const hash of hashes) { + if (!block.hasTX(hash)) { throw new RPCError(errs.VERIFY_ERROR, 'Block does not contain all txids.'); } } - block = MerkleBlock.fromHashes(block, txids); + block = MerkleBlock.fromHashes(block, hashes); return block.toRaw().toString('hex'); };