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

[bug]: Invoice Amount Paid Field also account for canceled/accepted HTLCs #9436

Open
ziggie1984 opened this issue Jan 22, 2025 · 0 comments
Open
Labels
bug Unintended code behaviour hodl-invoices invoices

Comments

@ziggie1984
Copy link
Collaborator

Came up during the development of the invoice migration PR (#8831).

An invoice has an AmtPaid field when represented on disk and also in memory:

// AmtPaid is the final amount that we ultimately accepted for pay for
// this invoice. We specify this value independently as it's possible
// that the invoice originally didn't specify an amount, or the sender
// overpaid.
AmtPaid lnwire.MilliSatoshi

We need to make the description more clear what AmtPaid really means especially when it comes to HoldInvoice which can cancel the HTLC which right now results in the AmtPaid increasing even though the HTLC might have been canceled. So either we clarify the description or we do not increase the Amt if an HTLC is just in the Accepted state.

Example:

  "settle_index": "0",
            "amt_paid": "100000",
            "amt_paid_sat": "100",
            "amt_paid_msat": "100000",
            "state": "CANCELED",
            "htlcs": [
                {
                    "chan_id": "369435906998272",
                    "htlc_index": "0",
                    "amt_msat": "100000",
                    "accept_height": 341,
                    "accept_time": "1737587642",
                    "resolve_time": "1737587833",
                    "expiry_height": 424,
                    "state": "CANCELED",
                    "custom_records": {},
                    "mpp_total_amt_msat": "100000",
                    "amp": null,
                    "custom_channel_data": ""
                }
            ],

or in case it was just accepted:

  "amt_paid": "100000",
            "amt_paid_sat": "100",
            "amt_paid_msat": "100000",
            "state": "ACCEPTED",
            "htlcs": [
                {
                    "chan_id": "369435906998272",
                    "htlc_index": "0",
                    "amt_msat": "100000",
                    "accept_height": 341,
                    "accept_time": "1737587642",
                    "resolve_time": "0",
                    "expiry_height": 424,
                    "state": "ACCEPTED",
                    "custom_records": {},
                    "mpp_total_amt_msat": "100000",
                    "amp": null,
                    "custom_channel_data": ""
                }
            ],
@ziggie1984 ziggie1984 added bug Unintended code behaviour hodl-invoices invoices labels Jan 22, 2025
@ziggie1984 ziggie1984 changed the title [bug]: Invoice Amount Paid Field [bug]: Invoice Amount Paid Field also account for canceled/accepted HTLCs Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unintended code behaviour hodl-invoices invoices
Projects
None yet
Development

No branches or pull requests

1 participant