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.
This commit is contained in:
parent
b03d8edcd9
commit
fbd599a2cb
@ -239,11 +239,11 @@ type Payment struct {
|
|||||||
// NOTE: Can be nil if no attempt is yet made.
|
// NOTE: Can be nil if no attempt is yet made.
|
||||||
Attempt *PaymentAttemptInfo
|
Attempt *PaymentAttemptInfo
|
||||||
|
|
||||||
// PaymentPreimage is the preimage of a successful payment. This serves
|
// Preimage is the preimage of a successful payment. This serves as a
|
||||||
// as a proof of payment. It will only be non-nil for settled payments.
|
// proof of payment. It will only be non-nil for settled payments.
|
||||||
//
|
//
|
||||||
// NOTE: Can be nil if payment is not settled.
|
// 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
|
// Failure is a failure reason code indicating the reason the payment
|
||||||
// failed. It is only non-nil for failed payments.
|
// failed. It is only non-nil for failed payments.
|
||||||
@ -363,7 +363,7 @@ func fetchPayment(bucket *bbolt.Bucket) (*Payment, error) {
|
|||||||
if b != nil {
|
if b != nil {
|
||||||
var preimg lntypes.Preimage
|
var preimg lntypes.Preimage
|
||||||
copy(preimg[:], b[:])
|
copy(preimg[:], b[:])
|
||||||
p.PaymentPreimage = &preimg
|
p.Preimage = &preimg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get failure reason if available.
|
// Get failure reason if available.
|
||||||
|
@ -214,7 +214,7 @@ func (p *controlTower) SubscribePayment(paymentHash lntypes.Hash) (
|
|||||||
// immediately.
|
// immediately.
|
||||||
case channeldb.StatusSucceeded:
|
case channeldb.StatusSucceeded:
|
||||||
event = *createSuccessResult(
|
event = *createSuccessResult(
|
||||||
&payment.Attempt.Route, *payment.PaymentPreimage,
|
&payment.Attempt.Route, *payment.Preimage,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Payment already failed. It is not necessary to register as a
|
// Payment already failed. It is not necessary to register as a
|
||||||
|
12
rpcserver.go
12
rpcserver.go
@ -4348,9 +4348,8 @@ func (r *rpcServer) ListPayments(ctx context.Context,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a payment attempt has been made we can fetch the route.
|
// Fetch the payment's route, which will be empty if an attempt
|
||||||
// Otherwise we'll just populate the RPC response with an empty
|
// has not been made.
|
||||||
// one.
|
|
||||||
var route route.Route
|
var route route.Route
|
||||||
if payment.Attempt != nil {
|
if payment.Attempt != nil {
|
||||||
route = payment.Attempt.Route
|
route = payment.Attempt.Route
|
||||||
@ -4360,10 +4359,11 @@ func (r *rpcServer) ListPayments(ctx context.Context,
|
|||||||
path[i] = hex.EncodeToString(hop.PubKeyBytes[:])
|
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
|
var preimage lntypes.Preimage
|
||||||
if payment.PaymentPreimage != nil {
|
if payment.Preimage != nil {
|
||||||
preimage = *payment.PaymentPreimage
|
preimage = *payment.Preimage
|
||||||
}
|
}
|
||||||
|
|
||||||
msatValue := int64(payment.Info.Value)
|
msatValue := int64(payment.Info.Value)
|
||||||
|
Loading…
Reference in New Issue
Block a user