lnrpc: set either payHash or setId depending on payreq type

This commit is contained in:
Conner Fromknecht 2021-05-06 09:18:42 -07:00
parent 8c404ade18
commit 64d07558d9
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -702,9 +702,31 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payIntent.MaxParts = 1
}
err = payIntent.SetPaymentHash(*payReq.PaymentHash)
if err != nil {
return nil, err
if payReq.Features.HasFeature(lnwire.AMPOptional) {
// Generate random SetID and root share.
var setID [32]byte
_, err = rand.Read(setID[:])
if err != nil {
return nil, err
}
var rootShare [32]byte
_, err = rand.Read(rootShare[:])
if err != nil {
return nil, err
}
err := payIntent.SetAMP(&routing.AMPOptions{
SetID: setID,
RootShare: rootShare,
})
if err != nil {
return nil, err
}
} else {
err = payIntent.SetPaymentHash(*payReq.PaymentHash)
if err != nil {
return nil, err
}
}
destKey := payReq.Destination.SerializeCompressed()