Merge pull request #3705 from joostjager/payment-fail-log
routing+htlcswitch: improve failed payment logging
This commit is contained in:
commit
d4d8b03d5b
@ -30,10 +30,14 @@ type ForwardingError struct {
|
|||||||
// returned.
|
// returned.
|
||||||
func (f *ForwardingError) Error() string {
|
func (f *ForwardingError) Error() string {
|
||||||
if f.ExtraMsg == "" {
|
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
|
// ErrorDecrypter is an interface that is used to decrypt the onion encrypted
|
||||||
|
@ -1248,8 +1248,14 @@ func TestChannelLinkMultiHopUnknownNextHop(t *testing.T) {
|
|||||||
totalTimelock).Wait(30 * time.Second)
|
totalTimelock).Wait(30 * time.Second)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("error haven't been received")
|
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.
|
// Wait for Alice to receive the revocation.
|
||||||
|
@ -341,8 +341,8 @@ func (p *paymentLifecycle) sendPaymentAttempt(firstHop lnwire.ShortChannelID,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Payment %x (pid=%v) successfully sent to switch",
|
log.Debugf("Payment %x (pid=%v) successfully sent to switch, route: %v",
|
||||||
p.payment.PaymentHash, p.attempt.PaymentID)
|
p.payment.PaymentHash, p.attempt.PaymentID, &p.attempt.Route)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -340,15 +340,19 @@ func (r *Route) ToSphinxPath() (*sphinx.PaymentPath, error) {
|
|||||||
func (r *Route) String() string {
|
func (r *Route) String() string {
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
|
|
||||||
|
amt := r.TotalAmount
|
||||||
for i, hop := range r.Hops {
|
for i, hop := range r.Hops {
|
||||||
if i > 0 {
|
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",
|
return fmt.Sprintf("%v, cltv %v",
|
||||||
r.TotalAmount-r.TotalFees(), r.TotalFees(), r.TotalTimeLock,
|
b.String(), r.TotalTimeLock,
|
||||||
b.String(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user