From de33010e90396b1755c9a7187e5bff6ffcd2734e Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 11 Nov 2019 15:35:23 +0100 Subject: [PATCH 1/4] htlcswitch/test: do not string match error --- htlcswitch/link_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 2ad917067..06613aa1a 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -1248,8 +1248,14 @@ func TestChannelLinkMultiHopUnknownNextHop(t *testing.T) { totalTimelock).Wait(30 * time.Second) if err == nil { t.Fatal("error haven't been received") - } else if err.Error() != lnwire.CodeUnknownNextPeer.String() { - t.Fatalf("wrong error have been received: %v", err) + } + fErr, ok := err.(*ForwardingError) + if !ok { + t.Fatalf("expected ForwardingError") + } + if _, ok = fErr.FailureMessage.(*lnwire.FailUnknownNextPeer); !ok { + t.Fatalf("wrong error has been received: %T", + fErr.FailureMessage) } // Wait for Alice to receive the revocation. From 85dcaff0d99ab0c9829cd49efd7d4a98b8f4287e Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 11 Nov 2019 12:25:36 +0100 Subject: [PATCH 2/4] routing/route: report amount per hop in Route.String() Makes log output slightly more descriptive to aid debugging of routing problems. --- routing/route/route.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/routing/route/route.go b/routing/route/route.go index 62511c3f1..6858f3b8d 100644 --- a/routing/route/route.go +++ b/routing/route/route.go @@ -340,15 +340,19 @@ func (r *Route) ToSphinxPath() (*sphinx.PaymentPath, error) { func (r *Route) String() string { var b strings.Builder + amt := r.TotalAmount for i, hop := range r.Hops { if i > 0 { - b.WriteString(",") + b.WriteString(" -> ") } - b.WriteString(strconv.FormatUint(hop.ChannelID, 10)) + b.WriteString(fmt.Sprintf("%v (%v)", + strconv.FormatUint(hop.ChannelID, 10), + amt, + )) + amt = hop.AmtToForward } - return fmt.Sprintf("amt=%v, fees=%v, tl=%v, chans=%v", - r.TotalAmount-r.TotalFees(), r.TotalFees(), r.TotalTimeLock, - b.String(), + return fmt.Sprintf("%v, cltv %v", + b.String(), r.TotalTimeLock, ) } From 53076880f1e137c6a40c3a105b2a81ed12621c1c Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 11 Nov 2019 12:26:48 +0100 Subject: [PATCH 3/4] htlcswitch: report failure source index for forwarding errors --- htlcswitch/failure.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htlcswitch/failure.go b/htlcswitch/failure.go index 4526e3560..0d817a07d 100644 --- a/htlcswitch/failure.go +++ b/htlcswitch/failure.go @@ -30,10 +30,14 @@ type ForwardingError struct { // returned. func (f *ForwardingError) Error() string { if f.ExtraMsg == "" { - return fmt.Sprintf("%v", f.FailureMessage) + return fmt.Sprintf( + "%v@%v", f.FailureMessage, f.FailureSourceIdx, + ) } - return fmt.Sprintf("%v: %v", f.FailureMessage, f.ExtraMsg) + return fmt.Sprintf( + "%v@%v: %v", f.FailureMessage, f.FailureSourceIdx, f.ExtraMsg, + ) } // ErrorDecrypter is an interface that is used to decrypt the onion encrypted From a364d2cd823ab5c366b15f5cd73f95909482f01d Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 11 Nov 2019 12:27:24 +0100 Subject: [PATCH 4/4] routing: log route when payment attempt fails --- routing/payment_lifecycle.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 695a0d498..a8017eaa3 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -341,8 +341,8 @@ func (p *paymentLifecycle) sendPaymentAttempt(firstHop lnwire.ShortChannelID, return err } - log.Debugf("Payment %x (pid=%v) successfully sent to switch", - p.payment.PaymentHash, p.attempt.PaymentID) + log.Debugf("Payment %x (pid=%v) successfully sent to switch, route: %v", + p.payment.PaymentHash, p.attempt.PaymentID, &p.attempt.Route) return nil }