Dynamically chose fee for TxCancel.

Bob chooses the fee for TxCancel because he is the one that cares.
This commit is contained in:
Philipp Hoenisch 2021-04-29 10:59:40 +10:00
parent 1012e39527
commit 38540b4de5
No known key found for this signature in database
GPG key ID: E5F8E74C672BC666
8 changed files with 121 additions and 36 deletions

View file

@ -8,10 +8,6 @@ pub const RPC_PORT: u16 = 18443;
pub const PORT: u16 = 18886;
pub const DATADIR: &str = "/home/bdk";
// Bitcoin regtest TX fee. The fee itself does not matter for our tests. It just
// has to be static so that we can assert on the amounts.
pub const TX_FEE: u64 = 15_000;
#[derive(Debug)]
pub struct Bitcoind {
args: BitcoindArgs,

View file

@ -1,7 +1,6 @@
mod bitcoind;
mod electrs;
use crate::harness::bitcoind::TX_FEE;
use anyhow::{bail, Context, Result};
use async_trait::async_trait;
use bitcoin_harness::{BitcoindRpcApi, Client};
@ -41,7 +40,8 @@ use uuid::Uuid;
// TODO: see if there is a better way.
const TX_REDEEM_FEE: u64 = 12500;
const TX_REFUND_FEE: u64 = 12500;
const TX_CANCEL_FEE: u64 = TX_FEE;
const TX_CANCEL_FEE: u64 = 12500;
const TX_PUNISH_FEE: u64 = 12500;
pub async fn setup_test<T, F, C>(_config: C, testfn: T)
where
@ -719,7 +719,8 @@ impl TestContext {
fn alice_punished_btc_balance(&self) -> bitcoin::Amount {
self.alice_starting_balances.btc + self.btc_amount
- bitcoin::Amount::from_sat(2 * bitcoind::TX_FEE)
- bitcoin::Amount::from_sat(TX_CANCEL_FEE)
- bitcoin::Amount::from_sat(TX_PUNISH_FEE)
}
fn bob_punished_xmr_balance(&self) -> monero::Amount {