karask / python-bitcoin-utils

Library to interact with the Bitcoin network. Ideal for low-level learning and experimenting.
MIT License
262 stars 99 forks source link

Fix witness stack size to use encode_varint #97

Closed ramonamela closed 1 month ago

ramonamela commented 1 month ago

witness_count_bytes is incorrect when the witness stack has more than 127 elements. It should be computed as encode_varint as is done in lines 1050 and 1051 with txin_count_bytes and txout_count_bytes. I found the error in local using bitcoin core regtest. With this fix my transaction went through.

karask commented 1 month ago

Thanks for the fix