Merge PR 'Populate non-witness UTXOs in bump PSBTs' (#5471)
What changed, and why it matters
This change fixes how transaction fee-bumping PSBTs (Partially Signed Bitcoin Transactions) are built in LDK. Previously, when a non-witness UTXO (a non-SegWit coin) was used as an input, the PSBT only had a witness UTXO field populated for SegWit inputs and left non-witness inputs without the required non_witness_utxo data. The patch now correctly fills in the previous full transaction (non_witness_utxo) for legacy/non-witness inputs. This is a correctness fix that can affect whether hardware wallets and signers accept and properly sign fee-bump transactions, which matters for Lightning channel security (timely confirmation of commitment/HTLC transactions).
Review whether any deployed LDK-based signer or wallet relies on non-witness UTXOs in fee-bump transactions; upgrade to include this fix. Validate that PSBTs produced for non-SegWit confirmed UTXOs now include non_witness_utxo and are accepted by downstream signers. No immediate emergency response is indicated, but treat as a correctness fix in a security-critical path.
Security signals we found
PSBT input metadata correctness fix
Non-witness UTXO now populated for legacy inputs in fee-bump transactions
Affects CPFP anchor and HTLC transaction signing paths
Could prevent signing failures or incorrect sighash computation on non-SegWit inputs
No explicit vendor security disclosure or CVE in commit materials
Evidence from the diff
In lightning/src/events/bump_transaction/mod.rs, two PSBT construction sites (anchor/CPFP bump and HTLC timeout/success bump) previously set witness_utxo for all confirmed UTXOs unconditionally. The patch branches on utxo.output().script_pubkey.is_witness_program(): witness UTXOs still get witness_utxo, while non-witness UTXOs now get non_witness_utxo = Some(utxo.prevtx). This aligns with BIP-174 PSBT semantics and ensures signers have the full previous transaction for non-witness inputs, satisfying signature hash requirements and improving compatibility with hardware wallets that require non_witness_utxo for legacy inputs.
Changed components
lightning/src/events/bump_transaction/mod.rsAnchor/CPFP fee-bump PSBT constructionHTLC timeout/success fee-bump PSBT constructionSignerProvider / wallet signer integrationInspect captured patch +4 / −2
### lightning/src/events/bump_transaction/mod.rs
@@ -469,7 +469,6 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
let mut anchor_psbt = Psbt::from_unsigned_tx(anchor_tx).unwrap();
// add witness_utxo to anchor input
anchor_psbt.inputs[0].witness_utxo = Some(anchor_descriptor.previous_utxo());
- // add witness_utxo to remaining inputs
for (idx, utxo) in coin_selection.confirmed_utxos.into_iter().enumerate() {
// add 1 to skip the anchor input
let index = idx + 1;
@@ -479,6 +478,8 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
);
if utxo.output().script_pubkey.is_witness_program() {
anchor_psbt.inputs[index].witness_utxo = Some(utxo.into_output());
+ } else {
+ anchor_psbt.inputs[index].non_witness_utxo = Some(utxo.prevtx);
}
}
@@ -750,7 +751,6 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
htlc_psbt.inputs[i].witness_utxo = Some(htlc_descriptor.previous_utxo(&self.secp));
}
- // add witness_utxo to remaining inputs
for (idx, utxo) in coin_selection.confirmed_utxos.into_iter().enumerate() {
// offset to skip the htlc inputs
let index = idx + selected_htlcs.len();
@@ -760,6 +760,8 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
);
if utxo.output().script_pubkey.is_witness_program() {
htlc_psbt.inputs[index].witness_utxo = Some(utxo.into_output());
+ } else {
+ htlc_psbt.inputs[index].non_witness_utxo = Some(utxo.prevtx);
}
}
Why this scored 35/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.