AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 46 Bitcoin

tests: add regression tests for withdraw returning unsigned tx

Public commit record

What the developer wrote

Authored by Vincenzo Palazzo

100/100 · Strong
tests: add regression tests for withdraw returning unsigned tx

Adds two tests to reproduce issue #8701 where the withdraw command
returns an unsigned raw transaction in the 'tx' response field:

1. test_withdraw_returns_signed_tx: verifies that withdraw's 'tx' field
contains witness data for all inputs (basic wallet UTXOs).

2. test_withdraw_close_output_signed: verifies signing works when
withdrawing funds that include channel close outputs (anchor/P2WSH
with CSV locks), which was the exact scenario in the reported issue.

The root cause is that psbt_txid() uses WALLY_PSBT_EXTRACT_NON_FINAL
which strips signatures/witnesses, and the withdraw response returns
this unsigned tx instead of the finalized one.

Changelog-None
Signed-off-by: Vincenzo Palazzo <vincenzopalazzo@member.fsf.org>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit only adds two new automated tests that demonstrate an existing bug: the 'withdraw' command returns an unsigned raw transaction in its 'tx' field because an internal helper strips away signatures. The tests are marked as expected-to-fail, so the actual code flaw is not fixed here. A user relying on the returned transaction could receive a version that looks valid but would be rejected by the Bitcoin network because it lacks required witness data. The commit documents the regression but does not change the wallet logic itself.

Recommended action

Treat this as a test-only commit that reproduces a known bug. The actual fix must be made in the wallet/PSBT extraction logic so withdraw returns a finalized, signed transaction (or the correct signed raw tx) instead of the non-final extraction. Review and merge the separate production-code fix, then remove the xfail markers from these tests to confirm the bug is resolved.

Security signals we found

01

Regression tests for issue #8701: withdraw returns unsigned raw transaction

02

Root cause identified in commit message: psbt_txid() uses WALLY_PSBT_EXTRACT_NON_FINAL which strips signatures/witnesses

03

Tests assert all segwit inputs have non-empty witness data in withdraw response

04

Tests cover both regular wallet UTXOs and channel close outputs (anchor/P2WSH with CSV locks)

05

Tests marked xfail(strict=True): bug is reproduced but not fixed by this commit

Risk score

Why this scored 46/100

Our methodology →
Potential impact 12/30
Exploitability 5/25
Stealth signal 8/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.