mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 12:14:21 +01:00
* Update protos * Update handlers * Support macaroons and TLS * Add arkd cli * Minor fixes * Update deps * Fixes * Update makefile * Fixes * Fix * Fix * Fix * Remove trusted onboarding from client * Completely remove trusted onboarding * Fix compose files and add --no-macaroon flag to arkd cli * Lint * Remove e2e for trusted onboarding * Add sleep time
119 lines
3.0 KiB
Go
Executable File
119 lines
3.0 KiB
Go
Executable File
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"path/filepath"
|
|
"syscall"
|
|
|
|
"github.com/ark-network/ark/common"
|
|
appconfig "github.com/ark-network/ark/internal/app-config"
|
|
"github.com/ark-network/ark/internal/config"
|
|
grpcservice "github.com/ark-network/ark/internal/interface/grpc"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
//nolint:all
|
|
var (
|
|
version = "dev"
|
|
commit = "none"
|
|
date = "unknown"
|
|
)
|
|
|
|
// flags
|
|
var (
|
|
urlFlag = &cli.StringFlag{
|
|
Name: "url",
|
|
Usage: "the url where to reach ark server",
|
|
Value: fmt.Sprintf("http://localhost:%d", config.DefaultPort),
|
|
}
|
|
noMacaroonFlag = &cli.BoolFlag{
|
|
Name: "no-macaroon",
|
|
Usage: "don't use macaroon auth",
|
|
Value: false,
|
|
}
|
|
macaroonFlag = &cli.StringFlag{
|
|
Name: "macaroon-path",
|
|
Usage: "the path where to find the admin macaroon file",
|
|
Value: filepath.Join(common.AppDataDir("arkd", false), "macaroons", "admin.macaroon"),
|
|
}
|
|
tlsCertFlag = &cli.StringFlag{
|
|
Name: "tls-cert-path",
|
|
Usage: "the path where to find the TLS certificate",
|
|
Value: filepath.Join(common.AppDataDir("arkd", false), "tls", "cert.pem"),
|
|
}
|
|
)
|
|
|
|
func mainAction(_ *cli.Context) error {
|
|
cfg, err := config.LoadConfig()
|
|
if err != nil {
|
|
return fmt.Errorf("invalid config: %s", err)
|
|
}
|
|
|
|
log.SetLevel(log.Level(cfg.LogLevel))
|
|
|
|
svcConfig := grpcservice.Config{
|
|
Datadir: cfg.Datadir,
|
|
Port: cfg.Port,
|
|
NoTLS: cfg.NoTLS,
|
|
NoMacaroons: cfg.NoMacaroons,
|
|
TLSExtraIPs: cfg.TLSExtraIPs,
|
|
TLSExtraDomains: cfg.TLSExtraDomains,
|
|
}
|
|
|
|
appConfig := &appconfig.Config{
|
|
EventDbType: cfg.EventDbType,
|
|
DbType: cfg.DbType,
|
|
DbDir: cfg.DbDir,
|
|
DbMigrationPath: cfg.DbMigrationPath,
|
|
EventDbDir: cfg.DbDir,
|
|
RoundInterval: cfg.RoundInterval,
|
|
Network: cfg.Network,
|
|
SchedulerType: cfg.SchedulerType,
|
|
TxBuilderType: cfg.TxBuilderType,
|
|
BlockchainScannerType: cfg.BlockchainScannerType,
|
|
WalletAddr: cfg.WalletAddr,
|
|
MinRelayFee: cfg.MinRelayFee,
|
|
RoundLifetime: cfg.RoundLifetime,
|
|
UnilateralExitDelay: cfg.UnilateralExitDelay,
|
|
EsploraURL: cfg.EsploraURL,
|
|
NeutrinoPeer: cfg.NeutrinoPeer,
|
|
}
|
|
svc, err := grpcservice.NewService(svcConfig, appConfig)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
log.RegisterExitHandler(svc.Stop)
|
|
|
|
log.Info("starting service...")
|
|
if err := svc.Start(); err != nil {
|
|
return err
|
|
}
|
|
|
|
sigChan := make(chan os.Signal, 1)
|
|
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, os.Interrupt)
|
|
<-sigChan
|
|
|
|
log.Info("shutting down service...")
|
|
log.Exit(0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
app := cli.NewApp()
|
|
app.Version = version
|
|
app.Name = "Arkd CLI"
|
|
app.Usage = "arkd command line interface"
|
|
app.Commands = append(app.Commands, walletCmd)
|
|
app.Action = mainAction
|
|
app.Flags = append(app.Flags, urlFlag, noMacaroonFlag, macaroonFlag, tlsCertFlag)
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|