Skip to content

Commit 653031a

Browse files
committed
refactor: clarify try_finalize_psbt timelock inputs
1 parent c884ac2 commit 653031a

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/wallet/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,13 +1973,11 @@ impl Wallet {
19731973
Ok(self
19741974
.try_finalize_psbt_with(
19751975
psbt,
1976+
Some(current_height),
19761977
|_, input| {
1977-
Some((
1978-
current_height,
1979-
confirmation_heights
1980-
.get(&input.previous_output.txid)
1981-
.copied(),
1982-
))
1978+
confirmation_heights
1979+
.get(&input.previous_output.txid)
1980+
.copied()
19831981
},
19841982
true,
19851983
)?
@@ -2001,17 +1999,18 @@ impl Wallet {
20011999
&self,
20022000
psbt: &mut Psbt,
20032001
) -> Result<FinalizedInputs, IndexOutOfBoundsError> {
2004-
self.try_finalize_psbt_with(psbt, |_, _| None, false)
2002+
self.try_finalize_psbt_with(psbt, None, |_, _| None, false)
20052003
}
20062004

20072005
fn try_finalize_psbt_with<F>(
20082006
&self,
20092007
psbt: &mut Psbt,
2010-
mut wallet_timelocks: F,
2008+
current_height: Option<u32>,
2009+
mut confirmation_height_for_input: F,
20112010
clear_output_derivations: bool,
20122011
) -> Result<FinalizedInputs, IndexOutOfBoundsError>
20132012
where
2014-
F: FnMut(usize, &bitcoin::TxIn) -> Option<(u32, Option<u32>)>,
2013+
F: FnMut(usize, &bitcoin::TxIn) -> Option<u32>,
20152014
{
20162015
let tx = &psbt.unsigned_tx;
20172016

@@ -2045,9 +2044,8 @@ impl Wallet {
20452044
match desc {
20462045
Some(desc) => {
20472046
let mut tmp_input = bitcoin::TxIn::default();
2048-
let satisfy_result = if let Some((current_height, confirmation_height)) =
2049-
wallet_timelocks(n, input)
2050-
{
2047+
let satisfy_result = if let Some(current_height) = current_height {
2048+
let confirmation_height = confirmation_height_for_input(n, input);
20512049
desc.satisfy(
20522050
&mut tmp_input,
20532051
(

0 commit comments

Comments
 (0)