models.go raw
1 package db
2
3 import (
4 "time"
5
6 "gorm.io/datatypes"
7 )
8
9 type UserConfig struct {
10 ID uint
11 Key string
12 Value string
13 Encrypted bool
14 CreatedAt time.Time
15 UpdatedAt time.Time
16 }
17
18 type App struct {
19 ID uint
20 Name string `validate:"required"`
21 Description string
22 AppPubkey string `validate:"required"`
23 WalletPubkey *string
24 CreatedAt time.Time
25 UpdatedAt time.Time
26 LastUsedAt *time.Time
27 LastSettledTransactionAt *time.Time
28 Isolated bool
29 Metadata datatypes.JSON
30 }
31
32 type AppPermission struct {
33 ID uint
34 AppId uint `validate:"required"`
35 App App
36 Scope string `validate:"required"`
37 MaxAmountSat int
38 BudgetRenewal string
39 ExpiresAt *time.Time
40 CreatedAt time.Time
41 UpdatedAt time.Time
42 }
43
44 type RequestEvent struct {
45 ID uint
46 AppId *uint
47 App App
48 NostrId string `validate:"required"`
49 ContentData string
50 Method string
51 State string
52 CreatedAt time.Time
53 UpdatedAt time.Time
54 }
55
56 type ResponseEvent struct {
57 ID uint
58 NostrId string `validate:"required"`
59 RequestId uint `validate:"required"`
60 State string
61 RepliedAt time.Time
62 CreatedAt time.Time
63 UpdatedAt time.Time
64 }
65
66 type Transaction struct {
67 ID uint
68 AppId *uint
69 App *App
70 RequestEventId *uint
71 RequestEvent *RequestEvent
72 Type string
73 State string
74 AmountMsat uint64
75 FeeMsat uint64
76 FeeReserveMsat uint64
77 PaymentRequest string
78 PaymentHash string
79 Description string
80 DescriptionHash string
81 Preimage *string
82 CreatedAt time.Time
83 ExpiresAt *time.Time
84 UpdatedAt time.Time
85 SettledAt *time.Time
86 Metadata datatypes.JSON
87 SelfPayment bool
88 Boostagram datatypes.JSON
89 FailureReason string
90 Hold bool
91 SettleDeadline *uint32 // block number for accepted hold invoices
92 }
93
94 type Swap struct {
95 ID uint
96 SwapId string `validate:"required"`
97 Type string
98 State string
99 Invoice string
100 SendAmountSat uint64 `gorm:"column:send_amount"`
101 ReceiveAmountSat uint64 `gorm:"column:receive_amount"`
102 Preimage string
103 PaymentHash string
104 DestinationAddress string
105 RefundAddress string
106 LockupAddress string
107 LockupTxId string
108 ClaimTxId string
109 AutoSwap bool
110 UsedXpub bool
111 TimeoutBlockHeight uint32
112 BoltzPubkey string
113 SwapTree datatypes.JSON
114 CreatedAt time.Time
115 UpdatedAt time.Time
116 }
117
118 type Forward struct {
119 ID uint
120 OutboundAmountForwardedMsat uint64
121 TotalFeeEarnedMsat uint64
122 CreatedAt time.Time
123 UpdatedAt time.Time
124 }
125
126 const (
127 REQUEST_EVENT_STATE_HANDLER_EXECUTING = "executing"
128 REQUEST_EVENT_STATE_HANDLER_EXECUTED = "executed"
129 REQUEST_EVENT_STATE_HANDLER_ERROR = "error"
130 )
131 const (
132 RESPONSE_EVENT_STATE_PUBLISH_CONFIRMED = "confirmed"
133 RESPONSE_EVENT_STATE_PUBLISH_FAILED = "failed"
134 RESPONSE_EVENT_STATE_PUBLISH_UNCONFIRMED = "unconfirmed"
135 )
136