From dd9568b648df5281f1763697e44a80183ddba9e4 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Fri, 16 Aug 2024 13:05:54 -0700 Subject: [PATCH] htlcswitch: remove PaymentDescriptor from hodlHtlc This is part of a systematic removal of PaymentDescriptor from the mechanics of the htlcswitch package. --- htlcswitch/link.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index b00f7762a..6d243db0a 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -442,7 +442,8 @@ func (m *hookMap) invoke() { // hodlHtlc contains htlc data that is required for resolution. type hodlHtlc struct { - pd *lnwallet.PaymentDescriptor + add lnwire.UpdateAddHTLC + sourceRef channeldb.AddRef obfuscator hop.ErrorEncrypter } @@ -1521,7 +1522,7 @@ func (l *channelLink) processHtlcResolution(resolution invoices.HtlcResolution, "with outcome: %v", circuitKey, res.Outcome) return l.settleHTLC( - res.Preimage, htlc.pd.HtlcIndex, *htlc.pd.SourceRef, + res.Preimage, htlc.add.ID, htlc.sourceRef, ) // For htlc failures, we get the relevant failure message based @@ -1532,12 +1533,10 @@ func (l *channelLink) processHtlcResolution(resolution invoices.HtlcResolution, // Get the lnwire failure message based on the resolution // result. - failure := getResolutionFailure(res, htlc.pd.Amount) + failure := getResolutionFailure(res, htlc.add.Amount) - //nolint:forcetypeassert - add := htlc.pd.ToLogUpdate().UpdateMsg.(*lnwire.UpdateAddHTLC) l.sendHTLCError( - *add, *htlc.pd.SourceRef, failure, htlc.obfuscator, + htlc.add, htlc.sourceRef, failure, htlc.obfuscator, true, ) return nil @@ -3860,16 +3859,8 @@ func (l *channelLink) processExitHop(add lnwire.UpdateAddHTLC, // Create a hodlHtlc struct and decide either resolved now or later. htlc := hodlHtlc{ - pd: &lnwallet.PaymentDescriptor{ - EntryType: lnwallet.Add, - ChanID: add.ChanID, - RHash: add.PaymentHash, - Timeout: add.Expiry, - Amount: add.Amount, - HtlcIndex: add.ID, - SourceRef: &sourceRef, - BlindingPoint: add.BlindingPoint, - }, + add: add, + sourceRef: sourceRef, obfuscator: obfuscator, }