mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-25 18:26:28 -05:00
Dynamically calculate fees using electrum's estimate_fee.
Electrum has an estimate-fee feature which takes as input the block you want a tx to be included. The result is a recommendation of BTC/vbyte. Using this recommendation and the knowledge about the size of our transactions we compute an appropriate fee. The size of the transactions were taken from real transactions as published on bitcoin testnet. Note: in reality these sizes might fluctuate a bit but not for much.
This commit is contained in:
parent
38540b4de5
commit
ee90c228b4
11 changed files with 163 additions and 66 deletions
|
|
@ -66,8 +66,12 @@ async fn next_state(
|
|||
Ok(match state {
|
||||
BobState::Started { btc_amount } => {
|
||||
let bitcoin_refund_address = bitcoin_wallet.new_address().await?;
|
||||
let tx_refund_fee = bitcoin_wallet.estimate_fee(bitcoin::ESTIMATED_WEIGHT_TX_REDEEM);
|
||||
let tx_cancel_fee = bitcoin_wallet.estimate_fee(bitcoin::ESTIMATED_WEIGHT_TX_CANCEL);
|
||||
let tx_refund_fee = bitcoin_wallet
|
||||
.estimate_fee(bitcoin::ESTIMATED_WEIGHT_TX_REDEEM)
|
||||
.await?;
|
||||
let tx_cancel_fee = bitcoin_wallet
|
||||
.estimate_fee(bitcoin::ESTIMATED_WEIGHT_TX_CANCEL)
|
||||
.await?;
|
||||
|
||||
let state2 = request_price_and_setup(
|
||||
swap_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue