multi: introduce BlindedPaymentPathSet

This commit introduces a new type, `BlindedPaymentPathSet`. For now, it
holds only a single `BlindedPayment` but eventually it will hold and
manage a set of blinded payments provided for a specific payment. To
make the PR easier to follow though, we start off just letting it hold a
single one and do some basic replacements.
This commit is contained in:
Elle Mouton
2024-05-15 14:38:53 +02:00
parent 67c5fa9478
commit 3d5f20b70f
3 changed files with 207 additions and 59 deletions

View File

@ -5242,28 +5242,24 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
payIntent.metadata = payReq.Metadata
if len(payReq.BlindedPaymentPaths) > 0 {
// NOTE: Currently we only choose a single payment path.
// This will be updated in a future PR to handle
// multiple blinded payment paths.
path := payReq.BlindedPaymentPaths[0]
if len(path.Hops) == 0 {
return payIntent, fmt.Errorf("a blinded " +
"payment must have at least 1 hop")
pathSet, err := routerrpc.BuildBlindedPathSet(
payReq.BlindedPaymentPaths,
)
if err != nil {
return payIntent, err
}
payIntent.blindedPayment = pathSet.GetPath()
finalHop := path.Hops[len(path.Hops)-1]
payIntent.blindedPayment =
routerrpc.MarshalBlindedPayment(path)
// Replace the target node with the blinded public key
// of the blinded path's final node.
// Replace the destination node with the target public
// key of the blinded path set.
copy(
payIntent.dest[:],
finalHop.BlindedNodePub.SerializeCompressed(),
pathSet.TargetPubKey().SerializeCompressed(),
)
if !payReq.BlindedPaymentPaths[0].Features.IsEmpty() {
payIntent.destFeatures = path.Features.Clone()
pathFeatures := pathSet.Features()
if !pathFeatures.IsEmpty() {
payIntent.destFeatures = pathFeatures.Clone()
}
}