models.go raw
1 package alby
2
3 import (
4 "context"
5
6 "github.com/getAlby/hub/events"
7 "github.com/getAlby/hub/lnclient"
8 )
9
10 type AlbyService interface {
11 GetInfo(ctx context.Context) (*AlbyInfo, error)
12 GetBitcoinRate(ctx context.Context, currency string) (*BitcoinRate, error)
13 GetCurrencies(ctx context.Context) ([]Currency, error)
14 GetChannelPeerSuggestions(ctx context.Context) ([]ChannelPeerSuggestion, error)
15 }
16
17 type AlbyOAuthService interface {
18 events.EventSubscriber
19 GetLSPChannelOffer(ctx context.Context) (*LSPChannelOffer, error)
20 GetLSPInfo(ctx context.Context, lsp, network string) (*LSPInfo, error)
21 CreateLSPOrder(ctx context.Context, lsp, network string, lspChannelRequest *LSPChannelRequest) (*LSPChannelResponse, error)
22 GetAuthUrl() string
23 GetUserIdentifier() (string, error)
24 GetLightningAddress() (string, error)
25 IsConnected(ctx context.Context) bool
26 LinkAccount(ctx context.Context, lnClient lnclient.LNClient, budgetSat uint64, renewal string) error
27 CallbackHandler(ctx context.Context, code string) error
28 GetMe(ctx context.Context) (*AlbyMe, error)
29 UnlinkAccount(ctx context.Context) error
30 RequestAutoChannel(ctx context.Context, lnClient lnclient.LNClient, isPublic bool) (*AutoChannelResponse, error)
31 GetVssAuthToken(ctx context.Context, nodeIdentifier string) (string, error)
32 RemoveOAuthAccessToken() error
33 CreateLightningAddress(ctx context.Context, address string, appId uint) (*CreateLightningAddressResponse, error)
34 DeleteLightningAddress(ctx context.Context, address string) error
35 GetStories(ctx context.Context) ([]Story, error)
36 }
37
38 type CreateLightningAddressResponse struct {
39 Address string `json:"address"`
40 FullAddress string `json:"full_address"`
41 }
42
43 type AlbyLinkAccountRequest struct {
44 Budget uint64 `json:"budget"`
45 Renewal string `json:"renewal"`
46 }
47
48 type AutoChannelRequest struct {
49 IsPublic bool `json:"isPublic"`
50 }
51
52 type AutoChannelResponse struct {
53 Invoice string `json:"invoice"`
54 ChannelSize uint64 `json:"channelSize"` // deprecated
55 ChannelSizeSat uint64 `json:"channelSizeSat"`
56 Fee uint64 `json:"fee"` // deprecated
57 FeeSat uint64 `json:"feeSat"`
58 }
59
60 type AlbyInfoHub struct {
61 LatestVersion string `json:"latestVersion"`
62 LatestReleaseNotes string `json:"latestReleaseNotes"`
63 }
64
65 type AlbyInfoIncident struct {
66 Name string `json:"name"`
67 Started string `json:"started"`
68 Status string `json:"status"`
69 Impact string `json:"impact"`
70 Url string `json:"url"`
71 }
72
73 type AlbyInfo struct {
74 Hub AlbyInfoHub `json:"hub"`
75 Status string `json:"status"`
76 Healthy bool `json:"healthy"`
77 AccountAvailable bool `json:"accountAvailable"` // false if country is blocked (can still use Alby Hub without an Alby Account)
78 Incidents []AlbyInfoIncident `json:"incidents"`
79 }
80
81 type AlbyMeHub struct {
82 Name string `json:"name"`
83 Config map[string]interface{} `json:"config"`
84 }
85
86 type AlbyMeSubscription struct {
87 PlanCode string `json:"plan_code"`
88 }
89
90 type AlbyMe struct {
91 Identifier string `json:"identifier"`
92 NPub string `json:"nostr_pubkey"`
93 LightningAddress string `json:"lightning_address"`
94 Email string `json:"email"`
95 Name string `json:"name"`
96 Avatar string `json:"avatar"`
97 KeysendPubkey string `json:"keysend_pubkey"`
98 SharedNode bool `json:"shared_node"`
99 Hub AlbyMeHub `json:"hub"`
100 Subscription AlbyMeSubscription `json:"subscription"`
101 }
102
103 type ChannelPeerSuggestion struct {
104 Network string `json:"network"`
105 PaymentMethod string `json:"paymentMethod"`
106 Pubkey string `json:"pubkey"`
107 Host string `json:"host"`
108 MinimumChannelSize uint64 `json:"minimumChannelSize"` // deprecated
109 MinimumChannelSizeSat uint64 `json:"minimumChannelSizeSat"`
110 MaximumChannelSize uint64 `json:"maximumChannelSize"` // deprecated
111 MaximumChannelSizeSat uint64 `json:"maximumChannelSizeSat"`
112 MaximumChannelExpiryBlocks *uint32 `json:"maximumChannelExpiryBlocks"`
113 Name string `json:"name"`
114 Image string `json:"image"`
115 Identifier string `json:"identifier"`
116 ContactUrl string `json:"contactUrl"`
117 Type string `json:"type"`
118 Terms string `json:"terms"`
119 Description string `json:"description"`
120 Note string `json:"note"`
121 PublicChannelsAllowed bool `json:"publicChannelsAllowed"`
122 NodeAddress string `json:"nodeAddress"`
123 FeeTotalSat1m *uint32 `json:"feeTotalSat1m"`
124 FeeTotalSat2m *uint32 `json:"feeTotalSat2m"`
125 FeeTotalSat3m *uint32 `json:"feeTotalSat3m"`
126 }
127
128 type LSPChannelOffer struct {
129 LspName string `json:"lspName"`
130 LspContactUrl string `json:"lspContactUrl"`
131 LspBalanceSat uint64 `json:"lspBalanceSat"`
132 FeeTotalSat uint64 `json:"feeTotalSat"`
133 FeeTotalUsd uint64 `json:"feeTotalUsd"` // in cents
134 CurrentPaymentMethod string `json:"currentPaymentMethod"`
135 Terms string `json:"terms"`
136 LspDescription string `json:"lspDescription"`
137 }
138
139 type Currency struct {
140 IsoCode string `json:"iso_code"`
141 Symbol string `json:"symbol"`
142 Name string `json:"name"`
143 Priority int `json:"priority"`
144 }
145
146 type BitcoinRate struct {
147 Code string `json:"code"`
148 Symbol string `json:"symbol"`
149 Rate string `json:"rate"`
150 RateFloat float64 `json:"rate_float"`
151 RateCents int64 `json:"rate_cents"`
152 }
153
154 type ErrorResponse struct {
155 Message string `json:"message"`
156 }
157
158 type StoryCta struct {
159 Label string `json:"label"`
160 URL string `json:"url"`
161 OpenInNewTab bool `json:"openInNewTab"`
162 }
163
164 type Story struct {
165 ID int `json:"id"`
166 Title string `json:"title"`
167 Avatar string `json:"avatar"`
168 VideoID string `json:"videoId,omitempty"`
169 Cta *StoryCta `json:"cta,omitempty"`
170 }
171
172 type LSPChannelPaymentBolt11 struct {
173 Invoice string `json:"invoice"`
174 FeeTotalSat string `json:"fee_total_sat"`
175 }
176
177 type LSPChannelPayment struct {
178 Bolt11 LSPChannelPaymentBolt11 `json:"bolt11"`
179 // TODO: add onchain
180 }
181
182 type LSPChannelResponse struct {
183 Payment *LSPChannelPayment `json:"payment"`
184 }
185
186 type LSPChannelRequest struct {
187 PublicKey string `json:"public_key"`
188 LSPBalanceSat string `json:"lsp_balance_sat"`
189 ClientBalanceSat string `json:"client_balance_sat"`
190 RequiredChannelConfirmations uint64 `json:"required_channel_confirmations"`
191 FundingConfirmsWithinBlocks uint64 `json:"funding_confirms_within_blocks"`
192 ChannelExpiryBlocks uint64 `json:"channel_expiry_blocks"`
193 Token string `json:"token"`
194 RefundOnchainAddress string `json:"refund_onchain_address"`
195 AnnounceChannel bool `json:"announce_channel"`
196 }
197
198 type LSPInfo struct {
199 Pubkey string
200 Address string
201 Port uint16
202 MaxChannelExpiryBlocks uint64
203 MinRequiredChannelConfirmations uint64
204 MinFundingConfirmsWithinBlocks uint64
205 }
206