Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lnrpc/invoicesrpc/addinvoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ type AddInvoiceData struct {
// RouteHints are optional route hints that can each be individually
// used to assist in reaching the invoice's destination.
RouteHints [][]zpay32.HopHint

// Metadata is additional data that is sent along with the payment to
// the payee.
Metadata []byte
}

// BlindedPathConfig holds the configuration values required for blinded path
Expand Down Expand Up @@ -489,6 +493,11 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
}
options = append(options, zpay32.Features(invoiceFeatures))

// If metadata is provided, add it to the invoice options.
if len(invoice.Metadata) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some constraints here w.r.t the max accepted meta data size.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think is reasonable? this is quite dynamic as the max metadata size depends on the final route length

options = append(options, zpay32.Metadata(invoice.Metadata))
}

// Generate and set a random payment address for this payment. If the
// sender understands payment addresses, this can be used to avoid
// intermediaries probing the receiver. If the invoice does not have
Expand Down
1 change: 1 addition & 0 deletions lnrpc/invoicesrpc/invoices_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
HodlInvoice: true,
Preimage: nil,
RouteHints: routeHints,
Metadata: invoice.Metadata,
}

_, dbInvoice, err := AddInvoice(ctx, addInvoiceCfg, addInvoiceData)
Expand Down
1 change: 1 addition & 0 deletions lnrpc/invoicesrpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func CreateRPCInvoice(invoice *invoices.Invoice,
PaymentAddr: invoice.Terms.PaymentAddr[:],
IsAmp: invoice.IsAMP(),
IsBlinded: invoice.IsBlinded(),
Metadata: decoded.Metadata,
}

rpcInvoice.AmpInvoiceState = make(map[string]*lnrpc.AMPInvoiceState)
Expand Down
2 changes: 2 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6454,6 +6454,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
RouteHints: routeHints,
Amp: invoice.IsAmp,
BlindedPathCfg: blindedPathCfg,
Metadata: invoice.Metadata,
}

if invoice.RPreimage != nil {
Expand Down Expand Up @@ -7840,6 +7841,7 @@ func (r *rpcServer) DecodePayReq(ctx context.Context,
BlindedPaths: blindedPaymentPaths,
PaymentAddr: paymentAddr[:],
Features: invoicesrpc.CreateRPCFeatures(payReq.Features),
Metadata: payReq.Metadata,
}, nil
}

Expand Down