From 38131e4e616f02baa621172af5351b697a49237e Mon Sep 17 00:00:00 2001 From: Roei Erez Date: Tue, 8 Oct 2024 16:37:00 +0300 Subject: [PATCH 1/2] Optimize fetching claim tx by querying the lockup address --- libs/sdk-core/src/swap_out/reverseswap.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/sdk-core/src/swap_out/reverseswap.rs b/libs/sdk-core/src/swap_out/reverseswap.rs index bc7a94146..b61120ca6 100644 --- a/libs/sdk-core/src/swap_out/reverseswap.rs +++ b/libs/sdk-core/src/swap_out/reverseswap.rs @@ -533,13 +533,17 @@ impl BTCSendSwap { let lockup_addr = rsi.get_lockup_address(self.config.network)?; Ok(self .chain_service - .address_transactions(rsi.claim_pubkey.clone()) + .address_transactions(lockup_addr.to_string()) .await? .into_iter() .find(|tx| { tx.vin .iter() .any(|vin| vin.prevout.scriptpubkey_address == lockup_addr.to_string()) + && tx + .vout + .iter() + .any(|vout| vout.scriptpubkey_address == rsi.claim_pubkey.clone()) })) } @@ -646,6 +650,12 @@ impl BTCSendSwap { let claim_tx = self.get_claim_tx(&rsi).await?; let claim_tx_status = TxStatus::from(&claim_tx); + if let Some(tx) = &claim_tx { + info!( + "Cound claim tx for reverse swap {:?}: {:?}, status: {:?}", + rsi.id, tx.txid, claim_tx_status + ); + } // Update cached state when new state is detected if let Some(new_status) = self .get_status_update_for_monitored(&rsi, claim_tx_status) From 12a6e582ec37d89f5e331b26e733a0d126776487 Mon Sep 17 00:00:00 2001 From: Roei Erez Date: Wed, 9 Oct 2024 10:31:47 +0300 Subject: [PATCH 2/2] fix error --- libs/sdk-core/src/swap_out/reverseswap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/sdk-core/src/swap_out/reverseswap.rs b/libs/sdk-core/src/swap_out/reverseswap.rs index b61120ca6..4d725e346 100644 --- a/libs/sdk-core/src/swap_out/reverseswap.rs +++ b/libs/sdk-core/src/swap_out/reverseswap.rs @@ -652,7 +652,7 @@ impl BTCSendSwap { if let Some(tx) = &claim_tx { info!( - "Cound claim tx for reverse swap {:?}: {:?}, status: {:?}", + "Found claim tx for reverse swap {:?}: {:?}, status: {:?}", rsi.id, tx.txid, claim_tx_status ); }