htlcswitch+lnwallet: persist peer custom records

This commit is contained in:
George Tsagkarelis 2024-04-17 20:54:48 +02:00 committed by Oliver Gugger
parent 995f1fe53d
commit 44427a7467
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
5 changed files with 27 additions and 9 deletions

View File

@ -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,
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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