diff --git a/electrum/transaction.py b/electrum/transaction.py index d0b409d02..b5f6e79ba 100644 --- a/electrum/transaction.py +++ b/electrum/transaction.py @@ -597,6 +597,7 @@ class BCDataStream(object): def script_GetOp(_bytes : bytes): + _bytes_len = len(_bytes) i = 0 while i < len(_bytes): vch = None @@ -617,6 +618,10 @@ def script_GetOp(_bytes : bytes): try: (nSize,) = struct.unpack_from(' _bytes_len - i: + raise MalformedBitcoinScript(f"Push of data element that is larger than remaining data: {nSize} vs {_bytes_len - i}") + vch = _bytes[i:i + nSize] i += nSize