mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 06:59:36 -05:00
Add upper bound for bitcoin fees of 100,000 satoshi.
Fees are hard to compute and it is too easy to get wrong and lose a lot of money. Hence, a hardcoded maximum of 100,000 satoshi for a single transaction is in place.
This commit is contained in:
parent
46e0449b8e
commit
14c5a4f025
@ -22,6 +22,7 @@ use std::time::{Duration, Instant};
|
||||
use tokio::sync::{watch, Mutex};
|
||||
|
||||
const SLED_TREE_NAME: &str = "default_tree";
|
||||
const MAX_TX_FEE: u64 = 100_000;
|
||||
|
||||
pub struct Wallet<B = ElectrumBlockchain, D = bdk::sled::Tree, C = Client> {
|
||||
client: Arc<Mutex<C>>,
|
||||
@ -344,6 +345,7 @@ where
|
||||
fee_rate,
|
||||
sats_per_vbyte
|
||||
);
|
||||
|
||||
if sats_per_vbyte < min_relay_fee.as_sat() {
|
||||
tracing::warn!(
|
||||
"Estimated fee of {} is smaller than the min relay fee, defaulting to min relay fee {}",
|
||||
@ -351,6 +353,12 @@ where
|
||||
min_relay_fee.as_sat()
|
||||
);
|
||||
Ok(min_relay_fee)
|
||||
} else if sats_per_vbyte > MAX_TX_FEE {
|
||||
tracing::warn!(
|
||||
"Hard bound of max transaction fees reached. Falling back to: {} sats",
|
||||
MAX_TX_FEE
|
||||
);
|
||||
Ok(bitcoin::Amount::from_sat(MAX_TX_FEE))
|
||||
} else {
|
||||
Ok(bitcoin::Amount::from_sat(sats_per_vbyte))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user