mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-10 15:10:48 +02:00
htlcswitch: add new ExtraMsg field to ForwardingError
This commit adds a new field to the ForwardingError struct: ExtraMsg. The purpose of this field is to allow the htlcswitch to tack on additional error context to ForwardingError messages returned to the L3 router.
This commit is contained in:
@@ -2,6 +2,7 @@ package htlcswitch
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lightning-onion"
|
"github.com/lightningnetwork/lightning-onion"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@@ -16,9 +17,24 @@ type ForwardingError struct {
|
|||||||
// of candidate routes in response to the type of error extracted.
|
// of candidate routes in response to the type of error extracted.
|
||||||
ErrorSource *btcec.PublicKey
|
ErrorSource *btcec.PublicKey
|
||||||
|
|
||||||
|
// ExtraMsg is an additional error message that callers can provide in
|
||||||
|
// order to provide context specific error details.
|
||||||
|
ExtraMsg string
|
||||||
|
|
||||||
lnwire.FailureMessage
|
lnwire.FailureMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error implements the built-in error interface. We use this method to allow
|
||||||
|
// the switch or any callers to insert additional context to the error message
|
||||||
|
// returned.
|
||||||
|
func (f *ForwardingError) Error() string {
|
||||||
|
if f.ExtraMsg == "" {
|
||||||
|
return f.FailureMessage.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%v: %v", f.FailureMessage.Error(), f.ExtraMsg)
|
||||||
|
}
|
||||||
|
|
||||||
// ErrorDecrypter is an interface that is used to decrypt the onion encrypted
|
// ErrorDecrypter is an interface that is used to decrypt the onion encrypted
|
||||||
// failure reason an extra out a well formed error.
|
// failure reason an extra out a well formed error.
|
||||||
type ErrorDecrypter interface {
|
type ErrorDecrypter interface {
|
||||||
|
Reference in New Issue
Block a user