models.go raw
1 package api
2
3 import (
4 "context"
5 "errors"
6 "io"
7 "time"
8
9 "github.com/getAlby/hub/alby"
10 "github.com/getAlby/hub/db"
11 "github.com/getAlby/hub/swaps"
12 )
13
14 type API interface {
15 CreateApp(createAppRequest *CreateAppRequest) (*CreateAppResponse, error)
16 UpdateApp(app *db.App, updateAppRequest *UpdateAppRequest) error
17 Transfer(ctx context.Context, fromAppId *uint, toAppId *uint, amountMsat uint64, description string) error
18 DeleteApp(app *db.App) error
19 GetApp(app *db.App) (*App, error)
20 ListApps(limit uint64, offset uint64, filters ListAppsFilters, orderBy string) (*ListAppsResponse, error)
21 CreateLightningAddress(ctx context.Context, createLightningAddressRequest *CreateLightningAddressRequest) error
22 DeleteLightningAddress(ctx context.Context, appId uint) error
23 ListChannels(ctx context.Context) ([]Channel, error)
24 GetChannelPeerSuggestions(ctx context.Context) ([]alby.ChannelPeerSuggestion, error)
25 GetStories(ctx context.Context) ([]alby.Story, error)
26 GetLSPChannelOffer(ctx context.Context) (*alby.LSPChannelOffer, error)
27 ResetRouter(key string) error
28 ChangeUnlockPassword(changeUnlockPasswordRequest *ChangeUnlockPasswordRequest) error
29 SetAutoUnlockPassword(unlockPassword string) error
30 Stop() error
31 GetNodeConnectionInfo(ctx context.Context) (*NodeConnectionInfo, error)
32 GetNodeStatus(ctx context.Context) (*NodeStatus, error)
33 ListPeers(ctx context.Context) ([]PeerDetails, error)
34 ConnectPeer(ctx context.Context, connectPeerRequest *ConnectPeerRequest) error
35 DisconnectPeer(ctx context.Context, peerId string) error
36 OpenChannel(ctx context.Context, openChannelRequest *OpenChannelRequest) (*OpenChannelResponse, error)
37 RebalanceChannel(ctx context.Context, rebalanceChannelRequest *RebalanceChannelRequest) (*RebalanceChannelResponse, error)
38 CloseChannel(ctx context.Context, peerId, channelId string, force bool) (*CloseChannelResponse, error)
39 UpdateChannel(ctx context.Context, updateChannelRequest *UpdateChannelRequest) error
40 MakeOffer(ctx context.Context, description string) (string, error)
41 GetNewOnchainAddress(ctx context.Context) (string, error)
42 GetUnusedOnchainAddress(ctx context.Context) (string, error)
43 SignMessage(ctx context.Context, message string) (*SignMessageResponse, error)
44 RedeemOnchainFunds(ctx context.Context, toAddress string, amountSat uint64, feeRate *uint64, sendAll bool) (*RedeemOnchainFundsResponse, error)
45 GetBalances(ctx context.Context) (*BalancesResponse, error)
46 ListTransactions(ctx context.Context, appId *uint, limit uint64, offset uint64, filters ListTransactionsFilters) (*ListTransactionsResponse, error)
47 ListOnchainTransactions(ctx context.Context) ([]OnchainTransaction, error)
48 SendPayment(ctx context.Context, invoice string, amountMsat *uint64, metadata map[string]interface{}, fromAppId *uint) (*SendPaymentResponse, error)
49 CreateInvoice(ctx context.Context, amountMsat uint64, description string, toAppId *uint) (*MakeInvoiceResponse, error)
50 LookupInvoice(ctx context.Context, paymentHash string) (*LookupInvoiceResponse, error)
51 SetTransactionUserLabels(ctx context.Context, id uint, labels map[string]string) error
52 RequestMempoolApi(ctx context.Context, endpoint string) (interface{}, error)
53 GetInfo(ctx context.Context) (*InfoResponse, error)
54 GetMnemonic(unlockPassword string) (*MnemonicResponse, error)
55 SetNextBackupReminder(backupReminderRequest *BackupReminderRequest) error
56 Start(startRequest *StartRequest)
57 Setup(ctx context.Context, setupRequest *SetupRequest) error
58 GetNetworkGraph(ctx context.Context, nodeIds []string) (NetworkGraphResponse, error)
59 SyncWallet() error
60 GetLogOutput(ctx context.Context, logType string, getLogRequest *GetLogOutputRequest) (*GetLogOutputResponse, error)
61 RequestLSPOrder(ctx context.Context, request *LSPOrderRequest) (*LSPOrderResponse, error)
62 CreateBackup(unlockPassword string, w io.Writer) error
63 RestoreBackup(unlockPassword string, r io.Reader) error
64 MigrateNodeStorage(ctx context.Context, to string) error
65 GetWalletCapabilities(ctx context.Context) (*WalletCapabilitiesResponse, error)
66 Health(ctx context.Context) (*HealthResponse, error)
67 UpdateSettings(updateSettingsRequest *UpdateSettingsRequest) error
68 LookupSwap(swapId string) (*LookupSwapResponse, error)
69 ListSwaps() (*ListSwapsResponse, error)
70 GetSwapInInfo() (*SwapInfoResponse, error)
71 GetSwapOutInfo() (*SwapInfoResponse, error)
72 InitiateSwapIn(ctx context.Context, initiateSwapInRequest *InitiateSwapRequest) (*swaps.SwapResponse, error)
73 InitiateSwapOut(ctx context.Context, initiateSwapOutRequest *InitiateSwapRequest) (*swaps.SwapResponse, error)
74 RefundSwap(refundSwapRequest *RefundSwapRequest) error
75 GetSwapMnemonic() string
76 GetAutoSwapConfig() (*GetAutoSwapConfigResponse, error)
77 EnableAutoSwapOut(ctx context.Context, autoSwapRequest *EnableAutoSwapRequest) error
78 DisableAutoSwap() error
79 SetNodeAlias(nodeAlias string) error
80 GetCustomNodeCommands() (*CustomNodeCommandsResponse, error)
81 ExecuteCustomNodeCommand(ctx context.Context, command string) (interface{}, error)
82 SendEvent(event string, properties interface{})
83 GetForwards() (*GetForwardsResponse, error)
84 }
85
86 var ErrLNClientNotStarted = errors.New("LNClient not started")
87
88 type App struct {
89 ID uint `json:"id"`
90 Name string `json:"name"`
91 Description string `json:"description"`
92 AppPubkey string `json:"appPubkey"`
93 CreatedAt time.Time `json:"createdAt"`
94 UpdatedAt time.Time `json:"updatedAt"`
95 LastUsedAt *time.Time `json:"lastUsedAt"`
96 LastSettledTransactionAt *time.Time `json:"lastSettledTransactionAt"`
97 ExpiresAt *time.Time `json:"expiresAt"`
98 Scopes []string `json:"scopes"`
99 MaxAmount uint64 `json:"maxAmount"` // deprecated
100 MaxAmountSat uint64 `json:"maxAmountSat"`
101 MaxAmountMsat uint64 `json:"maxAmountMsat"`
102 BudgetUsage uint64 `json:"budgetUsage"` // deprecated
103 BudgetUsageSat uint64 `json:"budgetUsageSat"`
104 BudgetUsageMsat uint64 `json:"budgetUsageMsat"`
105 BudgetRenewal string `json:"budgetRenewal"`
106 Isolated bool `json:"isolated"`
107 WalletPubkey string `json:"walletPubkey"`
108 UniqueWalletPubkey bool `json:"uniqueWalletPubkey"`
109 Balance int64 `json:"balance"` // deprecated
110 BalanceSat int64 `json:"balanceSat"`
111 BalanceMsat int64 `json:"balanceMsat"`
112 Metadata Metadata `json:"metadata,omitempty"`
113 }
114
115 type ListAppsFilters struct {
116 Name string `json:"name"`
117 AppStoreAppId string `json:"appStoreAppId"`
118 Unused bool `json:"unused"`
119 SubWallets *bool `json:"subWallets"`
120 }
121
122 type ListAppsResponse struct {
123 Apps []App `json:"apps"`
124 TotalCount uint64 `json:"totalCount"`
125 TotalBalance *int64 `json:"totalBalance,omitempty"` // deprecated
126 TotalBalanceSat *int64 `json:"totalBalanceSat,omitempty"`
127 TotalBalanceMsat *int64 `json:"totalBalanceMsat,omitempty"`
128 }
129
130 type UpdateAppRequest struct {
131 Name *string `json:"name"`
132 MaxAmount *uint64 `json:"maxAmount"` // deprecated
133 MaxAmountSat *uint64 `json:"maxAmountSat"`
134 MaxAmountMsat *uint64 `json:"maxAmountMsat"`
135 BudgetRenewal *string `json:"budgetRenewal"`
136 ExpiresAt *string `json:"expiresAt"`
137 UpdateExpiresAt bool `json:"updateExpiresAt"`
138 Scopes []string `json:"scopes"`
139 Metadata *Metadata `json:"metadata"`
140 Isolated *bool `json:"isolated"`
141 }
142
143 type TransferRequest struct {
144 AmountSat *uint64 `json:"amountSat"`
145 AmountMsat *uint64 `json:"amountMsat"`
146 FromAppId *uint `json:"fromAppId"`
147 ToAppId *uint `json:"toAppId"`
148 Description string `json:"description"`
149 }
150
151 type CreateAppRequest struct {
152 Name string `json:"name"`
153 Pubkey string `json:"pubkey"`
154 MaxAmount *uint64 `json:"maxAmount"` // deprecated
155 MaxAmountSat *uint64 `json:"maxAmountSat"`
156 MaxAmountMsat *uint64 `json:"maxAmountMsat"`
157 BudgetRenewal string `json:"budgetRenewal"`
158 ExpiresAt string `json:"expiresAt"`
159 Scopes []string `json:"scopes"`
160 ReturnTo string `json:"returnTo"`
161 Isolated bool `json:"isolated"`
162 Metadata Metadata `json:"metadata,omitempty"`
163 UnlockPassword string `json:"unlockPassword"`
164 }
165
166 type CreateLightningAddressRequest struct {
167 Address string `json:"address"`
168 AppId uint `json:"appId"`
169 }
170
171 type InitiateSwapRequest struct {
172 SwapAmount *uint64 `json:"swapAmount"` // deprecated
173 SwapAmountSat *uint64 `json:"swapAmountSat"`
174 Destination string `json:"destination"`
175 }
176
177 type RefundSwapRequest struct {
178 SwapId string `json:"swapId"`
179 Address string `json:"address"`
180 }
181
182 type EnableAutoSwapRequest struct {
183 BalanceThreshold *uint64 `json:"balanceThreshold"` // deprecated
184 BalanceThresholdSat *uint64 `json:"balanceThresholdSat"`
185 SwapAmount *uint64 `json:"swapAmount"` // deprecated
186 SwapAmountSat *uint64 `json:"swapAmountSat"`
187 Destination string `json:"destination"`
188 DestinationType string `json:"destinationType"`
189 UnlockPassword string `json:"unlockPassword"`
190 }
191
192 type GetAutoSwapConfigResponse struct {
193 Type string `json:"type"`
194 Enabled bool `json:"enabled"`
195 BalanceThreshold uint64 `json:"balanceThreshold"` // deprecated
196 BalanceThresholdSat uint64 `json:"balanceThresholdSat"`
197 SwapAmount uint64 `json:"swapAmount"` // deprecated
198 SwapAmountSat uint64 `json:"swapAmountSat"`
199 Destination string `json:"destination"`
200 }
201
202 type SwapInfoResponse struct {
203 AlbyServiceFee float64 `json:"albyServiceFee"`
204 BoltzServiceFee float64 `json:"boltzServiceFee"`
205 BoltzNetworkFee uint64 `json:"boltzNetworkFee"` // deprecated
206 BoltzNetworkFeeSat uint64 `json:"boltzNetworkFeeSat"`
207 MinAmount uint64 `json:"minAmount"` // deprecated
208 MinAmountSat uint64 `json:"minAmountSat"`
209 MaxAmount uint64 `json:"maxAmount"` // deprecated
210 MaxAmountSat uint64 `json:"maxAmountSat"`
211 }
212
213 type ListSwapsResponse struct {
214 Swaps []Swap `json:"swaps"`
215 }
216
217 type LookupSwapResponse = Swap
218
219 type Swap struct {
220 Id string `json:"id"`
221 Type string `json:"type"`
222 State string `json:"state"`
223 Invoice string `json:"invoice"`
224 SendAmount uint64 `json:"sendAmount"` // deprecated
225 SendAmountSat uint64 `json:"sendAmountSat"`
226 ReceiveAmount uint64 `json:"receiveAmount"` // deprecated
227 ReceiveAmountSat uint64 `json:"receiveAmountSat"`
228 PaymentHash string `json:"paymentHash"`
229 DestinationAddress string `json:"destinationAddress"`
230 RefundAddress string `json:"refundAddress"`
231 LockupAddress string `json:"lockupAddress"`
232 LockupTxId string `json:"lockupTxId"`
233 ClaimTxId string `json:"claimTxId"`
234 AutoSwap bool `json:"autoSwap"`
235 BoltzPubkey string `json:"boltzPubkey"`
236 CreatedAt string `json:"createdAt"`
237 UpdatedAt string `json:"updatedAt"`
238 UsedXpub bool `json:"usedXpub"`
239 }
240
241 type StartRequest struct {
242 UnlockPassword string `json:"unlockPassword"`
243 }
244
245 type UnlockRequest struct {
246 UnlockPassword string `json:"unlockPassword"`
247 TokenExpiryDays *uint64 `json:"tokenExpiryDays"`
248 Permission string `json:"permission,omitempty"` // "full" or "readonly"
249 }
250
251 type BackupReminderRequest struct {
252 NextBackupReminder string `json:"nextBackupReminder"`
253 }
254
255 type SendEventRequest struct {
256 Event string `json:"event"`
257 Properties interface{} `json:"properties"`
258 }
259
260 type SetupRequest struct {
261 LNBackendType string `json:"backendType"`
262 UnlockPassword string `json:"unlockPassword"`
263
264 Mnemonic string `json:"mnemonic"`
265 NextBackupReminder string `json:"nextBackupReminder"`
266
267 // LND fields
268 LNDAddress string `json:"lndAddress"`
269 LNDCertFile string `json:"lndCertFile"`
270 LNDMacaroonFile string `json:"lndMacaroonFile"`
271
272 // Phoenixd fields
273 PhoenixdAddress string `json:"phoenixdAddress"`
274 PhoenixdAuthorization string `json:"phoenixdAuthorization"`
275
276 // Cashu fields
277 CashuMintUrl string `json:"cashuMintUrl"`
278
279 // CLN fields
280 CLNAddress string `json:"clnAddress"`
281 CLNLightningDir string `json:"clnLightningDir"`
282 CLNAddressHold string `json:"clnAddressHold"`
283 }
284
285 type CreateAppResponse struct {
286 PairingUri string `json:"pairingUri"`
287 PairingSecret string `json:"pairingSecretKey"`
288 Pubkey string `json:"pairingPublicKey"`
289 RelayUrls []string `json:"relayUrls"`
290 WalletPubkey string `json:"walletPubkey"`
291 Lud16 string `json:"lud16"`
292 Id uint `json:"id"`
293 Name string `json:"name"`
294 ReturnTo string `json:"returnTo"`
295 }
296
297 type User struct {
298 Email string `json:"email"`
299 }
300
301 type InfoResponseRelay struct {
302 Url string `json:"url"`
303 Online bool `json:"online"`
304 }
305
306 type InfoResponse struct {
307 BackendType string `json:"backendType"`
308 SetupCompleted bool `json:"setupCompleted"`
309 OAuthRedirect bool `json:"oauthRedirect"`
310 Running bool `json:"running"`
311 Unlocked bool `json:"unlocked"`
312 AlbyAuthUrl string `json:"albyAuthUrl"`
313 NextBackupReminder string `json:"nextBackupReminder"`
314 AlbyUserIdentifier string `json:"albyUserIdentifier"`
315 AlbyAccountConnected bool `json:"albyAccountConnected"`
316 Version string `json:"version"`
317 Network string `json:"network"`
318 EnableAdvancedSetup bool `json:"enableAdvancedSetup"`
319 LdkVssEnabled bool `json:"ldkVssEnabled"`
320 LdkVssUrl string `json:"ldkVssUrl"`
321 VssSupported bool `json:"vssSupported"`
322 DatabaseType string `json:"databaseType"`
323 StartupState string `json:"startupState"`
324 StartupError string `json:"startupError"`
325 StartupErrorTime time.Time `json:"startupErrorTime"`
326 AutoUnlockPasswordSupported bool `json:"autoUnlockPasswordSupported"`
327 AutoUnlockPasswordEnabled bool `json:"autoUnlockPasswordEnabled"`
328 Nip07AuthEnabled bool `json:"nip07AuthEnabled"`
329 Currency string `json:"currency"`
330 BitcoinDisplayFormat string `json:"bitcoinDisplayFormat"`
331 Relays []InfoResponseRelay `json:"relays"`
332 NodeAlias string `json:"nodeAlias"`
333 MempoolUrl string `json:"mempoolUrl"`
334 ChainDataSourceType string `json:"chainDataSourceType,omitempty"`
335 ChainDataSourceAddress string `json:"chainDataSourceAddress,omitempty"`
336 JitChannelsLiquiditySource string `json:"jitChannelsLiquiditySource,omitempty"`
337 JitChannelsMinPaymentSizeMsat *uint64 `json:"jitChannelsMinPaymentSizeMsat,omitempty"`
338 JitChannelsMaxPaymentSizeMsat *uint64 `json:"jitChannelsMaxPaymentSizeMsat,omitempty"`
339 JitChannelsEnabled bool `json:"jitChannelsEnabled"`
340 HideUpdateBanner bool `json:"hideUpdateBanner"`
341 SupportsBolt12 bool `json:"supportsBolt12"`
342 NodeMigrationFileCreated bool `json:"nodeMigrationFileCreated"`
343 }
344
345 type UpdateSettingsRequest struct {
346 Currency string `json:"currency"`
347 BitcoinDisplayFormat string `json:"bitcoinDisplayFormat"`
348 JitChannelsEnabled *bool `json:"jitChannelsEnabled"`
349 }
350
351 type SetNodeAliasRequest struct {
352 NodeAlias string `json:"nodeAlias"`
353 }
354
355 type MnemonicRequest struct {
356 UnlockPassword string `json:"unlockPassword"`
357 }
358
359 type MnemonicResponse struct {
360 Mnemonic string `json:"mnemonic"`
361 }
362
363 type ChangeUnlockPasswordRequest struct {
364 CurrentUnlockPassword string `json:"currentUnlockPassword"`
365 NewUnlockPassword string `json:"newUnlockPassword"`
366 }
367 type AutoUnlockRequest struct {
368 UnlockPassword string `json:"unlockPassword"`
369 }
370
371 type ConnectPeerRequest struct {
372 Pubkey string `json:"pubkey"`
373 Address string `json:"address"`
374 Port uint16 `json:"port"`
375 }
376
377 type OpenChannelRequest struct {
378 Pubkey string `json:"pubkey"`
379 AmountSats int64 `json:"amountSats"`
380 Public bool `json:"public"`
381 }
382
383 type OpenChannelResponse struct {
384 FundingTxId string `json:"fundingTxId"`
385 }
386
387 type CloseChannelResponse struct {
388 }
389
390 type UpdateChannelRequest struct {
391 ChannelId string `json:"channelId"`
392 NodeId string `json:"nodeId"`
393 ForwardingFeeBaseMsat uint32 `json:"forwardingFeeBaseMsat"`
394 ForwardingFeeProportionalMillionths uint32 `json:"forwardingFeeProportionalMillionths"`
395 MaxDustHtlcExposureFromFeeRateMultiplier uint64 `json:"maxDustHtlcExposureFromFeeRateMultiplier"`
396 }
397
398 type NodeConnectionInfo struct {
399 Pubkey string `json:"pubkey"`
400 Address string `json:"address"`
401 Port int `json:"port"`
402 }
403
404 type NodeStatus struct {
405 IsReady bool `json:"isReady"`
406 InternalNodeStatus interface{} `json:"internalNodeStatus"`
407 }
408
409 type PeerDetails struct {
410 NodeId string `json:"nodeId"`
411 Address string `json:"address"`
412 IsPersisted bool `json:"isPersisted"`
413 IsConnected bool `json:"isConnected"`
414 }
415
416 type OnchainTransaction struct {
417 AmountSat uint64 `json:"amountSat"`
418 CreatedAt uint64 `json:"createdAt"`
419 State string `json:"state"`
420 Type string `json:"type"`
421 NumConfirmations uint32 `json:"numConfirmations"`
422 TxId string `json:"txId"`
423 }
424
425 type PendingBalanceDetails struct {
426 ChannelId string `json:"channelId"`
427 NodeId string `json:"nodeId"`
428 Amount uint64 `json:"amount"` // deprecated
429 AmountSat uint64 `json:"amountSat"`
430 FundingTxId string `json:"fundingTxId"`
431 FundingTxVout uint32 `json:"fundingTxVout"`
432 }
433
434 type RebalanceChannelRequest struct {
435 ReceiveThroughNodePubkey string `json:"receiveThroughNodePubkey"`
436 AmountSat *uint64 `json:"amountSat"`
437 AmountMsat *uint64 `json:"amountMsat"`
438 }
439 type RebalanceChannelResponse struct {
440 TotalFeeSat uint64 `json:"totalFeeSat"`
441 TotalFeeMsat uint64 `json:"totalFeeMsat"`
442 }
443
444 type RedeemOnchainFundsRequest struct {
445 ToAddress string `json:"toAddress"`
446 Amount *uint64 `json:"amount"` // deprecated
447 AmountSat *uint64 `json:"amountSat"`
448 FeeRate *uint64 `json:"feeRate"`
449 SendAll bool `json:"sendAll"`
450 }
451
452 type RedeemOnchainFundsResponse struct {
453 TxId string `json:"txId"`
454 }
455
456 type OnchainBalanceResponse struct {
457 Spendable int64 `json:"spendable"` // deprecated
458 SpendableSat int64 `json:"spendableSat"`
459 Total int64 `json:"total"` // deprecated
460 TotalSat int64 `json:"totalSat"`
461 Reserved int64 `json:"reserved"` // deprecated
462 ReservedSat int64 `json:"reservedSat"`
463 PendingBalancesFromChannelClosures uint64 `json:"pendingBalancesFromChannelClosures"` // deprecated
464 PendingBalancesFromChannelClosuresSat uint64 `json:"pendingBalancesFromChannelClosuresSat"`
465 PendingBalancesDetails []PendingBalanceDetails `json:"pendingBalancesDetails"`
466 PendingSweepBalancesDetails []PendingBalanceDetails `json:"pendingSweepBalancesDetails"`
467 InternalBalances interface{} `json:"internalBalances"`
468 }
469
470 type LightningBalanceResponse struct {
471 TotalSpendable int64 `json:"totalSpendable"` // deprecated
472 TotalSpendableSat int64 `json:"totalSpendableSat"`
473 TotalSpendableMsat int64 `json:"totalSpendableMsat"`
474 TotalReceivable int64 `json:"totalReceivable"` // deprecated
475 TotalReceivableSat int64 `json:"totalReceivableSat"`
476 TotalReceivableMsat int64 `json:"totalReceivableMsat"`
477 NextMaxSpendable int64 `json:"nextMaxSpendable"` // deprecated
478 NextMaxSpendableSat int64 `json:"nextMaxSpendableSat"`
479 NextMaxSpendableMsat int64 `json:"nextMaxSpendableMsat"`
480 NextMaxReceivable int64 `json:"nextMaxReceivable"` // deprecated
481 NextMaxReceivableSat int64 `json:"nextMaxReceivableSat"`
482 NextMaxReceivableMsat int64 `json:"nextMaxReceivableMsat"`
483 NextMaxSpendableMPP int64 `json:"nextMaxSpendableMPP"` // deprecated
484 NextMaxSpendableMPPSat int64 `json:"nextMaxSpendableMPPSat"`
485 NextMaxSpendableMPPMsat int64 `json:"nextMaxSpendableMPPMsat"`
486 NextMaxReceivableMPP int64 `json:"nextMaxReceivableMPP"` // deprecated
487 NextMaxReceivableMPPSat int64 `json:"nextMaxReceivableMPPSat"`
488 NextMaxReceivableMPPMsat int64 `json:"nextMaxReceivableMPPMsat"`
489 }
490
491 type BalancesResponse struct {
492 Onchain OnchainBalanceResponse `json:"onchain"`
493 Lightning LightningBalanceResponse `json:"lightning"`
494 }
495
496 type SendPaymentResponse = Transaction
497 type MakeInvoiceResponse = Transaction
498 type LookupInvoiceResponse = Transaction
499
500 type SetTransactionUserLabelsRequest struct {
501 Labels map[string]string `json:"labels"`
502 }
503
504 type ListTransactionsFilters struct {
505 Type *string
506 MinAmountMsat *uint64
507 HideFailed bool
508 SearchTerm string
509 }
510
511 type ListTransactionsResponse struct {
512 TotalCount uint64 `json:"totalCount"`
513 Transactions []Transaction `json:"transactions"`
514 }
515
516 // TODO: camelCase
517 type Transaction struct {
518 ID uint `json:"id"`
519 Type string `json:"type"`
520 State string `json:"state"`
521 Invoice string `json:"invoice"`
522 Description string `json:"description"`
523 DescriptionHash string `json:"descriptionHash"`
524 Preimage *string `json:"preimage"`
525 PaymentHash string `json:"paymentHash"`
526 Amount uint64 `json:"amount"` // deprecated
527 AmountSat uint64 `json:"amountSat"`
528 AmountMsat uint64 `json:"amountMsat"`
529 FeesPaid uint64 `json:"feesPaid"` // deprecated
530 FeesPaidSat uint64 `json:"feesPaidSat"`
531 FeesPaidMsat uint64 `json:"feesPaidMsat"`
532 UpdatedAt string `json:"updatedAt"`
533 CreatedAt string `json:"createdAt"`
534 SettledAt *string `json:"settledAt"`
535 AppId *uint `json:"appId"`
536 Metadata Metadata `json:"metadata,omitempty"`
537 Boostagram *Boostagram `json:"boostagram,omitempty"`
538 FailureReason string `json:"failureReason"`
539 }
540
541 type Metadata = map[string]interface{}
542
543 type Boostagram struct {
544 AppName string `json:"appName"`
545 Name string `json:"name"`
546 Podcast string `json:"podcast"`
547 URL string `json:"url"`
548 Episode string `json:"episode,omitempty"`
549 FeedId string `json:"feedId,omitempty"`
550 ItemId string `json:"itemId,omitempty"`
551 Timestamp int64 `json:"ts,omitempty"`
552 Message string `json:"message,omitempty"`
553 SenderId string `json:"senderId"`
554 SenderName string `json:"senderName"`
555 Time string `json:"time"`
556 Action string `json:"action"`
557 ValueSatTotal int64 `json:"valueSatTotal"`
558 ValueMsatTotal int64 `json:"valueMsatTotal"`
559 }
560
561 const (
562 LogTypeNode = "node"
563 LogTypeApp = "app"
564 )
565
566 type GetLogOutputRequest struct {
567 MaxLen int `query:"maxLen"`
568 }
569
570 type GetLogOutputResponse struct {
571 Log string `json:"logs"`
572 }
573
574 type SignMessageRequest struct {
575 Message string `json:"message"`
576 }
577
578 type SignMessageResponse struct {
579 Message string `json:"message"`
580 Signature string `json:"signature"`
581 }
582
583 type PayInvoiceRequest struct {
584 Amount *uint64 `json:"amount"` // deprecated
585 AmountSat *uint64 `json:"amountSat"`
586 AmountMsat *uint64 `json:"amountMsat"`
587 Metadata Metadata `json:"metadata"`
588 FromAppID *uint `json:"fromAppId"`
589 }
590
591 type MakeOfferRequest struct {
592 Description string `json:"description"`
593 }
594
595 type MakeInvoiceRequest struct {
596 Amount *uint64 `json:"amount"` // deprecated
597 AmountSat *uint64 `json:"amountSat"`
598 AmountMsat *uint64 `json:"amountMsat"`
599 Description string `json:"description"`
600 ToAppID *uint `json:"toAppId"`
601 }
602
603 type ResetRouterRequest struct {
604 Key string `json:"key"`
605 }
606
607 type BasicBackupRequest struct {
608 UnlockPassword string `json:"unlockPassword"`
609 }
610
611 type BasicRestoreWailsRequest struct {
612 UnlockPassword string `json:"unlockPassword"`
613 }
614
615 type NetworkGraphResponse = interface{}
616
617 type LSPOrderRequest struct {
618 Amount *uint64 `json:"amount"` // deprecated
619 AmountSat *uint64 `json:"amountSat"`
620 LSPType string `json:"lspType"`
621 LSPIdentifier string `json:"lspIdentifier"`
622 Public bool `json:"public"`
623 }
624
625 type LSPOrderResponse struct {
626 Invoice string `json:"invoice"`
627 Fee uint64 `json:"fee"` // deprecated
628 FeeSat uint64 `json:"feeSat"`
629 InvoiceAmount uint64 `json:"invoiceAmount"` // deprecated
630 InvoiceAmountSat uint64 `json:"invoiceAmountSat"`
631 IncomingLiquidity uint64 `json:"incomingLiquidity"` // deprecated
632 IncomingLiquiditySat uint64 `json:"incomingLiquiditySat"`
633 OutgoingLiquidity uint64 `json:"outgoingLiquidity"` // deprecated
634 OutgoingLiquiditySat uint64 `json:"outgoingLiquiditySat"`
635 }
636
637 type WalletCapabilitiesResponse struct {
638 Scopes []string `json:"scopes"`
639 Methods []string `json:"methods"`
640 NotificationTypes []string `json:"notificationTypes"`
641 }
642
643 type Channel struct {
644 LocalBalance int64 `json:"localBalance"` // deprecated
645 LocalBalanceSat int64 `json:"localBalanceSat"`
646 LocalBalanceMsat int64 `json:"localBalanceMsat"`
647 LocalSpendableBalance int64 `json:"localSpendableBalance"` // deprecated
648 LocalSpendableBalanceSat int64 `json:"localSpendableBalanceSat"`
649 LocalSpendableBalanceMsat int64 `json:"localSpendableBalanceMsat"`
650 RemoteBalance int64 `json:"remoteBalance"` // deprecated
651 RemoteBalanceSat int64 `json:"remoteBalanceSat"`
652 RemoteBalanceMsat int64 `json:"remoteBalanceMsat"`
653 Id string `json:"id"`
654 RemotePubkey string `json:"remotePubkey"`
655 FundingTxId string `json:"fundingTxId"`
656 FundingTxVout uint32 `json:"fundingTxVout"`
657 Active bool `json:"active"`
658 Public bool `json:"public"`
659 InternalChannel interface{} `json:"internalChannel"`
660 Confirmations *uint32 `json:"confirmations"`
661 ConfirmationsRequired *uint32 `json:"confirmationsRequired"`
662 ForwardingFeeBaseMsat uint32 `json:"forwardingFeeBaseMsat"` // expressed only in msat as per Lightning spec
663 ForwardingFeeProportionalMillionths uint32 `json:"forwardingFeeProportionalMillionths"`
664 UnspendablePunishmentReserve uint64 `json:"unspendablePunishmentReserve"` // deprecated
665 UnspendablePunishmentReserveSat uint64 `json:"unspendablePunishmentReserveSat"`
666 CounterpartyUnspendablePunishmentReserve uint64 `json:"counterpartyUnspendablePunishmentReserve"` // deprecated
667 CounterpartyUnspendablePunishmentReserveSat uint64 `json:"counterpartyUnspendablePunishmentReserveSat"`
668 Error *string `json:"error"`
669 Status string `json:"status"`
670 IsOutbound bool `json:"isOutbound"`
671 }
672
673 type MigrateNodeStorageRequest struct {
674 To string `json:"to"`
675 }
676
677 type HealthAlarmKind string
678
679 const (
680 HealthAlarmKindAlbyService HealthAlarmKind = "alby_service"
681 HealthAlarmKindNodeNotReady HealthAlarmKind = "node_not_ready"
682 HealthAlarmKindChannelsOffline HealthAlarmKind = "channels_offline"
683 HealthAlarmKindNostrRelayOffline HealthAlarmKind = "nostr_relay_offline"
684 HealthAlarmKindVssNoSubscription HealthAlarmKind = "vss_no_subscription"
685 )
686
687 type HealthAlarm struct {
688 Kind HealthAlarmKind `json:"kind"`
689 RawDetails any `json:"rawDetails,omitempty"`
690 }
691
692 func NewHealthAlarm(kind HealthAlarmKind, rawDetails any) HealthAlarm {
693 return HealthAlarm{
694 Kind: kind,
695 RawDetails: rawDetails,
696 }
697 }
698
699 type HealthResponse struct {
700 Alarms []HealthAlarm `json:"alarms,omitempty"`
701 }
702
703 type CustomNodeCommandArgDef struct {
704 Name string `json:"name"`
705 Description string `json:"description"`
706 }
707
708 type CustomNodeCommandDef struct {
709 Name string `json:"name"`
710 Description string `json:"description"`
711 Args []CustomNodeCommandArgDef `json:"args"`
712 }
713
714 type CustomNodeCommandsResponse struct {
715 Commands []CustomNodeCommandDef `json:"commands"`
716 }
717
718 type ExecuteCustomNodeCommandRequest struct {
719 Command string `json:"command"`
720 }
721
722 type GetForwardsResponse struct {
723 OutboundAmountForwardedSat uint64 `json:"outboundAmountForwardedSat"`
724 OutboundAmountForwardedMsat uint64 `json:"outboundAmountForwardedMsat"`
725 TotalFeeEarnedSat uint64 `json:"totalFeeEarnedSat"`
726 TotalFeeEarnedMsat uint64 `json:"totalFeeEarnedMsat"`
727 NumForwards uint64 `json:"numForwards"`
728 }
729
730 func ResolveToSat(satValue *uint64, msatValue *uint64, legacyValueSat *uint64, legacyValueMsat *uint64) (resolvedSatValue *uint64) {
731 if legacyValueSat != nil {
732 resolvedSatValue = legacyValueSat
733 }
734
735 if legacyValueMsat != nil {
736 tmpSat := *legacyValueMsat / 1000
737 resolvedSatValue = &tmpSat
738 }
739
740 if satValue != nil {
741 resolvedSatValue = satValue
742 }
743
744 if msatValue != nil {
745 tmpSat := *msatValue / 1000
746 resolvedSatValue = &tmpSat
747 }
748
749 return resolvedSatValue
750 }
751
752 func ResolveToMsat(satValue *uint64, msatValue *uint64, legacyValueSat *uint64, legacyValueMsat *uint64) (resolvedMsatValue *uint64) {
753 if legacyValueSat != nil {
754 tmpMsat := *legacyValueSat * 1000
755 resolvedMsatValue = &tmpMsat
756 }
757
758 if legacyValueMsat != nil {
759 resolvedMsatValue = legacyValueMsat
760 }
761
762 if satValue != nil {
763 tmpMsat := *satValue * 1000
764 resolvedMsatValue = &tmpMsat
765 }
766
767 if msatValue != nil {
768 resolvedMsatValue = msatValue
769 }
770
771 return resolvedMsatValue
772 }
773