From f06d00e6a6ddf57d6502ba89c19c77b1b69b2b59 Mon Sep 17 00:00:00 2001 From: luckysori Date: Thu, 9 Dec 2021 12:50:28 +1100 Subject: [PATCH] Re-use order fee rate for close transaction --- Cargo.lock | 2 +- daemon/src/collab_settlement_taker.rs | 2 +- daemon/src/maker_cfd.rs | 2 +- daemon/src/model/cfd.rs | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fb18dc..a51bfb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "maia" version = "0.1.0" -source = "git+https://github.com/comit-network/maia#baaad94a10291d4e55c3d2cd30f3736035ee10ea" +source = "git+https://github.com/comit-network/maia#a6846a244131108d93c62167c401e85d87d874bf" dependencies = [ "anyhow", "bdk", diff --git a/daemon/src/collab_settlement_taker.rs b/daemon/src/collab_settlement_taker.rs index b39836b..0d3d832 100644 --- a/daemon/src/collab_settlement_taker.rs +++ b/daemon/src/collab_settlement_taker.rs @@ -72,7 +72,7 @@ impl Actor { let dlc = self.cfd.dlc().context("No DLC in CFD")?; - let (tx, sig) = dlc.close_transaction(&self.proposal)?; + let (tx, sig) = dlc.close_transaction(&self.proposal, self.cfd.order.fee_rate)?; // Need to use `do_send_async` here because this handler is called in // context of a message arriving over the wire, and would result in a diff --git a/daemon/src/maker_cfd.rs b/daemon/src/maker_cfd.rs index 2807288..dfe7841 100644 --- a/daemon/src/maker_cfd.rs +++ b/daemon/src/maker_cfd.rs @@ -865,7 +865,7 @@ where let mut cfd = load_cfd_by_order_id(order_id, &mut conn).await?; let dlc = cfd.open_dlc().context("CFD was in wrong state")?; - let (tx, sig_maker) = dlc.close_transaction(proposal)?; + let (tx, sig_maker) = dlc.close_transaction(proposal, cfd.order.fee_rate)?; let own_script_pubkey = dlc.script_pubkey_for(cfd.role()); cfd.handle_proposal_signed(CollaborativeSettlement::new( diff --git a/daemon/src/model/cfd.rs b/daemon/src/model/cfd.rs index 74a4088..669d32d 100644 --- a/daemon/src/model/cfd.rs +++ b/daemon/src/model/cfd.rs @@ -1445,6 +1445,7 @@ impl Dlc { pub fn close_transaction( &self, proposal: &crate::model::cfd::SettlementProposal, + fee_rate: u32, ) -> Result<(Transaction, Signature)> { let (lock_tx, lock_desc) = &self.lock; let (lock_outpoint, lock_amount) = { @@ -1461,6 +1462,7 @@ impl Dlc { lock_amount, (&self.maker_address, proposal.maker), (&self.taker_address, proposal.taker), + fee_rate, ) .context("Unable to collaborative close transaction")?;