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

Ensure fees are calculated without overflow #671

Merged
merged 1 commit into from
Jan 17, 2025
Merged

Conversation

dangeross
Copy link
Collaborator

Getting an overflow calculating the payment fees_sat. It's from a incoming chain swap that was underpaid. I have used saturating_sub to prevent the overflow.

thread 'tokio-runtime-worker' panicked at /Users/rosssavage/Source/Projects/breez-sdk-liquid/lib/core/src/model.rs:1560:23:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is the PaymentSwapData causing the issue:

[2025-01-17 14:56:33.613 DEBUG breez_sdk_liquid::model:1548] Swap ID pending: PaymentSwapData { swap_id: "83CFncYW8e8R", swap_type: Chain, created_at: 1733902652, expiration_blockheight: 874405, preimage: Some("408dd22e5bf613b4d055c22ad2a1a79ba112e03b95237a3dacd305388fcd83f1"), invoice: None, bolt12_offer: None, payment_hash: None, destination_pubkey: None, description: "Bitcoin transfer", payer_amount_sat: 20000, receiver_amount_sat: 47645, swapper_fees_sat: 0, refund_tx_id: Some("fa6699f193043de11e9542496799166b59020416383011f8923837665bde07c1"), refund_tx_amount_sat: None, claim_address: None, status: Failed }

Copy link
Contributor

@danielgranhao danielgranhao left a comment

Choose a reason for hiding this comment

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

LGTM. Might be a good idea to log occurrences for debugging purposes, but we don't need to do it in this PR

@dangeross dangeross merged commit f92a6b9 into main Jan 17, 2025
9 checks passed
@dangeross dangeross deleted the savage-fix-fee-overflow branch January 17, 2025 14:28
dangeross added a commit that referenced this pull request Jan 17, 2025
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.

3 participants