Skip to content

Commit

Permalink
Merge pull request #1102 from breez/optimize-claim-fetch
Browse files Browse the repository at this point in the history
Optimize fetching claim tx by querying the lockup address
  • Loading branch information
roeierez authored Oct 9, 2024
2 parents e2fda44 + 12a6e58 commit 0c4d294
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libs/sdk-core/src/swap_out/reverseswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}))
}

Expand Down Expand Up @@ -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!(
"Found 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)
Expand Down

0 comments on commit 0c4d294

Please sign in to comment.