Skip to content

psbt: reject nil taproot leaf scripts - #2539

Merged
Roasbeef merged 2 commits into
btcsuite:masterfrom
0xjc65eth:fix-2495-nil-taproot-leaf
Jul 20, 2026
Merged

Roasbeef merged 2 commits into
btcsuite:masterfrom
0xjc65eth:fix-2495-nil-taproot-leaf

Conversation

@0xjc65eth

Copy link
Copy Markdown

Summary\n- Validate taproot leaf script entries before sorting/serializing PSBT inputs.\n- Return a descriptive error from B64Encode/Serialize when a nil leaf entry is present instead of panicking in SortBefore.\n- Add a regression test for the nil TaprootLeafScript case.\n\nFixes #2495.\n\n## Tests\n- go test . -run TestB64EncodeRejectsNilTaprootLeafScript -count=1

Julio Cesar and others added 2 commits June 3, 2026 22:15
In this commit, we extend taproot PSBT serialization and finalization to reject nil script spend signatures, leaf scripts, and BIP32 derivations before any sort or dereference. We return wrapped ErrInvalidPsbtFormat errors so callers can identify malformed packet state without parsing strings.

We also make FindLeafScript reject nil inputs and leaf entries. This keeps both the direct finalizer and MaybeFinalize paths from panicking on malformed in-memory packets.
@Roasbeef
Roasbeef merged commit 263ac0e into btcsuite:master Jul 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants