btcsuite / btcutil

Provides bitcoin-specific convenience functions and types
480 stars 410 forks source link

psbt: fix deserialization with zero inputs #162

Closed guggero closed 4 years ago

guggero commented 4 years ago

This is a fix/workaround for a special case that's caused by https://github.com/btcsuite/btcd/blob/master/wire/msgtx.go#L426. When a wire format transaction with no inputs is serialized, the wire package assumes it's a non-witness transaction (as there is indeed no witness data present). But when de-serializing the same transaction, the line mentioned above assumes that for the special case of a zero input length, the transaction must be in the witness format, which causes the de-serialization to fail. The workaround in this PR fixes this special case by just trying to de-serialize the transaction in the non-witness format too.