multi: introduce new traffic shaper method.

We introduce a new specific fail resolution error when the
external HTLC interceptor denies the incoming HTLC. Moreover
we introduce a new traffic shaper method which moves the
implementation of asset HTLC to the external layers.
Moreover itests are adopted to reflect this new change.
This commit is contained in:
ziggie
2025-01-28 19:05:46 +01:00
parent 9ee12ee029
commit 17e37bd7c2
8 changed files with 37 additions and 248 deletions

View File

@@ -1117,13 +1117,15 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
return nil, nil
}
// If a cancel signal was set for the htlc set, we set
// the resolution as a failure with an underpayment
// indication. Something was wrong with this htlc, so
// we probably can't settle the invoice at all.
// The error `ExternalValidationFailed` error
// information will be packed in the
// `FailIncorrectDetails` msg when sending the msg to
// the peer. Error codes are defined by the BOLT 04
// specification. The error text can be arbitrary
// therefore we return a custom error msg.
resolution = NewFailResolution(
ctx.circuitKey, ctx.currentHeight,
ResultAmountTooLow,
ExternalValidationFailed,
)
// We cancel all HTLCs which are in the accepted state.

View File

@@ -137,9 +137,6 @@ func (s *HtlcModificationInterceptor) Intercept(clientRequest HtlcModifyRequest,
// Wait for the client to respond or an error to occur.
select {
case response := <-responseChan:
log.Debugf("Received invoice HTLC interceptor response: %v",
response)
responseCallback(*response)
return nil

View File

@@ -120,6 +120,10 @@ const (
// ResultAmpReconstruction is returned when the derived child
// hash/preimage pairs were invalid for at least one HTLC in the set.
ResultAmpReconstruction
// ExternalValidationFailed is returned when the external validation
// failed.
ExternalValidationFailed
)
// String returns a string representation of the result.
@@ -189,6 +193,9 @@ func (f FailResolutionResult) FailureString() string {
case ResultAmpReconstruction:
return "amp reconstruction failed"
case ExternalValidationFailed:
return "external validation failed"
default:
return "unknown failure resolution result"
}
@@ -202,7 +209,8 @@ func (f FailResolutionResult) IsSetFailure() bool {
ResultAmpReconstruction,
ResultHtlcSetTotalTooLow,
ResultHtlcSetTotalMismatch,
ResultHtlcSetOverpayment:
ResultHtlcSetOverpayment,
ExternalValidationFailed:
return true