mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 04:04:21 +01:00
* ark credits * rename "ecash" --> "ark credit" * rework note_test.go * NewFromString * create several notes * note repo: rename "push" to "add" * RegisterInputsForNextRoundRequest: move "notes" to field #3 * use uint64 as note ID * rename to voucher * add nostr notification * nostr notification test and fixes * bump badger to 4.3 * allow npub to be registered * rename poolTxID * add default relays * Update server/internal/config/config.go Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com> * fix RedeemVouchers test * notification = voucher * WASM wrappers * fix arkd voucher cmd * test_utils.go ignore gosec rule G101 * fix permissions * rename ALL to notes * add URI prefix * note.go : fix signature encoding * fix decode note.Data * Update server/internal/infrastructure/notifier/nostr/nostr.go Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> * Update pkg/client-sdk/wasm/browser/wrappers.go Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> * Update server/internal/infrastructure/notifier/nostr/nostr.go Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> * rework note and entity db + sqlite implementations * NOTIFICATION_PREFIX -> NOTE_URI_PREFIX * validate NOTE_URI_PREFIX * Update defaults to convenant-less mainnet (#2) * config: defaults to convenant-less tx builder * Drop env var for blockchain scanner --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com> * add // before URI prefix * add URI prefix in admin CreateNote * Fixes * rework nonces encoding (#4) * rework nonces encoding * add a check in Musig2Nonce decode function * musig2_test: increase number of signers to 20 * musig2.json: add a test case with a 35 leaves tree * GetEventStream REST rework * fix round phases time intervals * [SDK] Use server-side streams in rest client * Fix history * make the URI optional * Updates * Fix settled txs in history * fix e2e test * go work sync in sdk unit test * fix signMessage in btc and liquid sdk wallets --------- Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com> Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
124 lines
3.3 KiB
Go
Executable File
124 lines
3.3 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/server/internal/app-config"
|
|
"github.com/ark-network/ark/server/internal/config"
|
|
grpcservice "github.com/ark-network/ark/server/internal/interface/grpc"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Version will be set during build time
|
|
var Version string
|
|
|
|
// 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,
|
|
WalletAddr: cfg.WalletAddr,
|
|
RoundLifetime: cfg.RoundLifetime,
|
|
UnilateralExitDelay: cfg.UnilateralExitDelay,
|
|
EsploraURL: cfg.EsploraURL,
|
|
NeutrinoPeer: cfg.NeutrinoPeer,
|
|
BitcoindRpcUser: cfg.BitcoindRpcUser,
|
|
BitcoindRpcPass: cfg.BitcoindRpcPass,
|
|
BitcoindRpcHost: cfg.BitcoindRpcHost,
|
|
BoardingExitDelay: cfg.BoardingExitDelay,
|
|
UnlockerType: cfg.UnlockerType,
|
|
UnlockerFilePath: cfg.UnlockerFilePath,
|
|
UnlockerPassword: cfg.UnlockerPassword,
|
|
NostrDefaultRelays: cfg.NostrDefaultRelays,
|
|
NoteUriPrefix: cfg.NoteUriPrefix,
|
|
}
|
|
svc, err := grpcservice.NewService(svcConfig, appConfig)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
log.Infof("Ark Server config: %+v", appConfig)
|
|
|
|
log.Info("starting service...")
|
|
if err := svc.Start(); err != nil {
|
|
return err
|
|
}
|
|
|
|
log.RegisterExitHandler(svc.Stop)
|
|
|
|
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)
|
|
}
|
|
}
|