-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
386 lines (329 loc) · 12.5 KB
/
types.go
File metadata and controls
386 lines (329 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
package lnbot
import (
"encoding/json"
"time"
)
// Ptr returns a pointer to v. Useful for optional fields in request params.
func Ptr[T any](v T) *T { return &v }
// ---------------------------------------------------------------------------
// Account
// ---------------------------------------------------------------------------
// RegisterResponse is returned when a new account is registered.
type RegisterResponse struct {
UserID string `json:"userId"`
PrimaryKey string `json:"primaryKey"`
SecondaryKey string `json:"secondaryKey"`
RecoveryPassphrase string `json:"recoveryPassphrase"`
}
// MeResponse is returned by the identity check endpoint.
type MeResponse struct {
WalletID string `json:"walletId"`
}
// ---------------------------------------------------------------------------
// Wallet
// ---------------------------------------------------------------------------
// Wallet represents a LnBot wallet.
type Wallet struct {
WalletID string `json:"walletId"`
Name string `json:"name"`
Balance int64 `json:"balance"`
OnHold int64 `json:"onHold"`
Available int64 `json:"available"`
}
// CreateWalletResponse is returned when a new wallet is created.
type CreateWalletResponse struct {
WalletID string `json:"walletId"`
Name string `json:"name"`
Address string `json:"address"`
}
// WalletListItem represents a wallet in the list response.
type WalletListItem struct {
WalletID string `json:"walletId"`
Name string `json:"name"`
CreatedAt *time.Time `json:"createdAt"`
}
// UpdateWalletParams are the parameters for updating a wallet.
type UpdateWalletParams struct {
Name string `json:"name"`
}
// ---------------------------------------------------------------------------
// Wallet Key
// ---------------------------------------------------------------------------
// WalletKeyResponse is returned when a wallet key is created or rotated.
type WalletKeyResponse struct {
Key string `json:"key"`
Hint string `json:"hint"`
}
// WalletKeyInfoResponse is returned when getting wallet key info.
type WalletKeyInfoResponse struct {
Hint string `json:"hint"`
CreatedAt *time.Time `json:"createdAt"`
LastUsedAt *time.Time `json:"lastUsedAt"`
}
// ---------------------------------------------------------------------------
// API Keys
// ---------------------------------------------------------------------------
// RotatedAPIKey is returned after rotating an API key.
type RotatedAPIKey struct {
Key string `json:"key"`
Name string `json:"name"`
}
// ---------------------------------------------------------------------------
// Invoices
// ---------------------------------------------------------------------------
// CreateInvoiceParams are the parameters for creating a new invoice.
type CreateInvoiceParams struct {
Amount int64 `json:"amount"`
Reference *string `json:"reference,omitempty"`
Memo *string `json:"memo,omitempty"`
}
// Invoice represents a Lightning invoice.
type Invoice struct {
Number int `json:"number"`
Status string `json:"status"`
Amount int64 `json:"amount"`
Bolt11 string `json:"bolt11"`
Reference *string `json:"reference"`
Memo *string `json:"memo"`
Preimage *string `json:"preimage"`
TxNumber *int `json:"txNumber"`
CreatedAt *time.Time `json:"createdAt"`
SettledAt *time.Time `json:"settledAt"`
ExpiresAt *time.Time `json:"expiresAt"`
}
// ListInvoicesParams are the pagination parameters for listing invoices.
type ListInvoicesParams struct {
Limit *int
After *int
}
// InvoiceEvent represents a server-sent event for an invoice.
type InvoiceEvent struct {
Event string
Data Invoice
}
// CreateInvoiceForWalletParams are the parameters for creating an invoice for a specific wallet.
// No authentication required. Rate limited by IP.
type CreateInvoiceForWalletParams struct {
WalletID string `json:"walletId"`
Amount int64 `json:"amount"`
Reference *string `json:"reference,omitempty"`
Comment *string `json:"comment,omitempty"`
}
// CreateInvoiceForAddressParams are the parameters for creating an invoice for a Lightning address.
// No authentication required. Rate limited by IP.
type CreateInvoiceForAddressParams struct {
Address string `json:"address"`
Amount int64 `json:"amount"`
Tag *string `json:"tag,omitempty"`
Comment *string `json:"comment,omitempty"`
}
// AddressInvoice is an invoice created via wallet ID or Lightning address.
type AddressInvoice struct {
Bolt11 string `json:"bolt11"`
Amount int64 `json:"amount"`
ExpiresAt *time.Time `json:"expiresAt"`
}
// ---------------------------------------------------------------------------
// Payments
// ---------------------------------------------------------------------------
// CreatePaymentParams are the parameters for creating a new payment.
// Target accepts a Lightning address (user@domain), LNURL, or BOLT11 invoice.
type CreatePaymentParams struct {
Target string `json:"target"`
Amount *int64 `json:"amount,omitempty"`
IdempotencyKey *string `json:"idempotencyKey,omitempty"`
MaxFee *int64 `json:"maxFee,omitempty"`
Reference *string `json:"reference,omitempty"`
}
// Payment represents a Lightning payment.
type Payment struct {
Number int `json:"number"`
Status string `json:"status"`
Amount int64 `json:"amount"`
MaxFee int64 `json:"maxFee"`
ServiceFee int64 `json:"serviceFee"`
ActualFee *int64 `json:"actualFee"`
Address string `json:"address"`
Reference *string `json:"reference"`
Preimage *string `json:"preimage"`
TxNumber *int `json:"txNumber"`
FailureReason *string `json:"failureReason"`
CreatedAt *time.Time `json:"createdAt"`
SettledAt *time.Time `json:"settledAt"`
}
// ListPaymentsParams are the pagination parameters for listing payments.
type ListPaymentsParams struct {
Limit *int
After *int
}
// PaymentEvent represents a server-sent event for a payment.
type PaymentEvent struct {
Event string
Data Payment
}
// ResolveTargetResponse is returned when resolving a payment target.
type ResolveTargetResponse struct {
Type string `json:"type"`
Min *int64 `json:"min"`
Max *int64 `json:"max"`
Fixed *bool `json:"fixed"`
Amount *int64 `json:"amount"`
}
// WalletEvent represents a real-time event from the wallet event stream.
type WalletEvent struct {
Event string `json:"event"`
CreatedAt string `json:"createdAt"`
Data json.RawMessage `json:"data"`
}
// ---------------------------------------------------------------------------
// Addresses
// ---------------------------------------------------------------------------
// CreateAddressParams are the parameters for creating a Lightning address.
type CreateAddressParams struct {
Address *string `json:"address,omitempty"`
}
// Address represents a Lightning address.
type Address struct {
Address string `json:"address"`
Generated bool `json:"generated"`
Cost int64 `json:"cost"`
CreatedAt *time.Time `json:"createdAt"`
}
// TransferAddressParams are the parameters for transferring an address.
type TransferAddressParams struct {
TargetWalletKey string `json:"targetWalletKey"`
}
// AddressTransfer is returned after transferring an address.
type AddressTransfer struct {
Address string `json:"address"`
TransferredTo string `json:"transferredTo"`
}
// ---------------------------------------------------------------------------
// Transactions
// ---------------------------------------------------------------------------
// Transaction represents a wallet transaction.
type Transaction struct {
Number int `json:"number"`
Type string `json:"type"`
Amount int64 `json:"amount"`
BalanceAfter int64 `json:"balanceAfter"`
NetworkFee int64 `json:"networkFee"`
ServiceFee int64 `json:"serviceFee"`
PaymentHash *string `json:"paymentHash"`
Preimage *string `json:"preimage"`
Reference *string `json:"reference"`
Note *string `json:"note"`
CreatedAt *time.Time `json:"createdAt"`
}
// ListTransactionsParams are the pagination parameters for listing transactions.
type ListTransactionsParams struct {
Limit *int
After *int
}
// ---------------------------------------------------------------------------
// Webhooks
// ---------------------------------------------------------------------------
// CreateWebhookParams are the parameters for creating a webhook.
type CreateWebhookParams struct {
URL string `json:"url"`
}
// WebhookWithSecret is returned when a webhook is created.
// It includes the secret used for signature verification.
type WebhookWithSecret struct {
ID string `json:"id"`
URL string `json:"url"`
Secret string `json:"secret"`
CreatedAt *time.Time `json:"createdAt"`
}
// Webhook represents a webhook endpoint.
type Webhook struct {
ID string `json:"id"`
URL string `json:"url"`
Active bool `json:"active"`
CreatedAt *time.Time `json:"createdAt"`
}
// ---------------------------------------------------------------------------
// Backup / Restore
// ---------------------------------------------------------------------------
// RecoveryPassphrase is returned when backup via recovery passphrase is initiated.
type RecoveryPassphrase struct {
Passphrase string `json:"passphrase"`
}
// RecoveryRestoreParams are the parameters for restoring via recovery passphrase.
type RecoveryRestoreParams struct {
Passphrase string `json:"passphrase"`
}
// RestoredWallet is returned after a successful wallet restore.
type RestoredWallet struct {
WalletID string `json:"walletId"`
Name string `json:"name"`
PrimaryKey string `json:"primaryKey"`
SecondaryKey string `json:"secondaryKey"`
}
// PasskeyRegistrationChallenge is returned when beginning passkey backup.
type PasskeyRegistrationChallenge struct {
SessionID string `json:"sessionId"`
Options map[string]any `json:"options"`
}
// PasskeyAttestationParams are the parameters for completing passkey backup.
type PasskeyAttestationParams struct {
SessionID string `json:"sessionId"`
Attestation map[string]any `json:"attestation"`
}
// PasskeyAuthenticationChallenge is returned when beginning passkey restore.
type PasskeyAuthenticationChallenge struct {
SessionID string `json:"sessionId"`
Options map[string]any `json:"options"`
}
// PasskeyAssertionParams are the parameters for completing passkey restore.
type PasskeyAssertionParams struct {
SessionID string `json:"sessionId"`
Assertion map[string]any `json:"assertion"`
}
// ---------------------------------------------------------------------------
// L402
// ---------------------------------------------------------------------------
// CreateL402ChallengeParams are the parameters for creating an L402 challenge.
type CreateL402ChallengeParams struct {
Amount int64 `json:"amount"`
Description *string `json:"description,omitempty"`
ExpirySeconds *int `json:"expirySeconds,omitempty"`
Caveats []string `json:"caveats,omitempty"`
}
// L402Challenge is returned when an L402 challenge is created.
type L402Challenge struct {
Macaroon string `json:"macaroon"`
Invoice string `json:"invoice"`
PaymentHash string `json:"paymentHash"`
ExpiresAt time.Time `json:"expiresAt"`
WwwAuthenticate string `json:"wwwAuthenticate"`
}
// VerifyL402Params are the parameters for verifying an L402 token.
type VerifyL402Params struct {
Authorization string `json:"authorization"`
}
// VerifyL402Response is returned when verifying an L402 token.
type VerifyL402Response struct {
Valid bool `json:"valid"`
PaymentHash *string `json:"paymentHash"`
Caveats []string `json:"caveats"`
Error *string `json:"error"`
}
// PayL402Params are the parameters for paying an L402 challenge.
type PayL402Params struct {
WwwAuthenticate string `json:"wwwAuthenticate"`
MaxFee *int64 `json:"maxFee,omitempty"`
Reference *string `json:"reference,omitempty"`
Wait *bool `json:"wait,omitempty"`
Timeout *int `json:"timeout,omitempty"`
}
// L402PayResponse is returned after paying an L402 challenge.
type L402PayResponse struct {
Authorization *string `json:"authorization"`
PaymentHash string `json:"paymentHash"`
Preimage *string `json:"preimage"`
Amount int64 `json:"amount"`
Fee *int64 `json:"fee"`
PaymentNumber int `json:"paymentNumber"`
Status string `json:"status"`
}