lnwire: update ChannelUpdate to latest spec change, min HTLC is 8-bytes

This commit is contained in:
Olaoluwa Osuntokun
2017-06-16 22:46:31 +02:00
parent 2452f2ed82
commit 319afb14f1
2 changed files with 24 additions and 21 deletions

View File

@@ -37,13 +37,16 @@ type ChannelUpdate struct {
TimeLockDelta uint16 TimeLockDelta uint16
// HtlcMinimumMsat is the minimum HTLC value which will be accepted. // HtlcMinimumMsat is the minimum HTLC value which will be accepted.
HtlcMinimumMsat uint32 HtlcMinimumMsat uint64
// FeeBaseMstat... // BaseFee is the base fee that must be used for incoming HTLC's to
FeeBaseMsat uint32 // this particular channel. This value will be tacked onto the required
// for a payment independent of the size of the payment.
BaseFee uint32
// FeeProportionalMillionths... // FeeRate is the fee rate that will be charged per millionth of a
FeeProportionalMillionths uint32 // satoshi.
FeeRate uint32
} }
// A compile time check to ensure ChannelUpdate implements the lnwire.Message // A compile time check to ensure ChannelUpdate implements the lnwire.Message
@@ -62,8 +65,8 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
&a.Flags, &a.Flags,
&a.TimeLockDelta, &a.TimeLockDelta,
&a.HtlcMinimumMsat, &a.HtlcMinimumMsat,
&a.FeeBaseMsat, &a.BaseFee,
&a.FeeProportionalMillionths, &a.FeeRate,
) )
} }
@@ -79,8 +82,8 @@ func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error {
a.Flags, a.Flags,
a.TimeLockDelta, a.TimeLockDelta,
a.HtlcMinimumMsat, a.HtlcMinimumMsat,
a.FeeBaseMsat, a.BaseFee,
a.FeeProportionalMillionths, a.FeeRate,
) )
} }
@@ -114,8 +117,8 @@ func (a *ChannelUpdate) MaxPayloadLength(pver uint32) uint32 {
// Expiry - 2 bytes // Expiry - 2 bytes
length += 2 length += 2
// HtlcMinimumMstat - 4 bytes // HtlcMinimumMstat - 8 bytes
length += 4 length += 8
// FeeBaseMstat - 4 bytes // FeeBaseMstat - 4 bytes
length += 4 length += 4
@@ -138,8 +141,8 @@ func (a *ChannelUpdate) DataToSign() ([]byte, error) {
a.Flags, a.Flags,
a.TimeLockDelta, a.TimeLockDelta,
a.HtlcMinimumMsat, a.HtlcMinimumMsat,
a.FeeBaseMsat, a.BaseFee,
a.FeeProportionalMillionths, a.FeeRate,
) )
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -385,14 +385,14 @@ func TestLightningWireProtocol(t *testing.T) {
}, },
MsgChannelUpdate: func(v []reflect.Value, r *rand.Rand) { MsgChannelUpdate: func(v []reflect.Value, r *rand.Rand) {
req := ChannelUpdate{ req := ChannelUpdate{
Signature: testSig, Signature: testSig,
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())), ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
Timestamp: uint32(r.Int31()), Timestamp: uint32(r.Int31()),
Flags: uint16(r.Int31()), Flags: uint16(r.Int31()),
TimeLockDelta: uint16(r.Int31()), TimeLockDelta: uint16(r.Int31()),
HtlcMinimumMsat: uint32(r.Int31()), HtlcMinimumMsat: uint64(r.Int63()),
FeeBaseMsat: uint32(r.Int31()), BaseFee: uint32(r.Int31()),
FeeProportionalMillionths: uint32(r.Int31()), FeeRate: uint32(r.Int31()),
} }
v[0] = reflect.ValueOf(req) v[0] = reflect.ValueOf(req)