sqldb: simplify and fixup the existing invoice store schema and queries

This commit attempts to fix some issues with the invoice store's schema that we
couldn't foresee before the implementation was finished. This is safe as the
schema has not been instantiated yet outside of unit tests. Furthermore the
commit updates invoice store SQL queries according to fixes in the schema as
well as to prepare the higher level implementation in the upcoming commits.
This commit is contained in:
Andras Banki-Horvath committed 2024-03-01 10:08:07 +01:00
1 parent 3e0f98a75a
commit 6a360fb2e2
12 files changed
+781 -937

No files matched your search

+41 -41
View File
@@ -9,50 +9,52 @@ import (
"time"
)
type AmpInvoiceHtlc struct {
type AmpSubInvoice struct {
SetID []byte
State int16
CreatedAt time.Time
SettledAt sql.NullTime
SettleIndex sql.NullInt64
InvoiceID int64
}
type AmpSubInvoiceHtlc struct {
InvoiceID int64
SetID []byte
HtlcID int64
InvoiceID int32
RootShare []byte
ChildIndex int64
Hash []byte
Preimage []byte
}
type AmpInvoicePayment struct {
SetID []byte
State int16
CreatedAt time.Time
SettledIndex sql.NullInt32
InvoiceID int32
}
type Invoice struct {
ID int32
Hash []byte
Preimage []byte
Memo sql.NullString
AmountMsat int64
CltvDelta sql.NullInt32
Expiry int32
PaymentAddr []byte
PaymentRequest sql.NullString
State int16
AmountPaidMsat int64
IsAmp bool
IsHodl bool
IsKeysend bool
CreatedAt time.Time
ID int64
Hash []byte
Preimage []byte
SettleIndex sql.NullInt64
SettledAt sql.NullTime
Memo sql.NullString
AmountMsat int64
CltvDelta sql.NullInt32
Expiry int32
PaymentAddr []byte
PaymentRequest sql.NullString
PaymentRequestHash []byte
State int16
AmountPaidMsat int64
IsAmp bool
IsHodl bool
IsKeysend bool
CreatedAt time.Time
}
type InvoiceEvent struct {
ID int32
CreatedAt time.Time
InvoiceID int32
HtlcID sql.NullInt64
SetID []byte
EventType int32
EventMetadata []byte
ID int64
AddedAt time.Time
EventType int32
InvoiceID int64
SetID []byte
}
type InvoiceEventType struct {
@@ -62,13 +64,13 @@ type InvoiceEventType struct {
type InvoiceFeature struct {
Feature int32
InvoiceID int32
InvoiceID int64
}
type InvoiceHtlc struct {
ID int32
HtlcID int64
ID int64
ChanID string
HtlcID int64
AmountMsat int64
TotalMppMsat sql.NullInt64
AcceptHeight int32
@@ -76,7 +78,7 @@ type InvoiceHtlc struct {
ExpiryHeight int32
State int16
ResolveTime sql.NullTime
InvoiceID int32
InvoiceID int64
}
type InvoiceHtlcCustomRecord struct {
@@ -85,9 +87,7 @@ type InvoiceHtlcCustomRecord struct {
HtlcID int64
}
type InvoicePayment struct {
ID int32
SettledAt time.Time
AmountPaidMsat int64
InvoiceID int32
type InvoiceSequence struct {
Name string
CurrentValue int64
}