Merge pull request #3749 from joostjager/extended-routing-failures

routing: local balance check before path finding
This commit is contained in:
Joost Jager 2019-12-04 12:17:17 +01:00 committed by GitHub
commit 883f9e5f9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 307 additions and 186 deletions

@ -105,6 +105,10 @@ const (
// or the final cltv delta or amount is incorrect. // or the final cltv delta or amount is incorrect.
FailureReasonPaymentDetails FailureReason = 3 FailureReasonPaymentDetails FailureReason = 3
// FailureReasonInsufficientBalance indicates that we didn't have enough
// balance to complete the payment.
FailureReasonInsufficientBalance FailureReason = 4
// TODO(halseth): cancel state. // TODO(halseth): cancel state.
// TODO(joostjager): Add failure reasons for: // TODO(joostjager): Add failure reasons for:
@ -122,6 +126,8 @@ func (r FailureReason) String() string {
return "error" return "error"
case FailureReasonPaymentDetails: case FailureReasonPaymentDetails:
return "incorrect_payment_details" return "incorrect_payment_details"
case FailureReasonInsufficientBalance:
return "insufficient_balance"
} }
return "unknown" return "unknown"

@ -46,6 +46,9 @@ const (
//Payment details incorrect (unknown hash, invalid amt or //Payment details incorrect (unknown hash, invalid amt or
//invalid final cltv delta) //invalid final cltv delta)
PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS PaymentState = 5 PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS PaymentState = 5
//*
//Insufficient local balance.
PaymentState_FAILED_INSUFFICIENT_BALANCE PaymentState = 6
) )
var PaymentState_name = map[int32]string{ var PaymentState_name = map[int32]string{
@ -55,6 +58,7 @@ var PaymentState_name = map[int32]string{
3: "FAILED_NO_ROUTE", 3: "FAILED_NO_ROUTE",
4: "FAILED_ERROR", 4: "FAILED_ERROR",
5: "FAILED_INCORRECT_PAYMENT_DETAILS", 5: "FAILED_INCORRECT_PAYMENT_DETAILS",
6: "FAILED_INSUFFICIENT_BALANCE",
} }
var PaymentState_value = map[string]int32{ var PaymentState_value = map[string]int32{
@ -64,6 +68,7 @@ var PaymentState_value = map[string]int32{
"FAILED_NO_ROUTE": 3, "FAILED_NO_ROUTE": 3,
"FAILED_ERROR": 4, "FAILED_ERROR": 4,
"FAILED_INCORRECT_PAYMENT_DETAILS": 5, "FAILED_INCORRECT_PAYMENT_DETAILS": 5,
"FAILED_INSUFFICIENT_BALANCE": 6,
} }
func (x PaymentState) String() string { func (x PaymentState) String() string {
@ -1505,135 +1510,136 @@ func init() {
func init() { proto.RegisterFile("routerrpc/router.proto", fileDescriptor_7a0613f69d37b0a5) } func init() { proto.RegisterFile("routerrpc/router.proto", fileDescriptor_7a0613f69d37b0a5) }
var fileDescriptor_7a0613f69d37b0a5 = []byte{ var fileDescriptor_7a0613f69d37b0a5 = []byte{
// 2038 bytes of a gzipped FileDescriptorProto // 2053 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x58, 0x51, 0x73, 0x1a, 0xc9, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x58, 0x5f, 0x73, 0xdb, 0xc6,
0x11, 0xbe, 0x15, 0x20, 0x50, 0x03, 0x62, 0x35, 0xd2, 0xc9, 0x6b, 0x64, 0x9d, 0x75, 0x6b, 0xc7, 0x11, 0x0f, 0xc4, 0xff, 0x4b, 0x52, 0x84, 0x4e, 0x8a, 0x4c, 0x53, 0x56, 0xa2, 0x20, 0xae, 0xc3,
0x47, 0xb9, 0x7c, 0x92, 0xa3, 0xd4, 0x5d, 0xb9, 0xee, 0x21, 0x29, 0x0c, 0xcb, 0x69, 0x65, 0x58, 0xf1, 0x38, 0x92, 0xab, 0x4e, 0x32, 0x9e, 0x3c, 0xb4, 0x43, 0x91, 0x60, 0x04, 0x99, 0x04, 0xe5,
0xe4, 0x01, 0x7c, 0xe7, 0xdc, 0xc3, 0xd4, 0x08, 0x46, 0x62, 0x4b, 0xcb, 0x2e, 0xb7, 0x3b, 0xf8, 0x23, 0xe9, 0xc4, 0xcd, 0xc3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x98, 0x72, 0x8f, 0x0f, 0x6a, 0x87, 0x0f, 0x48, 0x95, 0xa9, 0xb3, 0xdf, 0xfe,
0x5d, 0xff, 0xda, 0x67, 0xfc, 0x97, 0x20, 0xbc, 0x39, 0xf1, 0xfc, 0xd1, 0x89, 0xbc, 0x75, 0x27, 0xf1, 0xe4, 0xc6, 0xe1, 0x93, 0xf9, 0xd5, 0xf1, 0xc8, 0x9f, 0x9e, 0xb8, 0xa2, 0xa3, 0xf7, 0x1c,
0x73, 0x2b, 0x97, 0x9b, 0xf2, 0xdf, 0x9f, 0xdf, 0xfd, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x28, 0xbb, 0xef, 0xc6, 0x63, 0xfc, 0x17, 0x3f, 0xb8, 0x3d, 0x71, 0xbd, 0xf1, 0x89, 0xbc, 0x96, 0x27, 0x0b,
0xdd, 0x1c, 0x2d, 0x12, 0x00, 0x00, 0x2b, 0x57, 0x59, 0xf9, 0xf7, 0xd0, 0xef, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x2d, 0x5b,
0xa8, 0x4e, 0x12, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.

@ -142,6 +142,11 @@ enum PaymentState {
invalid final cltv delta) invalid final cltv delta)
*/ */
FAILED_INCORRECT_PAYMENT_DETAILS = 5; FAILED_INCORRECT_PAYMENT_DETAILS = 5;
/**
Insufficient local balance.
*/
FAILED_INSUFFICIENT_BALANCE = 6;
} }

@ -678,6 +678,9 @@ func marshallFailureReason(reason channeldb.FailureReason) (
case channeldb.FailureReasonPaymentDetails: case channeldb.FailureReasonPaymentDetails:
return PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS, nil return PaymentState_FAILED_INCORRECT_PAYMENT_DETAILS, nil
case channeldb.FailureReasonInsufficientBalance:
return PaymentState_FAILED_INSUFFICIENT_BALANCE, nil
} }
return 0, errors.New("unknown failure reason") return 0, errors.New("unknown failure reason")

@ -7,28 +7,10 @@ import "github.com/go-errors/errors"
type errorCode uint8 type errorCode uint8
const ( const (
// ErrNoPathFound is returned when a path to the target destination
// does not exist in the graph.
ErrNoPathFound errorCode = iota
// ErrNoRouteFound is returned when the router is unable to find a
// valid route to the target destination after fees and time-lock
// limitations are factored in.
ErrNoRouteFound
// ErrInsufficientCapacity is returned when a path if found, yet the
// capacity of one of the channels in the path is insufficient to carry
// the payment.
ErrInsufficientCapacity
// ErrMaxHopsExceeded is returned when a candidate path is found, but
// the length of that path exceeds HopLimit.
ErrMaxHopsExceeded
// ErrTargetNotInNetwork is returned when the target of a path-finding // ErrTargetNotInNetwork is returned when the target of a path-finding
// or payment attempt isn't known to be within the current version of // or payment attempt isn't known to be within the current version of
// the channel graph. // the channel graph.
ErrTargetNotInNetwork ErrTargetNotInNetwork errorCode = iota
// ErrOutdated is returned when the routing update already have // ErrOutdated is returned when the routing update already have
// been applied, or a newer update is already known. // been applied, or a newer update is already known.
@ -39,18 +21,9 @@ const (
// announcement was given for node not found in any channel. // announcement was given for node not found in any channel.
ErrIgnored ErrIgnored
// ErrRejected is returned if the update is for a channel ID that was
// previously added to the reject cache because of an invalid update
// was attempted to be processed.
ErrRejected
// ErrPaymentAttemptTimeout is an error that indicates that a payment // ErrPaymentAttemptTimeout is an error that indicates that a payment
// attempt timed out before we were able to successfully route an HTLC. // attempt timed out before we were able to successfully route an HTLC.
ErrPaymentAttemptTimeout ErrPaymentAttemptTimeout
// ErrFeeLimitExceeded is returned when the total fees of a route exceed
// the user-specified fee limit.
ErrFeeLimitExceeded
) )
// routerError is a structure that represent the error inside the routing package, // routerError is a structure that represent the error inside the routing package,

@ -2,13 +2,13 @@ package routing
import ( import (
"container/heap" "container/heap"
"errors"
"fmt" "fmt"
"math" "math"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec"
"github.com/coreos/bbolt" "github.com/coreos/bbolt"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
@ -63,6 +63,23 @@ var (
// DefaultAprioriHopProbability is the default a priori probability for // DefaultAprioriHopProbability is the default a priori probability for
// a hop. // a hop.
DefaultAprioriHopProbability = float64(0.6) DefaultAprioriHopProbability = float64(0.6)
// errNoTlvPayload is returned when the destination hop does not support
// a tlv payload.
errNoTlvPayload = errors.New("destination hop doesn't " +
"understand new TLV payloads")
// errNoPathFound is returned when a path to the target destination does
// not exist in the graph.
errNoPathFound = errors.New("unable to find a path to destination")
// errMaxHopsExceeded is returned when a candidate path is found, but
// the length of that path exceeds HopLimit.
errMaxHopsExceeded = errors.New("potential path has too many hops")
// errInsufficientLocalBalance is returned when none of the local
// channels have enough balance for the payment.
errInsufficientBalance = errors.New("insufficient local balance")
) )
// edgePolicyWithSource is a helper struct to keep track of the source node // edgePolicyWithSource is a helper struct to keep track of the source node
@ -292,6 +309,50 @@ type PathFindingConfig struct {
MinProbability float64 MinProbability float64
} }
// getMaxOutgoingAmt returns the maximum available balance in any of the
// channels of the given node.
func getMaxOutgoingAmt(node route.Vertex, outgoingChan *uint64,
g *graphParams, tx *bbolt.Tx) (lnwire.MilliSatoshi, error) {
var max lnwire.MilliSatoshi
cb := func(_ *bbolt.Tx, edgeInfo *channeldb.ChannelEdgeInfo, outEdge,
_ *channeldb.ChannelEdgePolicy) error {
if outEdge == nil {
return nil
}
chanID := outEdge.ChannelID
// Enforce outgoing channel restriction.
if outgoingChan != nil && chanID != *outgoingChan {
return nil
}
bandwidth, ok := g.bandwidthHints[chanID]
// If the bandwidth is not available for whatever reason, don't
// fail the pathfinding early.
if !ok {
max = lnwire.MaxMilliSatoshi
return nil
}
if bandwidth > max {
max = bandwidth
}
return nil
}
// Iterate over all channels of the to node.
err := g.graph.ForEachNodeChannel(tx, node[:], cb)
if err != nil {
return 0, err
}
return max, err
}
// findPath attempts to find a path from the source node within the // findPath attempts to find a path from the source node within the
// ChannelGraph to the target node that's capable of supporting a payment of // ChannelGraph to the target node that's capable of supporting a payment of
// `amt` value. The current approach implemented is modified version of // `amt` value. The current approach implemented is modified version of
@ -319,7 +380,13 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
"time=%v", nodesVisited, edgesExpanded, timeElapsed) "time=%v", nodesVisited, edgesExpanded, timeElapsed)
}() }()
var err error // Get source node outside of the pathfinding tx, to prevent a deadlock.
selfNode, err := g.graph.SourceNode()
if err != nil {
return nil, err
}
self := selfNode.PubKeyBytes
tx := g.tx tx := g.tx
if tx == nil { if tx == nil {
tx, err = g.graph.Database().Begin(false) tx, err = g.graph.Database().Begin(false)
@ -347,12 +414,23 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
lnwire.TLVOnionPayloadOptional, lnwire.TLVOnionPayloadOptional,
) )
if !supportsTLV { if !supportsTLV {
return nil, fmt.Errorf("destination hop doesn't " + return nil, errNoTlvPayload
"understand new TLV paylods")
} }
} }
} }
// If we are routing from ourselves, check that we have enough local
// balance available.
if source == self {
max, err := getMaxOutgoingAmt(self, r.OutgoingChannelID, g, tx)
if err != nil {
return nil, err
}
if max < amt {
return nil, errInsufficientBalance
}
}
// First we'll initialize an empty heap which'll help us to quickly // First we'll initialize an empty heap which'll help us to quickly
// locate the next edge we should visit next during our graph // locate the next edge we should visit next during our graph
// traversal. // traversal.
@ -363,7 +441,6 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
additionalEdgesWithSrc := make(map[route.Vertex][]*edgePolicyWithSource) additionalEdgesWithSrc := make(map[route.Vertex][]*edgePolicyWithSource)
for vertex, outgoingEdgePolicies := range g.additionalEdges { for vertex, outgoingEdgePolicies := range g.additionalEdges {
// Build reverse lookup to find incoming edges. Needed because // Build reverse lookup to find incoming edges. Needed because
// search is taken place from target to source. // search is taken place from target to source.
for _, outgoingEdgePolicy := range outgoingEdgePolicies { for _, outgoingEdgePolicy := range outgoingEdgePolicies {
@ -552,7 +629,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
pivot := partialPath.node pivot := partialPath.node
// Create unified policies for all incoming connections. // Create unified policies for all incoming connections.
u := newUnifiedPolicies(source, pivot, r.OutgoingChannelID) u := newUnifiedPolicies(self, pivot, r.OutgoingChannelID)
err := u.addGraphPolicies(g.graph, tx) err := u.addGraphPolicies(g.graph, tx)
if err != nil { if err != nil {
@ -622,8 +699,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
currentNodeWithDist, ok := distance[currentNode] currentNodeWithDist, ok := distance[currentNode]
if !ok { if !ok {
// If the node doesnt have a next hop it means we didn't find a path. // If the node doesnt have a next hop it means we didn't find a path.
return nil, newErrf(ErrNoPathFound, "unable to find a "+ return nil, errNoPathFound
"path to destination")
} }
// Add the next hop to the list of path edges. // Add the next hop to the list of path edges.
@ -646,8 +722,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
// hops, then it's invalid. // hops, then it's invalid.
numEdges := len(pathEdges) numEdges := len(pathEdges)
if numEdges > HopLimit { if numEdges > HopLimit {
return nil, newErr(ErrMaxHopsExceeded, "potential path has "+ return nil, errMaxHopsExceeded
"too many hops")
} }
log.Debugf("Found route: probability=%v, hops=%v, fee=%v\n", log.Debugf("Found route: probability=%v, hops=%v, fee=%v\n",

@ -1269,7 +1269,7 @@ func TestPathNotAvailable(t *testing.T) {
noRestrictions, testPathFindingConfig, noRestrictions, testPathFindingConfig,
sourceNode.PubKeyBytes, unknownNode, 100, sourceNode.PubKeyBytes, unknownNode, 100,
) )
if !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("path shouldn't have been found: %v", err) t.Fatalf("path shouldn't have been found: %v", err)
} }
} }
@ -1306,7 +1306,7 @@ func TestPathInsufficientCapacity(t *testing.T) {
noRestrictions, testPathFindingConfig, noRestrictions, testPathFindingConfig,
sourceNode.PubKeyBytes, target, payAmt, sourceNode.PubKeyBytes, target, payAmt,
) )
if !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("graph shouldn't be able to support payment: %v", err) t.Fatalf("graph shouldn't be able to support payment: %v", err)
} }
} }
@ -1339,7 +1339,7 @@ func TestRouteFailMinHTLC(t *testing.T) {
noRestrictions, testPathFindingConfig, noRestrictions, testPathFindingConfig,
sourceNode.PubKeyBytes, target, payAmt, sourceNode.PubKeyBytes, target, payAmt,
) )
if !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("graph shouldn't be able to support payment: %v", err) t.Fatalf("graph shouldn't be able to support payment: %v", err)
} }
} }
@ -1403,7 +1403,7 @@ func TestRouteFailMaxHTLC(t *testing.T) {
// We'll now attempt to route through that edge with a payment above // We'll now attempt to route through that edge with a payment above
// 100k msat, which should fail. // 100k msat, which should fail.
_, err = ctx.findPath(target, payAmt) _, err = ctx.findPath(target, payAmt)
if !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("graph shouldn't be able to support payment: %v", err) t.Fatalf("graph shouldn't be able to support payment: %v", err)
} }
} }
@ -1491,7 +1491,7 @@ func TestRouteFailDisabledEdge(t *testing.T) {
noRestrictions, testPathFindingConfig, noRestrictions, testPathFindingConfig,
sourceNode.PubKeyBytes, target, payAmt, sourceNode.PubKeyBytes, target, payAmt,
) )
if !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("graph shouldn't be able to support payment: %v", err) t.Fatalf("graph shouldn't be able to support payment: %v", err)
} }
} }
@ -1549,7 +1549,7 @@ func TestPathSourceEdgesBandwidth(t *testing.T) {
noRestrictions, testPathFindingConfig, noRestrictions, testPathFindingConfig,
sourceNode.PubKeyBytes, target, payAmt, sourceNode.PubKeyBytes, target, payAmt,
) )
if !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("graph shouldn't be able to support payment: %v", err) t.Fatalf("graph shouldn't be able to support payment: %v", err)
} }
@ -1971,7 +1971,7 @@ func testCltvLimit(t *testing.T, limit uint32, expectedChannel uint64) {
path, err := ctx.findPath(target, paymentAmt) path, err := ctx.findPath(target, paymentAmt)
if expectedChannel == 0 { if expectedChannel == 0 {
// Finish test if we expect no route. // Finish test if we expect no route.
if IsError(err, ErrNoPathFound) { if err == errNoPathFound {
return return
} }
t.Fatal("expected no path to be found") t.Fatal("expected no path to be found")
@ -2137,7 +2137,7 @@ func testProbabilityRouting(t *testing.T, p10, p11, p20, minProbability float64,
path, err := ctx.findPath(target, paymentAmt) path, err := ctx.findPath(target, paymentAmt)
if expectedChan == 0 { if expectedChan == 0 {
if err == nil || !IsError(err, ErrNoPathFound) { if err != errNoPathFound {
t.Fatalf("expected no path found, but got %v", err) t.Fatalf("expected no path found, but got %v", err)
} }
return return
@ -2337,6 +2337,37 @@ func TestRouteToSelf(t *testing.T) {
ctx.assertPath(path, []uint64{1, 3, 2}) ctx.assertPath(path, []uint64{1, 3, 2})
} }
// TestInsufficientBalance tests that a dedicated error is returned for
// insufficient local balance.
func TestInsufficientBalance(t *testing.T) {
t.Parallel()
testChannels := []*testChannel{
symmetricTestChannel("source", "target", 100000, &testChannelPolicy{
Expiry: 144,
FeeBaseMsat: 500,
}, 1),
}
ctx := newPathFindingTestContext(t, testChannels, "source")
defer ctx.cleanup()
paymentAmt := lnwire.NewMSatFromSatoshis(100)
target := ctx.keyFromAlias("target")
ctx.graphParams.bandwidthHints = map[uint64]lnwire.MilliSatoshi{
1: lnwire.NewMSatFromSatoshis(50),
}
// Find the best path to self. We expect this to be source->a->source,
// because a charges the lowest forwarding fee.
_, err := ctx.findPath(target, paymentAmt)
if err != errInsufficientBalance {
t.Fatalf("expected insufficient balance error, but got: %v",
err)
}
}
type pathFindingTestContext struct { type pathFindingTestContext struct {
t *testing.T t *testing.T
graphParams graphParams graphParams graphParams
@ -2365,16 +2396,13 @@ func newPathFindingTestContext(t *testing.T, testChannels []*testChannel,
t: t, t: t,
testGraphInstance: testGraphInstance, testGraphInstance: testGraphInstance,
source: route.Vertex(sourceNode.PubKeyBytes), source: route.Vertex(sourceNode.PubKeyBytes),
pathFindingConfig: *testPathFindingConfig,
graphParams: graphParams{
graph: testGraphInstance.graph,
},
restrictParams: *noRestrictions,
} }
ctx.pathFindingConfig = *testPathFindingConfig
ctx.graphParams.graph = testGraphInstance.graph
ctx.restrictParams.FeeLimit = noFeeLimit
ctx.restrictParams.ProbabilitySource = noProbabilitySource
ctx.restrictParams.CltvLimit = math.MaxUint32
return ctx return ctx
} }

@ -186,6 +186,22 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
} }
// errorToPaymentFailure takes a path finding error and converts it into a
// payment-level failure.
func errorToPaymentFailure(err error) channeldb.FailureReason {
switch err {
case errNoTlvPayload, errNoPathFound, errMaxHopsExceeded,
errPrebuiltRouteTried:
return channeldb.FailureReasonNoRoute
case errInsufficientBalance:
return channeldb.FailureReasonInsufficientBalance
}
return channeldb.FailureReasonError
}
// createNewPaymentAttempt creates and stores a new payment attempt to the // createNewPaymentAttempt creates and stores a new payment attempt to the
// database. // database.
func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID, func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID,
@ -230,11 +246,14 @@ func (p *paymentLifecycle) createNewPaymentAttempt() (lnwire.ShortChannelID,
log.Warnf("Failed to find route for payment %x: %v", log.Warnf("Failed to find route for payment %x: %v",
p.payment.PaymentHash, err) p.payment.PaymentHash, err)
// Convert error to payment-level failure.
failure := errorToPaymentFailure(err)
// If we're unable to successfully make a payment using // If we're unable to successfully make a payment using
// any of the routes we've found, then mark the payment // any of the routes we've found, then mark the payment
// as permanently failed. // as permanently failed.
saveErr := p.router.cfg.Control.Fail( saveErr := p.router.cfg.Control.Fail(
p.payment.PaymentHash, channeldb.FailureReasonNoRoute, p.payment.PaymentHash, failure,
) )
if saveErr != nil { if saveErr != nil {
return lnwire.ShortChannelID{}, nil, saveErr return lnwire.ShortChannelID{}, nil, saveErr

@ -1,7 +1,7 @@
package routing package routing
import ( import (
"fmt" "errors"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@ -12,6 +12,12 @@ import (
// to prevent an HTLC being failed if some blocks are mined while it's in-flight. // to prevent an HTLC being failed if some blocks are mined while it's in-flight.
const BlockPadding uint16 = 3 const BlockPadding uint16 = 3
var (
// errPrebuiltRouteTried is returned when the single pre-built route
// failed and there is nothing more we can do.
errPrebuiltRouteTried = errors.New("pre-built route already tried")
)
// PaymentSession is used during SendPayment attempts to provide routes to // PaymentSession is used during SendPayment attempts to provide routes to
// attempt. It also defines methods to give the PaymentSession additional // attempt. It also defines methods to give the PaymentSession additional
// information learned during the previous attempts. // information learned during the previous attempts.
@ -66,7 +72,7 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
// If the pre-built route has been tried already, the payment session is // If the pre-built route has been tried already, the payment session is
// over. // over.
case p.preBuiltRoute != nil: case p.preBuiltRoute != nil:
return nil, fmt.Errorf("pre-built route already tried") return nil, errPrebuiltRouteTried
} }
// Add BlockPadding to the finalCltvDelta so that the receiving node // Add BlockPadding to the finalCltvDelta so that the receiving node