blink
blink copied to clipboard
Standardize lighting invoice amount rounding
Background
The Lightning Network is denominated in millisatoshis but amounts in our system are usually presented as a rounded version of satoshis.
Within lnd
there are usually two types of token amounts quoted:
-
tokens
: a rounded down version ofmillitokens
-
safe_tokens
: a rounded up version ofmillitokens
In our own domain we express this distinction with the roundedUp-
and roundedDown-
prefixs, and you will see types defined as things like roundedUpAmount
or roundedDownFees
Issue
There's a discrepancy in the amount we present in a fee probe and the amount we write to the ledger. These two values are usually off by exactly 1 satoshi and the issue may be coming from inconsistent rounding.
To observe the issue someone can:
- call our
lnInvoiceFeeProbe
mutation with an invoice and note the fee returned - call our
lnInvoicePaymentSend
mutation with the same invoice and make sure it returnsSUCCESS
- fetch the last transaction via our
me
query and compare the fee recorded in the transaction
Suggested Task
This issue has two potential tiers to solve:
-
Investigate and fix the immediate discrepancy
-
Look at how we use roundedUp/roundedDown values across the codebase to see if there are any other potential discrepancies. My initial instinct is that we can probably standardize on using one of these (
roundedUp-
maybe) consistently and phase out ourroundedDown-
usage but this would need to be investigated.
Hey @vindard I started working on this but am having trouble initiating lnInvoiceCreate to get a paymentRequest to start investigating lnInvoiceFeeProbe Do I need to be using a testnet invoice when mocking these API calls locally, or am I missing something else?
Hey @vindard I started working on this but am having trouble initiating lnInvoiceCreate to get a paymentRequest to start investigating lnInvoiceFeeProbe Do I need to be using a testnet invoice when mocking these API calls locally, or am I missing something else?
Hey awesome, are you in our Slack yet?
With the dev setup it's testnet format yea. That one runs in regtest mode.
Ahh ok that makes sense Not yet but I would love to join!