-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Incorrect satoshi rounding #939
Labels
code health
Related to code commenting, refactoring, and other non-behaviour improvements
Comments
I see an error that may be a result of this:
Looks like it's picking up a route based on a rounded down value. |
@zavan I don't think that's related at all, this issue is isolated to the way we convert BTC from the rpc calls into satoshis that we'll use for manipulation internally. |
Roasbeef
added a commit
to Roasbeef/lnd
that referenced
this issue
Mar 26, 2018
In this commit, we fix an existing rounding related bug in the codebase. The RPC interface for btcd and bitcoind return values in BTC rather than in satoshis. So in several places, we're forced to convert ourselves manually. The existing logic attempted to do this, but didn't properly account for rounding. As a result, our values can be off due to not rounding incorrectly. The fix for this is easy: simply properly use btcutil.NewAmount everywhere which does rounding properly. Fixes lightningnetwork#939.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some code is based on the assumption that
satoshiAmount = int64(bitcoinAmount * 1e8)
. This seems to be incorrect. For example, the go code:prints
2
, not3
.This happens in btcwallet.go, where the value of some UTXOs is off by one satoshi which makes the wallet balance report wrong. Here, using the
btcutil.NewAmount
function instead (which does correct rounding) would solve the problem.But the issue seems to be present in other places (e.g. blockchain.go) which do not depend on btcutil and thus might need to be explicitly rounded.
The text was updated successfully, but these errors were encountered: