mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-24 19:30:34 +00:00
Merge pull request #2625 from nspcc-dev/excessive-cli-positionals
Handle excessive positional arguments in the CLI
This commit is contained in:
commit
41613cd631
22 changed files with 339 additions and 93 deletions
|
@ -41,6 +41,13 @@ func TestRegisterCandidate(t *testing.T) {
|
|||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", validatorWallet)
|
||||
|
||||
// additional parameter
|
||||
e.RunWithError(t, "neo-go", "wallet", "candidate", "register",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", validatorWallet,
|
||||
"--address", validatorPriv.Address(),
|
||||
"error")
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
e.Run(t, "neo-go", "wallet", "candidate", "register",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
|
@ -55,6 +62,13 @@ func TestRegisterCandidate(t *testing.T) {
|
|||
require.Equal(t, big.NewInt(0), vs[0].Votes)
|
||||
|
||||
t.Run("VoteUnvote", func(t *testing.T) {
|
||||
// positional instead of a flag.
|
||||
e.RunWithError(t, "neo-go", "wallet", "candidate", "vote",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", validatorWallet,
|
||||
"--address", validatorPriv.Address(),
|
||||
validatorHex) // not "--candidate hex", but "hex".
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
e.Run(t, "neo-go", "wallet", "candidate", "vote",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
|
@ -115,6 +129,12 @@ func TestRegisterCandidate(t *testing.T) {
|
|||
e.RunWithError(t, "neo-go", "wallet", "candidate", "unregister",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", validatorWallet)
|
||||
// additional argument
|
||||
e.RunWithError(t, "neo-go", "wallet", "candidate", "unregister",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", validatorWallet,
|
||||
"--address", validatorPriv.Address(),
|
||||
"argument")
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
e.Run(t, "neo-go", "wallet", "candidate", "unregister",
|
||||
|
@ -128,4 +148,8 @@ func TestRegisterCandidate(t *testing.T) {
|
|||
|
||||
// query voter: missing address
|
||||
e.RunWithError(t, "neo-go", "query", "voter")
|
||||
// Excessive parameters.
|
||||
e.RunWithError(t, "neo-go", "query", "voter", "--rpc-endpoint", "http://"+e.RPC.Addr, validatorPriv.Address(), validatorPriv.Address())
|
||||
e.RunWithError(t, "neo-go", "query", "committee", "--rpc-endpoint", "http://"+e.RPC.Addr, "something")
|
||||
e.RunWithError(t, "neo-go", "query", "candidates", "--rpc-endpoint", "http://"+e.RPC.Addr, "something")
|
||||
}
|
||||
|
|
|
@ -131,6 +131,15 @@ func GetDataFromContext(ctx *cli.Context) (int, interface{}, *cli.ExitError) {
|
|||
return offset, data, nil
|
||||
}
|
||||
|
||||
// EnsureNone returns an error if there are any positional arguments present.
|
||||
// It can be used to check for them in commands that don't accept arguments.
|
||||
func EnsureNone(ctx *cli.Context) *cli.ExitError {
|
||||
if ctx.Args().Present() {
|
||||
return cli.NewExitError("additional arguments given while this command expects none", 1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseParams extracts array of smartcontract.Parameter from the given args and
|
||||
// returns the number of handled words, the array itself and an error.
|
||||
// `calledFromMain` denotes whether the method was called from the outside or
|
||||
|
|
|
@ -78,6 +78,9 @@ func TestCalcHash(t *testing.T) {
|
|||
|
||||
cmd = append(cmd, "--in", nefPath, "--manifest", manifestPath)
|
||||
expected := state.CreateContractHash(sender, nefF.Checksum, manif.Name)
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "something")...)
|
||||
})
|
||||
t.Run("valid, uint160", func(t *testing.T) {
|
||||
e.Run(t, append(cmd, "--sender", sender.StringLE())...)
|
||||
e.checkNextLine(t, expected.StringLE())
|
||||
|
@ -156,6 +159,9 @@ func Blocks() []*alias.Block {
|
|||
"--out", filepath.Join(tmpDir, "out.nef"),
|
||||
"--manifest", manifestPath,
|
||||
"--bindings", bindingsPath)
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(cmd, "something")...)
|
||||
})
|
||||
e.Run(t, cmd...)
|
||||
e.checkEOF(t)
|
||||
require.FileExists(t, bindingsPath)
|
||||
|
@ -220,6 +226,10 @@ func TestContractInitAndCompile(t *testing.T) {
|
|||
})
|
||||
|
||||
ctrPath := filepath.Join(tmpDir, "testcontract")
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "contract", "init", "--name", ctrPath, "something")
|
||||
})
|
||||
|
||||
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
|
||||
|
||||
t.Run("don't rewrite existing directory", func(t *testing.T) {
|
||||
|
@ -263,6 +273,11 @@ func TestContractInitAndCompile(t *testing.T) {
|
|||
require.NoError(t, os.WriteFile(goMod, data, os.ModePerm))
|
||||
|
||||
cmd = append(cmd, "--config", cfgPath)
|
||||
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(cmd, "something")...)
|
||||
})
|
||||
|
||||
e.Run(t, cmd...)
|
||||
e.checkEOF(t)
|
||||
require.FileExists(t, nefPath)
|
||||
|
@ -504,6 +519,10 @@ func TestContractManifestGroups(t *testing.T) {
|
|||
cmd := []string{"neo-go", "contract", "manifest", "add-group",
|
||||
"--nef", nefName, "--manifest", manifestName}
|
||||
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(cmd, "--wallet", testWalletPath,
|
||||
"--sender", testWalletAccount, "--address", testWalletAccount, "something")...)
|
||||
})
|
||||
e.In.WriteString("testpass\r")
|
||||
e.Run(t, append(cmd, "--wallet", testWalletPath,
|
||||
"--sender", testWalletAccount, "--address", testWalletAccount)...)
|
||||
|
@ -916,6 +935,7 @@ func TestContractInspect(t *testing.T) {
|
|||
t.Run("with nef", func(t *testing.T) {
|
||||
e.RunWithError(t, append(cmd, "--in", nefName, "--compile")...)
|
||||
e.RunWithError(t, append(cmd, "--in", filepath.Join(tmpDir, "not.exists"))...)
|
||||
e.RunWithError(t, append(cmd, "--in", nefName, "something")...)
|
||||
e.Run(t, append(cmd, "--in", nefName)...)
|
||||
require.True(t, strings.Contains(e.Out.String(), "SYSCALL"))
|
||||
})
|
||||
|
|
|
@ -38,6 +38,9 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
baseArgs := []string{"neo-go", "db", "restore", "--unittest",
|
||||
"--config-path", tmpDir, "--in", inDump, "--dump", stateDump}
|
||||
|
||||
t.Run("excessive restore parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(baseArgs, "something")...)
|
||||
})
|
||||
// First 15 blocks.
|
||||
e.Run(t, append(baseArgs, "--count", "15")...)
|
||||
|
||||
|
@ -94,6 +97,9 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
t.Run("invalid start/count", func(t *testing.T) {
|
||||
e.RunWithError(t, append(baseCmd, "--start", "5", "--count", strconv.Itoa(50-5+1+1))...)
|
||||
})
|
||||
t.Run("excessive dump parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(baseCmd, "something")...)
|
||||
})
|
||||
|
||||
e.Run(t, baseCmd...)
|
||||
|
||||
|
|
|
@ -148,6 +148,11 @@ func TestSignMultisigTx(t *testing.T) {
|
|||
e.checkEOF(t)
|
||||
})
|
||||
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "util", "txdump",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
txPath, "garbage")
|
||||
})
|
||||
e.Run(t, "neo-go", "util", "txdump",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
txPath)
|
||||
|
|
|
@ -52,6 +52,9 @@ func TestNEP11Import(t *testing.T) {
|
|||
// missing token hash
|
||||
e.RunWithError(t, args...)
|
||||
|
||||
// excessive parameters
|
||||
e.RunWithError(t, append(args, "--token", nnsContractHash.StringLE(), "something")...)
|
||||
|
||||
// good: non-divisible
|
||||
e.Run(t, append(args, "--token", nnsContractHash.StringLE())...)
|
||||
|
||||
|
@ -73,6 +76,10 @@ func TestNEP11Import(t *testing.T) {
|
|||
e.checkNextLine(t, "^Standard:\\s*"+string(manifest.NEP11StandardName))
|
||||
}
|
||||
t.Run("Info", func(t *testing.T) {
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "wallet", "nep11", "info",
|
||||
"--wallet", walletPath, "--token", nnsContractHash.StringLE(), "qwerty")
|
||||
})
|
||||
t.Run("WithToken", func(t *testing.T) {
|
||||
e.Run(t, "neo-go", "wallet", "nep11", "info",
|
||||
"--wallet", walletPath, "--token", nnsContractHash.StringLE())
|
||||
|
@ -88,6 +95,8 @@ func TestNEP11Import(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Remove", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "wallet", "nep11", "remove",
|
||||
"--wallet", walletPath, "--token", nnsContractHash.StringLE(), "parameter")
|
||||
e.In.WriteString("y\r")
|
||||
e.Run(t, "neo-go", "wallet", "nep11", "remove",
|
||||
"--wallet", walletPath, "--token", nnsContractHash.StringLE())
|
||||
|
@ -166,6 +175,8 @@ func TestNEP11_ND_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
|||
}
|
||||
// balance check: by symbol, token is not imported
|
||||
e.RunWithError(t, append(cmdCheckBalance, "--token", "HASHY")...)
|
||||
// balance check: excessive parameters
|
||||
e.RunWithError(t, append(cmdCheckBalance, "--token", h.StringLE(), "neo-go")...)
|
||||
// balance check: by hash, ok
|
||||
e.Run(t, append(cmdCheckBalance, "--token", h.StringLE())...)
|
||||
checkBalanceResult(t, nftOwnerAddr, "1")
|
||||
|
@ -256,6 +267,8 @@ func TestNEP11_ND_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
|||
e.RunWithError(t, cmdTokens...)
|
||||
cmdTokens = append(cmdTokens, "--token", h.StringLE())
|
||||
|
||||
// tokens: excessive parameters
|
||||
e.RunWithError(t, append(cmdTokens, "additional")...)
|
||||
// tokens: good, several tokens
|
||||
e.Run(t, cmdTokens...)
|
||||
require.Equal(t, hex.EncodeToString(fst), e.getNextLine(t))
|
||||
|
@ -482,6 +495,9 @@ func TestNEP11_D_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
|||
e.RunWithError(t, cmdProperties...)
|
||||
cmdProperties = append(cmdProperties, "--id", hex.EncodeToString(token2ID))
|
||||
|
||||
// properties: additional parameter
|
||||
e.RunWithError(t, append(cmdProperties, "additiona")...)
|
||||
|
||||
// properties: ok
|
||||
e.Run(t, cmdProperties...)
|
||||
jProps = e.getNextLine(t)
|
||||
|
|
|
@ -24,6 +24,9 @@ func TestNEP17Balance(t *testing.T) {
|
|||
"--wallet", validatorWallet,
|
||||
)
|
||||
cmd := append(cmdbase, "--address", validatorAddr)
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(cmd, "--token", "NEO", "gas")...)
|
||||
})
|
||||
t.Run("NEO", func(t *testing.T) {
|
||||
b, index := e.Chain.GetGoverningTokenBalance(validatorHash)
|
||||
checkResult := func(t *testing.T) {
|
||||
|
@ -321,6 +324,11 @@ func TestNEP17ImportToken(t *testing.T) {
|
|||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath)
|
||||
|
||||
// additional parameter
|
||||
e.RunWithError(t, "neo-go", "wallet", "nep17", "import",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath,
|
||||
"--token", gasContractHash.StringLE(), "useless")
|
||||
e.Run(t, "neo-go", "wallet", "nep17", "import",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath,
|
||||
|
@ -345,6 +353,10 @@ func TestNEP17ImportToken(t *testing.T) {
|
|||
e.checkNextLine(t, "^Address:\\s*"+address.Uint160ToString(gasContractHash))
|
||||
e.checkNextLine(t, "^Standard:\\s*"+string(manifest.NEP17StandardName))
|
||||
}
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "wallet", "nep17", "info",
|
||||
"--wallet", walletPath, "--token", gasContractHash.StringLE(), "parameter")
|
||||
})
|
||||
t.Run("WithToken", func(t *testing.T) {
|
||||
e.Run(t, "neo-go", "wallet", "nep17", "info",
|
||||
"--wallet", walletPath, "--token", gasContractHash.StringLE())
|
||||
|
@ -364,6 +376,8 @@ func TestNEP17ImportToken(t *testing.T) {
|
|||
e.checkNextLine(t, "^Standard:\\s*"+string(manifest.NEP17StandardName))
|
||||
})
|
||||
t.Run("Remove", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "wallet", "nep17", "remove",
|
||||
"--wallet", walletPath, "--token", neoContractHash.StringLE(), "add")
|
||||
e.In.WriteString("y\r")
|
||||
e.Run(t, "neo-go", "wallet", "nep17", "remove",
|
||||
"--wallet", walletPath, "--token", neoContractHash.StringLE())
|
||||
|
|
|
@ -23,9 +23,9 @@ const RPCEndpointFlag = "rpc-endpoint"
|
|||
// Network is a set of flags for choosing the network to operate on
|
||||
// (privnet/mainnet/testnet).
|
||||
var Network = []cli.Flag{
|
||||
cli.BoolFlag{Name: "privnet, p"},
|
||||
cli.BoolFlag{Name: "mainnet, m"},
|
||||
cli.BoolFlag{Name: "testnet, t"},
|
||||
cli.BoolFlag{Name: "privnet, p", Usage: "use private network configuration"},
|
||||
cli.BoolFlag{Name: "mainnet, m", Usage: "use mainnet network configuration"},
|
||||
cli.BoolFlag{Name: "testnet, t", Usage: "use testnet network configuration"},
|
||||
cli.BoolFlag{Name: "unittest", Hidden: true},
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||
|
@ -41,31 +42,35 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "candidates",
|
||||
Usage: "Get candidates and votes",
|
||||
UsageText: "neo-go query candidates -r endpoint [-s timeout]",
|
||||
Action: queryCandidates,
|
||||
Flags: options.RPC,
|
||||
},
|
||||
{
|
||||
Name: "committee",
|
||||
Usage: "Get committee list",
|
||||
UsageText: "neo-go query committee -r endpoint [-s timeout]",
|
||||
Action: queryCommittee,
|
||||
Flags: options.RPC,
|
||||
},
|
||||
{
|
||||
Name: "height",
|
||||
Usage: "Get node height",
|
||||
UsageText: "neo-go query height -r endpoint [-s timeout]",
|
||||
Action: queryHeight,
|
||||
Flags: options.RPC,
|
||||
},
|
||||
{
|
||||
Name: "tx",
|
||||
Usage: "Query transaction status",
|
||||
UsageText: "neo-go query tx <hash> -r endpoint [-v]",
|
||||
UsageText: "neo-go query tx <hash> -r endpoint [-s timeout] [-v]",
|
||||
Action: queryTx,
|
||||
Flags: queryTxFlags,
|
||||
},
|
||||
{
|
||||
Name: "voter",
|
||||
Usage: "Print NEO holder account state",
|
||||
UsageText: "neo-go query voter <address> -r endpoint [-s timeout]",
|
||||
Action: queryVoter,
|
||||
Flags: options.RPC,
|
||||
},
|
||||
|
@ -77,6 +82,8 @@ func queryTx(ctx *cli.Context) error {
|
|||
args := ctx.Args()
|
||||
if len(args) == 0 {
|
||||
return cli.NewExitError("Transaction hash is missing", 1)
|
||||
} else if len(args) > 1 {
|
||||
return cli.NewExitError("only one transaction hash is accepted", 1)
|
||||
}
|
||||
|
||||
txHash, err := util.Uint256DecodeStringLE(strings.TrimPrefix(args[0], "0x"))
|
||||
|
@ -160,6 +167,10 @@ func DumpApplicationLog(
|
|||
func queryCandidates(ctx *cli.Context) error {
|
||||
var err error
|
||||
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gctx, cancel := options.GetTimeoutContext(ctx)
|
||||
defer cancel()
|
||||
|
||||
|
@ -200,6 +211,10 @@ func queryCandidates(ctx *cli.Context) error {
|
|||
func queryCommittee(ctx *cli.Context) error {
|
||||
var err error
|
||||
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gctx, cancel := options.GetTimeoutContext(ctx)
|
||||
defer cancel()
|
||||
|
||||
|
@ -222,6 +237,10 @@ func queryCommittee(ctx *cli.Context) error {
|
|||
func queryHeight(ctx *cli.Context) error {
|
||||
var err error
|
||||
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gctx, cancel := options.GetTimeoutContext(ctx)
|
||||
defer cancel()
|
||||
|
||||
|
@ -250,6 +269,8 @@ func queryVoter(ctx *cli.Context) error {
|
|||
args := ctx.Args()
|
||||
if len(args) == 0 {
|
||||
return cli.NewExitError("No address specified", 1)
|
||||
} else if len(args) > 1 {
|
||||
return cli.NewExitError("this command only accepts one address", 1)
|
||||
}
|
||||
|
||||
addr, err := flags.ParseAddress(args[0])
|
||||
|
|
|
@ -101,6 +101,9 @@ func TestQueryTx(t *testing.T) {
|
|||
t.Run("missing tx argument", func(t *testing.T) {
|
||||
e.RunWithError(t, args...)
|
||||
})
|
||||
t.Run("excessive arguments", func(t *testing.T) {
|
||||
e.RunWithError(t, append(args, txHash.StringLE(), txHash.StringLE())...)
|
||||
})
|
||||
t.Run("invalid hash", func(t *testing.T) {
|
||||
e.RunWithError(t, append(args, "notahash")...)
|
||||
})
|
||||
|
@ -142,8 +145,12 @@ func (e *executor) compareQueryTxVerbose(t *testing.T, tx *transaction.Transacti
|
|||
func TestQueryHeight(t *testing.T) {
|
||||
e := newExecutor(t, true)
|
||||
|
||||
e.Run(t, "neo-go", "query", "height", "--rpc-endpoint", "http://"+e.RPC.Addr)
|
||||
args := []string{"neo-go", "query", "height", "--rpc-endpoint", "http://" + e.RPC.Addr}
|
||||
e.Run(t, args...)
|
||||
e.checkNextLine(t, `^Latest block: [0-9]+$`)
|
||||
e.checkNextLine(t, `^Validated state: [0-9]+$`)
|
||||
e.checkEOF(t)
|
||||
t.Run("excessive arguments", func(t *testing.T) {
|
||||
e.RunWithError(t, append(args, "something")...)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
|
@ -42,12 +43,13 @@ var (
|
|||
// NewCommands returns 'node' command.
|
||||
func NewCommands() []cli.Command {
|
||||
var cfgFlags = []cli.Flag{
|
||||
cli.StringFlag{Name: "config-path"},
|
||||
cli.BoolFlag{Name: "debug, d"},
|
||||
cli.StringFlag{Name: "config-path", Usage: "path to directory with configuration files"},
|
||||
}
|
||||
cfgFlags = append(cfgFlags, options.Network...)
|
||||
var cfgWithCountFlags = make([]cli.Flag, len(cfgFlags))
|
||||
copy(cfgWithCountFlags, cfgFlags)
|
||||
cfgFlags = append(cfgFlags, cli.BoolFlag{Name: "debug, d", Usage: "enable debug logging (LOTS of output)"})
|
||||
|
||||
cfgWithCountFlags = append(cfgWithCountFlags,
|
||||
cli.UintFlag{
|
||||
Name: "count, c",
|
||||
|
@ -86,6 +88,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "node",
|
||||
Usage: "start a NEO node",
|
||||
UsageText: "neo-go node [--config-path path] [-d] [-p/-m/-t]",
|
||||
Action: startServer,
|
||||
Flags: cfgFlags,
|
||||
},
|
||||
|
@ -96,12 +99,14 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "dump",
|
||||
Usage: "dump blocks (starting with block #1) to the file",
|
||||
UsageText: "neo-go db dump -o file [-s start] [-c count] [--config-path path] [-p/-m/-t]",
|
||||
Action: dumpDB,
|
||||
Flags: cfgCountOutFlags,
|
||||
},
|
||||
{
|
||||
Name: "restore",
|
||||
Usage: "restore blocks from the file",
|
||||
UsageText: "neo-go db restore -i file [--dump] [-n] [-c count] [--config-path path] [-p/-m/-t]",
|
||||
Action: restoreDB,
|
||||
Flags: cfgCountInFlags,
|
||||
},
|
||||
|
@ -223,6 +228,9 @@ func initBCWithMetrics(cfg config.Config, log *zap.Logger) (*core.Blockchain, *m
|
|||
}
|
||||
|
||||
func dumpDB(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
cfg, err := getConfigFromContext(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -273,6 +281,9 @@ func dumpDB(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func restoreDB(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
cfg, err := getConfigFromContext(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -455,6 +466,10 @@ func mkP2PNotary(config config.P2PNotary, chain *core.Blockchain, serv *network.
|
|||
}
|
||||
|
||||
func startServer(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg, err := getConfigFromContext(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
|
|
@ -98,9 +98,11 @@ func TestServerStart(t *testing.T) {
|
|||
// We can't properly shutdown server on windows and release the resources.
|
||||
// Also, windows doesn't support SIGHUP and SIGINT.
|
||||
if runtime.GOOS != "windows" {
|
||||
t.Run("good", func(t *testing.T) {
|
||||
saveCfg(t, func(cfg *config.Config) {})
|
||||
|
||||
t.Run("excessive parameters", func(t *testing.T) {
|
||||
e.RunWithError(t, append(baseCmd, "something")...)
|
||||
})
|
||||
t.Run("good", func(t *testing.T) {
|
||||
go func() {
|
||||
e.Run(t, baseCmd...)
|
||||
}()
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/urfave/cli"
|
||||
|
@ -39,6 +40,9 @@ var generateWrapperCmd = cli.Command{
|
|||
|
||||
// contractGenerateWrapper deploys contract.
|
||||
func contractGenerateWrapper(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
m, _, err := readManifest(ctx.String("manifest"))
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("can't read contract manifest: %w", err), 1)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
|
@ -14,6 +15,9 @@ import (
|
|||
)
|
||||
|
||||
func manifestAddGroup(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
sender, err := flags.ParseAddress(ctx.String("sender"))
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("invalid sender: %w", err), 1)
|
||||
|
|
|
@ -138,6 +138,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "compile",
|
||||
Usage: "compile a smart contract to a .nef file",
|
||||
UsageText: "neo-go contract compile -i path [-o nef] [-v] [-d] [-m manifest] [-c yaml] [--bindings file] [--no-standards] [--no-events] [--no-permissions]",
|
||||
Action: contractCompile,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
|
@ -342,6 +343,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "init",
|
||||
Usage: "initialize a new smart-contract in a directory with boiler plate code",
|
||||
UsageText: "neo-go contract init -n name [--skip-details]",
|
||||
Action: initSmartContract,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
|
@ -357,6 +359,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "inspect",
|
||||
Usage: "creates a user readable dump of the program instructions",
|
||||
UsageText: "neo-go contract inspect -i file [-c]",
|
||||
Action: inspect,
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
|
@ -372,6 +375,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "calc-hash",
|
||||
Usage: "calculates hash of a contract after deployment",
|
||||
UsageText: "neo-go contract calc-hash -i nef -m manifest -s address",
|
||||
Action: calcHash,
|
||||
Flags: []cli.Flag{
|
||||
flags.AddressFlag{
|
||||
|
@ -395,6 +399,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "add-group",
|
||||
Usage: "adds group to the manifest",
|
||||
UsageText: "neo-go contract manifest add-group -w wallet [--wallet-config path] -n nef -m manifest -a address -s address",
|
||||
Action: manifestAddGroup,
|
||||
Flags: []cli.Flag{
|
||||
walletFlag,
|
||||
|
@ -425,6 +430,9 @@ func NewCommands() []cli.Command {
|
|||
|
||||
// initSmartContract initializes a given directory with some boiler plate code.
|
||||
func initSmartContract(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
contractName := ctx.String("name")
|
||||
if contractName == "" {
|
||||
return cli.NewExitError(errNoSmartContractName, 1)
|
||||
|
@ -494,6 +502,9 @@ require (
|
|||
}
|
||||
|
||||
func contractCompile(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
src := ctx.String("in")
|
||||
if len(src) == 0 {
|
||||
return cli.NewExitError(errNoInput, 1)
|
||||
|
@ -546,6 +557,9 @@ func contractCompile(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func calcHash(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
sender := ctx.Generic("sender").(*flags.Address)
|
||||
if !sender.IsSet {
|
||||
return cli.NewExitError("sender is not set", 1)
|
||||
|
@ -798,6 +812,9 @@ type ProjectConfig struct {
|
|||
}
|
||||
|
||||
func inspect(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
in := ctx.String("in")
|
||||
compile := ctx.Bool("compile")
|
||||
if len(in) == 0 {
|
||||
|
|
|
@ -12,11 +12,14 @@ import (
|
|||
)
|
||||
|
||||
func txDump(ctx *cli.Context) error {
|
||||
if len(ctx.Args()) == 0 {
|
||||
args := ctx.Args()
|
||||
if len(args) == 0 {
|
||||
return cli.NewExitError("missing input file", 1)
|
||||
} else if len(args) > 1 {
|
||||
return cli.NewExitError("only one input file is accepted", 1)
|
||||
}
|
||||
|
||||
c, err := paramcontext.Read(ctx.Args()[0])
|
||||
c, err := paramcontext.Read(args[0])
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/chzyer/readline"
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
vmcli "github.com/nspcc-dev/neo-go/pkg/vm/cli"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -21,6 +22,9 @@ func NewCommands() []cli.Command {
|
|||
}
|
||||
|
||||
func startVMPrompt(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
p := vmcli.NewWithConfig(true, os.Exit, &readline.Config{})
|
||||
return p.Run()
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package wallet
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
"github.com/nspcc-dev/neo-go/cli/paramcontext"
|
||||
|
@ -12,6 +13,9 @@ import (
|
|||
)
|
||||
|
||||
func signStoredTransaction(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/input"
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
|
@ -47,21 +48,21 @@ func newNEP11Commands() []cli.Command {
|
|||
{
|
||||
Name: "balance",
|
||||
Usage: "get address balance",
|
||||
UsageText: "balance --wallet <path> --rpc-endpoint <node> [--timeout <time>] [--address <address>] --token <hash-or-name> [--id <token-id>]",
|
||||
UsageText: "balance -w wallet [--wallet-config path] --rpc-endpoint <node> [--timeout <time>] [--address <address>] --token <hash-or-name> [--id <token-id>]",
|
||||
Action: getNEP11Balance,
|
||||
Flags: balanceFlags,
|
||||
},
|
||||
{
|
||||
Name: "import",
|
||||
Usage: "import NEP-11 token to a wallet",
|
||||
UsageText: "import --wallet <path> --rpc-endpoint <node> --timeout <time> --token <hash>",
|
||||
UsageText: "import -w wallet [--wallet-config path] --rpc-endpoint <node> --timeout <time> --token <hash>",
|
||||
Action: importNEP11Token,
|
||||
Flags: importFlags,
|
||||
},
|
||||
{
|
||||
Name: "info",
|
||||
Usage: "print imported NEP-11 token info",
|
||||
UsageText: "print --wallet <path> [--token <hash-or-name>]",
|
||||
UsageText: "print -w wallet [--wallet-config path] [--token <hash-or-name>]",
|
||||
Action: printNEP11Info,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -72,7 +73,7 @@ func newNEP11Commands() []cli.Command {
|
|||
{
|
||||
Name: "remove",
|
||||
Usage: "remove NEP-11 token from the wallet",
|
||||
UsageText: "remove --wallet <path> --token <hash-or-name>",
|
||||
UsageText: "remove -w wallet [--wallet-config path] --token <hash-or-name>",
|
||||
Action: removeNEP11Token,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -84,7 +85,7 @@ func newNEP11Commands() []cli.Command {
|
|||
{
|
||||
Name: "transfer",
|
||||
Usage: "transfer NEP-11 tokens",
|
||||
UsageText: "transfer --wallet <path> --rpc-endpoint <node> --timeout <time> --from <addr> --to <addr> --token <hash-or-name> --id <token-id> [--amount string] [data] [-- <cosigner1:Scope> [<cosigner2> [...]]]",
|
||||
UsageText: "transfer -w wallet [--wallet-config path] --rpc-endpoint <node> --timeout <time> --from <addr> --to <addr> --token <hash-or-name> --id <token-id> [--amount string] [data] [-- <cosigner1:Scope> [<cosigner2> [...]]]",
|
||||
Action: transferNEP11,
|
||||
Flags: transferFlags,
|
||||
Description: `Transfers specified NEP-11 token with optional cosigners list attached to
|
||||
|
@ -163,6 +164,10 @@ func removeNEP11Token(ctx *cli.Context) error {
|
|||
func getNEP11Balance(ctx *cli.Context) error {
|
||||
var accounts []*wallet.Account
|
||||
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
wall, _, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("bad wallet: %w", err), 1)
|
||||
|
@ -309,6 +314,9 @@ func printNEP11DOwner(ctx *cli.Context) error {
|
|||
|
||||
func printNEP11Owner(ctx *cli.Context, divisible bool) error {
|
||||
var err error
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
tokenHash := ctx.Generic("token").(*flags.Address)
|
||||
if !tokenHash.IsSet {
|
||||
return cli.NewExitError("token contract hash was not set", 1)
|
||||
|
@ -383,6 +391,9 @@ func printNEP11TokensOf(ctx *cli.Context) error {
|
|||
|
||||
func printNEP11Tokens(ctx *cli.Context) error {
|
||||
var err error
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
tokenHash := ctx.Generic("token").(*flags.Address)
|
||||
if !tokenHash.IsSet {
|
||||
return cli.NewExitError("token contract hash was not set", 1)
|
||||
|
@ -409,6 +420,9 @@ func printNEP11Tokens(ctx *cli.Context) error {
|
|||
|
||||
func printNEP11Properties(ctx *cli.Context) error {
|
||||
var err error
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
tokenHash := ctx.Generic("token").(*flags.Address)
|
||||
if !tokenHash.IsSet {
|
||||
return cli.NewExitError("token contract hash was not set", 1)
|
||||
|
|
|
@ -90,21 +90,21 @@ func newNEP17Commands() []cli.Command {
|
|||
{
|
||||
Name: "balance",
|
||||
Usage: "get address balance",
|
||||
UsageText: "balance --wallet <path> --rpc-endpoint <node> [--timeout <time>] [--address <address>] [--token <hash-or-name>]",
|
||||
UsageText: "balance -w wallet [--wallet-config path] --rpc-endpoint <node> [--timeout <time>] [--address <address>] [--token <hash-or-name>]",
|
||||
Action: getNEP17Balance,
|
||||
Flags: balanceFlags,
|
||||
},
|
||||
{
|
||||
Name: "import",
|
||||
Usage: "import NEP-17 token to a wallet",
|
||||
UsageText: "import --wallet <path> --rpc-endpoint <node> --timeout <time> --token <hash>",
|
||||
UsageText: "import -w wallet [--wallet-config path] --rpc-endpoint <node> --timeout <time> --token <hash>",
|
||||
Action: importNEP17Token,
|
||||
Flags: importFlags,
|
||||
},
|
||||
{
|
||||
Name: "info",
|
||||
Usage: "print imported NEP-17 token info",
|
||||
UsageText: "print --wallet <path> [--token <hash-or-name>]",
|
||||
UsageText: "print -w wallet [--wallet-config path] [--token <hash-or-name>]",
|
||||
Action: printNEP17Info,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -115,7 +115,7 @@ func newNEP17Commands() []cli.Command {
|
|||
{
|
||||
Name: "remove",
|
||||
Usage: "remove NEP-17 token from the wallet",
|
||||
UsageText: "remove --wallet <path> --token <hash-or-name>",
|
||||
UsageText: "remove -w wallet [--wallet-config path] --token <hash-or-name>",
|
||||
Action: removeNEP17Token,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -127,7 +127,7 @@ func newNEP17Commands() []cli.Command {
|
|||
{
|
||||
Name: "transfer",
|
||||
Usage: "transfer NEP-17 tokens",
|
||||
UsageText: "transfer --wallet <path> --rpc-endpoint <node> --timeout <time> --from <addr> --to <addr> --token <hash-or-name> --amount string [data] [-- <cosigner1:Scope> [<cosigner2> [...]]]",
|
||||
UsageText: "transfer -w wallet [--wallet-config path] --rpc-endpoint <node> --timeout <time> --from <addr> --to <addr> --token <hash-or-name> --amount string [data] [-- <cosigner1:Scope> [<cosigner2> [...]]]",
|
||||
Action: transferNEP17,
|
||||
Flags: transferFlags,
|
||||
Description: `Transfers specified NEP-17 token amount with optional 'data' parameter and cosigners
|
||||
|
@ -140,7 +140,7 @@ func newNEP17Commands() []cli.Command {
|
|||
{
|
||||
Name: "multitransfer",
|
||||
Usage: "transfer NEP-17 tokens to multiple recipients",
|
||||
UsageText: `multitransfer --wallet <path> --rpc-endpoint <node> --timeout <time> --from <addr>` +
|
||||
UsageText: `multitransfer -w wallet [--wallet-config path] --rpc-endpoint <node> --timeout <time> --from <addr>` +
|
||||
` <token1>:<addr1>:<amount1> [<token2>:<addr2>:<amount2> [...]] [-- <cosigner1:Scope> [<cosigner2> [...]]]`,
|
||||
Action: multiTransferNEP17,
|
||||
Flags: multiTransferFlags,
|
||||
|
@ -151,6 +151,9 @@ func newNEP17Commands() []cli.Command {
|
|||
func getNEP17Balance(ctx *cli.Context) error {
|
||||
var accounts []*wallet.Account
|
||||
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("bad wallet: %w", err), 1)
|
||||
|
@ -349,6 +352,9 @@ func importNEP17Token(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func importNEPToken(ctx *cli.Context, standard string) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := openWallet(ctx, true)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -411,6 +417,9 @@ func printNEP17Info(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func printNEPInfo(ctx *cli.Context, standard string) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -443,6 +452,9 @@ func removeNEP17Token(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func removeNEPToken(ctx *cli.Context, standard string) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := openWallet(ctx, true)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
|
|
@ -3,6 +3,7 @@ package wallet
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/input"
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
|
@ -83,6 +84,9 @@ func handleUnregister(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -138,6 +142,9 @@ func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
|
|||
}
|
||||
|
||||
func handleVote(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/input"
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
|
@ -111,12 +112,14 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "claim",
|
||||
Usage: "claim GAS",
|
||||
UsageText: "neo-go wallet claim -w wallet [--wallet-config path] -a address -r endpoint [-s timeout]",
|
||||
Action: claimGas,
|
||||
Flags: claimFlags,
|
||||
},
|
||||
{
|
||||
Name: "init",
|
||||
Usage: "create a new wallet",
|
||||
UsageText: "neo-go wallet init -w wallet [--wallet-config path] [-a]",
|
||||
Action: createWallet,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -130,6 +133,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "change-password",
|
||||
Usage: "change password for accounts",
|
||||
UsageText: "neo-go wallet change-password -w wallet -a address",
|
||||
Action: changePassword,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -142,6 +146,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "convert",
|
||||
Usage: "convert addresses from existing NEO2 NEP6-wallet to NEO3 format",
|
||||
UsageText: "neo-go wallet convert -w legacywallet [--wallet-config path] -o n3wallet",
|
||||
Action: convertWallet,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -155,6 +160,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "create",
|
||||
Usage: "add an account to the existing wallet",
|
||||
UsageText: "neo-go wallet create -w wallet [--wallet-config path]",
|
||||
Action: addAccount,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -164,6 +170,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "dump",
|
||||
Usage: "check and dump an existing NEO wallet",
|
||||
UsageText: "neo-go wallet dump -w wallet [--wallet-config path] [-d]",
|
||||
Action: dumpWallet,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -174,6 +181,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "dump-keys",
|
||||
Usage: "dump public keys for account",
|
||||
UsageText: "neo-go wallet dump-keys -w wallet [--wallet-config path] [-a address]",
|
||||
Action: dumpKeys,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -187,7 +195,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "export",
|
||||
Usage: "export keys for address",
|
||||
UsageText: "export --wallet <path> [--decrypt] [<address>]",
|
||||
UsageText: "export -w wallet [--wallet-config path] [--decrypt] [<address>]",
|
||||
Action: exportKeys,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -198,7 +206,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "import",
|
||||
Usage: "import WIF of a standard signature contract",
|
||||
UsageText: "import --wallet <path> --wif <wif> [--name <account_name>]",
|
||||
UsageText: "import -w wallet [--wallet-config path] --wif <wif> [--name <account_name>]",
|
||||
Action: importWallet,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -217,7 +225,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "import-multisig",
|
||||
Usage: "import multisig contract",
|
||||
UsageText: "import-multisig --wallet <path> --wif <wif> [--name <account_name>] --min <n>" +
|
||||
UsageText: "import-multisig -w wallet [--wallet-config path] --wif <wif> [--name <account_name>] --min <n>" +
|
||||
" [<pubkey1> [<pubkey2> [...]]]",
|
||||
Action: importMultisig,
|
||||
Flags: []cli.Flag{
|
||||
|
@ -237,7 +245,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "import-deployed",
|
||||
Usage: "import deployed contract",
|
||||
UsageText: "import-deployed --wallet <path> --wif <wif> --contract <hash> [--name <account_name>]",
|
||||
UsageText: "import-deployed -w wallet [--wallet-config path] --wif <wif> --contract <hash> [--name <account_name>]",
|
||||
Action: importDeployed,
|
||||
Flags: append([]cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -256,7 +264,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "remove",
|
||||
Usage: "remove an account from the wallet",
|
||||
UsageText: "remove --wallet <path> [--force] --address <addr>",
|
||||
UsageText: "remove -w wallet [--wallet-config path] [--force] --address <addr>",
|
||||
Action: removeAccount,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
|
@ -271,7 +279,7 @@ func NewCommands() []cli.Command {
|
|||
{
|
||||
Name: "sign",
|
||||
Usage: "cosign transaction with multisig/contract/additional account",
|
||||
UsageText: "sign --wallet <path> --address <address> --in <file.in> --out <file.out> [-r <endpoint>]",
|
||||
UsageText: "sign -w wallet [--wallet-config path] --address <address> --in <file.in> --out <file.out> [-r <endpoint>]",
|
||||
Action: signStoredTransaction,
|
||||
Flags: signFlags,
|
||||
},
|
||||
|
@ -295,6 +303,9 @@ func NewCommands() []cli.Command {
|
|||
}
|
||||
|
||||
func claimGas(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -332,6 +343,9 @@ func claimGas(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func changePassword(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := openWallet(ctx, false)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -384,6 +398,9 @@ func changePassword(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func convertWallet(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := newWalletV2FromFile(ctx.String("wallet"), ctx.String("wallet-config"))
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -421,6 +438,9 @@ func convertWallet(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func addAccount(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := openWallet(ctx, true)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -535,6 +555,9 @@ func importMultisig(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func importDeployed(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := openWallet(ctx, true)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -588,6 +611,9 @@ func importDeployed(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func importWallet(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := openWallet(ctx, true)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -617,6 +643,9 @@ func importWallet(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func removeAccount(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := openWallet(ctx, true)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -660,6 +689,9 @@ func askForConsent(w io.Writer) bool {
|
|||
}
|
||||
|
||||
func dumpWallet(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, pass, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -685,6 +717,9 @@ func dumpWallet(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func dumpKeys(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
wall, _, err := readWallet(ctx)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
@ -732,6 +767,9 @@ func dumpKeys(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func createWallet(ctx *cli.Context) error {
|
||||
if err := cmdargs.EnsureNone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
path := ctx.String("wallet")
|
||||
configPath := ctx.String("wallet-config")
|
||||
|
||||
|
|
Loading…
Reference in a new issue