From 9b173e4895c1f0f5f101bf8d81d9ef9156367dd0 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:55:25 +0200 Subject: [PATCH 01/11] rescan_onchain_swaps: separate internal (scheduled) from external (manual) call --- lib/core/src/chain_swap.rs | 23 +++++++++++++++++++---- lib/core/src/sdk.rs | 11 ++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index 5af15b8d2..fce9642f5 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -76,7 +76,7 @@ impl ChainSwapHandler { loop { tokio::select! { _ = rescan_interval.tick() => { - if let Err(e) = cloned.rescan_incoming_chain_swaps().await { + if let Err(e) = cloned.rescan_incoming_chain_swaps(false).await { error!("Error checking incoming chain swaps: {e:?}"); } if let Err(e) = cloned.rescan_outgoing_chain_swaps().await { @@ -110,7 +110,10 @@ impl ChainSwapHandler { } } - pub(crate) async fn rescan_incoming_chain_swaps(&self) -> Result<()> { + pub(crate) async fn rescan_incoming_chain_swaps( + &self, + ignore_monitoring_block_height: bool, + ) -> Result<()> { let current_height = self.bitcoin_chain_service.lock().await.tip()?.height as u32; let chain_swaps: Vec = self .persister @@ -124,22 +127,34 @@ impl ChainSwapHandler { current_height ); for swap in chain_swaps { - if let Err(e) = self.rescan_incoming_chain_swap(&swap, current_height).await { + if let Err(e) = self + .rescan_incoming_chain_swap(&swap, current_height, ignore_monitoring_block_height) + .await + { error!("Error rescanning incoming Chain Swap {}: {e:?}", swap.id); } } Ok(()) } + /// ### Arguments + /// - `swap`: the swap being rescanned + /// - `current_height`: the tip + /// - `ignore_monitoring_block_height`: if true, it rescans an expired swap even after the + /// cutoff monitoring block height async fn rescan_incoming_chain_swap( &self, swap: &ChainSwap, current_height: u32, + ignore_monitoring_block_height: bool, ) -> Result<()> { let monitoring_block_height = swap.timeout_block_height + CHAIN_SWAP_MONITORING_PERIOD_BITCOIN_BLOCKS; let is_swap_expired = current_height > swap.timeout_block_height; - let is_monitoring_expired = current_height > monitoring_block_height; + let is_monitoring_expired = match ignore_monitoring_block_height { + true => false, + false => current_height > monitoring_block_height, + }; if (is_swap_expired && !is_monitoring_expired) || swap.state == RefundPending { let swap_script = swap.get_lockup_swap_script()?.as_bitcoin_script()?; diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 900c75672..de877be74 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1808,11 +1808,16 @@ impl LiquidSdk { Ok(RefundResponse { refund_tx_id }) } - /// Rescans all expired chain swaps created from calling [LiquidSdk::receive_onchain] within - /// the monitoring period to check if there are any confirmed funds available to refund. + /// Rescans all expired chain swaps created from calling [LiquidSdk::receive_onchain] to check + /// if there are any confirmed funds available to refund. + /// + /// Since it bypasses the monitoring period, this should be called rarely or when the caller + /// expects there is a very old refundable chain swap. Otherwise, for relatively recent swaps + /// (within last [CHAIN_SWAP_MONITORING_PERIOD_BITCOIN_BLOCKS] blocks = ~30 days), calling this + /// is not necessary as it happens automatically in the background. pub async fn rescan_onchain_swaps(&self) -> SdkResult<()> { self.chain_swap_handler - .rescan_incoming_chain_swaps() + .rescan_incoming_chain_swaps(true) .await?; Ok(()) } From d2eae3f566dc214b0e72bf21d25fa6f795ba565b Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:13:08 +0200 Subject: [PATCH 02/11] Add TODOs for supporting more utxos in BtcSwapTx::new_refund --- lib/core/src/chain_swap.rs | 6 +++--- lib/core/src/swapper/boltz/bitcoin.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index fce9642f5..36d816735 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -749,7 +749,7 @@ impl ChainSwapHandler { Ok(()) } - pub async fn prepare_refund( + pub(crate) async fn prepare_refund( &self, lockup_address: &str, refund_address: &str, @@ -759,7 +759,7 @@ impl ChainSwapHandler { .persister .fetch_chain_swap_by_lockup_address(lockup_address)? .ok_or(SdkError::Generic { - err: format!("Swap {} not found", lockup_address), + err: format!("Swap for lockup address {} not found", lockup_address), })?; let refund_tx_id = swap.refund_tx_id.clone(); @@ -790,7 +790,7 @@ impl ChainSwapHandler { .persister .fetch_chain_swap_by_lockup_address(lockup_address)? .ok_or(PaymentError::Generic { - err: format!("Swap {} not found", lockup_address), + err: format!("Swap for lockup address {} not found", lockup_address), })?; ensure_sdk!( diff --git a/lib/core/src/swapper/boltz/bitcoin.rs b/lib/core/src/swapper/boltz/bitcoin.rs index 468bcc4a3..625f1da54 100644 --- a/lib/core/src/swapper/boltz/bitcoin.rs +++ b/lib/core/src/swapper/boltz/bitcoin.rs @@ -25,6 +25,7 @@ impl BoltzSwapper { Swap::Chain(swap) => match swap.direction { Direction::Incoming => { let swap_script = swap.get_lockup_swap_script()?; + // TODO Update boltz-client to build refund tx with all utxos BtcSwapTx::new_refund( swap_script.as_bitcoin_script()?, refund_address, From dd0ca82ccd67dad7323cb33d8890814f6f857e5e Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Fri, 20 Sep 2024 18:11:42 +0200 Subject: [PATCH 03/11] Update boltz-client to build refund tx with all utxos --- cli/Cargo.lock | 2 +- lib/Cargo.lock | 2 +- lib/core/Cargo.toml | 2 +- lib/core/src/swapper/boltz/bitcoin.rs | 13 +++++-------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cli/Cargo.lock b/cli/Cargo.lock index dd91d4025..b811880aa 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -500,7 +500,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/hydra-yse/boltz-rust?branch=yse-fee-calculation#09710fb508a2a188978f37c091ebb488331d627d" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#1917a187998b3f0801532fef350f8530a7544871" dependencies = [ "bip39", "bitcoin 0.31.2", diff --git a/lib/Cargo.lock b/lib/Cargo.lock index bdfb82cdf..49da52587 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -614,7 +614,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/hydra-yse/boltz-rust?branch=yse-fee-calculation#09710fb508a2a188978f37c091ebb488331d627d" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#1917a187998b3f0801532fef350f8530a7544871" dependencies = [ "bip39", "bitcoin 0.31.2", diff --git a/lib/core/Cargo.toml b/lib/core/Cargo.toml index 26b6ab981..c159b519c 100644 --- a/lib/core/Cargo.toml +++ b/lib/core/Cargo.toml @@ -14,7 +14,7 @@ frb = ["dep:flutter_rust_bridge"] [dependencies] anyhow = { workspace = true } bip39 = "2.0.0" -boltz-client = { git = "https://github.com/hydra-yse/boltz-rust", branch = "yse-fee-calculation" } +boltz-client = { git = "https://github.com/ok300/boltz-rust", branch = "ok300-chain-swap-refund-check-all-utoxs" } chrono = "0.4" env_logger = "0.11" flutter_rust_bridge = { version = "=2.3.0", features = [ diff --git a/lib/core/src/swapper/boltz/bitcoin.rs b/lib/core/src/swapper/boltz/bitcoin.rs index 625f1da54..9591814eb 100644 --- a/lib/core/src/swapper/boltz/bitcoin.rs +++ b/lib/core/src/swapper/boltz/bitcoin.rs @@ -25,7 +25,6 @@ impl BoltzSwapper { Swap::Chain(swap) => match swap.direction { Direction::Incoming => { let swap_script = swap.get_lockup_swap_script()?; - // TODO Update boltz-client to build refund tx with all utxos BtcSwapTx::new_refund( swap_script.as_bitcoin_script()?, refund_address, @@ -77,18 +76,16 @@ impl BoltzSwapper { } ); - let utxo = utxos - .first() - .and_then(|utxo| utxo.as_bitcoin().cloned()) - .ok_or(SdkError::Generic { - err: "No UTXO found".to_string(), - })?; + let utxos = utxos + .iter() + .filter_map(|utxo| utxo.as_bitcoin().cloned()) + .collect(); let refund_tx = BtcSwapTx { kind: SwapTxKind::Refund, swap_script, output_address: address.assume_checked(), - utxo, + utxos, }; let refund_tx_size = refund_tx.size(refund_keypair, &Preimage::new())?; From e22a5f803b4f79eb9e414737c6fd17c7f2fb0df1 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Sun, 22 Sep 2024 11:38:38 +0200 Subject: [PATCH 04/11] list-refundables: show refundable amount, not swap amount --- lib/core/src/chain_swap.rs | 6 +----- lib/core/src/model.rs | 13 +++++++++++++ lib/core/src/sdk.rs | 27 +++++++++++++++++++++------ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index 36d816735..c5f88a20c 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -157,11 +157,7 @@ impl ChainSwapHandler { }; if (is_swap_expired && !is_monitoring_expired) || swap.state == RefundPending { - let swap_script = swap.get_lockup_swap_script()?.as_bitcoin_script()?; - let script_pubkey = swap_script - .to_address(self.config.network.as_bitcoin_chain()) - .map_err(|e| anyhow!("Error getting script address: {e:?}"))? - .script_pubkey(); + let script_pubkey = swap.get_lockup_swap_script_pubkey(self.config.network)?; let script_balance = self .bitcoin_chain_service .lock() diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index bb62f0545..42dd62e92 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use anyhow::{anyhow, Result}; use boltz_client::{ + bitcoin::ScriptBuf, network::Chain, swaps::boltz::{ CreateChainResponse, CreateReverseResponse, CreateSubmarineResponse, Leaf, Side, SwapTree, @@ -608,6 +609,18 @@ impl ChainSwap { Ok(swap_script) } + pub(crate) fn get_lockup_swap_script_pubkey( + &self, + network: LiquidNetwork, + ) -> SdkResult { + let swap_script = self.get_lockup_swap_script()?.as_bitcoin_script()?; + let script_pubkey = swap_script + .to_address(network.as_bitcoin_chain()) + .map_err(|e| anyhow!("Error getting script address: {e:?}"))? + .script_pubkey(); + Ok(script_pubkey) + } + pub(crate) fn from_boltz_struct_to_json( create_response: &CreateChainResponse, expected_swap_id: &str, diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index de877be74..d0096d502 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1744,12 +1744,27 @@ impl LiquidSdk { /// List all failed chain swaps that need to be refunded. /// They can be refunded by calling [LiquidSdk::prepare_refund] then [LiquidSdk::refund]. pub async fn list_refundables(&self) -> SdkResult> { - Ok(self - .persister - .list_refundable_chain_swaps()? - .into_iter() - .map(Into::into) - .collect()) + let chain_swaps = self.persister.list_refundable_chain_swaps()?; + + let mut refundables = vec![]; + for chain_swap in chain_swaps { + let script_pubkey = chain_swap.get_lockup_swap_script_pubkey(self.config.network)?; + let script_balance = self + .bitcoin_chain_service + .lock() + .await + .script_get_balance(script_pubkey.as_script())?; + info!( + "Incoming Chain Swap {} is refundable with {} confirmed sats", + chain_swap.id, script_balance.confirmed + ); + + let mut refundable: RefundableSwap = chain_swap.into(); + refundable.amount_sat = script_balance.confirmed; + refundables.push(refundable); + } + + Ok(refundables) } /// Prepares to refund a failed chain swap by calculating the refund transaction size and absolute fee. From 8a325e3c13b7e9b54b9f5256bea206989eac53b6 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:25:04 +0200 Subject: [PATCH 05/11] Chain swap cooperative refund: fix "Liquid chain used for Bitcoin operations" error --- lib/core/src/chain_swap.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index bf1cb0790..dee04c322 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -819,8 +819,8 @@ impl ChainSwapHandler { let bitcoin_chain_service = self.bitcoin_chain_service.lock().await; let script_pk = swap_script - .to_address(self.config.network.into()) - .map_err(|_| anyhow!("Could not retrieve address from swap script"))? + .to_address(self.config.network.as_bitcoin_chain()) + .map_err(|e| anyhow!("Could not retrieve address from swap script: {e:?}"))? .script_pubkey(); let utxos = bitcoin_chain_service.get_script_utxos(&script_pk).await?; @@ -839,6 +839,7 @@ impl ChainSwapHandler { ), }); }; + debug!("Built refund tx: {refund_tx:?}"); let refund_tx_id = bitcoin_chain_service.broadcast(&refund_tx)?.to_string(); info!( From fd10940965d316e82a5fc4103bcfd2182a677e41 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:33:34 +0200 Subject: [PATCH 06/11] Revert "Chain swap cooperative refund: fix "Liquid chain used for Bitcoin operations" error" This reverts commit 8a325e3c13b7e9b54b9f5256bea206989eac53b6. --- lib/core/src/chain_swap.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index dee04c322..bf1cb0790 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -819,8 +819,8 @@ impl ChainSwapHandler { let bitcoin_chain_service = self.bitcoin_chain_service.lock().await; let script_pk = swap_script - .to_address(self.config.network.as_bitcoin_chain()) - .map_err(|e| anyhow!("Could not retrieve address from swap script: {e:?}"))? + .to_address(self.config.network.into()) + .map_err(|_| anyhow!("Could not retrieve address from swap script"))? .script_pubkey(); let utxos = bitcoin_chain_service.get_script_utxos(&script_pk).await?; @@ -839,7 +839,6 @@ impl ChainSwapHandler { ), }); }; - debug!("Built refund tx: {refund_tx:?}"); let refund_tx_id = bitcoin_chain_service.broadcast(&refund_tx)?.to_string(); info!( From d98fd0754878cca14ed2cb112b61e6106fa50c4a Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:56:37 +0200 Subject: [PATCH 07/11] Bump boltz-rust to include sign_refund fix --- cli/Cargo.lock | 2 +- lib/Cargo.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/Cargo.lock b/cli/Cargo.lock index f93c08e08..18a09596b 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -500,7 +500,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#1917a187998b3f0801532fef350f8530a7544871" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#edf97658fe71621fbfef8c7a1def05c411ab2de7" dependencies = [ "bip39", "bitcoin 0.31.2", diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 5dd8047f9..c67bdc565 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -614,7 +614,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#1917a187998b3f0801532fef350f8530a7544871" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#edf97658fe71621fbfef8c7a1def05c411ab2de7" dependencies = [ "bip39", "bitcoin 0.31.2", From 82264e9622efba62bb7b915f3e754ab7dd25d3ad Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:31:51 +0200 Subject: [PATCH 08/11] Bump boltz-rust to include sign_refund fix for non-coop refund --- cli/Cargo.lock | 2 +- lib/Cargo.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 18a09596b..04e187af0 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -500,7 +500,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#edf97658fe71621fbfef8c7a1def05c411ab2de7" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#368d31c3ea34027e6e8f07daa5e9a43c5fa91dde" dependencies = [ "bip39", "bitcoin 0.31.2", diff --git a/lib/Cargo.lock b/lib/Cargo.lock index c67bdc565..5f7385d7f 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -614,7 +614,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#edf97658fe71621fbfef8c7a1def05c411ab2de7" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#368d31c3ea34027e6e8f07daa5e9a43c5fa91dde" dependencies = [ "bip39", "bitcoin 0.31.2", From 4d56bda72225b250e74a32dde140be16aaafd3ce Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:34:30 +0200 Subject: [PATCH 09/11] Fix state handling when incoming chain swaps are refunded --- lib/core/src/sdk.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 1bde9db18..c79e16715 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1822,6 +1822,28 @@ impl LiquidSdk { ) }) .await?; + + let swap = self + .persister + .fetch_chain_swap_by_lockup_address(&req.swap_address)? + .ok_or(PaymentError::Generic { + err: format!("Swap for lockup address {} not found", &req.swap_address), + })?; + + // Set the payment state to `RefundPending`. This ensures: + // - the swap is not shown in `list-refundables` anymore + // - the background thread will move it to Failed once the refund tx confirms + self.chain_swap_handler + .update_swap_info( + &swap.id, + RefundPending, + None, + None, + None, + Some(&refund_tx_id), + ) + .await?; + Ok(RefundResponse { refund_tx_id }) } From 29872000a802b475408ee19bd4aa0a0b7c3af9d2 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:18:37 +0200 Subject: [PATCH 10/11] Move swap state change inside refund_incoming_swap --- lib/core/src/chain_swap.rs | 36 +++++++++++++++++++----------------- lib/core/src/sdk.rs | 21 --------------------- 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index 67ff3bd7a..9a04cdc0f 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -788,28 +788,23 @@ impl ChainSwapHandler { .ok_or(PaymentError::Generic { err: format!("Swap for lockup address {} not found", lockup_address), })?; + let id = &swap.id; ensure_sdk!( swap.state == Refundable, PaymentError::Generic { - err: format!("Chain Swap {} was not marked as `Refundable`", swap.id) + err: format!("Chain Swap {id} was not marked as `Refundable`") } ); ensure_sdk!( swap.refund_tx_id.is_none(), PaymentError::Generic { - err: format!( - "A refund tx for incoming Chain Swap {} was already broadcast", - swap.id - ) + err: format!("A refund tx for incoming Chain Swap {id} was already broadcast",) } ); - info!( - "Initiating refund for incoming Chain Swap {}, is_cooperative: {is_cooperative}", - swap.id - ); + info!("Initiating refund for incoming Chain Swap {id}, is_cooperative: {is_cooperative}",); let SwapScriptV2::Bitcoin(swap_script) = swap.get_lockup_swap_script()? else { return Err(PaymentError::Generic { @@ -833,18 +828,25 @@ impl ChainSwapHandler { )? else { return Err(PaymentError::Generic { - err: format!( - "Unexpected refund tx type returned for incoming Chain swap {}", - swap.id - ), + err: format!("Unexpected refund tx type returned for incoming Chain swap {id}",), }); }; let refund_tx_id = bitcoin_chain_service.broadcast(&refund_tx)?.to_string(); - info!( - "Successfully broadcast refund for incoming Chain Swap {}, is_cooperative: {is_cooperative}", - swap.id - ); + info!("Successfully broadcast refund for incoming Chain Swap {id}, is_cooperative: {is_cooperative}"); + + // After refund tx is broadcasted, set the payment state to `RefundPending`. This ensures: + // - the swap is not shown in `list-refundables` anymore + // - the background thread will move it to Failed once the refund tx confirms + self.update_swap_info( + &swap.id, + RefundPending, + None, + None, + None, + Some(&refund_tx_id), + ) + .await?; Ok(refund_tx_id) } diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index c79e16715..a14c89c9f 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1823,27 +1823,6 @@ impl LiquidSdk { }) .await?; - let swap = self - .persister - .fetch_chain_swap_by_lockup_address(&req.swap_address)? - .ok_or(PaymentError::Generic { - err: format!("Swap for lockup address {} not found", &req.swap_address), - })?; - - // Set the payment state to `RefundPending`. This ensures: - // - the swap is not shown in `list-refundables` anymore - // - the background thread will move it to Failed once the refund tx confirms - self.chain_swap_handler - .update_swap_info( - &swap.id, - RefundPending, - None, - None, - None, - Some(&refund_tx_id), - ) - .await?; - Ok(RefundResponse { refund_tx_id }) } From 87e9327d24e1da02febf3f0e7bba08570111f29e Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:28:42 +0200 Subject: [PATCH 11/11] Bump to latest boltz-client branch version --- lib/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 5c110b014..b4ee40723 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -653,7 +653,7 @@ dependencies = [ [[package]] name = "boltz-client" version = "0.1.3" -source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#368d31c3ea34027e6e8f07daa5e9a43c5fa91dde" +source = "git+https://github.com/ok300/boltz-rust?branch=ok300-chain-swap-refund-check-all-utoxs#5934ec921ac3240cabcab2d98be29b2b4652af56" dependencies = [ "bip39", "bitcoin 0.31.2",