From a370bd74eda77fafd329a7ce93377a73d5d993e5 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 4 May 2016 01:07:33 -0700 Subject: [PATCH] remove old FindAndDelete. --- lib/bcoin/script.js | 90 --------------------------------------------- 1 file changed, 90 deletions(-) diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 5d35b4b0..1cb887b6 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -2009,96 +2009,6 @@ Script.prototype.removeData = function removeData(data) { return index.length; }; -Script.prototype.removeDataRaw = function removeDataRaw(data) { - var total = 0; - var p, sig, raw, i, a, b, op, size; - - // We need to reserialize the - // signature as a minimal push - // Note that this is _NOT_ - // minimaldata completely. It - // _always_ encodes a pushdata - // op! - p = new BufferWriter(); - if (data.length <= 0x4b) { - p.writeU8(data.length); - p.writeBytes(data); - } else if (data.length <= 0xff) { - p.writeU8(opcodes.OP_PUSHDATA1); - p.writeU8(data.length); - p.writeBytes(data); - } else if (data.length <= 0xffff) { - p.writeU8(opcodes.OP_PUSHDATA2); - p.writeU16(data.length); - p.writeBytes(data); - } else if (data.length <= 0xffffffff) { - p.writeU8(opcodes.OP_PUSHDATA4); - p.writeU32(data.length); - p.writeBytes(data); - } else { - assert(false, 'Bad pushdata op.'); - } - sig = p.render(); - - // Should never happen, but - // bitcoind does this anyway. - if (sig.length === 0) - return total; - - // Compare on the byte level. - raw = this.encode(); - - p = new BufferReader(raw, true); - - while (p.left() >= sig.length) { - if (utils.icmp(raw, sig, p.offset) === 0) { - a = raw.slice(0, p.offset); - b = raw.slice(p.offset + sig.length); - raw = Buffer.concat([a, b]); - p.data = raw; - total++; - } - - if (p.left() === 0) - break; - - op = p.readU8(); - if (op >= 0x01 && op <= 0x4b) { - if (p.left() < op) - break; - } else if (op === opcodes.OP_PUSHDATA1) { - if (p.left() < 1) - break; - size = p.readU8(); - if (p.left() < size) - break; - p.seek(size); - } else if (op === opcodes.OP_PUSHDATA2) { - if (p.left() < 2) - break; - size = p.readU16(); - if (p.left() < size) - break; - p.seek(size); - } else if (op === opcodes.OP_PUSHDATA4) { - if (p.left() < 4) - break; - size = p.readU32(); - if (p.left() < size) - break; - p.seek(size); - } - } - - if (total > 0) { - this.code = Script.decode(raw); - if (this.raw) - this.raw = raw; - } - - return total; -}; - /** * Find a data element in a script. * @param {Buffer} data - Data element to match against.