htlcswitch/switch+payment_result: define networkResult, extractResult

This commit is contained in:
Johan T. Halseth
2019-05-16 15:27:29 +02:00
parent 5a8b892bb6
commit f99d0c4c68
2 changed files with 89 additions and 49 deletions

View File

@@ -1,6 +1,10 @@
package htlcswitch
import "errors"
import (
"errors"
"github.com/lightningnetwork/lnd/lnwire"
)
var (
// ErrPaymentIDNotFound is an error returned if the given paymentID is
@@ -12,8 +16,9 @@ var (
ErrPaymentIDAlreadyExists = errors.New("paymentID already exists")
)
// PaymentResult wraps a result received from the network after a payment
// attempt was made.
// PaymentResult wraps a decoded result received from the network after a
// payment attempt was made. This is what is eventually handed to the router
// for processing.
type PaymentResult struct {
// Preimage is set by the switch in case a sent HTLC was settled.
Preimage [32]byte
@@ -23,3 +28,21 @@ type PaymentResult struct {
// error will be a *ForwardingError.
Error error
}
// networkResult is the raw result received from the network after a payment
// attempt has been made. Since the switch doesn't always have the necessary
// data to decode the raw message, we store it together with some meta data,
// and decode it when the router query for the final result.
type networkResult struct {
// msg is the received result. This should be of type UpdateFulfillHTLC
// or UpdateFailHTLC.
msg lnwire.Message
// unencrypted indicates whether the failure encoded in the message is
// unencrypted, and hence doesn't need to be decrypted.
unencrypted bool
// isResolution indicates whether this is a resolution message, in
// which the failure reason might not be included.
isResolution bool
}