Skip to content

Fix litcli sendpayment panic #911

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

Merged

Conversation

GeorgeTsagk
Copy link
Member

@GeorgeTsagk GeorgeTsagk commented Dec 3, 2024

Description

Sometimes the asset units may not be sufficient to carry out a payment (depending on the granularity and asset price). This may be lead to calculating "zero" units for a payment. This pr fixes a small piece of code that would blindly divide by numUnits without checking whether it's zero. If it's zero we need to error out as this means the payment cannot be carried out.

Solution

If we have numUnits equal to 0 we skip the division that would cause the panic, and instead return an error to the user which looks like this

Payment hash: 5cf59c0af46885e67054c8e0d5cf732952650e0965881db2e1e42d706528a78f
Description: 
Amount (in satoshis): 99
Fee limit (in satoshis): 99
Destination: 0327e3031fa45faa56be7e702de23e3d8c2305a5d69b410e2f44fa8bbca6dfa5ef
Confirm payment (yes/no): yes
[litcli] smallest payment with asset rate 1000000 is 100000 mSAT, cannot send 99000 mSAT

Related issues

Closes lightninglabs/taproot-assets#1230

@GeorgeTsagk GeorgeTsagk self-assigned this Dec 3, 2024
@dstadulis dstadulis added this to the tapd v0.5 milestone Dec 3, 2024
@GeorgeTsagk GeorgeTsagk requested review from Roasbeef and guggero and removed request for ellemouton December 4, 2024 09:50
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

tACK

While testing I noticed that the payment actually stays in-flight in the background forever. But that's unrelated to this change and needs to be fixed in lnd. Going to create a PR for it.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 👑

@Roasbeef Roasbeef merged commit d4505dd into lightninglabs:update-to-lnd-18-4 Dec 4, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants