-
Notifications
You must be signed in to change notification settings - Fork 123
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]: asset amount received off by 1 #1391
Comments
OK, so it seems you don't work in sat
but do work in msat
? |
Yes, the fundamental unit of the LN is milli-satoshi. |
OK, so the problem here is that internally asset units are always derived units and so we loose precision when going back and forth? So, this is basically a won't fix? |
Yes, it's a fundamental issue of not having true fractional units and exchange rate calculations. We've decided to go with "allow underpayment by at most 1 unit by sender" instead of the other possibility which would be "always overpay by at most 1 unit on sender". |
So, it seems you are only giving the option of ceil vs floor as a rounding technique, but why not also allow rounding up if greater or equal to 1/2 fractional assets and rounding down if less than 1/2 fractional assets? That case would make more sense to me if we have a FixedPoint type that has many more digits that can capture fractional assets in it's arithmetic before converting back to an integer. |
How does that differ from ceil vs floor? Or is it that you suggest a piece-wise rounding scheme? I think we'd need to carefully analyze the proposal. If we're always slowly rounding up anytime something is above 1/2 fractional cents, then I would be worried about the consistent upward drift that could include. |
ceil and floor are off by up to 1, whereas rounding at 1/2, you are off by at most 1/2. If there is already a standard throughout all LL products to use floor, then maybe it is best with that to be consistent though. |
@Liongrass , one thing that may not be as heavily emphasized in the docs as it should be is that sats are the base of everything, even if we think we are working in assets. Even if we are doing a direct asset only channel, assets are still a derived unit so we have other weird stuff that comes up like #1392 . |
I have the following network configuration:
Frank is trying to receive 36000 asset. Frank creates an invoice and then dave pays it, but only 35999 asset are received by frank. Here's the output of my test script:
The text was updated successfully, but these errors were encountered: