Skip to content

Commit d04b1be

Browse files
committed
Make num_blocks_from_conf_target usable outside of Wallet
1 parent 8310678 commit d04b1be

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/wallet.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,8 @@ where
122122
ConfirmationTarget::HighPriority,
123123
];
124124
for target in confirmation_targets {
125-
let num_blocks = match target {
126-
ConfirmationTarget::MempoolMinimum => 1008,
127-
ConfirmationTarget::Background => 144,
128-
ConfirmationTarget::Normal => 12,
129-
ConfirmationTarget::HighPriority => 1,
130-
};
131-
132-
let est_fee_rate = self.blockchain.estimate_fee(num_blocks).await;
125+
let num_blocks = num_blocks_from_conf_target(target);
126+
let est_fee_rate = self.blockchain.estimate_fee(num_blocks as usize).await;
133127

134128
match est_fee_rate {
135129
Ok(rate) => {
@@ -347,6 +341,15 @@ where
347341
}
348342
}
349343

344+
pub(crate) fn num_blocks_from_conf_target(target: ConfirmationTarget) -> u32 {
345+
match target {
346+
ConfirmationTarget::MempoolMinimum => 1008,
347+
ConfirmationTarget::Background => 144,
348+
ConfirmationTarget::Normal => 12,
349+
ConfirmationTarget::HighPriority => 1,
350+
}
351+
}
352+
350353
/// Similar to [`KeysManager`], but overrides the destination and shutdown scripts so they are
351354
/// directly spendable by the BDK wallet.
352355
pub struct WalletKeysManager<D, L: Deref>

0 commit comments

Comments
 (0)