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

txprepare: fix withdraw returning unsigned transaction

Public commit record

What the developer wrote

Authored by Vincenzo Palazzo

100/100 · Strong
txprepare: fix withdraw returning unsigned transaction

The withdraw command was returning an unsigned raw transaction in
its 'tx' response field. This happened because signpsbt_done() used
psbt_txid() to extract utx->tx, which internally calls
wally_psbt_extract() with WALLY_PSBT_EXTRACT_NON_FINAL — stripping
all signature and witness data.

The broadcast itself succeeded because sendpsbt internally finalizes
the PSBT via psbt_final_tx(), but the 'tx' field returned to the
user had empty scriptSigs and no witness data.

This is a regression from 908f834d6 ("Update libwally to 0.8.8,
support PSBTv2") which rewrote psbt_txid() from manually copying
final_scriptsig/redeem_script into the cloned tx, to using
wally_psbt_extract(WALLY_PSBT_EXTRACT_NON_FINAL) which strips all
signing data by design.

Fix by finalizing the signed PSBT in signpsbt_done() and extracting
the fully signed transaction via psbt_final_tx(). The txid
verification still uses psbt_txid() (which is correct for txid
computation since txids exclude witness data).

Fixes: https://github.com/ElementsProject/lightning/issues/8701
Changelog-Fixed: withdraw now returns a fully signed transaction in the `tx` response field.
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✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a bug in Core Lightning's 'withdraw' command where the transaction shown to the user was returned without valid signatures or witness data, even though the actual network broadcast worked correctly. The returned 'tx' field looked like a real transaction but would be rejected if a user tried to broadcast it themselves. The fix ensures the returned transaction is fully signed and final.

Recommended action

Apply the patch. Users relying on the 'tx' field from withdraw for offline rebroadcast or external verification should upgrade, as previous versions may return an invalid/unbroadcastable transaction. No immediate network-level exploit is indicated.

Security signals we found

01

API response returned unsigned transaction data to the user

02

Regression introduced by libwally 0.8.8 / PSBTv2 update

03

Witness and scriptSig data stripped due to WALLY_PSBT_EXTRACT_NON_FINAL flag

04

Fix finalizes PSBT before extracting response transaction

05

Tests changed from expected-fail to expected-pass

Risk score

Why this scored 33/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 6/15
Confidence 8/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.