python-bitcoinlib icon indicating copy to clipboard operation
python-bitcoinlib copied to clipboard

CScript.witness_version() should call CSriptOp.decode_op_n() on the value before returning

Open dgpv opened this issue 1 year ago • 0 comments

https://github.com/petertodd/python-bitcoinlib/blob/173a73e74781dcd2edce120d8685550a88a73189/bitcoin/core/script.py#L692-L694

Because the witness version is actually a 'small int' opcode - that is, for witness version 1, without decode_op_n(), the returned value will be 0x51. It worked for version 0 because 'small int' opcode is decoded as 0 --> 0; 0x51..0x60 --> 1..16

dgpv avatar Jan 19 '24 14:01 dgpv