diff --git a/htlcswitch/interceptable_switch.go b/htlcswitch/interceptable_switch.go index 767088fbd..0b62a6ef2 100644 --- a/htlcswitch/interceptable_switch.go +++ b/htlcswitch/interceptable_switch.go @@ -484,6 +484,8 @@ func (s *InterceptableSwitch) interceptForward(packet *htlcPacket, return false, nil } + packet.wireRecords = record.CustomSet(htlc.CustomRecords) + intercepted := &interceptedForward{ htlc: htlc, packet: packet, @@ -617,15 +619,16 @@ func (f *interceptedForward) Packet() InterceptedPacket { ChanID: f.packet.incomingChanID, HtlcID: f.packet.incomingHTLCID, }, - OutgoingChanID: f.packet.outgoingChanID, - Hash: f.htlc.PaymentHash, - OutgoingExpiry: f.htlc.Expiry, - OutgoingAmount: f.htlc.Amount, - IncomingAmount: f.packet.incomingAmount, - IncomingExpiry: f.packet.incomingTimeout, - CustomRecords: f.packet.customRecords, - OnionBlob: f.htlc.OnionBlob, - AutoFailHeight: f.autoFailHeight, + OutgoingChanID: f.packet.outgoingChanID, + Hash: f.htlc.PaymentHash, + OutgoingExpiry: f.htlc.Expiry, + OutgoingAmount: f.htlc.Amount, + IncomingAmount: f.packet.incomingAmount, + IncomingExpiry: f.packet.incomingTimeout, + CustomRecords: f.packet.customRecords, + OnionBlob: f.htlc.OnionBlob, + AutoFailHeight: f.autoFailHeight, + CustomPeerRecords: f.packet.wireRecords, } } diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index a8d77d6e6..d246bc954 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -357,6 +357,10 @@ type InterceptedPacket struct { // OnionBlob is the onion packet for the next hop OnionBlob [lnwire.OnionPacketSize]byte + // CustomPeerRecords are user-defined records that were defined by the + // peer that forwarded this htlc to us. + CustomPeerRecords record.CustomSet + // AutoFailHeight is the block height at which this intercept will be // failed back automatically. AutoFailHeight int32 diff --git a/htlcswitch/link.go b/htlcswitch/link.go index cd93cc862..b21c33131 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -3375,6 +3375,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, Amount: fwdInfo.AmountToForward, PaymentHash: pd.RHash, BlindingPoint: fwdInfo.NextBlinding, + CustomRecords: pd.WireRecords, } // Finally, we'll encode the onion packet for @@ -3421,6 +3422,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, Amount: fwdInfo.AmountToForward, PaymentHash: pd.RHash, BlindingPoint: fwdInfo.NextBlinding, + CustomRecords: pd.WireRecords, } // Finally, we'll encode the onion packet for the diff --git a/htlcswitch/packet.go b/htlcswitch/packet.go index 45f4e465b..760bb5976 100644 --- a/htlcswitch/packet.go +++ b/htlcswitch/packet.go @@ -98,6 +98,10 @@ type htlcPacket struct { // were included in the payload. customRecords record.CustomSet + // wireRecords are user-defined records in the custom type range that + // were included in the peer's wire message. + wireRecords record.CustomSet + // originalOutgoingChanID is used when sending back failure messages. // It is only used for forwarded Adds on option_scid_alias channels. // This is to avoid possible confusion if a payer uses the public SCID diff --git a/lnwallet/channel.go b/lnwallet/channel.go index d95ffdf36..ce456390c 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -383,6 +383,10 @@ type PaymentDescriptor struct { // blinded route (ie, not the introduction node) from update_add_htlc's // TLVs. BlindingPoint lnwire.BlindingPointRecord + + // WireRecords contains the TLV records blob that was included in + // the original wire message that added this HTLC. + WireRecords lnwire.CustomRecords } // AddHeight returns a pointer to the height at which the HTLC was added to the @@ -6531,6 +6535,7 @@ func (lc *LightningChannel) ReceiveHTLC(htlc *lnwire.UpdateAddHTLC) (uint64, err HtlcIndex: lc.remoteUpdateLog.htlcCounter, OnionBlob: htlc.OnionBlob[:], BlindingPoint: htlc.BlindingPoint, + WireRecords: htlc.CustomRecords, } // Copy over any extra data included to ensure we can forward and