channeldb: update the OutgoingPayment struct to use lnwire.MilliSatoshi

This commit is contained in:
Olaoluwa Osuntokun
2017-08-21 22:49:56 -07:00
parent 6e17c34229
commit 063525c6e0
3 changed files with 20 additions and 18 deletions

View File

@@ -6,7 +6,7 @@ import (
"io"
"github.com/boltdb/bolt"
"github.com/roasbeef/btcutil"
"github.com/lightningnetwork/lnd/lnwire"
)
var (
@@ -25,8 +25,8 @@ var (
type OutgoingPayment struct {
Invoice
// Fee is the total fee paid for the payment in satoshis.
Fee btcutil.Amount
// Fee is the total fee paid for the payment in milli-satoshis.
Fee lnwire.MilliSatoshi
// TotalTimeLock is the total cumulative time-lock in the HTLC extended
// from the second-to-last hop to the destination.
@@ -184,7 +184,7 @@ func deserializeOutgoingPayment(r io.Reader) (*OutgoingPayment, error) {
if _, err := r.Read(scratch[:]); err != nil {
return nil, err
}
p.Fee = btcutil.Amount(byteOrder.Uint64(scratch[:]))
p.Fee = lnwire.MilliSatoshi(byteOrder.Uint64(scratch[:]))
if _, err = r.Read(scratch[:4]); err != nil {
return nil, err

View File

@@ -10,7 +10,7 @@ import (
"time"
"github.com/davecgh/go-spew/spew"
"github.com/roasbeef/btcutil"
"github.com/lightningnetwork/lnd/lnwire"
)
func makeFakePayment() *OutgoingPayment {
@@ -21,7 +21,7 @@ func makeFakePayment() *OutgoingPayment {
}
copy(fakeInvoice.Terms.PaymentPreimage[:], rev[:])
fakeInvoice.Terms.Value = btcutil.Amount(10000)
fakeInvoice.Terms.Value = lnwire.NewMSatFromSatoshis(10000)
fakePath := make([][33]byte, 3)
for i := 0; i < 3; i++ {
@@ -71,7 +71,7 @@ func makeRandomFakePayment() (*OutgoingPayment, error) {
}
copy(fakeInvoice.Terms.PaymentPreimage[:], preImg)
fakeInvoice.Terms.Value = btcutil.Amount(rand.Intn(10000))
fakeInvoice.Terms.Value = lnwire.MilliSatoshi(rand.Intn(10000))
fakePathLen := 1 + rand.Intn(5)
fakePath := make([][33]byte, fakePathLen)
@@ -86,7 +86,7 @@ func makeRandomFakePayment() (*OutgoingPayment, error) {
rHash := sha256.Sum256(fakeInvoice.Terms.PaymentPreimage[:])
fakePayment := &OutgoingPayment{
Invoice: *fakeInvoice,
Fee: btcutil.Amount(rand.Intn(1001)),
Fee: lnwire.MilliSatoshi(rand.Intn(1001)),
Path: fakePath,
TimeLockLength: uint32(rand.Intn(10000)),
PaymentHash: rHash,