routing: use Identifier in place of PaymentHash

Since we want to support AMP payment using a different unique payment
identifier (AMP payments don't go to one specific hash), we change the
nomenclature to be Identifier instead of PaymentHash.
This commit is contained in:
Johan T. Halseth
2021-03-31 12:23:08 +02:00
parent 6104d12cf8
commit f07c9d002c
17 changed files with 296 additions and 245 deletions

View File

@@ -698,7 +698,11 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payIntent.MaxParts = 1
}
copy(payIntent.PaymentHash[:], payReq.PaymentHash[:])
err = payIntent.SetPaymentHash(*payReq.PaymentHash)
if err != nil {
return nil, err
}
destKey := payReq.Destination.SerializeCompressed()
copy(payIntent.Target[:], destKey)
@@ -737,7 +741,15 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payIntent.Amount = reqAmt
// Payment hash.
copy(payIntent.PaymentHash[:], rpcPayReq.PaymentHash)
paymentHash, err := lntypes.MakeHash(rpcPayReq.PaymentHash)
if err != nil {
return nil, err
}
err = payIntent.SetPaymentHash(paymentHash)
if err != nil {
return nil, err
}
// Parse destination feature bits.
features, err := UnmarshalFeatures(rpcPayReq.DestFeatures)
@@ -1217,7 +1229,7 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
htlcs = append(htlcs, htlc)
}
paymentHash := payment.Info.PaymentHash
paymentID := payment.Info.PaymentIdentifier
creationTimeNS := MarshalTimeNano(payment.Info.CreationTime)
failureReason, err := marshallPaymentFailureReason(
@@ -1228,7 +1240,8 @@ func (r *RouterBackend) MarshallPayment(payment *channeldb.MPPayment) (
}
return &lnrpc.Payment{
PaymentHash: hex.EncodeToString(paymentHash[:]),
// TODO: set this to setID for AMP-payments?
PaymentHash: hex.EncodeToString(paymentID[:]),
Value: satValue,
ValueMsat: msatValue,
ValueSat: satValue,