mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
feat: bip177 (#1864)
* feat: bip177 option in settings * fix: tests * fix: use constants * fix: bitcoin display format type * fix: patch request * fix: cleanup types * fix: migrate to formatted bitcoin amount component * fix: prevent banner from being shown again when updating settings * fix: move stuff into api * fix: component usage * fix: onchain transaction table * fix: amounts * fix: format numbers * fix: settings sections * fix: copy * chore: use existing constants * chore: minor ui fixes and copy improvements for amount displays --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
This commit is contained in:
parent
ef10799d4b
commit
6294d519c2
58 changed files with 722 additions and 376 deletions
33
api/api.go
33
api/api.go
|
|
@ -1200,6 +1200,7 @@ func (api *api) GetInfo(ctx context.Context) (*InfoResponse, error) {
|
|||
autoUnlockPassword, _ := api.cfg.Get("AutoUnlockPassword", "")
|
||||
info.SetupCompleted = api.cfg.SetupCompleted()
|
||||
info.Currency = api.cfg.GetCurrency()
|
||||
info.BitcoinDisplayFormat = api.cfg.GetBitcoinDisplayFormat()
|
||||
info.StartupState = api.svc.GetStartupState()
|
||||
if api.startupError != nil {
|
||||
info.StartupError = api.startupError.Error()
|
||||
|
|
@ -1264,6 +1265,38 @@ func (api *api) SetCurrency(currency string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (api *api) SetBitcoinDisplayFormat(format string) error {
|
||||
if format != constants.BITCOIN_DISPLAY_FORMAT_SATS && format != constants.BITCOIN_DISPLAY_FORMAT_BIP177 {
|
||||
return fmt.Errorf("bitcoin display format must be '%s' or '%s'", constants.BITCOIN_DISPLAY_FORMAT_SATS, constants.BITCOIN_DISPLAY_FORMAT_BIP177)
|
||||
}
|
||||
|
||||
err := api.cfg.SetBitcoinDisplayFormat(format)
|
||||
if err != nil {
|
||||
logger.Logger.WithError(err).Error("Failed to update bitcoin display format")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *api) UpdateSettings(updateSettingsRequest *UpdateSettingsRequest) error {
|
||||
if updateSettingsRequest.Currency != "" {
|
||||
err := api.SetCurrency(updateSettingsRequest.Currency)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set currency: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if updateSettingsRequest.BitcoinDisplayFormat != "" {
|
||||
err := api.SetBitcoinDisplayFormat(updateSettingsRequest.BitcoinDisplayFormat)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set bitcoin display format: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *api) SetNodeAlias(nodeAlias string) error {
|
||||
err := api.cfg.SetUpdate("NodeAlias", nodeAlias, "")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ type API interface {
|
|||
GetWalletCapabilities(ctx context.Context) (*WalletCapabilitiesResponse, error)
|
||||
Health(ctx context.Context) (*HealthResponse, error)
|
||||
SetCurrency(currency string) error
|
||||
SetBitcoinDisplayFormat(format string) error
|
||||
UpdateSettings(updateSettingsRequest *UpdateSettingsRequest) error
|
||||
LookupSwap(swapId string) (*LookupSwapResponse, error)
|
||||
ListSwaps() (*ListSwapsResponse, error)
|
||||
GetSwapInInfo() (*SwapInfoResponse, error)
|
||||
|
|
@ -291,13 +293,15 @@ type InfoResponse struct {
|
|||
AutoUnlockPasswordSupported bool `json:"autoUnlockPasswordSupported"`
|
||||
AutoUnlockPasswordEnabled bool `json:"autoUnlockPasswordEnabled"`
|
||||
Currency string `json:"currency"`
|
||||
BitcoinDisplayFormat string `json:"bitcoinDisplayFormat"`
|
||||
Relays []InfoResponseRelay `json:"relays"`
|
||||
NodeAlias string `json:"nodeAlias"`
|
||||
MempoolUrl string `json:"mempoolUrl"`
|
||||
}
|
||||
|
||||
type UpdateSettingsRequest struct {
|
||||
Currency string `json:"currency"`
|
||||
Currency string `json:"currency"`
|
||||
BitcoinDisplayFormat string `json:"bitcoinDisplayFormat"`
|
||||
}
|
||||
|
||||
type SetNodeAliasRequest struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue