Skip to content

Commit

Permalink
test: Remove FindAndDelete from RPC test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Nov 17, 2020
1 parent 8bc0a59 commit bbed3ec
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions qa/rpc-tests/test_framework/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ def __new__(cls, n):
OP_SHA256,
OP_HASH160,
OP_HASH256,
OP_CODESEPARATOR,
OP_CHECKSIG,
OP_CHECKSIGVERIFY,
OP_CHECKMULTISIG,
Expand Down Expand Up @@ -821,23 +820,6 @@ def GetSigOpCount(self, fAccurate):
SIGHASH_SINGLE = 3
SIGHASH_ANYONECANPAY = 0x80

def FindAndDelete(script, sig):
"""Consensus critical, see FindAndDelete() in Satoshi codebase"""
r = b''
last_sop_idx = sop_idx = 0
skip = True
for (opcode, data, sop_idx) in script.raw_iter():
if not skip:
r += script[last_sop_idx:sop_idx]
last_sop_idx = sop_idx
if script[sop_idx:sop_idx + len(sig)] == sig:
skip = True
else:
skip = False
if not skip:
r += script[last_sop_idx:]
return CScript(r)


def SignatureHash(script, txTo, inIdx, hashtype):
"""Consensus-correct SignatureHash
Expand All @@ -853,7 +835,7 @@ def SignatureHash(script, txTo, inIdx, hashtype):

for txin in txtmp.vin:
txin.scriptSig = b''
txtmp.vin[inIdx].scriptSig = FindAndDelete(script, CScript([OP_CODESEPARATOR]))
txtmp.vin[inIdx].scriptSig = script

if (hashtype & 0x1f) == SIGHASH_NONE:
txtmp.vout = []
Expand Down

0 comments on commit bbed3ec

Please sign in to comment.