lnwire: convert all relevant fields to use the MilliSatoshi type
This commit is contained in:
parent
05d05ac5ee
commit
b174ae80bf
@ -25,9 +25,7 @@ type AcceptChannel struct {
|
||||
// MaxValueInFlight represents the maximum amount of coins that can be
|
||||
// pending within the channel at any given time. If the amount of funds
|
||||
// in limbo exceeds this amount, then the channel will be failed.
|
||||
//
|
||||
// TODO(roasbeef): is msat
|
||||
MaxValueInFlight btcutil.Amount
|
||||
MaxValueInFlight MilliSatoshi
|
||||
|
||||
// ChannelReserve is the amount of BTC that the receiving party MUST
|
||||
// maintain a balance above at all times. This is a safety mechanism to
|
||||
@ -41,9 +39,7 @@ type AcceptChannel struct {
|
||||
|
||||
// HtlcMinimum is the smallest HTLC that the sender of this message
|
||||
// will accept.
|
||||
//
|
||||
// TODO(roasbeef): is msat
|
||||
HtlcMinimum uint32
|
||||
HtlcMinimum MilliSatoshi
|
||||
|
||||
// CsvDelay is the number of blocks to use for the relative time lock
|
||||
// in the pay-to-self output of both commitment transactions.
|
||||
@ -149,6 +145,6 @@ func (a *AcceptChannel) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *AcceptChannel) MaxPayloadLength(uint32) uint32 {
|
||||
// 32 + (8 * 3) + (4 * 2) + (2 * 2) + (33 * 5)
|
||||
return 233
|
||||
// 32 + (8 * 4) + (4 * 1) + (2 * 2) + (33 * 5)
|
||||
return 237
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
}
|
||||
if !reflect.DeepEqual(msg, newMsg) {
|
||||
t.Fatalf("messages don't match after re-encoding: %v "+
|
||||
"vs %v", msg, newMsg)
|
||||
"vs %v", spew.Sdump(msg), spew.Sdump(newMsg))
|
||||
return false
|
||||
}
|
||||
|
||||
@ -149,11 +149,11 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
MsgOpenChannel: func(v []reflect.Value, r *rand.Rand) {
|
||||
req := OpenChannel{
|
||||
FundingAmount: btcutil.Amount(r.Int63()),
|
||||
PushAmount: btcutil.Amount(r.Int63()),
|
||||
PushAmount: MilliSatoshi(r.Int63()),
|
||||
DustLimit: btcutil.Amount(r.Int63()),
|
||||
MaxValueInFlight: btcutil.Amount(r.Int63()),
|
||||
MaxValueInFlight: MilliSatoshi(r.Int63()),
|
||||
ChannelReserve: btcutil.Amount(r.Int63()),
|
||||
HtlcMinimum: uint32(r.Int31()),
|
||||
HtlcMinimum: MilliSatoshi(r.Int31()),
|
||||
FeePerKiloWeight: uint32(r.Int63()),
|
||||
CsvDelay: uint16(r.Int31()),
|
||||
MaxAcceptedHTLCs: uint16(r.Int31()),
|
||||
@ -202,10 +202,10 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
MsgAcceptChannel: func(v []reflect.Value, r *rand.Rand) {
|
||||
req := AcceptChannel{
|
||||
DustLimit: btcutil.Amount(r.Int63()),
|
||||
MaxValueInFlight: btcutil.Amount(r.Int63()),
|
||||
MaxValueInFlight: MilliSatoshi(r.Int63()),
|
||||
ChannelReserve: btcutil.Amount(r.Int63()),
|
||||
MinAcceptDepth: uint32(r.Int31()),
|
||||
HtlcMinimum: uint32(r.Int31()),
|
||||
HtlcMinimum: MilliSatoshi(r.Int31()),
|
||||
CsvDelay: uint16(r.Int31()),
|
||||
MaxAcceptedHTLCs: uint16(r.Int31()),
|
||||
}
|
||||
@ -412,7 +412,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
Timestamp: uint32(r.Int31()),
|
||||
Flags: uint16(r.Int31()),
|
||||
TimeLockDelta: uint16(r.Int31()),
|
||||
HtlcMinimumMsat: uint64(r.Int63()),
|
||||
HtlcMinimumMsat: MilliSatoshi(r.Int63()),
|
||||
BaseFee: uint32(r.Int31()),
|
||||
FeeRate: uint32(r.Int31()),
|
||||
}
|
||||
|
@ -448,15 +448,15 @@ func (f *FailTemporaryChannelFailure) Encode(w io.Writer, pver uint32) error {
|
||||
// NOTE: May only be returned by the intermediate nodes in the path.
|
||||
type FailAmountBelowMinimum struct {
|
||||
// HtlcMsat is the wrong amount of the incoming HTLC.
|
||||
HtlcMsat btcutil.Amount
|
||||
HtlcMsat MilliSatoshi
|
||||
|
||||
// Update is used to update information about state of the channel which
|
||||
// caused the failure.
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
}
|
||||
|
||||
// NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.
|
||||
func NewAmountBelowMinimum(htlcMsat btcutil.Amount,
|
||||
func NewAmountBelowMinimum(htlcMsat MilliSatoshi,
|
||||
update ChannelUpdate) *FailAmountBelowMinimum {
|
||||
|
||||
return &FailAmountBelowMinimum{
|
||||
@ -512,7 +512,7 @@ func (f *FailAmountBelowMinimum) Encode(w io.Writer, pver uint32) error {
|
||||
// NOTE: May only be returned by intermediate nodes.
|
||||
type FailFeeInsufficient struct {
|
||||
// HtlcMsat is the wrong amount of the incoming HTLC.
|
||||
HtlcMsat btcutil.Amount
|
||||
HtlcMsat MilliSatoshi
|
||||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
@ -520,7 +520,7 @@ type FailFeeInsufficient struct {
|
||||
}
|
||||
|
||||
// NewFeeInsufficient creates new instance of the FailFeeInsufficient.
|
||||
func NewFeeInsufficient(htlcMsat btcutil.Amount,
|
||||
func NewFeeInsufficient(htlcMsat MilliSatoshi,
|
||||
update ChannelUpdate) *FailFeeInsufficient {
|
||||
return &FailFeeInsufficient{
|
||||
HtlcMsat: htlcMsat,
|
||||
@ -791,12 +791,12 @@ func (f *FailFinalIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error {
|
||||
// NOTE: May only be returned by the final node.
|
||||
type FailFinalIncorrectHtlcAmount struct {
|
||||
// IncomingHTLCAmount is the wrong forwarded htlc amount.
|
||||
IncomingHTLCAmount btcutil.Amount
|
||||
IncomingHTLCAmount MilliSatoshi
|
||||
}
|
||||
|
||||
// NewFinalIncorrectHtlcAmount creates new instance of the
|
||||
// FailFinalIncorrectHtlcAmount.
|
||||
func NewFinalIncorrectHtlcAmount(amount btcutil.Amount) *FailFinalIncorrectHtlcAmount {
|
||||
func NewFinalIncorrectHtlcAmount(amount MilliSatoshi) *FailFinalIncorrectHtlcAmount {
|
||||
return &FailFinalIncorrectHtlcAmount{
|
||||
IncomingHTLCAmount: amount,
|
||||
}
|
||||
|
@ -4,13 +4,11 @@ import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/roasbeef/btcutil"
|
||||
)
|
||||
|
||||
var (
|
||||
testOnionHash = []byte{}
|
||||
testAmount = btcutil.Amount(1)
|
||||
testAmount = MilliSatoshi(1)
|
||||
testCtlvExpiry = uint32(2)
|
||||
testFlags = uint16(2)
|
||||
testChannelUpdate = ChannelUpdate{
|
||||
|
@ -31,9 +31,7 @@ type OpenChannel struct {
|
||||
// PushAmount is the value that the initiating party wishes to "push"
|
||||
// to the responding as part of the first commitment state. If the
|
||||
// responder accepts, then this will be their initial balance.
|
||||
//
|
||||
// TODO(roasbeef): is msat
|
||||
PushAmount btcutil.Amount
|
||||
PushAmount MilliSatoshi
|
||||
|
||||
// DustLimit is the specific dust limit the sender of this message
|
||||
// would like enforced on their version of the commitment transaction.
|
||||
@ -44,7 +42,7 @@ type OpenChannel struct {
|
||||
// MaxValueInFlight represents the maximum amount of coins that can be
|
||||
// pending within the channel at any given time. If the amount of funds
|
||||
// in limbo exceeds this amount, then the channel will be failed.
|
||||
MaxValueInFlight btcutil.Amount
|
||||
MaxValueInFlight MilliSatoshi
|
||||
|
||||
// ChannelReserve is the amount of BTC that the receiving party MUST
|
||||
// maintain a balance above at all times. This is a safety mechanism to
|
||||
@ -54,9 +52,7 @@ type OpenChannel struct {
|
||||
|
||||
// HtlcMinimum is the smallest HTLC that the sender of this message
|
||||
// will accept.
|
||||
//
|
||||
// TODO(roasbeef): is msat
|
||||
HtlcMinimum uint32
|
||||
HtlcMinimum MilliSatoshi
|
||||
|
||||
// FeePerKiloWeight is the initial fee rate that the initiator suggests
|
||||
// for both commitment transaction. This value is expressed in sat per
|
||||
@ -179,6 +175,6 @@ func (o *OpenChannel) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (o *OpenChannel) MaxPayloadLength(uint32) uint32 {
|
||||
// (32 * 2) + (8 * 5) + (4 * 2) + (2 * 2) + (33 * 5) + 1
|
||||
return 282
|
||||
// (32 * 2) + (8 * 6) + (4 * 1) + (2 * 2) + (33 * 5) + 1
|
||||
return 286
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
package lnwire
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/roasbeef/btcutil"
|
||||
)
|
||||
import "io"
|
||||
|
||||
// OnionPacketSize is the size of the serialized Sphinx onion packet included
|
||||
// in each UpdateAddHTLC message. The breakdown of the onion packet is as
|
||||
@ -35,8 +31,8 @@ type UpdateAddHTLC struct {
|
||||
// sufficient expiry value to allow her to redeem the incoming HTLC.
|
||||
Expiry uint32
|
||||
|
||||
// Amount is the amount of satoshis this HTLC is worth.
|
||||
Amount btcutil.Amount
|
||||
// Amount is the amount of millisatoshis this HTLC is worth.
|
||||
Amount MilliSatoshi
|
||||
|
||||
// PaymentHash is the payment hash to be included in the HTLC this
|
||||
// request creates. The pre-image to this HTLC must be revelaed by the
|
||||
|
Loading…
Reference in New Issue
Block a user