invoices: add resolution result to htlcResolution
This commit adds the resolution result obtained while updating an invoice in the registry to htlcResolution. The field can be used by calling functions to determine the outcome of the update and act appropriately.
This commit is contained in:
5 files changed
+109
-27
No files matched your search
+9
-6
@@ -1195,7 +1195,8 @@ func (l *channelLink) processHtlcResolution(resolution invoices.HtlcResolution,
|
||||
|
||||
circuitKey := resolution.CircuitKey
|
||||
|
||||
// Determine required action for the resolution.
|
||||
// Determine required action for the resolution. If the event's preimage is
|
||||
// non-nil, the htlc must be settled. Otherwise, it should be canceled.
|
||||
if resolution.Preimage != nil {
|
||||
l.log.Debugf("received settle resolution for %v", circuitKey)
|
||||
|
||||
@@ -1205,10 +1206,12 @@ func (l *channelLink) processHtlcResolution(resolution invoices.HtlcResolution,
|
||||
)
|
||||
}
|
||||
|
||||
l.log.Debugf("received cancel resolution for %v", circuitKey)
|
||||
l.log.Debugf("received cancel resolution for %v with outcome: %v",
|
||||
circuitKey, resolution.Outcome)
|
||||
|
||||
// In case of a cancel, always return
|
||||
// incorrect_or_unknown_payment_details in order to avoid leaking info.
|
||||
// The htlc has failed so we cancel it with FailIncorrectDetails. This
|
||||
// error covers invoice failures and hodl cancels (which return it to avoid
|
||||
// leaking information).
|
||||
failure := lnwire.NewFailIncorrectDetails(
|
||||
htlc.pd.Amount, uint32(resolution.AcceptHeight),
|
||||
)
|
||||
@@ -2844,10 +2847,10 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor,
|
||||
obfuscator: obfuscator,
|
||||
}
|
||||
|
||||
// If the event is nil, the invoice is being held, so we save payment
|
||||
// descriptor for future reference.
|
||||
if event == nil {
|
||||
// Save payment descriptor for future reference.
|
||||
l.hodlMap[circuitKey] = htlc
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user