htlcswitch: set packet obfuscator for failures through switch

Set obfuscator for use in blinded error handling when we forward
failures through the switch.
This commit is contained in:
Carla Kirk-Cohen 2024-04-08 15:14:11 -04:00
parent 72260adddb
commit de9c9c028c
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91
2 changed files with 15 additions and 1 deletions

View file

@ -738,6 +738,7 @@ func (m *memoryMailBox) FailAdd(pkt *htlcPacket) {
sourceRef: pkt.sourceRef,
hasSource: true,
localFailure: localFailure,
obfuscator: pkt.obfuscator,
linkFailure: linkError,
htlc: &lnwire.UpdateFailHTLC{
Reason: reason,

View file

@ -1297,6 +1297,11 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
fail, isFail := htlc.(*lnwire.UpdateFailHTLC)
if isFail && !packet.hasSource {
// HTLC resolutions and messages restored from disk
// don't have the obfuscator set from the original htlc
// add packet - set it here for use in blinded errors.
packet.obfuscator = circuit.ErrorEncrypter
switch {
// No message to encrypt, locally sourced payment.
case circuit.ErrorEncrypter == nil:
@ -1485,6 +1490,7 @@ func (s *Switch) failAddPacket(packet *htlcPacket, failure *LinkError) error {
incomingTimeout: packet.incomingTimeout,
outgoingTimeout: packet.outgoingTimeout,
circuit: packet.circuit,
obfuscator: packet.obfuscator,
linkFailure: failure,
htlc: &lnwire.UpdateFailHTLC{
Reason: reason,
@ -1841,6 +1847,10 @@ out:
// resolution message on restart.
resolutionMsg.errChan <- nil
// Create a htlc packet for this resolution. We do
// not have some of the information that we'll need
// for blinded error handling here , so we'll rely on
// our forwarding logic to fill it in later.
pkt := &htlcPacket{
outgoingChanID: resolutionMsg.SourceChan,
outgoingHTLCID: resolutionMsg.HtlcIndex,
@ -2065,6 +2075,8 @@ func (s *Switch) reforwardResolutions() error {
// The circuit is still open, so we can assume that the link or
// switch (if we are the source) hasn't cleaned it up yet.
// We rely on our forwarding logic to fill in details that
// are not currently available to us.
resPkt := &htlcPacket{
outgoingChanID: resMsg.SourceChan,
outgoingHTLCID: resMsg.HtlcIndex,
@ -2214,7 +2226,8 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
// we can continue to propagate it. This
// failure originated from another node, so
// the linkFailure field is not set on this
// packet.
// packet. We rely on the link to fill in
// additional circuit information for us.
failPacket := &htlcPacket{
outgoingChanID: fwdPkg.Source,
outgoingHTLCID: pd.ParentIndex,