package wallet import ( "encoding/hex" "errors" "fmt" "math/big" "strings" "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/txctx" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient/actor" "github.com/nspcc-dev/neo-go/pkg/rpcclient/gas" "github.com/nspcc-dev/neo-go/pkg/rpcclient/neo" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17" "github.com/nspcc-dev/neo-go/pkg/rpcclient/neptoken" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/urfave/cli/v2" ) // transferTarget represents target address, token amount and data for transfer. type transferTarget struct { Token util.Uint160 Address util.Uint160 Amount int64 Data any } var ( tokenFlag = &cli.StringFlag{ Name: "token", Usage: "Token to use (hash or name (for NEO/GAS or imported tokens))", } baseBalanceFlags = []cli.Flag{ walletPathFlag, walletConfigFlag, tokenFlag, &flags.AddressFlag{ Name: "address", Aliases: []string{"a"}, Usage: "Address to use", }, } importFlags = append([]cli.Flag{ walletPathFlag, walletConfigFlag, &flags.AddressFlag{ Name: "token", Usage: "Token contract address or hash in LE", Required: true, }, }, options.RPC...) baseTransferFlags = []cli.Flag{ walletPathFlag, walletConfigFlag, txctx.OutFlag, fromAddrFlag, toAddrFlag, tokenFlag, txctx.GasFlag, txctx.SysGasFlag, txctx.ForceFlag, txctx.AwaitFlag, &cli.StringFlag{ Name: "amount", Usage: "Amount of asset to send", }, } multiTransferFlags = append([]cli.Flag{ walletPathFlag, walletConfigFlag, txctx.OutFlag, fromAddrFlag, txctx.GasFlag, txctx.SysGasFlag, txctx.ForceFlag, txctx.AwaitFlag, }, options.RPC...) ) func newNEP17Commands() []*cli.Command { balanceFlags := make([]cli.Flag, len(baseBalanceFlags)) copy(balanceFlags, baseBalanceFlags) balanceFlags = append(balanceFlags, options.RPC...) transferFlags := make([]cli.Flag, len(baseTransferFlags)) copy(transferFlags, baseTransferFlags) transferFlags = append(transferFlags, options.RPC...) return []*cli.Command{ { Name: "balance", Usage: "Get address balance", UsageText: "balance -w wallet [--wallet-config path] --rpc-endpoint [--timeout