Skip to content

Commit 09d2cd0

Browse files
committed
refactor: clarify try_finalize_psbt timelock inputs
1 parent bbc6888 commit 09d2cd0

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
@@ -1924,13 +1924,11 @@ impl Wallet {
19241924
Ok(self
19251925
.try_finalize_psbt_with(
19261926
psbt,
1927+
Some(current_height),
19271928
|_, input| {
1928-
Some((
1929-
current_height,
1930-
confirmation_heights
1931-
.get(&input.previous_output.txid)
1932-
.copied(),
1933-
))
1929+
confirmation_heights
1930+
.get(&input.previous_output.txid)
1931+
.copied()
19341932
},
19351933
true,
19361934
)?
@@ -1952,17 +1950,18 @@ impl Wallet {
19521950
&self,
19531951
psbt: &mut Psbt,
19541952
) -> Result<FinalizePsbtOutcome, IndexOutOfBoundsError> {
1955-
self.try_finalize_psbt_with(psbt, |_, _| None, false)
1953+
self.try_finalize_psbt_with(psbt, None, |_, _| None, false)
19561954
}
19571955

19581956
fn try_finalize_psbt_with<F>(
19591957
&self,
19601958
psbt: &mut Psbt,
1961-
mut wallet_timelocks: F,
1959+
current_height: Option<u32>,
1960+
mut confirmation_height_for_input: F,
19621961
clear_output_derivations: bool,
19631962
) -> Result<FinalizePsbtOutcome, IndexOutOfBoundsError>
19641963
where
1965-
F: FnMut(usize, &bitcoin::TxIn) -> Option<(u32, Option<u32>)>,
1964+
F: FnMut(usize, &bitcoin::TxIn) -> Option<u32>,
19661965
{
19671966
let tx = &psbt.unsigned_tx;
19681967

@@ -1996,9 +1995,8 @@ impl Wallet {
19961995
match desc {
19971996
Some(desc) => {
19981997
let mut tmp_input = bitcoin::TxIn::default();
1999-
let satisfy_result = if let Some((current_height, confirmation_height)) =
2000-
wallet_timelocks(n, input)
2001-
{
1998+
let satisfy_result = if let Some(current_height) = current_height {
1999+
let confirmation_height = confirmation_height_for_input(n, input);
20022000
desc.satisfy(
20032001
&mut tmp_input,
20042002
(

0 commit comments

Comments
 (0)