From fbd599a2cbe193c42c77010bb9738f525899b060 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 19 Nov 2019 20:40:29 -0800 Subject: [PATCH] multi: rename Payment.PaymentPreimage to Payment.Preimage Preliminary step to exposing PaymentPreimage() as a method that can be shared between legacy payments and mutli-path payments. --- channeldb/payments.go | 8 ++++---- routing/control_tower.go | 2 +- rpcserver.go | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/channeldb/payments.go b/channeldb/payments.go index d576c65c..ddf80ed0 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -239,11 +239,11 @@ type Payment struct { // NOTE: Can be nil if no attempt is yet made. Attempt *PaymentAttemptInfo - // PaymentPreimage is the preimage of a successful payment. This serves - // as a proof of payment. It will only be non-nil for settled payments. + // Preimage is the preimage of a successful payment. This serves as a + // proof of payment. It will only be non-nil for settled payments. // // NOTE: Can be nil if payment is not settled. - PaymentPreimage *lntypes.Preimage + Preimage *lntypes.Preimage // Failure is a failure reason code indicating the reason the payment // failed. It is only non-nil for failed payments. @@ -363,7 +363,7 @@ func fetchPayment(bucket *bbolt.Bucket) (*Payment, error) { if b != nil { var preimg lntypes.Preimage copy(preimg[:], b[:]) - p.PaymentPreimage = &preimg + p.Preimage = &preimg } // Get failure reason if available. diff --git a/routing/control_tower.go b/routing/control_tower.go index 0bf08476..9cd63a95 100644 --- a/routing/control_tower.go +++ b/routing/control_tower.go @@ -214,7 +214,7 @@ func (p *controlTower) SubscribePayment(paymentHash lntypes.Hash) ( // immediately. case channeldb.StatusSucceeded: event = *createSuccessResult( - &payment.Attempt.Route, *payment.PaymentPreimage, + &payment.Attempt.Route, *payment.Preimage, ) // Payment already failed. It is not necessary to register as a diff --git a/rpcserver.go b/rpcserver.go index 828ce7cf..157a714a 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -4348,9 +4348,8 @@ func (r *rpcServer) ListPayments(ctx context.Context, continue } - // If a payment attempt has been made we can fetch the route. - // Otherwise we'll just populate the RPC response with an empty - // one. + // Fetch the payment's route, which will be empty if an attempt + // has not been made. var route route.Route if payment.Attempt != nil { route = payment.Attempt.Route @@ -4360,10 +4359,11 @@ func (r *rpcServer) ListPayments(ctx context.Context, path[i] = hex.EncodeToString(hop.PubKeyBytes[:]) } - // If this payment is settled, the preimage will be available. + // Fetch the preimage if the payment was successful, otherwise a + // zero-value preimage will be used. var preimage lntypes.Preimage - if payment.PaymentPreimage != nil { - preimage = *payment.PaymentPreimage + if payment.Preimage != nil { + preimage = *payment.Preimage } msatValue := int64(payment.Info.Value)