lnwire: add HtlcMaximumMsat field to ChannelUpdate
In this commit, we add a field to the ChannelUpdate denoting the maximum HTLC we support sending over this channel, a field which was recently added to the spec. This field serves multiple purposes. In the short term, it enables nodes to signal the largest HTLC they're willing to carry, allows light clients who don't verify channel existence to have some guidance when routing HTLCs, and finally may allow nodes to preserve a portion of bandwidth at all times. In the long term, this field can be used by implementations of AMP to guide payment splitting, as it becomes apparent to a node the largest possible HTLC one can route over a particular channel. This PR was made possible by the merge of #1825, which enables older nodes to properly retain and verify signatures on updates that include new fields (like this new max HTLC field) that they haven't yet been updated to recognize. In addition, the new ChannelUpdate fields are added to the lnwire fuzzing tests. Co-authored-by: Johan T. Halseth <johanth@gmail.com>
This commit is contained in:
1 parent
f0ba4b454c
commit
b49637fbe9
2 files changed
+58
-4
No files matched your search
+14
-1
@@ -649,13 +649,26 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
},
|
||||
MsgChannelUpdate: func(v []reflect.Value, r *rand.Rand) {
|
||||
var err error
|
||||
|
||||
msgFlags := ChanUpdateMsgFlags(r.Int31())
|
||||
maxHtlc := MilliSatoshi(r.Int63())
|
||||
|
||||
// We make the max_htlc field zero if it is not flagged
|
||||
// as being part of the ChannelUpdate, to pass
|
||||
// serialization tests, as it will be ignored if the bit
|
||||
// is not set.
|
||||
if msgFlags&ChanUpdateOptionMaxHtlc == 0 {
|
||||
maxHtlc = 0
|
||||
}
|
||||
|
||||
req := ChannelUpdate{
|
||||
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
|
||||
Timestamp: uint32(r.Int31()),
|
||||
MessageFlags: ChanUpdateMsgFlags(r.Int31()),
|
||||
MessageFlags: msgFlags,
|
||||
ChannelFlags: ChanUpdateChanFlags(r.Int31()),
|
||||
TimeLockDelta: uint16(r.Int31()),
|
||||
HtlcMinimumMsat: MilliSatoshi(r.Int63()),
|
||||
HtlcMaximumMsat: maxHtlc,
|
||||
BaseFee: uint32(r.Int31()),
|
||||
FeeRate: uint32(r.Int31()),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user