mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
rpcserver+invoicesrpc: set payment addr on new invoices
This commit modifies Lighting.AddInvoice and InvoicesRPC.AddHoldInvoice to include the node's supported feature bits on the invoice. For now this only includes the optional TLV Onion Payload bit.
This commit is contained in:
parent
df72097f2d
commit
cd27ee7cfc
1 changed files with 10 additions and 0 deletions
|
@ -370,6 +370,15 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
|
|||
)
|
||||
options = append(options, zpay32.Features(invoiceFeatures))
|
||||
|
||||
// Generate and set a random payment address for this invoice. If the
|
||||
// sender understands payment addresses, this can be used to avoid
|
||||
// intermediaries probing the receiver.
|
||||
var paymentAddr [32]byte
|
||||
if _, err := rand.Read(paymentAddr[:]); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
options = append(options, zpay32.PaymentAddr(paymentAddr))
|
||||
|
||||
// Create and encode the payment request as a bech32 (zpay32) string.
|
||||
creationDate := time.Now()
|
||||
payReq, err := zpay32.NewInvoice(
|
||||
|
@ -397,6 +406,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
|
|||
Expiry: payReq.Expiry(),
|
||||
Value: amtMSat,
|
||||
PaymentPreimage: paymentPreimage,
|
||||
PaymentAddr: paymentAddr,
|
||||
Features: invoiceFeatures,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue