sqldb+invoices: add migration to fix incorrectly stored invoice expiries
Previously, when using the native schema, invoice expiries were incorrectly stored as 64-bit values (expiry in nanoseconds instead of seconds), causing overflow issues. Since we cannot determine the original values, we will set the expiries for existing invoices to 1 hour with this migration.
This commit is contained in:
4 files changed
+21
-3
No files matched your search
@@ -233,7 +233,7 @@ func (i *SQLStore) AddInvoice(ctx context.Context,
|
||||
CltvDelta: sqldb.SQLInt32(
|
||||
newInvoice.Terms.FinalCltvDelta,
|
||||
),
|
||||
Expiry: int32(newInvoice.Terms.Expiry),
|
||||
Expiry: int32(newInvoice.Terms.Expiry.Seconds()),
|
||||
// Note: keysend invoices don't have a payment request.
|
||||
PaymentRequest: sqldb.SQLStr(string(
|
||||
newInvoice.PaymentRequest),
|
||||
@@ -1598,6 +1598,8 @@ func unmarshalInvoice(row sqlc.Invoice) (*lntypes.Hash, *Invoice,
|
||||
cltvDelta = row.CltvDelta.Int32
|
||||
}
|
||||
|
||||
expiry := time.Duration(row.Expiry) * time.Second
|
||||
|
||||
invoice := &Invoice{
|
||||
SettleIndex: uint64(settleIndex),
|
||||
SettleDate: settledAt,
|
||||
@@ -1606,7 +1608,7 @@ func unmarshalInvoice(row sqlc.Invoice) (*lntypes.Hash, *Invoice,
|
||||
CreationDate: row.CreatedAt.Local(),
|
||||
Terms: ContractTerm{
|
||||
FinalCltvDelta: cltvDelta,
|
||||
Expiry: time.Duration(row.Expiry),
|
||||
Expiry: expiry,
|
||||
PaymentPreimage: preimage,
|
||||
Value: lnwire.MilliSatoshi(row.AmountMsat),
|
||||
PaymentAddr: paymentAddr,
|
||||
|
||||
Reference in new issue
Block a user