diff --git a/.github/workflows/ark.intergation.yaml b/.github/workflows/ark.intergation.yaml index a9d3d93..1955102 100755 --- a/.github/workflows/ark.intergation.yaml +++ b/.github/workflows/ark.intergation.yaml @@ -5,7 +5,7 @@ on: branches: - master paths: - - "asp/**" + - "server/**" jobs: test: @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./asp + working-directory: ./server steps: - uses: actions/setup-go@v3 with: diff --git a/.github/workflows/ark.release.yaml b/.github/workflows/ark.release.yaml index d8d0f76..b7f0430 100755 --- a/.github/workflows/ark.release.yaml +++ b/.github/workflows/ark.release.yaml @@ -6,14 +6,14 @@ on: tags: - "*" paths: - - "asp/**" + - "server/**" jobs: goreleaser: runs-on: ubuntu-20.04 defaults: run: - working-directory: ./asp + working-directory: ./server env: DOCKER_CLI_EXPERIMENTAL: "enabled" diff --git a/.github/workflows/ark.unit.yaml b/.github/workflows/ark.unit.yaml index e37dd32..285073b 100755 --- a/.github/workflows/ark.unit.yaml +++ b/.github/workflows/ark.unit.yaml @@ -3,13 +3,13 @@ name: ci_unit on: push: paths: - - "asp/**" + - "server/**" branches: [master] pull_request: branches: - master paths: - - "asp/**" + - "server/**" jobs: test: @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: ./asp + working-directory: ./server steps: - uses: actions/setup-go@v3 with: @@ -27,7 +27,7 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.54 - working-directory: ./asp + working-directory: ./server - name: check code integrity uses: securego/gosec@master with: diff --git a/Dockerfile b/Dockerfile index 191246e..4b6ff6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ WORKDIR /app COPY . . -RUN cd asp && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.Version=${COMMIT}' -X 'main.Commit=${COMMIT}' -X 'main.Date=${COMMIT}'" -o ../bin/arkd cmd/arkd/main.go +RUN cd server && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.Version=${COMMIT}' -X 'main.Commit=${COMMIT}' -X 'main.Date=${COMMIT}'" -o ../bin/arkd cmd/arkd/main.go # Second image, running the arkd executable FROM debian:buster-slim diff --git a/README.md b/README.md index e9b50be..ba8fa26 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Welcome to the Ark monorepo. In this repository you can find: -- `asp` - a proof of concept of an Ark Service Provider. +- `server` - a proof of concept of an Ark Service Provider. - `website` - the website where to find documentation about Ark protocol and products. -- `noah` - the initial Ark wallet, served as CLI. +- `client` - the initial Ark wallet, served as CLI. diff --git a/asp/cmd/ark/config.go b/asp/cmd/ark/config.go deleted file mode 100644 index 8f13870..0000000 --- a/asp/cmd/ark/config.go +++ /dev/null @@ -1,81 +0,0 @@ -package main - -import ( - "fmt" - "strconv" - - "github.com/urfave/cli/v2" -) - -var ( - rpcServerFlag = &cli.StringFlag{ - Name: "rpcserver", - Usage: "the addr of the arkd to connect to in the form :", - Value: defaultRpcServer, - } - noTlsFlag = &cli.BoolFlag{ - Name: "no-tls", - Usage: "used to disable TLS termination", - Value: false, - } -) - -var configCommand = &cli.Command{ - Name: "config", - Usage: "Print local configuration of the ark CLI", - Action: printConfigAction, - Subcommands: []*cli.Command{ - { - Name: "init", - Usage: "initialize the CLI state with flags", - Action: configInitAction, - Flags: []cli.Flag{rpcServerFlag, noTlsFlag}, - }, - { - Name: "set", - Usage: "set a in the local state", - Action: configSetAction, - }, - }, -} - -func printConfigAction(ctx *cli.Context) error { - state, err := getState() - if err != nil { - return err - } - - for key, value := range state { - fmt.Println(key + ": " + value) - } - - return nil -} - -func configInitAction(ctx *cli.Context) error { - return setState(map[string]string{ - "rpcserver": ctx.String("rpcserver"), - "no-tls": strconv.FormatBool(ctx.Bool("no-tls")), - }) -} - -func configSetAction(c *cli.Context) error { - if c.NArg() < 2 { - return fmt.Errorf("key and/or value are missing") - } - - key := c.Args().Get(0) - value := c.Args().Get(1) - - if value == "" { - return fmt.Errorf("value must not be an empty string") - } - - if err := setState(map[string]string{key: value}); err != nil { - return err - } - - fmt.Printf("%s %s has been set\n", key, value) - - return nil -} diff --git a/asp/cmd/ark/main.go b/asp/cmd/ark/main.go deleted file mode 100644 index b413958..0000000 --- a/asp/cmd/ark/main.go +++ /dev/null @@ -1,209 +0,0 @@ -package main - -import ( - "encoding/json" - "errors" - "fmt" - "os" - "os/user" - "path/filepath" - "strconv" - "strings" - - arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1" - "github.com/ark-network/ark/common" - "github.com/gogo/protobuf/jsonpb" - "github.com/gogo/protobuf/proto" - "github.com/urfave/cli/v2" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" -) - -const ( - DATADIR_ENVVAR = "ARK_CLI_DATADIR" - STATE_FILE = "state.json" -) - -var ( - version = "alpha" - - datadir = common.AppDataDir("ark", false) - statePath = filepath.Join(datadir, STATE_FILE) - - defaultRpcServer = "localhost:6000" - defaultNoTls = true - - initialState = map[string]string{ - "rpcserver": defaultRpcServer, - "no-tls": strconv.FormatBool(defaultNoTls), - } -) - -func initCLIEnv() { - dir := cleanAndExpandPath(os.Getenv(DATADIR_ENVVAR)) - if len(dir) <= 0 { - return - } - datadir = dir - statePath = filepath.Join(dir, STATE_FILE) -} - -func main() { - initCLIEnv() - - app := cli.NewApp() - - app.Version = version - app.Name = "Ark CLI" - app.Usage = "Command line interface to interact with arkd" - app.Commands = append(app.Commands, configCommand, roundCommand) - - app.Before = func(ctx *cli.Context) error { - if _, err := os.Stat(datadir); os.IsNotExist(err) { - return os.Mkdir(datadir, os.ModeDir|0755) - } - return nil - } - - if err := app.Run(os.Args); err != nil { - fmt.Println(fmt.Errorf("error: %v", err)) - os.Exit(1) - } -} - -// cleanAndExpandPath expands environment variables and leading ~ in the -// passed path, cleans the result, and returns it. -// This function is taken from https://github.com/btcsuite/btcd -func cleanAndExpandPath(path string) string { - if path == "" { - return "" - } - - // Expand initial ~ to OS specific home directory. - if strings.HasPrefix(path, "~") { - var homeDir string - u, err := user.Current() - if err == nil { - homeDir = u.HomeDir - } else { - homeDir = os.Getenv("HOME") - } - - path = strings.Replace(path, "~", homeDir, 1) - } - - // NOTE: The os.ExpandEnv doesn't work with Windows-style %VARIABLE%, - // but the variables can still be expanded via POSIX-style $VARIABLE. - return filepath.Clean(os.ExpandEnv(path)) -} - -func getState() (map[string]string, error) { - file, err := os.ReadFile(statePath) - if err != nil { - if !os.IsNotExist(err) { - return nil, err - } - if err := setInitialState(); err != nil { - return nil, err - } - return initialState, nil - } - - data := map[string]string{} - if err := json.Unmarshal(file, &data); err != nil { - return nil, err - } - - return data, nil -} - -func setInitialState() error { - jsonString, err := json.Marshal(initialState) - if err != nil { - return err - } - return os.WriteFile(statePath, jsonString, 0755) -} - -func setState(data map[string]string) error { - currentData, err := getState() - if err != nil { - return err - } - - mergedData := merge(currentData, data) - - jsonString, err := json.Marshal(mergedData) - if err != nil { - return err - } - err = os.WriteFile(statePath, jsonString, 0755) - if err != nil { - return fmt.Errorf("writing to file: %w", err) - } - - return nil -} - -func merge(maps ...map[string]string) map[string]string { - merge := make(map[string]string, 0) - for _, m := range maps { - for k, v := range m { - merge[k] = v - } - } - return merge -} - -func printRespJSON(resp interface{}) { - jsonMarshaler := &jsonpb.Marshaler{ - EmitDefaults: true, - OrigName: true, - Indent: "\t", // Matches indentation of printJSON. - } - - jsonStr, err := jsonMarshaler.MarshalToString(resp.(proto.Message)) - if err != nil { - fmt.Println("unable to decode response: ", err) - return - } - - fmt.Println(jsonStr) -} - -func getServiceClient() (arkv1.ArkServiceClient, func(), error) { - conn, err := getClientConn() - if err != nil { - return nil, nil, err - } - cleanup := func() { conn.Close() } - - return arkv1.NewArkServiceClient(conn), cleanup, nil -} - -func getClientConn() (*grpc.ClientConn, error) { - state, err := getState() - if err != nil { - return nil, err - } - address, ok := state["rpcserver"] - if !ok { - return nil, errors.New("set rpcserver with `config set rpcserver`") - } - - opts := []grpc.DialOption{grpc.WithDefaultCallOptions()} - - noTls, _ := strconv.ParseBool(state["no-tls"]) - if !noTls { - return nil, fmt.Errorf("secure connection not supported yet") - } - opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) - - conn, err := grpc.Dial(address, opts...) - if err != nil { - return nil, fmt.Errorf("unable to connect to RPC server: %v", - err) - } - - return conn, nil -} diff --git a/asp/cmd/ark/round.go b/asp/cmd/ark/round.go deleted file mode 100644 index dc133db..0000000 --- a/asp/cmd/ark/round.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "context" - "fmt" - - arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1" - "github.com/urfave/cli/v2" -) - -var ( - roundTxidFlag = &cli.StringFlag{ - Name: "txid", - Usage: "the hash of a broadcasted pool transaction", - } - currentFlag = &cli.BoolFlag{ - Name: "current", - Usage: "info about the status of the ongoing round", - Value: false, - } -) - -var roundCommand = &cli.Command{ - Name: "round", - Usage: "Get info about an ark round", - Action: getRoundAction, - Flags: []cli.Flag{roundTxidFlag, currentFlag}, -} - -func getRoundAction(ctx *cli.Context) error { - client, cleanup, err := getServiceClient() - if err != nil { - return err - } - defer cleanup() - - txid := ctx.String("txid") - current := ctx.Bool("current") - - if txid == "" && !current { - return fmt.Errorf("missing flag, please provide either --txid or --current") - } - - if current { - return fmt.Errorf("not supported yet") - } - - res, err := client.GetRound(context.Background(), &arkv1.GetRoundRequest{Txid: txid}) - if err != nil { - return err - } - - printRespJSON(res) - return nil -} diff --git a/noah/.gitignore b/client/.gitignore similarity index 100% rename from noah/.gitignore rename to client/.gitignore diff --git a/noah/Makefile b/client/Makefile similarity index 73% rename from noah/Makefile rename to client/Makefile index bae9840..c1042b7 100644 --- a/noah/Makefile +++ b/client/Makefile @@ -1,9 +1,13 @@ -.PHONY: build clean help lint vet +.PHONY: build build-all clean help lint vet build: - @echo "Building noah binary..." + @echo "Building binary..." @bash ./scripts/build +build-all: + @echo "Building binary..." + @bash ./scripts/build-all + ## clean: cleans the binary clean: @echo "Cleaning..." diff --git a/noah/balance.go b/client/balance.go similarity index 96% rename from noah/balance.go rename to client/balance.go index 4fd31af..5e45359 100644 --- a/noah/balance.go +++ b/client/balance.go @@ -8,7 +8,7 @@ import ( var balanceCommand = cli.Command{ Name: "balance", - Usage: "Print balance of the Noah wallet", + Usage: "Print balance of the Ark wallet", Action: balanceAction, } diff --git a/noah/client.go b/client/client.go similarity index 100% rename from noah/client.go rename to client/client.go diff --git a/noah/common.go b/client/common.go similarity index 100% rename from noah/common.go rename to client/common.go diff --git a/noah/config.go b/client/config.go similarity index 83% rename from noah/config.go rename to client/config.go index a7cb83b..9b48d7c 100644 --- a/noah/config.go +++ b/client/config.go @@ -6,7 +6,7 @@ import ( var configCommand = cli.Command{ Name: "config", - Usage: "Print local configuration of the Noah CLI", + Usage: "Print local configuration of the Ark CLI", Action: printConfigAction, } diff --git a/noah/cypher.go b/client/cypher.go similarity index 100% rename from noah/cypher.go rename to client/cypher.go diff --git a/noah/explorer.go b/client/explorer.go similarity index 100% rename from noah/explorer.go rename to client/explorer.go diff --git a/noah/faucet.go b/client/faucet.go similarity index 100% rename from noah/faucet.go rename to client/faucet.go diff --git a/noah/go.mod b/client/go.mod similarity index 94% rename from noah/go.mod rename to client/go.mod index 22c2ac5..fad166c 100644 --- a/noah/go.mod +++ b/client/go.mod @@ -1,10 +1,10 @@ -module github.com/ark-network/noah +module github.com/ark-network/ark-cli go 1.21.0 replace github.com/ark-network/ark/common => ../common -replace github.com/ark-network/ark => ../asp +replace github.com/ark-network/ark => ../server require ( github.com/ark-network/ark v0.0.0-00010101000000-000000000000 diff --git a/noah/go.sum b/client/go.sum similarity index 100% rename from noah/go.sum rename to client/go.sum diff --git a/noah/init.go b/client/init.go similarity index 100% rename from noah/init.go rename to client/init.go diff --git a/noah/main.go b/client/main.go similarity index 82% rename from noah/main.go rename to client/main.go index 0432c8e..f557dfd 100644 --- a/noah/main.go +++ b/client/main.go @@ -14,24 +14,23 @@ import ( ) const ( - DATADIR_ENVVAR = "NOAH_DATADIR" + DATADIR_ENVVAR = "ARK_WALLET_DATADIR" STATE_FILE = "state.json" - defaultArkURL = "localhost:6000" defaultNetwork = "testnet" ) var ( version = "alpha" - noahDataDirectory = common.AppDataDir("noah", false) - statePath = filepath.Join(noahDataDirectory, STATE_FILE) - explorerUrl = map[string]string{ + datadir = common.AppDataDir("ark-cli", false) + statePath = filepath.Join(datadir, STATE_FILE) + explorerUrl = map[string]string{ network.Liquid.Name: "https://blockstream.info/liquid/api", network.Testnet.Name: "https://blockstream.info/liquidtestnet/api", } initialState = map[string]string{ - "ark_url": defaultArkURL, + "ark_url": "", "ark_pubkey": "", "encrypted_private_key": "", "password_hash": "", @@ -41,13 +40,13 @@ var ( ) func initCLIEnv() { - dataDir := cleanAndExpandPath(os.Getenv(DATADIR_ENVVAR)) - if len(dataDir) <= 0 { + dir := cleanAndExpandPath(os.Getenv(DATADIR_ENVVAR)) + if len(dir) <= 0 { return } - noahDataDirectory = dataDir - statePath = filepath.Join(noahDataDirectory, STATE_FILE) + datadir = dir + statePath = filepath.Join(datadir, STATE_FILE) } func main() { @@ -56,8 +55,8 @@ func main() { app := cli.NewApp() app.Version = version - app.Name = "noah CLI" - app.Usage = "Command line interface for Ark wallet" + app.Name = "Ark CLI" + app.Usage = "command line interface for Ark wallet" app.Commands = append( app.Commands, &balanceCommand, @@ -70,8 +69,8 @@ func main() { ) app.Before = func(ctx *cli.Context) error { - if _, err := os.Stat(noahDataDirectory); os.IsNotExist(err) { - return os.Mkdir(noahDataDirectory, os.ModeDir|0755) + if _, err := os.Stat(datadir); os.IsNotExist(err) { + return os.Mkdir(datadir, os.ModeDir|0755) } return nil } diff --git a/noah/receive.go b/client/receive.go similarity index 100% rename from noah/receive.go rename to client/receive.go diff --git a/noah/redeem.go b/client/redeem.go similarity index 100% rename from noah/redeem.go rename to client/redeem.go diff --git a/noah/scripts/build b/client/scripts/build similarity index 70% rename from noah/scripts/build rename to client/scripts/build index 1bb1e77..2fd3930 100755 --- a/noah/scripts/build +++ b/client/scripts/build @@ -12,5 +12,5 @@ ARCH=$(eval "go env GOARCH") pushd $PARENT_PATH mkdir -p build -GO111MODULE=on go build -ldflags="-s -w" -o build/noah-$OS-$ARCH . +GO111MODULE=on go build -ldflags="-s -w" -o build/ark-cli-$OS-$ARCH . popd diff --git a/client/scripts/build-all b/client/scripts/build-all new file mode 100755 index 0000000..4bc5b6e --- /dev/null +++ b/client/scripts/build-all @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +PARENT_PATH=$(dirname $( + cd $(dirname $0) + pwd -P +)) + +declare -a OS=("darwin" "linux") +declare -a ARCH=("amd64" "arm64") + +pushd $PARENT_PATH +mkdir -p build + +for os in "${OS[@]}"; do + for arch in "${ARCH[@]}"; do + echo "Building for $os $arch" + GOOS=$os GOARCH=$arch go build -o build/ark-$os-$arch . + done +done + +popd \ No newline at end of file diff --git a/noah/send.go b/client/send.go similarity index 100% rename from noah/send.go rename to client/send.go diff --git a/noah/signer.go b/client/signer.go similarity index 100% rename from noah/signer.go rename to client/signer.go diff --git a/noah/unilateral_redeem.go b/client/unilateral_redeem.go similarity index 100% rename from noah/unilateral_redeem.go rename to client/unilateral_redeem.go diff --git a/asp/.gitignore b/server/.gitignore similarity index 100% rename from asp/.gitignore rename to server/.gitignore diff --git a/asp/.goreleaser.yaml b/server/.goreleaser.yaml similarity index 100% rename from asp/.goreleaser.yaml rename to server/.goreleaser.yaml diff --git a/asp/LICENSE b/server/LICENSE similarity index 100% rename from asp/LICENSE rename to server/LICENSE diff --git a/asp/Makefile b/server/Makefile similarity index 100% rename from asp/Makefile rename to server/Makefile diff --git a/asp/README.md b/server/README.md similarity index 100% rename from asp/README.md rename to server/README.md diff --git a/asp/api-spec/openapi/swagger/ark/v1/service.swagger.json b/server/api-spec/openapi/swagger/ark/v1/service.swagger.json similarity index 100% rename from asp/api-spec/openapi/swagger/ark/v1/service.swagger.json rename to server/api-spec/openapi/swagger/ark/v1/service.swagger.json diff --git a/asp/api-spec/openapi/swagger/ocean/v1/account.swagger.json b/server/api-spec/openapi/swagger/ocean/v1/account.swagger.json similarity index 100% rename from asp/api-spec/openapi/swagger/ocean/v1/account.swagger.json rename to server/api-spec/openapi/swagger/ocean/v1/account.swagger.json diff --git a/asp/api-spec/openapi/swagger/ocean/v1/notification.swagger.json b/server/api-spec/openapi/swagger/ocean/v1/notification.swagger.json similarity index 100% rename from asp/api-spec/openapi/swagger/ocean/v1/notification.swagger.json rename to server/api-spec/openapi/swagger/ocean/v1/notification.swagger.json diff --git a/asp/api-spec/openapi/swagger/ocean/v1/transaction.swagger.json b/server/api-spec/openapi/swagger/ocean/v1/transaction.swagger.json similarity index 100% rename from asp/api-spec/openapi/swagger/ocean/v1/transaction.swagger.json rename to server/api-spec/openapi/swagger/ocean/v1/transaction.swagger.json diff --git a/asp/api-spec/openapi/swagger/ocean/v1/types.swagger.json b/server/api-spec/openapi/swagger/ocean/v1/types.swagger.json similarity index 100% rename from asp/api-spec/openapi/swagger/ocean/v1/types.swagger.json rename to server/api-spec/openapi/swagger/ocean/v1/types.swagger.json diff --git a/asp/api-spec/openapi/swagger/ocean/v1/wallet.swagger.json b/server/api-spec/openapi/swagger/ocean/v1/wallet.swagger.json similarity index 100% rename from asp/api-spec/openapi/swagger/ocean/v1/wallet.swagger.json rename to server/api-spec/openapi/swagger/ocean/v1/wallet.swagger.json diff --git a/asp/api-spec/protobuf/ark/v1/service.proto b/server/api-spec/protobuf/ark/v1/service.proto similarity index 100% rename from asp/api-spec/protobuf/ark/v1/service.proto rename to server/api-spec/protobuf/ark/v1/service.proto diff --git a/asp/api-spec/protobuf/buf.lock b/server/api-spec/protobuf/buf.lock similarity index 100% rename from asp/api-spec/protobuf/buf.lock rename to server/api-spec/protobuf/buf.lock diff --git a/asp/api-spec/protobuf/buf.yaml b/server/api-spec/protobuf/buf.yaml similarity index 100% rename from asp/api-spec/protobuf/buf.yaml rename to server/api-spec/protobuf/buf.yaml diff --git a/asp/api-spec/protobuf/gen/ark/v1/service.pb.go b/server/api-spec/protobuf/gen/ark/v1/service.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ark/v1/service.pb.go rename to server/api-spec/protobuf/gen/ark/v1/service.pb.go diff --git a/asp/api-spec/protobuf/gen/ark/v1/service.pb.gw.go b/server/api-spec/protobuf/gen/ark/v1/service.pb.gw.go similarity index 100% rename from asp/api-spec/protobuf/gen/ark/v1/service.pb.gw.go rename to server/api-spec/protobuf/gen/ark/v1/service.pb.gw.go diff --git a/asp/api-spec/protobuf/gen/ark/v1/service_grpc.pb.go b/server/api-spec/protobuf/gen/ark/v1/service_grpc.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ark/v1/service_grpc.pb.go rename to server/api-spec/protobuf/gen/ark/v1/service_grpc.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/account.pb.go b/server/api-spec/protobuf/gen/ocean/v1/account.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/account.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/account.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/account_grpc.pb.go b/server/api-spec/protobuf/gen/ocean/v1/account_grpc.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/account_grpc.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/account_grpc.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/notification.pb.go b/server/api-spec/protobuf/gen/ocean/v1/notification.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/notification.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/notification.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/notification_grpc.pb.go b/server/api-spec/protobuf/gen/ocean/v1/notification_grpc.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/notification_grpc.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/notification_grpc.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/transaction.pb.go b/server/api-spec/protobuf/gen/ocean/v1/transaction.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/transaction.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/transaction.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/transaction_grpc.pb.go b/server/api-spec/protobuf/gen/ocean/v1/transaction_grpc.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/transaction_grpc.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/transaction_grpc.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/types.pb.go b/server/api-spec/protobuf/gen/ocean/v1/types.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/types.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/types.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/wallet.pb.go b/server/api-spec/protobuf/gen/ocean/v1/wallet.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/wallet.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/wallet.pb.go diff --git a/asp/api-spec/protobuf/gen/ocean/v1/wallet_grpc.pb.go b/server/api-spec/protobuf/gen/ocean/v1/wallet_grpc.pb.go similarity index 100% rename from asp/api-spec/protobuf/gen/ocean/v1/wallet_grpc.pb.go rename to server/api-spec/protobuf/gen/ocean/v1/wallet_grpc.pb.go diff --git a/asp/buf.Dockerfile b/server/buf.Dockerfile similarity index 100% rename from asp/buf.Dockerfile rename to server/buf.Dockerfile diff --git a/asp/buf.gen.yaml b/server/buf.gen.yaml similarity index 100% rename from asp/buf.gen.yaml rename to server/buf.gen.yaml diff --git a/asp/buf.work.yaml b/server/buf.work.yaml similarity index 100% rename from asp/buf.work.yaml rename to server/buf.work.yaml diff --git a/asp/cmd/arkd/main.go b/server/cmd/arkd/main.go similarity index 100% rename from asp/cmd/arkd/main.go rename to server/cmd/arkd/main.go diff --git a/asp/go.mod b/server/go.mod similarity index 100% rename from asp/go.mod rename to server/go.mod diff --git a/asp/go.sum b/server/go.sum similarity index 100% rename from asp/go.sum rename to server/go.sum diff --git a/asp/goreleaser.Dockerfile b/server/goreleaser.Dockerfile similarity index 100% rename from asp/goreleaser.Dockerfile rename to server/goreleaser.Dockerfile diff --git a/asp/internal/app-config/config.go b/server/internal/app-config/config.go similarity index 100% rename from asp/internal/app-config/config.go rename to server/internal/app-config/config.go diff --git a/asp/internal/config/config.go b/server/internal/config/config.go similarity index 100% rename from asp/internal/config/config.go rename to server/internal/config/config.go diff --git a/asp/internal/core/application/service.go b/server/internal/core/application/service.go similarity index 100% rename from asp/internal/core/application/service.go rename to server/internal/core/application/service.go diff --git a/asp/internal/core/application/sweeper.go b/server/internal/core/application/sweeper.go similarity index 100% rename from asp/internal/core/application/sweeper.go rename to server/internal/core/application/sweeper.go diff --git a/asp/internal/core/application/utils.go b/server/internal/core/application/utils.go similarity index 100% rename from asp/internal/core/application/utils.go rename to server/internal/core/application/utils.go diff --git a/asp/internal/core/domain/events.go b/server/internal/core/domain/events.go similarity index 100% rename from asp/internal/core/domain/events.go rename to server/internal/core/domain/events.go diff --git a/asp/internal/core/domain/payment.go b/server/internal/core/domain/payment.go similarity index 100% rename from asp/internal/core/domain/payment.go rename to server/internal/core/domain/payment.go diff --git a/asp/internal/core/domain/payment_test.go b/server/internal/core/domain/payment_test.go similarity index 100% rename from asp/internal/core/domain/payment_test.go rename to server/internal/core/domain/payment_test.go diff --git a/asp/internal/core/domain/round.go b/server/internal/core/domain/round.go similarity index 100% rename from asp/internal/core/domain/round.go rename to server/internal/core/domain/round.go diff --git a/asp/internal/core/domain/round_repo.go b/server/internal/core/domain/round_repo.go similarity index 100% rename from asp/internal/core/domain/round_repo.go rename to server/internal/core/domain/round_repo.go diff --git a/asp/internal/core/domain/round_test.go b/server/internal/core/domain/round_test.go similarity index 100% rename from asp/internal/core/domain/round_test.go rename to server/internal/core/domain/round_test.go diff --git a/asp/internal/core/ports/repo_manager.go b/server/internal/core/ports/repo_manager.go similarity index 100% rename from asp/internal/core/ports/repo_manager.go rename to server/internal/core/ports/repo_manager.go diff --git a/asp/internal/core/ports/scanner.go b/server/internal/core/ports/scanner.go similarity index 100% rename from asp/internal/core/ports/scanner.go rename to server/internal/core/ports/scanner.go diff --git a/asp/internal/core/ports/scheduler.go b/server/internal/core/ports/scheduler.go similarity index 100% rename from asp/internal/core/ports/scheduler.go rename to server/internal/core/ports/scheduler.go diff --git a/asp/internal/core/ports/tx_builder.go b/server/internal/core/ports/tx_builder.go similarity index 100% rename from asp/internal/core/ports/tx_builder.go rename to server/internal/core/ports/tx_builder.go diff --git a/asp/internal/core/ports/wallet.go b/server/internal/core/ports/wallet.go similarity index 100% rename from asp/internal/core/ports/wallet.go rename to server/internal/core/ports/wallet.go diff --git a/asp/internal/infrastructure/db/badger/event_repo.go b/server/internal/infrastructure/db/badger/event_repo.go similarity index 100% rename from asp/internal/infrastructure/db/badger/event_repo.go rename to server/internal/infrastructure/db/badger/event_repo.go diff --git a/asp/internal/infrastructure/db/badger/round_repo.go b/server/internal/infrastructure/db/badger/round_repo.go similarity index 100% rename from asp/internal/infrastructure/db/badger/round_repo.go rename to server/internal/infrastructure/db/badger/round_repo.go diff --git a/asp/internal/infrastructure/db/badger/utils.go b/server/internal/infrastructure/db/badger/utils.go similarity index 100% rename from asp/internal/infrastructure/db/badger/utils.go rename to server/internal/infrastructure/db/badger/utils.go diff --git a/asp/internal/infrastructure/db/badger/vtxo_repo.go b/server/internal/infrastructure/db/badger/vtxo_repo.go similarity index 100% rename from asp/internal/infrastructure/db/badger/vtxo_repo.go rename to server/internal/infrastructure/db/badger/vtxo_repo.go diff --git a/asp/internal/infrastructure/db/service.go b/server/internal/infrastructure/db/service.go similarity index 100% rename from asp/internal/infrastructure/db/service.go rename to server/internal/infrastructure/db/service.go diff --git a/asp/internal/infrastructure/db/service_test.go b/server/internal/infrastructure/db/service_test.go similarity index 100% rename from asp/internal/infrastructure/db/service_test.go rename to server/internal/infrastructure/db/service_test.go diff --git a/asp/internal/infrastructure/db/types/types.go b/server/internal/infrastructure/db/types/types.go similarity index 100% rename from asp/internal/infrastructure/db/types/types.go rename to server/internal/infrastructure/db/types/types.go diff --git a/asp/internal/infrastructure/ocean-wallet/account.go b/server/internal/infrastructure/ocean-wallet/account.go similarity index 100% rename from asp/internal/infrastructure/ocean-wallet/account.go rename to server/internal/infrastructure/ocean-wallet/account.go diff --git a/asp/internal/infrastructure/ocean-wallet/notification.go b/server/internal/infrastructure/ocean-wallet/notification.go similarity index 100% rename from asp/internal/infrastructure/ocean-wallet/notification.go rename to server/internal/infrastructure/ocean-wallet/notification.go diff --git a/asp/internal/infrastructure/ocean-wallet/service.go b/server/internal/infrastructure/ocean-wallet/service.go similarity index 100% rename from asp/internal/infrastructure/ocean-wallet/service.go rename to server/internal/infrastructure/ocean-wallet/service.go diff --git a/asp/internal/infrastructure/ocean-wallet/transaction.go b/server/internal/infrastructure/ocean-wallet/transaction.go similarity index 100% rename from asp/internal/infrastructure/ocean-wallet/transaction.go rename to server/internal/infrastructure/ocean-wallet/transaction.go diff --git a/asp/internal/infrastructure/ocean-wallet/wallet.go b/server/internal/infrastructure/ocean-wallet/wallet.go similarity index 100% rename from asp/internal/infrastructure/ocean-wallet/wallet.go rename to server/internal/infrastructure/ocean-wallet/wallet.go diff --git a/asp/internal/infrastructure/scheduler/gocron/service.go b/server/internal/infrastructure/scheduler/gocron/service.go similarity index 100% rename from asp/internal/infrastructure/scheduler/gocron/service.go rename to server/internal/infrastructure/scheduler/gocron/service.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/builder.go b/server/internal/infrastructure/tx-builder/covenant/builder.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/builder.go rename to server/internal/infrastructure/tx-builder/covenant/builder.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/builder_test.go b/server/internal/infrastructure/tx-builder/covenant/builder_test.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/builder_test.go rename to server/internal/infrastructure/tx-builder/covenant/builder_test.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/connectors.go b/server/internal/infrastructure/tx-builder/covenant/connectors.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/connectors.go rename to server/internal/infrastructure/tx-builder/covenant/connectors.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/forfeit.go b/server/internal/infrastructure/tx-builder/covenant/forfeit.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/forfeit.go rename to server/internal/infrastructure/tx-builder/covenant/forfeit.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/mocks_test.go b/server/internal/infrastructure/tx-builder/covenant/mocks_test.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/mocks_test.go rename to server/internal/infrastructure/tx-builder/covenant/mocks_test.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/sweep.go b/server/internal/infrastructure/tx-builder/covenant/sweep.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/sweep.go rename to server/internal/infrastructure/tx-builder/covenant/sweep.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/testdata/fixtures.json b/server/internal/infrastructure/tx-builder/covenant/testdata/fixtures.json similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/testdata/fixtures.json rename to server/internal/infrastructure/tx-builder/covenant/testdata/fixtures.json diff --git a/asp/internal/infrastructure/tx-builder/covenant/tree.go b/server/internal/infrastructure/tx-builder/covenant/tree.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/tree.go rename to server/internal/infrastructure/tx-builder/covenant/tree.go diff --git a/asp/internal/infrastructure/tx-builder/covenant/utils.go b/server/internal/infrastructure/tx-builder/covenant/utils.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/covenant/utils.go rename to server/internal/infrastructure/tx-builder/covenant/utils.go diff --git a/asp/internal/infrastructure/tx-builder/dummy/builder.go b/server/internal/infrastructure/tx-builder/dummy/builder.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/dummy/builder.go rename to server/internal/infrastructure/tx-builder/dummy/builder.go diff --git a/asp/internal/infrastructure/tx-builder/dummy/builder_test.go b/server/internal/infrastructure/tx-builder/dummy/builder_test.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/dummy/builder_test.go rename to server/internal/infrastructure/tx-builder/dummy/builder_test.go diff --git a/asp/internal/infrastructure/tx-builder/dummy/connectors.go b/server/internal/infrastructure/tx-builder/dummy/connectors.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/dummy/connectors.go rename to server/internal/infrastructure/tx-builder/dummy/connectors.go diff --git a/asp/internal/infrastructure/tx-builder/dummy/forfeit.go b/server/internal/infrastructure/tx-builder/dummy/forfeit.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/dummy/forfeit.go rename to server/internal/infrastructure/tx-builder/dummy/forfeit.go diff --git a/asp/internal/infrastructure/tx-builder/dummy/tree.go b/server/internal/infrastructure/tx-builder/dummy/tree.go similarity index 100% rename from asp/internal/infrastructure/tx-builder/dummy/tree.go rename to server/internal/infrastructure/tx-builder/dummy/tree.go diff --git a/asp/internal/interface/grpc/config.go b/server/internal/interface/grpc/config.go similarity index 100% rename from asp/internal/interface/grpc/config.go rename to server/internal/interface/grpc/config.go diff --git a/asp/internal/interface/grpc/handlers/arkservice.go b/server/internal/interface/grpc/handlers/arkservice.go similarity index 100% rename from asp/internal/interface/grpc/handlers/arkservice.go rename to server/internal/interface/grpc/handlers/arkservice.go diff --git a/asp/internal/interface/grpc/handlers/utils.go b/server/internal/interface/grpc/handlers/utils.go similarity index 100% rename from asp/internal/interface/grpc/handlers/utils.go rename to server/internal/interface/grpc/handlers/utils.go diff --git a/asp/internal/interface/grpc/interceptors/interceptor.go b/server/internal/interface/grpc/interceptors/interceptor.go similarity index 100% rename from asp/internal/interface/grpc/interceptors/interceptor.go rename to server/internal/interface/grpc/interceptors/interceptor.go diff --git a/asp/internal/interface/grpc/interceptors/logger.go b/server/internal/interface/grpc/interceptors/logger.go similarity index 100% rename from asp/internal/interface/grpc/interceptors/logger.go rename to server/internal/interface/grpc/interceptors/logger.go diff --git a/asp/internal/interface/grpc/permissions/.gitkeep b/server/internal/interface/grpc/permissions/.gitkeep similarity index 100% rename from asp/internal/interface/grpc/permissions/.gitkeep rename to server/internal/interface/grpc/permissions/.gitkeep diff --git a/asp/internal/interface/grpc/service.go b/server/internal/interface/grpc/service.go similarity index 100% rename from asp/internal/interface/grpc/service.go rename to server/internal/interface/grpc/service.go diff --git a/asp/internal/interface/service.go b/server/internal/interface/service.go similarity index 100% rename from asp/internal/interface/service.go rename to server/internal/interface/service.go diff --git a/asp/internal/test/.gitkeep b/server/internal/test/.gitkeep similarity index 100% rename from asp/internal/test/.gitkeep rename to server/internal/test/.gitkeep diff --git a/asp/pkg/.gitkeep b/server/pkg/.gitkeep similarity index 100% rename from asp/pkg/.gitkeep rename to server/pkg/.gitkeep diff --git a/asp/scripts/build b/server/scripts/build similarity index 67% rename from asp/scripts/build rename to server/scripts/build index c9b0b02..88357c0 100755 --- a/asp/scripts/build +++ b/server/scripts/build @@ -13,6 +13,6 @@ ARCH=$(eval "go env GOARCH") pushd $PARENT_PATH mkdir -p build -GO111MODULE=on go build -ldflags="-s -w" -o build/arkd-$OS-$ARCH cmd/arkd/main.go +GO111MODULE=on go build -o build/arkd-$OS-$ARCH cmd/arkd/main.go popd \ No newline at end of file diff --git a/server/scripts/build-all b/server/scripts/build-all new file mode 100755 index 0000000..56ae1a9 --- /dev/null +++ b/server/scripts/build-all @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +PARENT_PATH=$(dirname $( + cd $(dirname $0) + pwd -P +)) + +declare -a OS=("darwin" "linux") +declare -a ARCH=("amd64" "arm64") + +pushd $PARENT_PATH +mkdir -p build + +for os in "${OS[@]}"; do + for arch in "${ARCH[@]}"; do + echo "Building for $os $arch" + GOOS=$os GOARCH=$arch go build -o build/arkd-$os-$arch cmd/arkd/main.go + done +done + +popd \ No newline at end of file diff --git a/website/docs/user/ark-cli.md b/website/docs/user/ark-cli.md new file mode 100644 index 0000000..420bb47 --- /dev/null +++ b/website/docs/user/ark-cli.md @@ -0,0 +1,71 @@ +--- +sidebar_position: 2 +title: Ark CLI +--- + +The Ark CLI allows you to interact with the Ark Service Provider (ASP). It is a command line tool that can be used to create and manage your Ark Wallet. + +## Configure the CLI + +The CLI requires an initial setup to initialize the wallet and connect to the ASP: + +```bash +$ ark init init --password --ark-url +``` + +You can also restore a wallet by specifying the hex encoded private key with the `--prvkey` flag. + +## Receive VTXO + +### Get receiving address + +You can print your onchain and offchain receiving addresses to receive funds with: + +```bash +$ ark receive +``` + +This command also shows the list of relays used to reach the ASP. + +:::tip +testnet only: `ark faucet` to receive newly created VTXO from the service provider. +::: + +### Print balance + +You can see both the onchain and offchain balance of the wallet with: +```bash +$ ark balance +``` + +## Send VTXO(s) + +You can make an offchain payment by sending to either one or many receivers: + +```bash +$ ark send --to --amount +$ ark send --receivers '[{"to": "", "amount": }, ...]' +``` + +The amount must be specified in _sats_ unit. + +## Redemption + +### Collaborative redemption + +You can redeem onchain your funds by collaborating with the ASP with: + +```bash +$ ark redeem --address --amount +``` + +Any change produced with this operation goes to your offchain address. + +### Unilateral redemption + +If the ASP is unresponsive you can redeem all your offchain funds unilaterally with: + +```bash +$ ark redeem --address --force +``` + diff --git a/website/docs/user/noah-cli.md b/website/docs/user/noah-cli.md deleted file mode 100644 index aac0119..0000000 --- a/website/docs/user/noah-cli.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -sidebar_position: 2 -title: Noah CLI ---- - -The Noah CLI allows you to interact with the Ark Service Provider (ASP). It is a command line tool that can be used to create and manage your Ark Wallet. - -## Configure the CLI - -The noah CLI requires a set of variables to be set, use flags to set them. - -```bash -noah config connect -``` - -## Set up Noah wallet - -`noah init` is a command that sets up a Noah wallet with a 32-bytes private key and a password in order to encrypt the private key. - -```bash -noah init --password [--prvkey ] -``` - -## Receive VTXO - -### Get receiving address - -You can use the noah CLI to print your Ark address. This can be used to receive VTXO. - -```bash -noah receive -``` - -:::tip -testnet only: `noah faucet ` to receive newly created VTXO from the service provider. -::: - -### Print balance - -```bash -noah balance -``` - -`balance` returns the sum of all VTXOs belonging to the Noah wallet. - -## Send VTXO(s) - -```bash -noah send --receivers '[{"to": "}, ...]' -``` - -Noah CLI is responsible to select the coins to send for the given amount. It will sync with the service provider to forfeit the VTXO(s) and create a new VTXO belonging to the recipient. A change VTXO will be created if needed. Asks user password before signing. - -## Redemption - -### Collaborative redemption - -```bash -noah redeem --address --amount -``` - -Noah CLI will sync with the service provider in order to redeem onchain the given amount in the next round, any remaining change will become a new vTXO. Asks user password before signing. - -### Unilateral redemption - -```bash -noah redeem --address --force -``` - -With the `--force` flag Noah CLI will unilateraly redeem all VTXOs by signing the psbt(s) and broadcast them. Asks user password before signing. diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 2f7dc3f..d145ed8 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -33,7 +33,7 @@ const config = { '**/provider/gateway/**', '**/provider/coordinator/**', '**/provider/treasury/**', - '**/user/noah-cli.md' + '**/user/ark-cli.md' ] }, blog: {