lnwallet: use btcutil.NewAmount for BTC -> SAT conversions
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 #939.
This commit is contained in:
4 files changed
+66
-21
No files matched your search
@@ -163,7 +163,11 @@ func forceStateTransition(chanA, chanB *LightningChannel) error {
|
||||
func createTestChannels(revocationWindow int) (*LightningChannel,
|
||||
*LightningChannel, func(), error) {
|
||||
|
||||
channelCapacity := btcutil.Amount(10 * 1e8)
|
||||
channelCapacity, err := btcutil.NewAmount(10)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
channelBal := channelCapacity / 2
|
||||
aliceDustLimit := btcutil.Amount(200)
|
||||
bobDustLimit := btcutil.Amount(1300)
|
||||
|
||||
Reference in new issue
Block a user