Skip to content

Commit 12491e9

Browse files
fix(lsps4): use unconfirmed UTXOs for splice funding
Splices are zero-conf anyway, so using unconfirmed inputs adds no additional risk. Prevents splice failures when the LSP wallet has unconfirmed change from a previous splice.
1 parent 5f400bb commit 12491e9

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/liquidity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ where
20122012

20132013
let inputs = self
20142014
.wallet
2015-
.select_confirmed_utxos(vec![shared_input], &[shared_output], fee_rate)
2015+
.select_utxos(vec![shared_input], &[shared_output], fee_rate)
20162016
.map_err(|()| APIError::APIMisuseError {
20172017
err: "Insufficient confirmed UTXOs for splice".to_string(),
20182018
})?;

src/wallet/mod.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,19 @@ impl Wallet {
579579

580580
pub(crate) fn select_confirmed_utxos(
581581
&self, must_spend: Vec<Input>, must_pay_to: &[TxOut], fee_rate: FeeRate,
582+
) -> Result<Vec<FundingTxInput>, ()> {
583+
self.select_utxos_inner(must_spend, must_pay_to, fee_rate, true)
584+
}
585+
586+
pub(crate) fn select_utxos(
587+
&self, must_spend: Vec<Input>, must_pay_to: &[TxOut], fee_rate: FeeRate,
588+
) -> Result<Vec<FundingTxInput>, ()> {
589+
self.select_utxos_inner(must_spend, must_pay_to, fee_rate, false)
590+
}
591+
592+
fn select_utxos_inner(
593+
&self, must_spend: Vec<Input>, must_pay_to: &[TxOut], fee_rate: FeeRate,
594+
confirmed_only: bool,
582595
) -> Result<Vec<FundingTxInput>, ()> {
583596
let mut locked_wallet = self.inner.lock().unwrap();
584597
debug_assert!(matches!(
@@ -607,12 +620,14 @@ impl Wallet {
607620
}
608621

609622
tx_builder.fee_rate(fee_rate);
610-
tx_builder.exclude_unconfirmed();
623+
if confirmed_only {
624+
tx_builder.exclude_unconfirmed();
625+
}
611626

612627
tx_builder
613628
.finish()
614629
.map_err(|e| {
615-
log_error!(self.logger, "Failed to select confirmed UTXOs: {}", e);
630+
log_error!(self.logger, "Failed to select UTXOs: {}", e);
616631
})?
617632
.unsigned_tx
618633
.input

0 commit comments

Comments
 (0)