mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
* feat: just in time channels with lsps2 * fix: clarify JIT receive channel fee * fix: fees * fix: fees 2 * fix: don't show low inbound when LSPS2 is active * fix: remove the receive limit below the input if LSPS2 is being used * fix: simplify * fix: bring back fee % for outgoing * fix: remove unneeded changes * fix: typo * fix: unneeded * fix: don't show open first channel is LSPS2 * feat: clearer JIT channel fee copy on receive screen * fix: add LSPS2 var info * fix: don't duplicate JIT fee hint on create invoice form * fix: make paymentDone a standard boolean * fix: update to golang:1.26 in Dockerfile * feat: read LSPS2 sources from channel suggestions, set minimum receive amount, update guide link * docs: update LDK_LSPS2_ADDRESSES to be used as an override * fix: only show minimum jit receive amount on validation error * fix: add more detail to receive error when receiving low amounts with jit * fix: do not use JIT when user has public channels * feat: add option to disable JIT * fix: isTrusted check, add jit property to event * fix: do not require node restart for toggling JIT * chore: simplify JIT alert * chore: add guide link on node settings JIT description * feat: fetch the lsp2info to have access to params like minimum/maximum payment size * refactor: share single learn-more link across JIT fee hint branches * fix: remove variable amount invoice support * fix: use lsps2info for min payment size and remove channelPeerSuggestion usage of minimumChannelSize * fix: only do amount validation according to lsps2Info values if jit is enabled in settings * feat: add jit first payment fee alert on receive via lightning address * fix: remove unnecessary conditional * fix: ensure at least one sat is left over when opening JIT channel * chore: remove hardcoded suggestions * chore: rename JIT enabled config variable * fix: ui checks when JIT is disabled * fix: amount input validation message * fix: formatting --------- Co-authored-by: anon <anon@anon.com> Co-authored-by: saunter <68239231+stackingsaunter@users.noreply.github.com> Co-authored-by: fmar <fmar@fmar> Co-authored-by: René Aaron <rene@twentyuno.net> Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
205 lines
7.2 KiB
Go
205 lines
7.2 KiB
Go
package alby
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/getAlby/hub/events"
|
|
"github.com/getAlby/hub/lnclient"
|
|
)
|
|
|
|
type AlbyService interface {
|
|
GetInfo(ctx context.Context) (*AlbyInfo, error)
|
|
GetBitcoinRate(ctx context.Context, currency string) (*BitcoinRate, error)
|
|
GetCurrencies(ctx context.Context) ([]Currency, error)
|
|
GetChannelPeerSuggestions(ctx context.Context) ([]ChannelPeerSuggestion, error)
|
|
}
|
|
|
|
type AlbyOAuthService interface {
|
|
events.EventSubscriber
|
|
GetLSPChannelOffer(ctx context.Context) (*LSPChannelOffer, error)
|
|
GetLSPInfo(ctx context.Context, lsp, network string) (*LSPInfo, error)
|
|
CreateLSPOrder(ctx context.Context, lsp, network string, lspChannelRequest *LSPChannelRequest) (*LSPChannelResponse, error)
|
|
GetAuthUrl() string
|
|
GetUserIdentifier() (string, error)
|
|
GetLightningAddress() (string, error)
|
|
IsConnected(ctx context.Context) bool
|
|
LinkAccount(ctx context.Context, lnClient lnclient.LNClient, budgetSat uint64, renewal string) error
|
|
CallbackHandler(ctx context.Context, code string) error
|
|
GetMe(ctx context.Context) (*AlbyMe, error)
|
|
UnlinkAccount(ctx context.Context) error
|
|
RequestAutoChannel(ctx context.Context, lnClient lnclient.LNClient, isPublic bool) (*AutoChannelResponse, error)
|
|
GetVssAuthToken(ctx context.Context, nodeIdentifier string) (string, error)
|
|
RemoveOAuthAccessToken() error
|
|
CreateLightningAddress(ctx context.Context, address string, appId uint) (*CreateLightningAddressResponse, error)
|
|
DeleteLightningAddress(ctx context.Context, address string) error
|
|
GetStories(ctx context.Context) ([]Story, error)
|
|
}
|
|
|
|
type CreateLightningAddressResponse struct {
|
|
Address string `json:"address"`
|
|
FullAddress string `json:"full_address"`
|
|
}
|
|
|
|
type AlbyLinkAccountRequest struct {
|
|
Budget uint64 `json:"budget"`
|
|
Renewal string `json:"renewal"`
|
|
}
|
|
|
|
type AutoChannelRequest struct {
|
|
IsPublic bool `json:"isPublic"`
|
|
}
|
|
|
|
type AutoChannelResponse struct {
|
|
Invoice string `json:"invoice"`
|
|
ChannelSize uint64 `json:"channelSize"` // deprecated
|
|
ChannelSizeSat uint64 `json:"channelSizeSat"`
|
|
Fee uint64 `json:"fee"` // deprecated
|
|
FeeSat uint64 `json:"feeSat"`
|
|
}
|
|
|
|
type AlbyInfoHub struct {
|
|
LatestVersion string `json:"latestVersion"`
|
|
LatestReleaseNotes string `json:"latestReleaseNotes"`
|
|
}
|
|
|
|
type AlbyInfoIncident struct {
|
|
Name string `json:"name"`
|
|
Started string `json:"started"`
|
|
Status string `json:"status"`
|
|
Impact string `json:"impact"`
|
|
Url string `json:"url"`
|
|
}
|
|
|
|
type AlbyInfo struct {
|
|
Hub AlbyInfoHub `json:"hub"`
|
|
Status string `json:"status"`
|
|
Healthy bool `json:"healthy"`
|
|
AccountAvailable bool `json:"accountAvailable"` // false if country is blocked (can still use Alby Hub without an Alby Account)
|
|
Incidents []AlbyInfoIncident `json:"incidents"`
|
|
}
|
|
|
|
type AlbyMeHub struct {
|
|
Name string `json:"name"`
|
|
Config map[string]interface{} `json:"config"`
|
|
}
|
|
|
|
type AlbyMeSubscription struct {
|
|
PlanCode string `json:"plan_code"`
|
|
}
|
|
|
|
type AlbyMe struct {
|
|
Identifier string `json:"identifier"`
|
|
NPub string `json:"nostr_pubkey"`
|
|
LightningAddress string `json:"lightning_address"`
|
|
Email string `json:"email"`
|
|
Name string `json:"name"`
|
|
Avatar string `json:"avatar"`
|
|
KeysendPubkey string `json:"keysend_pubkey"`
|
|
SharedNode bool `json:"shared_node"`
|
|
Hub AlbyMeHub `json:"hub"`
|
|
Subscription AlbyMeSubscription `json:"subscription"`
|
|
}
|
|
|
|
type ChannelPeerSuggestion struct {
|
|
Network string `json:"network"`
|
|
PaymentMethod string `json:"paymentMethod"`
|
|
Pubkey string `json:"pubkey"`
|
|
Host string `json:"host"`
|
|
MinimumChannelSize uint64 `json:"minimumChannelSize"` // deprecated
|
|
MinimumChannelSizeSat uint64 `json:"minimumChannelSizeSat"`
|
|
MaximumChannelSize uint64 `json:"maximumChannelSize"` // deprecated
|
|
MaximumChannelSizeSat uint64 `json:"maximumChannelSizeSat"`
|
|
MaximumChannelExpiryBlocks *uint32 `json:"maximumChannelExpiryBlocks"`
|
|
Name string `json:"name"`
|
|
Image string `json:"image"`
|
|
Identifier string `json:"identifier"`
|
|
ContactUrl string `json:"contactUrl"`
|
|
Type string `json:"type"`
|
|
Terms string `json:"terms"`
|
|
Description string `json:"description"`
|
|
Note string `json:"note"`
|
|
PublicChannelsAllowed bool `json:"publicChannelsAllowed"`
|
|
NodeAddress string `json:"nodeAddress"`
|
|
FeeTotalSat1m *uint32 `json:"feeTotalSat1m"`
|
|
FeeTotalSat2m *uint32 `json:"feeTotalSat2m"`
|
|
FeeTotalSat3m *uint32 `json:"feeTotalSat3m"`
|
|
}
|
|
|
|
type LSPChannelOffer struct {
|
|
LspName string `json:"lspName"`
|
|
LspContactUrl string `json:"lspContactUrl"`
|
|
LspBalanceSat uint64 `json:"lspBalanceSat"`
|
|
FeeTotalSat uint64 `json:"feeTotalSat"`
|
|
FeeTotalUsd uint64 `json:"feeTotalUsd"` // in cents
|
|
CurrentPaymentMethod string `json:"currentPaymentMethod"`
|
|
Terms string `json:"terms"`
|
|
LspDescription string `json:"lspDescription"`
|
|
}
|
|
|
|
type Currency struct {
|
|
IsoCode string `json:"iso_code"`
|
|
Symbol string `json:"symbol"`
|
|
Name string `json:"name"`
|
|
Priority int `json:"priority"`
|
|
}
|
|
|
|
type BitcoinRate struct {
|
|
Code string `json:"code"`
|
|
Symbol string `json:"symbol"`
|
|
Rate string `json:"rate"`
|
|
RateFloat float64 `json:"rate_float"`
|
|
RateCents int64 `json:"rate_cents"`
|
|
}
|
|
|
|
type ErrorResponse struct {
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type StoryCta struct {
|
|
Label string `json:"label"`
|
|
URL string `json:"url"`
|
|
OpenInNewTab bool `json:"openInNewTab"`
|
|
}
|
|
|
|
type Story struct {
|
|
ID int `json:"id"`
|
|
Title string `json:"title"`
|
|
Avatar string `json:"avatar"`
|
|
VideoID string `json:"videoId,omitempty"`
|
|
Cta *StoryCta `json:"cta,omitempty"`
|
|
}
|
|
|
|
type LSPChannelPaymentBolt11 struct {
|
|
Invoice string `json:"invoice"`
|
|
FeeTotalSat string `json:"fee_total_sat"`
|
|
}
|
|
|
|
type LSPChannelPayment struct {
|
|
Bolt11 LSPChannelPaymentBolt11 `json:"bolt11"`
|
|
// TODO: add onchain
|
|
}
|
|
|
|
type LSPChannelResponse struct {
|
|
Payment *LSPChannelPayment `json:"payment"`
|
|
}
|
|
|
|
type LSPChannelRequest struct {
|
|
PublicKey string `json:"public_key"`
|
|
LSPBalanceSat string `json:"lsp_balance_sat"`
|
|
ClientBalanceSat string `json:"client_balance_sat"`
|
|
RequiredChannelConfirmations uint64 `json:"required_channel_confirmations"`
|
|
FundingConfirmsWithinBlocks uint64 `json:"funding_confirms_within_blocks"`
|
|
ChannelExpiryBlocks uint64 `json:"channel_expiry_blocks"`
|
|
Token string `json:"token"`
|
|
RefundOnchainAddress string `json:"refund_onchain_address"`
|
|
AnnounceChannel bool `json:"announce_channel"`
|
|
}
|
|
|
|
type LSPInfo struct {
|
|
Pubkey string
|
|
Address string
|
|
Port uint16
|
|
MaxChannelExpiryBlocks uint64
|
|
MinRequiredChannelConfirmations uint64
|
|
MinFundingConfirmsWithinBlocks uint64
|
|
}
|