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

Retry chain swap server lockup tx verification #557

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

dangeross
Copy link
Collaborator

@dangeross dangeross commented Nov 10, 2024

This PR retries adds monitoring of the incoming server lockup txs. If a server lockup tx is confirmed without a claim (tx failed verification when receiving the Boltz status), then perform the claim.

Fixes #547

let claim_details = chain_swap.get_boltz_create_response()?.claim_details;
let retries = if verify_confirmation { 30 } else { 0 };
let mut retry = 0;
loop {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concern here is that it will block the event status polling loop and may block other payment statuses.

Copy link
Collaborator Author

@dangeross dangeross Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would take a only couple of attempts to get the confirmation, it testing it was confirmed in the first request. Maybe it's better to add it to the tracking thread to verify and claim if needed

@dangeross
Copy link
Collaborator Author

I was able to catch a failed confirmation and see it picked up in the monitoring thread

[2024-11-10 21:03:35.587 INFO breez_sdk_liquid::chain_swap:323] Handling incoming Chain Swap transition to "transaction.server.confirmed" for swap 4HxGzWthwwaU
[2024-11-10 21:03:38.081 INFO breez_sdk_liquid::chain::liquid:250] Liquid transaction found, verifying transaction content...
[2024-11-10 21:03:38.083 INFO breez_sdk_liquid::chain_swap:732] Transitioning Chain swap 4HxGzWthwwaU to Pending (server_lockup_tx_id = Some("8af223ba1e7ccd05cac077a700cf90fd6f93955e1ea9161bbf9f49c288c33d05"), user_lockup_tx_id = None, claim_tx_id = None), refund_tx_id = None)
[2024-11-10 21:03:38.085 WARN breez_sdk_liquid::chain_swap:413] Server lockup transaction for incoming Chain Swap 4HxGzWthwwaU could not be verified. txid: 8af223ba1e7ccd05cac077a700cf90fd6f93955e1ea9161bbf9f49c288c33d05, err: Liquid transaction was not confirmed, txid=8af223ba1e7ccd05cac077a700cf90fd6f93955e1ea9161bbf9f49c288c33d05 waiting for confirmation

...

[2024-11-10 21:04:33.569 INFO breez_sdk_liquid::chain_swap:227] Rescanning 1 incoming Chain Swap(s) server lockup txs at height 3114131
[2024-11-10 21:04:33.846 INFO breez_sdk_liquid::chain_swap:261] Incoming Chain Swap 4HxGzWthwwaU server lockup tx is confirmed
[2024-11-10 21:04:33.847 DEBUG breez_sdk_liquid::chain_swap:770] Initiating claim for Chain Swap 4HxGzWthwwaU
[2024-11-10 21:04:42.730 INFO breez_sdk_liquid::chain_swap:732] Transitioning Chain swap 4HxGzWthwwaU to Pending (server_lockup_tx_id = None, user_lockup_tx_id = None, claim_tx_id = Some("bbe1b7dda86030489461784ffd70b31ff94531c65190a0607617533523050d55")), refund_tx_id = None)
[2024-11-10 21:04:42.735 INFO breez_liquid_cli:46] Received event: PaymentWaitingConfirmation { details: Payment { destination: Some("lq1qqg6vf68kjwdgalvv3gt58h5fvaz73lmxngq6xnjr62gwhwj6gwrvxmwszry4afz5gka38pys3srkkq22dt9w5tzc8stjm5xy9"), tx_id: Some("bbe1b7dda86030489461784ffd70b31ff94531c65190a0607617533523050d55"), timestamp: 1731269082, amount_sat: 49155, fees_sat: 845, payment_type: Receive, status: Pending, details: Bitcoin { swap_id: "4HxGzWthwwaU", description: "Bitcoin transfer", refund_tx_id: None, refund_tx_amount_sat: None } } }

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dangeross dangeross merged commit 2c70315 into main Nov 11, 2024
8 checks passed
@dangeross dangeross deleted the savage-retry-server-tx-verify branch November 11, 2024 15:06
roeierez added a commit that referenced this pull request Nov 17, 2024
* commit '1cbe6d7a8045df6474eba131a298df30e066c84f':
  fix typo
  fix clilppy
  wipe storage cache in case of data corrupted issue
  Log errors on starting an SDK instance (#565)
  Notify success when waiting for claim confirmation (#562)
  Validate the pay_onchain address (#561)
  Liquid/Lightning drain (#553)
  Monitor server lockup tx in thread to verify/claim (#557)
  Update README.md
  Fix chronological order of `list_payments` (#552)
  Onchain payment flow: add more logging (#551)
  Store claim_address for incoming chain swap when claiming (#548)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure to verify confirmed server transaction prevents claim
3 participants