-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor FeeEstimator
to introduce local target variants
#352
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
use crate::logger::{log_error, log_info, log_trace, Logger}; | ||
|
||
use crate::config::BDK_WALLET_SYNC_TIMEOUT_SECS; | ||
use crate::fee_estimator::{ConfirmationTarget, FeeEstimator}; | ||
use crate::Error; | ||
|
||
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator}; | ||
use lightning::chain::chaininterface::BroadcasterInterface; | ||
|
||
use lightning::events::bump_transaction::{Utxo, WalletSource}; | ||
use lightning::ln::msgs::{DecodeError, UnsignedGossipMessage}; | ||
|
@@ -18,8 +19,7 @@ use lightning::util::message_signing; | |
use bdk::blockchain::EsploraBlockchain; | ||
use bdk::database::BatchDatabase; | ||
use bdk::wallet::AddressIndex; | ||
use bdk::{Balance, FeeRate}; | ||
use bdk::{SignOptions, SyncOptions}; | ||
use bdk::{Balance, SignOptions, SyncOptions}; | ||
|
||
use bitcoin::address::{Payload, WitnessVersion}; | ||
use bitcoin::bech32::u5; | ||
|
@@ -43,7 +43,7 @@ enum WalletSyncStatus { | |
InProgress { subscribers: tokio::sync::broadcast::Sender<Result<(), Error>> }, | ||
} | ||
|
||
pub struct Wallet<D, B: Deref, E: Deref, L: Deref> | ||
pub(crate) struct Wallet<D, B: Deref, E: Deref, L: Deref> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Visibility control for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought so, too, but |
||
where | ||
D: BatchDatabase, | ||
B::Target: BroadcasterInterface, | ||
|
@@ -153,9 +153,7 @@ where | |
&self, output_script: ScriptBuf, value_sats: u64, confirmation_target: ConfirmationTarget, | ||
locktime: LockTime, | ||
) -> Result<Transaction, Error> { | ||
let fee_rate = FeeRate::from_sat_per_kwu( | ||
self.fee_estimator.get_est_sat_per_1000_weight(confirmation_target) as f32, | ||
); | ||
let fee_rate = self.fee_estimator.estimate_fee_rate(confirmation_target); | ||
|
||
let locked_wallet = self.inner.lock().unwrap(); | ||
let mut tx_builder = locked_wallet.build_tx(); | ||
|
@@ -240,10 +238,8 @@ where | |
pub(crate) fn send_to_address( | ||
&self, address: &bitcoin::Address, amount_msat_or_drain: Option<u64>, | ||
) -> Result<Txid, Error> { | ||
let confirmation_target = ConfirmationTarget::OutputSpendingFee; | ||
let fee_rate = FeeRate::from_sat_per_kwu( | ||
self.fee_estimator.get_est_sat_per_1000_weight(confirmation_target) as f32, | ||
); | ||
let confirmation_target = ConfirmationTarget::OnchainPayment; | ||
let fee_rate = self.fee_estimator.estimate_fee_rate(confirmation_target); | ||
|
||
let tx = { | ||
let locked_wallet = self.inner.lock().unwrap(); | ||
|
@@ -485,7 +481,7 @@ where | |
|
||
/// Similar to [`KeysManager`], but overrides the destination and shutdown scripts so they are | ||
/// directly spendable by the BDK wallet. | ||
pub struct WalletKeysManager<D, B: Deref, E: Deref, L: Deref> | ||
pub(crate) struct WalletKeysManager<D, B: Deref, E: Deref, L: Deref> | ||
where | ||
D: BatchDatabase, | ||
B::Target: BroadcasterInterface, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like in practice the values are the same as before. Is this change to allow us to vary them in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I intentionally left the behavior unchanged for now. This is really only an overdue refactor and also prepares for the LDK upgrade where we'll get more
ConfirmationTarget
s and in particular will splitOnChainSweep
.At some point in the future (probably when tackling #176), we'll revisit if the chosen defaults could be improved in any way, or if they are fine as is.