lnrpc/addinvoice: bump default LND invoice timeouts
Increases the default MPP expiry from 1 hour to 1 day. For the new AMP invoices, we increase the interval to 1 month. The longer time frames for AMP invoices is used so that the invoice can be pseudo reused as implemented in the prior commit. The BOLT 11 default of 1 hour is still preserved whenever the field is missing in the payment request itself, but as of this commit the field will always be set by lnd.
This commit is contained in:
parent
d6f88cbe6f
commit
4bb6cc9cee
@ -23,6 +23,16 @@ import (
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultInvoiceExpiry is the default invoice expiry for new MPP
|
||||
// invoices.
|
||||
DefaultInvoiceExpiry = 24 * time.Hour
|
||||
|
||||
// DefaultAMPInvoiceExpiry is the default invoice expiry for new AMP
|
||||
// invoices.
|
||||
DefaultAMPInvoiceExpiry = 30 * 24 * time.Hour
|
||||
)
|
||||
|
||||
// AddInvoiceConfig contains dependencies for invoice creation.
|
||||
type AddInvoiceConfig struct {
|
||||
// AddInvoice is called to add the invoice to the registry.
|
||||
@ -270,10 +280,12 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
|
||||
options = append(options, zpay32.FallbackAddr(addr))
|
||||
}
|
||||
|
||||
switch {
|
||||
|
||||
// If expiry is set, specify it. If it is not provided, no expiry time
|
||||
// will be explicitly added to this payment request, which will imply
|
||||
// the default 3600 seconds.
|
||||
if invoice.Expiry > 0 {
|
||||
case invoice.Expiry > 0:
|
||||
|
||||
// We'll ensure that the specified expiry is restricted to sane
|
||||
// number of seconds. As a result, we'll reject an invoice with
|
||||
@ -289,6 +301,15 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
|
||||
|
||||
expiry := time.Duration(invoice.Expiry) * time.Second
|
||||
options = append(options, zpay32.Expiry(expiry))
|
||||
|
||||
// If no custom expiry is provided, use the default MPP expiry.
|
||||
case !invoice.Amp:
|
||||
options = append(options, zpay32.Expiry(DefaultInvoiceExpiry))
|
||||
|
||||
// Otherwise, use the default AMP expiry.
|
||||
default:
|
||||
options = append(options, zpay32.Expiry(DefaultAMPInvoiceExpiry))
|
||||
|
||||
}
|
||||
|
||||
// If the description hash is set, then we add it do the list of options.
|
||||
|
Loading…
Reference in New Issue
Block a user