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 Currency string `json:"currency"`
329 BitcoinDisplayFormat string `json:"bitcoinDisplayFormat"`
330 Relays []InfoResponseRelay `json:"relays"`
331 NodeAlias string `json:"nodeAlias"`
332 MempoolUrl string `json:"mempoolUrl"`
333 ChainDataSourceType string `json:"chainDataSourceType,omitempty"`
334 ChainDataSourceAddress string `json:"chainDataSourceAddress,omitempty"`
335 JitChannelsLiquiditySource string `json:"jitChannelsLiquiditySource,omitempty"`
336 JitChannelsMinPaymentSizeMsat *uint64 `json:"jitChannelsMinPaymentSizeMsat,omitempty"`
337 JitChannelsMaxPaymentSizeMsat *uint64 `json:"jitChannelsMaxPaymentSizeMsat,omitempty"`
338 JitChannelsEnabled bool `json:"jitChannelsEnabled"`
339 HideUpdateBanner bool `json:"hideUpdateBanner"`
340 SupportsBolt12 bool `json:"supportsBolt12"`
341 NodeMigrationFileCreated bool `json:"nodeMigrationFileCreated"`
342 }
343
344 type UpdateSettingsRequest struct {
345 Currency string `json:"currency"`
346 BitcoinDisplayFormat string `json:"bitcoinDisplayFormat"`
347 JitChannelsEnabled *bool `json:"jitChannelsEnabled"`
348 }
349
350 type SetNodeAliasRequest struct {
351 NodeAlias string `json:"nodeAlias"`
352 }
353
354 type MnemonicRequest struct {
355 UnlockPassword string `json:"unlockPassword"`
356 }
357
358 type MnemonicResponse struct {
359 Mnemonic string `json:"mnemonic"`
360 }
361
362 type ChangeUnlockPasswordRequest struct {
363 CurrentUnlockPassword string `json:"currentUnlockPassword"`
364 NewUnlockPassword string `json:"newUnlockPassword"`
365 }
366 type AutoUnlockRequest struct {
367 UnlockPassword string `json:"unlockPassword"`
368 }
369
370 type ConnectPeerRequest struct {
371 Pubkey string `json:"pubkey"`
372 Address string `json:"address"`
373 Port uint16 `json:"port"`
374 }
375
376 type OpenChannelRequest struct {
377 Pubkey string `json:"pubkey"`
378 AmountSats int64 `json:"amountSats"`
379 Public bool `json:"public"`
380 }
381
382 type OpenChannelResponse struct {
383 FundingTxId string `json:"fundingTxId"`
384 }
385
386 type CloseChannelResponse struct {
387 }
388
389 type UpdateChannelRequest struct {
390 ChannelId string `json:"channelId"`
391 NodeId string `json:"nodeId"`
392 ForwardingFeeBaseMsat uint32 `json:"forwardingFeeBaseMsat"`
393 ForwardingFeeProportionalMillionths uint32 `json:"forwardingFeeProportionalMillionths"`
394 MaxDustHtlcExposureFromFeeRateMultiplier uint64 `json:"maxDustHtlcExposureFromFeeRateMultiplier"`
395 }
396
397 type NodeConnectionInfo struct {
398 Pubkey string `json:"pubkey"`
399 Address string `json:"address"`
400 Port int `json:"port"`
401 }
402
403 type NodeStatus struct {
404 IsReady bool `json:"isReady"`
405 InternalNodeStatus interface{} `json:"internalNodeStatus"`
406 }
407
408 type PeerDetails struct {
409 NodeId string `json:"nodeId"`
410 Address string `json:"address"`
411 IsPersisted bool `json:"isPersisted"`
412 IsConnected bool `json:"isConnected"`
413 }
414
415 type OnchainTransaction struct {
416 AmountSat uint64 `json:"amountSat"`
417 CreatedAt uint64 `json:"createdAt"`
418 State string `json:"state"`
419 Type string `json:"type"`
420 NumConfirmations uint32 `json:"numConfirmations"`
421 TxId string `json:"txId"`
422 }
423
424 type PendingBalanceDetails struct {
425 ChannelId string `json:"channelId"`
426 NodeId string `json:"nodeId"`
427 Amount uint64 `json:"amount"` // deprecated
428 AmountSat uint64 `json:"amountSat"`
429 FundingTxId string `json:"fundingTxId"`
430 FundingTxVout uint32 `json:"fundingTxVout"`
431 }
432
433 type RebalanceChannelRequest struct {
434 ReceiveThroughNodePubkey string `json:"receiveThroughNodePubkey"`
435 AmountSat *uint64 `json:"amountSat"`
436 AmountMsat *uint64 `json:"amountMsat"`
437 }
438 type RebalanceChannelResponse struct {
439 TotalFeeSat uint64 `json:"totalFeeSat"`
440 TotalFeeMsat uint64 `json:"totalFeeMsat"`
441 }
442
443 type RedeemOnchainFundsRequest struct {
444 ToAddress string `json:"toAddress"`
445 Amount *uint64 `json:"amount"` // deprecated
446 AmountSat *uint64 `json:"amountSat"`
447 FeeRate *uint64 `json:"feeRate"`
448 SendAll bool `json:"sendAll"`
449 }
450
451 type RedeemOnchainFundsResponse struct {
452 TxId string `json:"txId"`
453 }
454
455 type OnchainBalanceResponse struct {
456 Spendable int64 `json:"spendable"` // deprecated
457 SpendableSat int64 `json:"spendableSat"`
458 Total int64 `json:"total"` // deprecated
459 TotalSat int64 `json:"totalSat"`
460 Reserved int64 `json:"reserved"` // deprecated
461 ReservedSat int64 `json:"reservedSat"`
462 PendingBalancesFromChannelClosures uint64 `json:"pendingBalancesFromChannelClosures"` // deprecated
463 PendingBalancesFromChannelClosuresSat uint64 `json:"pendingBalancesFromChannelClosuresSat"`
464 PendingBalancesDetails []PendingBalanceDetails `json:"pendingBalancesDetails"`
465 PendingSweepBalancesDetails []PendingBalanceDetails `json:"pendingSweepBalancesDetails"`
466 InternalBalances interface{} `json:"internalBalances"`
467 }
468
469 type LightningBalanceResponse struct {
470 TotalSpendable int64 `json:"totalSpendable"` // deprecated
471 TotalSpendableSat int64 `json:"totalSpendableSat"`
472 TotalSpendableMsat int64 `json:"totalSpendableMsat"`
473 TotalReceivable int64 `json:"totalReceivable"` // deprecated
474 TotalReceivableSat int64 `json:"totalReceivableSat"`
475 TotalReceivableMsat int64 `json:"totalReceivableMsat"`
476 NextMaxSpendable int64 `json:"nextMaxSpendable"` // deprecated
477 NextMaxSpendableSat int64 `json:"nextMaxSpendableSat"`
478 NextMaxSpendableMsat int64 `json:"nextMaxSpendableMsat"`
479 NextMaxReceivable int64 `json:"nextMaxReceivable"` // deprecated
480 NextMaxReceivableSat int64 `json:"nextMaxReceivableSat"`
481 NextMaxReceivableMsat int64 `json:"nextMaxReceivableMsat"`
482 NextMaxSpendableMPP int64 `json:"nextMaxSpendableMPP"` // deprecated
483 NextMaxSpendableMPPSat int64 `json:"nextMaxSpendableMPPSat"`
484 NextMaxSpendableMPPMsat int64 `json:"nextMaxSpendableMPPMsat"`
485 NextMaxReceivableMPP int64 `json:"nextMaxReceivableMPP"` // deprecated
486 NextMaxReceivableMPPSat int64 `json:"nextMaxReceivableMPPSat"`
487 NextMaxReceivableMPPMsat int64 `json:"nextMaxReceivableMPPMsat"`
488 }
489
490 type BalancesResponse struct {
491 Onchain OnchainBalanceResponse `json:"onchain"`
492 Lightning LightningBalanceResponse `json:"lightning"`
493 }
494
495 type SendPaymentResponse = Transaction
496 type MakeInvoiceResponse = Transaction
497 type LookupInvoiceResponse = Transaction
498
499 type SetTransactionUserLabelsRequest struct {
500 Labels map[string]string `json:"labels"`
501 }
502
503 type ListTransactionsFilters struct {
504 Type *string
505 MinAmountMsat *uint64
506 HideFailed bool
507 SearchTerm string
508 }
509
510 type ListTransactionsResponse struct {
511 TotalCount uint64 `json:"totalCount"`
512 Transactions []Transaction `json:"transactions"`
513 }
514
515 // TODO: camelCase
516 type Transaction struct {
517 ID uint `json:"id"`
518 Type string `json:"type"`
519 State string `json:"state"`
520 Invoice string `json:"invoice"`
521 Description string `json:"description"`
522 DescriptionHash string `json:"descriptionHash"`
523 Preimage *string `json:"preimage"`
524 PaymentHash string `json:"paymentHash"`
525 Amount uint64 `json:"amount"` // deprecated
526 AmountSat uint64 `json:"amountSat"`
527 AmountMsat uint64 `json:"amountMsat"`
528 FeesPaid uint64 `json:"feesPaid"` // deprecated
529 FeesPaidSat uint64 `json:"feesPaidSat"`
530 FeesPaidMsat uint64 `json:"feesPaidMsat"`
531 UpdatedAt string `json:"updatedAt"`
532 CreatedAt string `json:"createdAt"`
533 SettledAt *string `json:"settledAt"`
534 AppId *uint `json:"appId"`
535 Metadata Metadata `json:"metadata,omitempty"`
536 Boostagram *Boostagram `json:"boostagram,omitempty"`
537 FailureReason string `json:"failureReason"`
538 }
539
540 type Metadata = map[string]interface{}
541
542 type Boostagram struct {
543 AppName string `json:"appName"`
544 Name string `json:"name"`
545 Podcast string `json:"podcast"`
546 URL string `json:"url"`
547 Episode string `json:"episode,omitempty"`
548 FeedId string `json:"feedId,omitempty"`
549 ItemId string `json:"itemId,omitempty"`
550 Timestamp int64 `json:"ts,omitempty"`
551 Message string `json:"message,omitempty"`
552 SenderId string `json:"senderId"`
553 SenderName string `json:"senderName"`
554 Time string `json:"time"`
555 Action string `json:"action"`
556 ValueSatTotal int64 `json:"valueSatTotal"`
557 ValueMsatTotal int64 `json:"valueMsatTotal"`
558 }
559
560 const (
561 LogTypeNode = "node"
562 LogTypeApp = "app"
563 )
564
565 type GetLogOutputRequest struct {
566 MaxLen int `query:"maxLen"`
567 }
568
569 type GetLogOutputResponse struct {
570 Log string `json:"logs"`
571 }
572
573 type SignMessageRequest struct {
574 Message string `json:"message"`
575 }
576
577 type SignMessageResponse struct {
578 Message string `json:"message"`
579 Signature string `json:"signature"`
580 }
581
582 type PayInvoiceRequest struct {
583 Amount *uint64 `json:"amount"` // deprecated
584 AmountSat *uint64 `json:"amountSat"`
585 AmountMsat *uint64 `json:"amountMsat"`
586 Metadata Metadata `json:"metadata"`
587 FromAppID *uint `json:"fromAppId"`
588 }
589
590 type MakeOfferRequest struct {
591 Description string `json:"description"`
592 }
593
594 type MakeInvoiceRequest struct {
595 Amount *uint64 `json:"amount"` // deprecated
596 AmountSat *uint64 `json:"amountSat"`
597 AmountMsat *uint64 `json:"amountMsat"`
598 Description string `json:"description"`
599 ToAppID *uint `json:"toAppId"`
600 }
601
602 type ResetRouterRequest struct {
603 Key string `json:"key"`
604 }
605
606 type BasicBackupRequest struct {
607 UnlockPassword string `json:"unlockPassword"`
608 }
609
610 type BasicRestoreWailsRequest struct {
611 UnlockPassword string `json:"unlockPassword"`
612 }
613
614 type NetworkGraphResponse = interface{}
615
616 type LSPOrderRequest struct {
617 Amount *uint64 `json:"amount"` // deprecated
618 AmountSat *uint64 `json:"amountSat"`
619 LSPType string `json:"lspType"`
620 LSPIdentifier string `json:"lspIdentifier"`
621 Public bool `json:"public"`
622 }
623
624 type LSPOrderResponse struct {
625 Invoice string `json:"invoice"`
626 Fee uint64 `json:"fee"` // deprecated
627 FeeSat uint64 `json:"feeSat"`
628 InvoiceAmount uint64 `json:"invoiceAmount"` // deprecated
629 InvoiceAmountSat uint64 `json:"invoiceAmountSat"`
630 IncomingLiquidity uint64 `json:"incomingLiquidity"` // deprecated
631 IncomingLiquiditySat uint64 `json:"incomingLiquiditySat"`
632 OutgoingLiquidity uint64 `json:"outgoingLiquidity"` // deprecated
633 OutgoingLiquiditySat uint64 `json:"outgoingLiquiditySat"`
634 }
635
636 type WalletCapabilitiesResponse struct {
637 Scopes []string `json:"scopes"`
638 Methods []string `json:"methods"`
639 NotificationTypes []string `json:"notificationTypes"`
640 }
641
642 type Channel struct {
643 LocalBalance int64 `json:"localBalance"` // deprecated
644 LocalBalanceSat int64 `json:"localBalanceSat"`
645 LocalBalanceMsat int64 `json:"localBalanceMsat"`
646 LocalSpendableBalance int64 `json:"localSpendableBalance"` // deprecated
647 LocalSpendableBalanceSat int64 `json:"localSpendableBalanceSat"`
648 LocalSpendableBalanceMsat int64 `json:"localSpendableBalanceMsat"`
649 RemoteBalance int64 `json:"remoteBalance"` // deprecated
650 RemoteBalanceSat int64 `json:"remoteBalanceSat"`
651 RemoteBalanceMsat int64 `json:"remoteBalanceMsat"`
652 Id string `json:"id"`
653 RemotePubkey string `json:"remotePubkey"`
654 FundingTxId string `json:"fundingTxId"`
655 FundingTxVout uint32 `json:"fundingTxVout"`
656 Active bool `json:"active"`
657 Public bool `json:"public"`
658 InternalChannel interface{} `json:"internalChannel"`
659 Confirmations *uint32 `json:"confirmations"`
660 ConfirmationsRequired *uint32 `json:"confirmationsRequired"`
661 ForwardingFeeBaseMsat uint32 `json:"forwardingFeeBaseMsat"` // expressed only in msat as per Lightning spec
662 ForwardingFeeProportionalMillionths uint32 `json:"forwardingFeeProportionalMillionths"`
663 UnspendablePunishmentReserve uint64 `json:"unspendablePunishmentReserve"` // deprecated
664 UnspendablePunishmentReserveSat uint64 `json:"unspendablePunishmentReserveSat"`
665 CounterpartyUnspendablePunishmentReserve uint64 `json:"counterpartyUnspendablePunishmentReserve"` // deprecated
666 CounterpartyUnspendablePunishmentReserveSat uint64 `json:"counterpartyUnspendablePunishmentReserveSat"`
667 Error *string `json:"error"`
668 Status string `json:"status"`
669 IsOutbound bool `json:"isOutbound"`
670 }
671
672 type MigrateNodeStorageRequest struct {
673 To string `json:"to"`
674 }
675
676 type HealthAlarmKind string
677
678 const (
679 HealthAlarmKindAlbyService HealthAlarmKind = "alby_service"
680 HealthAlarmKindNodeNotReady HealthAlarmKind = "node_not_ready"
681 HealthAlarmKindChannelsOffline HealthAlarmKind = "channels_offline"
682 HealthAlarmKindNostrRelayOffline HealthAlarmKind = "nostr_relay_offline"
683 HealthAlarmKindVssNoSubscription HealthAlarmKind = "vss_no_subscription"
684 )
685
686 type HealthAlarm struct {
687 Kind HealthAlarmKind `json:"kind"`
688 RawDetails any `json:"rawDetails,omitempty"`
689 }
690
691 func NewHealthAlarm(kind HealthAlarmKind, rawDetails any) HealthAlarm {
692 return HealthAlarm{
693 Kind: kind,
694 RawDetails: rawDetails,
695 }
696 }
697
698 type HealthResponse struct {
699 Alarms []HealthAlarm `json:"alarms,omitempty"`
700 }
701
702 type CustomNodeCommandArgDef struct {
703 Name string `json:"name"`
704 Description string `json:"description"`
705 }
706
707 type CustomNodeCommandDef struct {
708 Name string `json:"name"`
709 Description string `json:"description"`
710 Args []CustomNodeCommandArgDef `json:"args"`
711 }
712
713 type CustomNodeCommandsResponse struct {
714 Commands []CustomNodeCommandDef `json:"commands"`
715 }
716
717 type ExecuteCustomNodeCommandRequest struct {
718 Command string `json:"command"`
719 }
720
721 type GetForwardsResponse struct {
722 OutboundAmountForwardedSat uint64 `json:"outboundAmountForwardedSat"`
723 OutboundAmountForwardedMsat uint64 `json:"outboundAmountForwardedMsat"`
724 TotalFeeEarnedSat uint64 `json:"totalFeeEarnedSat"`
725 TotalFeeEarnedMsat uint64 `json:"totalFeeEarnedMsat"`
726 NumForwards uint64 `json:"numForwards"`
727 }
728
729 func ResolveToSat(satValue *uint64, msatValue *uint64, legacyValueSat *uint64, legacyValueMsat *uint64) (resolvedSatValue *uint64) {
730 if legacyValueSat != nil {
731 resolvedSatValue = legacyValueSat
732 }
733
734 if legacyValueMsat != nil {
735 tmpSat := *legacyValueMsat / 1000
736 resolvedSatValue = &tmpSat
737 }
738
739 if satValue != nil {
740 resolvedSatValue = satValue
741 }
742
743 if msatValue != nil {
744 tmpSat := *msatValue / 1000
745 resolvedSatValue = &tmpSat
746 }
747
748 return resolvedSatValue
749 }
750
751 func ResolveToMsat(satValue *uint64, msatValue *uint64, legacyValueSat *uint64, legacyValueMsat *uint64) (resolvedMsatValue *uint64) {
752 if legacyValueSat != nil {
753 tmpMsat := *legacyValueSat * 1000
754 resolvedMsatValue = &tmpMsat
755 }
756
757 if legacyValueMsat != nil {
758 resolvedMsatValue = legacyValueMsat
759 }
760
761 if satValue != nil {
762 tmpMsat := *satValue * 1000
763 resolvedMsatValue = &tmpMsat
764 }
765
766 if msatValue != nil {
767 resolvedMsatValue = msatValue
768 }
769
770 return resolvedMsatValue
771 }
772