Skip to content

Issue/Bug with PSBT deserialization #2199

Description

@hax0kartik

Hello,

BTCD does not fail as it should when trying to deserialize the following bytes:

70736274ff01001c000000000002000000000000000000000000736210ff01000001010010ff70ff01001c00000000000000000000000000000000000000000000

For the above input, Bitcoin-core fails while trying to deserialize and throws the error ReadCompactSize(): size too large.

This issue partly seems to be due to incorrect implementation of bip-174. Bip-174 says that keytype is a compact size int and from what I see btcd simply treats keytype as a single byte.

The test case given below can be used to reproduce this issue:

func TestKeyType(t *testing.T) {
	k, _ := hex.DecodeString("70736274ff01001c000000000002000000000000000000000000736210ff01000001010010ff70ff01001c00000000000000000000000000000000000000000000")
	if _, err := NewFromRawBytes(bytes.NewReader(k), false); err == nil {
		require.Error(t, err, "Err should not be nil")
	}
}

cc: @brunoerg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions