Skip to content
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

Explicitly set absolute fees when signing transactions #682

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workspace = true
[dependencies]
anyhow = { workspace = true }
bip39 = "2.0.0"
boltz-client = { git = "https://github.com/danielgranhao/boltz-rust", rev = "e3e87186604c818c667b1293149423af5757dfbe" }
boltz-client = { git = "https://github.com/hydra-yse/boltz-rust", rev = "5c2a7aebd1669d599d76e782952b876a901bfb05" }
chrono = "0.4"
derivative = "2.2.0"
env_logger = "0.11"
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/send_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl SendSwapHandler {
ensure_sdk!(
history.len() <= 2,
PaymentError::Generic {
err: "Lockup address history for Send Swap {id} has more than 2 txs".to_string()
err: format!("Lockup address history for Send Swap {id} has more than 2 txs")
}
);

Expand Down Expand Up @@ -557,7 +557,7 @@ impl SendSwapHandler {
match (from_state, to_state) {
(TimedOut, Created) => Ok(()),
(_, Created) => Err(PaymentError::Generic {
err: "Cannot transition from {from_state:?} to Created state".to_string(),
err: format!("Cannot transition from {from_state:?} to Created state"),
}),

(Created | Pending, Pending) => Ok(()),
Expand Down
9 changes: 7 additions & 2 deletions lib/core/src/swapper/boltz/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::str::FromStr;
use boltz_client::{
bitcoin::{address::Address, Transaction},
boltz::SwapTxKind,
fees::Fee,
util::secrets::Preimage,
BtcSwapTx,
};
Expand Down Expand Up @@ -94,7 +95,11 @@ impl BoltzSwapper {
false => None,
};

let signed_tx = refund_tx.sign_refund(&refund_keypair, broadcast_fees_sat, cooperative)?;
let signed_tx = refund_tx.sign_refund(
&refund_keypair,
Fee::Absolute(broadcast_fees_sat),
cooperative,
)?;
Ok(signed_tx)
}

Expand All @@ -118,7 +123,7 @@ impl BoltzSwapper {
let signed_tx = claim_tx_wrapper.sign_claim(
&claim_keypair,
&Preimage::from_str(&swap.preimage)?,
swap.claim_fees_sat,
Fee::Absolute(swap.claim_fees_sat),
self.get_cooperative_details(swap.id.clone(), Some(pub_nonce), Some(partial_sig)),
)?;

Expand Down
12 changes: 8 additions & 4 deletions lib/core/src/swapper/boltz/liquid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::str::FromStr;
use boltz_client::{
boltz::SwapTxKind,
elements::Transaction,
fees::Fee,
util::{liquid_genesis_hash, secrets::Preimage},
Amount, ElementsAddress as Address, LBtcSwapTx,
ElementsAddress as Address, LBtcSwapTx,
};
use log::info;

Expand Down Expand Up @@ -47,8 +48,9 @@ impl BoltzSwapper {
let signed_tx = claim_tx_wrapper.sign_claim(
&swap.get_claim_keypair()?,
&Preimage::from_str(&swap.preimage)?,
Amount::from_sat(swap.claim_fees_sat),
Fee::Absolute(swap.claim_fees_sat),
self.get_cooperative_details(swap.id.clone(), None, None),
true,
)?;

Ok(signed_tx)
Expand All @@ -74,8 +76,9 @@ impl BoltzSwapper {
let signed_tx = claim_tx_wrapper.sign_claim(
&claim_keypair,
&Preimage::from_str(&swap.preimage)?,
Amount::from_sat(swap.claim_fees_sat),
Fee::Absolute(swap.claim_fees_sat),
self.get_cooperative_details(swap.id.clone(), Some(pub_nonce), Some(partial_sig)),
true,
)?;

Ok(signed_tx)
Expand Down Expand Up @@ -192,8 +195,9 @@ impl BoltzSwapper {

let signed_tx = refund_tx.sign_refund(
&refund_keypair,
Amount::from_sat(broadcast_fees_sat),
Fee::Absolute(broadcast_fees_sat),
cooperative,
true,
)?;
Ok(signed_tx)
}
Expand Down
Loading