Skip to content

Commit ec3a683

Browse files
committed
refactor: clarify try_finalize_psbt timelock inputs
1 parent 8a7b5de commit ec3a683

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
if psbt.inputs.len() < tx.input.len() {
@@ -2002,9 +2001,8 @@ impl Wallet {
20022001
match desc {
20032002
Some(desc) => {
20042003
let mut tmp_input = bitcoin::TxIn::default();
2005-
let satisfy_result = if let Some((current_height, confirmation_height)) =
2006-
wallet_timelocks(n, input)
2007-
{
2004+
let satisfy_result = if let Some(current_height) = current_height {
2005+
let confirmation_height = confirmation_height_for_input(n, input);
20082006
desc.satisfy(
20092007
&mut tmp_input,
20102008
(

0 commit comments

Comments
 (0)