Add admin APIs to manage wallet (#226)

* Add admin rpcs to manage wallet

* Fix

* Fixes

* Add sleeping time

* Increase sleeping time
This commit is contained in:
Pietralberto Mazza
2024-08-07 00:36:51 +02:00
committed by GitHub
parent fb8a127f4f
commit 1c67c56d9d
28 changed files with 3680 additions and 1721 deletions

View File

@@ -63,9 +63,8 @@ type Config struct {
RoundLifetime int64
UnilateralExitDelay int64
EsploraURL string
NeutrinoPeer string
WalletPassword string
EsploraURL string
NeutrinoPeer string
repo ports.RepoManager
svc application.Service
@@ -154,23 +153,29 @@ func (c *Config) Validate() error {
if err := c.schedulerService(); err != nil {
return err
}
if err := c.appService(); err != nil {
return err
}
if err := c.adminService(); err != nil {
return err
}
return nil
}
func (c *Config) AppService() application.Service {
return c.svc
func (c *Config) AppService() (application.Service, error) {
if c.svc == nil {
if err := c.appService(); err != nil {
return nil, err
}
}
return c.svc, nil
}
func (c *Config) AdminService() application.AdminService {
return c.adminSvc
}
func (c *Config) WalletService() ports.WalletService {
return c.wallet
}
func (c *Config) repoManager() error {
var svc ports.RepoManager
var err error
@@ -223,13 +228,9 @@ func (c *Config) walletService() error {
if len(c.EsploraURL) == 0 {
return fmt.Errorf("missing esplora url, covenant-less ark requires ARK_ESPLORA_URL to be set")
}
if len(c.WalletPassword) == 0 {
return fmt.Errorf("missing wallet password, covenant-less ark requires ARK_WALLET_PASSWORD to be set")
}
svc, err := btcwallet.NewService(btcwallet.WalletConfig{
Datadir: c.DbDir,
Password: []byte(c.WalletPassword),
Network: c.Network,
EsploraURL: c.EsploraURL,
},