Skip to content

Commit 557a058

Browse files
committed
refactor(wallet): make current_height field in filter_utxos not optional
There is no case in which current_height is None within create_tx.
1 parent 3dd59f4 commit 557a058

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

  • crates/wallet/src/wallet

crates/wallet/src/wallet/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ impl Wallet {
14181418
fee_amount += fee_rate * tx.weight();
14191419

14201420
let (required_utxos, optional_utxos) =
1421-
self.filter_utxos(&params, Some(current_height.to_consensus_u32()));
1421+
self.filter_utxos(&params, current_height.to_consensus_u32());
14221422

14231423
// get drain script
14241424
let mut drain_index = Option::<(KeychainKind, u32)>::None;
@@ -1973,7 +1973,7 @@ impl Wallet {
19731973
fn filter_utxos(
19741974
&self,
19751975
params: &TxParams,
1976-
current_height: Option<u32>,
1976+
current_height: u32,
19771977
) -> (Vec<WeightedUtxo>, Vec<WeightedUtxo>) {
19781978
self
19791979
// get all unspent UTxOs from wallet
@@ -1994,22 +1994,20 @@ impl Wallet {
19941994
params.bumping_fee.is_none() || local_output.chain_position.is_confirmed()
19951995
})
19961996
// only use UTxOs we posess and are mature if the origin tx is coinbase
1997-
.filter(|local_output| {
1997+
.filter(move |local_output| {
19981998
self.indexed_graph
19991999
.graph()
20002000
.get_tx(local_output.outpoint.txid)
20012001
.is_some_and(|tx| {
20022002
!tx.is_coinbase()
20032003
|| (local_output.chain_position.is_confirmed()
2004-
&& current_height.is_some_and(|current_height| {
2005-
local_output
2006-
.chain_position
2007-
.confirmation_height_upper_bound()
2008-
.is_some_and(|local_output_height| {
2009-
current_height.saturating_sub(local_output_height)
2010-
>= COINBASE_MATURITY
2011-
})
2012-
}))
2004+
&& local_output
2005+
.chain_position
2006+
.confirmation_height_upper_bound()
2007+
.is_some_and(|local_output_height| {
2008+
current_height.saturating_sub(local_output_height)
2009+
>= COINBASE_MATURITY
2010+
}))
20132011
})
20142012
})
20152013
// combine optional UTxOs with manually selected UTxOs

0 commit comments

Comments
 (0)