lnwire: fix ordering of the UpdateAddHTLC message on the wire

This commit fixes a diversion from the way the UpdateAddHTLC message is
defined within the specification. We had the HTLC expiry value in the
wrong place on the wire, which meant that we couldn’t parse the
messages as sent by the other LN implementations.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-09-12 17:58:48 +02:00
1 parent 1e5949cfbb
commit 9a93f83370
2 files changed
+18 -17

No files matched your search

+7 -7
View File
@@ -26,11 +26,6 @@ type UpdateAddHTLC struct {
// with each offered HTLC.
ID uint64
// Expiry is the number of blocks after which this HTLC should expire.
// It is the receiver's duty to ensure that the outgoing HTLC has a
// sufficient expiry value to allow her to redeem the incoming HTLC.
Expiry uint32
// Amount is the amount of millisatoshis this HTLC is worth.
Amount MilliSatoshi
@@ -39,6 +34,11 @@ type UpdateAddHTLC struct {
// upstream peer in order to fully settle the HTLC.
PaymentHash [32]byte
// Expiry is the number of blocks after which this HTLC should expire.
// It is the receiver's duty to ensure that the outgoing HTLC has a
// sufficient expiry value to allow her to redeem the incoming HTLC.
Expiry uint32
// OnionBlob is the raw serialized mix header used to route an HTLC in
// a privacy-preserving manner. The mix header is defined currently to
// be parsed as a 4-tuple: (groupElement, routingInfo, headerMAC,
@@ -69,9 +69,9 @@ func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
return readElements(r,
&c.ChanID,
&c.ID,
&c.Expiry,
&c.Amount,
c.PaymentHash[:],
&c.Expiry,
c.OnionBlob[:],
)
}
@@ -84,9 +84,9 @@ func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
c.ChanID,
c.ID,
c.Expiry,
c.Amount,
c.PaymentHash[:],
c.Expiry,
c.OnionBlob[:],
)
}