@@ -280,10 +280,8 @@ def parse_Transaction(vds, is_coinbase):
280280 "OP_WITHIN" , "OP_RIPEMD160" , "OP_SHA1" , "OP_SHA256" , "OP_HASH160" ,
281281 "OP_HASH256" , "OP_CODESEPARATOR" , "OP_CHECKSIG" , "OP_CHECKSIGVERIFY" , "OP_CHECKMULTISIG" ,
282282 "OP_CHECKMULTISIGVERIFY" ,
283- ("OP_SINGLEBYTE_END" , 0xF0 ),
284- ("OP_DOUBLEBYTE_BEGIN" , 0xF000 ),
285- "OP_PUBKEY" , "OP_PUBKEYHASH" ,
286- ("OP_INVALIDOPCODE" , 0xFFFF ),
283+ "OP_NOP1" , "OP_NOP2" , "OP_NOP3" , "OP_NOP4" , "OP_NOP5" , "OP_NOP6" , "OP_NOP7" , "OP_NOP8" , "OP_NOP9" , "OP_NOP10" ,
284+ ("OP_INVALIDOPCODE" , 0xFF ),
287285])
288286
289287
@@ -293,10 +291,6 @@ def script_GetOp(bytes):
293291 vch = None
294292 opcode = ord (bytes [i ])
295293 i += 1
296- if opcode >= opcodes .OP_SINGLEBYTE_END and i < len (bytes ):
297- opcode <<= 8
298- opcode |= ord (bytes [i ])
299- i += 1
300294
301295 if opcode <= opcodes .OP_PUSHDATA4 :
302296 nSize = opcode
@@ -309,14 +303,21 @@ def script_GetOp(bytes):
309303 elif opcode == opcodes .OP_PUSHDATA4 :
310304 (nSize ,) = struct .unpack_from ('<I' , bytes , i )
311305 i += 4
312- vch = bytes [i :i + nSize ]
313- i += nSize
306+ if i + nSize > len (bytes ):
307+ vch = "_INVALID_" + bytes [i :]
308+ i = len (bytes )
309+ else :
310+ vch = bytes [i :i + nSize ]
311+ i += nSize
314312
315313 yield (opcode , vch , i )
316314
317315
318316def script_GetOpName (opcode ):
317+ try :
319318 return (opcodes .whatis (opcode )).replace ("OP_" , "" )
319+ except KeyError :
320+ return "InvalidOp_" + str (opcode )
320321
321322
322323def decode_script (bytes ):
@@ -353,7 +354,7 @@ def get_address_from_input_script(bytes):
353354
354355 # non-generated TxIn transactions push a signature
355356 # (seventy-something bytes) and then their public key
356- # (65 bytes) onto the stack:
357+ # (33 or 65 bytes) onto the stack:
357358
358359 match = [ opcodes .OP_PUSHDATA4 , opcodes .OP_PUSHDATA4 ]
359360 if match_decoded (decoded , match ):
0 commit comments