diff --git a/CHANGELOG.md b/CHANGELOG.md index a09e9a1ec..6a20842ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- ASB+CONTROLLER: `get-swaps` now includes the `btc_punish_txid` per swap: the Bitcoin punish transaction id. This is deterministic from the swap's locked state, so it is set even before the punish transaction is published. + ## [4.6.5] - 2026-05-26 ## [4.6.4] - 2026-05-21 diff --git a/swap-controller-api/src/lib.rs b/swap-controller-api/src/lib.rs index 6a8c633af..e3a61f7f9 100644 --- a/swap-controller-api/src/lib.rs +++ b/swap-controller-api/src/lib.rs @@ -85,6 +85,9 @@ pub struct Swap { /// Bitcoin redeem transaction id. Deterministic from the swap's locked state, /// so this is set even before the redeem transaction is published. pub btc_redeem_txid: String, + /// Bitcoin punish transaction id. Deterministic from the swap's locked state, + /// so this is set even before the punish transaction is published. + pub btc_punish_txid: String, pub peer_id: String, pub completed: bool, } diff --git a/swap-controller/src/main.rs b/swap-controller/src/main.rs index 777781c23..108015a52 100644 --- a/swap-controller/src/main.rs +++ b/swap-controller/src/main.rs @@ -90,6 +90,7 @@ async fn dispatch(cmd: Cmd, client: impl AsbApiClient) -> anyhow::Result<()> { "Rate (BTC/XMR)", "BTC Redeem Fee", "BTC Redeem TxID", + "BTC Punish TxID", "Peer ID", "Completed", ]); @@ -110,6 +111,7 @@ async fn dispatch(cmd: Cmd, client: impl AsbApiClient) -> anyhow::Result<()> { &swap.exchange_rate.to_string(), &swap.btc_redeem_fee.to_string(), &swap.btc_redeem_txid, + &swap.btc_punish_txid, &swap.peer_id, &swap.completed.to_string(), ]); diff --git a/swap-core/src/bitcoin/punish.rs b/swap-core/src/bitcoin/punish.rs index 77c28cf4f..4d462dbea 100644 --- a/swap-core/src/bitcoin/punish.rs +++ b/swap-core/src/bitcoin/punish.rs @@ -51,6 +51,10 @@ impl TxPunish { self.digest } + pub fn txid(&self) -> Txid { + self.inner.compute_txid() + } + pub fn complete( self, tx_punish_sig_bob: bitcoin::Signature, diff --git a/swap-machine/src/alice/mod.rs b/swap-machine/src/alice/mod.rs index f9c1a562a..d7bfeb269 100644 --- a/swap-machine/src/alice/mod.rs +++ b/swap-machine/src/alice/mod.rs @@ -1051,7 +1051,7 @@ impl State3 { } } - fn tx_punish(&self) -> TxPunish { + pub fn tx_punish(&self) -> TxPunish { swap_core::bitcoin::TxPunish::new( &self.tx_cancel(), &self.punish_address, diff --git a/swap/src/asb/rpc/server.rs b/swap/src/asb/rpc/server.rs index ea0b21fe2..7ed89e10c 100644 --- a/swap/src/asb/rpc/server.rs +++ b/swap/src/asb/rpc/server.rs @@ -219,6 +219,7 @@ impl AsbApiServer for RpcImpl { exchange_rate, btc_redeem_fee: state3.tx_redeem_fee, btc_redeem_txid: state3.tx_redeem().txid().to_string(), + btc_punish_txid: state3.tx_punish().txid().to_string(), peer_id: peer_id.to_string(), completed: is_complete(¤t_alice), });