From 4a0a657eb02d4b6fbd5b5a52d473fce68ff2f296 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 24 Dec 2016 18:26:44 -0600 Subject: [PATCH] lnwallet/btcwallet: fix bug in implementation of GetUxo This commit fixes a bug within the btcwallet implementation of the BlockChainIO interface. The exact nature of the bug was a rounding error that would only manifest if the value of the UTXO was below 1 BTC. The tests within this package currently test channels with mostly whole values of BTC, as a result the bug went unnoticed until now. The fix itself is trivial: convert to an int64 AFTER performing the multiplication to convert to satoshis from Bitcoin. --- lnwallet/btcwallet/blockchain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnwallet/btcwallet/blockchain.go b/lnwallet/btcwallet/blockchain.go index 4853b1e7..93411786 100644 --- a/lnwallet/btcwallet/blockchain.go +++ b/lnwallet/btcwallet/blockchain.go @@ -32,7 +32,7 @@ func (b *BtcWallet) GetUtxo(txid *wire.ShaHash, index uint32) (*wire.TxOut, erro return &wire.TxOut{ // Sadly, gettxout returns the output value in BTC // instead of satoshis. - Value: int64(txout.Value) * 1e8, + Value: int64(txout.Value * 1e8), PkScript: pkScript, }, nil }