cmd

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2018 License: LGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	AppHelpTemplate = `` /* 800-byte string literal not displayed */

	CommandHelpTemplate = `` /* 577-byte string literal not displayed */

)

AppHelpTemplate is the test template for the default, global app help topic.

View Source
var (
	AccountCommand = cli.Command{
		Action:    cli.ShowSubcommandHelp,
		Name:      "account",
		Usage:     "Manage accounts",
		ArgsUsage: "[arguments...]",
		Description: `Wallet management commands can be used to add, view, modify, delete, import account, and so on.
You can use ./Ontology account --help command to view help information of wallet management command.`,
		Subcommands: []cli.Command{
			{
				Action:    accountCreate,
				Name:      "add",
				Usage:     "Add a new account",
				ArgsUsage: "[sub-command options]",
				Flags: []cli.Flag{
					utils.AccountQuantityFlag,
					utils.AccountTypeFlag,
					utils.AccountKeylenFlag,
					utils.AccountSigSchemeFlag,
					utils.AccountDefaultFlag,
					utils.AccountLabelFlag,
					utils.IdentityFlag,
					utils.WalletFileFlag,
				},
				Description: ` Add a new account to wallet.
   Ontology support three type of key: ecdsa, sm2 and ed25519, and support 224、256、384、521 bits length of key in ecdsa, but only support 256 bits length of key in sm2 and ed25519.
   Ontology support multiple signature scheme.
   For ECDSA support SHA224withECDSA、SHA256withECDSA、SHA384withECDSA、SHA512withEdDSA、SHA3-224withECDSA、SHA3-256withECDSA、SHA3-384withECDSA、SHA3-512withECDSA、RIPEMD160withECDSA;
   For SM2 support SM3withSM2, and for SHA512withEdDSA.
   -------------------------------------------------
      Key   |key-length(bits)|  signature-scheme
   ---------|----------------|----------------------
   1 ecdsa  |  1 P-224: 224  | 1 SHA224withECDSA
            |----------------|----------------------
            |  2 P-256: 256  | 2 SHA256withECDSA
            |----------------|----------------------
            |  3 P-384: 384  | 3 SHA384withECDSA
            |----------------|----------------------
            |  4 P-521: 521  | 4 SHA512withEdDSA
            |----------------|----------------------
            |                | 5 SHA3-224withECDSA
            |                |----------------------
            |                | 6 SHA3-256withECDSA
            |                |----------------------
            |                | 7 SHA3-384withECDSA
            |                |----------------------
            |                | 8 SHA3-512withECDSA
            |                |----------------------
            |                | 9 RIPEMD160withECDSA
   ---------|----------------|----------------------
   2 sm2    | sm2p256v1 256  | SM3withSM2
   ---------|----------------|----------------------
   3 ed25519|   25519 256    | SHA512withEdDSA
   -------------------------------------------------`,
			},
			{
				Action:    accountList,
				Name:      "list",
				Usage:     "List existing accounts",
				ArgsUsage: "[sub-command options] <label|address|index>",
				Flags: []cli.Flag{
					utils.WalletFileFlag,
					utils.AccountVerboseFlag,
				},
				Description: `List existing accounts. If specified in args, will list those account. If not specified in args, will list all accouns in wallet`,
			},
			{
				Action:    accountSet,
				Name:      "set",
				Usage:     "Modify an account",
				ArgsUsage: "[sub-command options] <label|address|index>",
				Flags: []cli.Flag{
					utils.AccountSetDefaultFlag,
					utils.WalletFileFlag,
					utils.AccountLabelFlag,
					utils.AccountChangePasswdFlag,
					utils.AccountSigSchemeFlag,
				},
				Description: `Modify settings for an account. Account is specified by address, label of index. Index start from 1. This can be showed by the 'list' command.`,
			},
			{
				Action:    accountDelete,
				Name:      "del",
				Usage:     "Delete an account",
				ArgsUsage: "[sub-command options] <address|label|index>",
				Flags: []cli.Flag{
					utils.WalletFileFlag,
				},
				Description: `Delete an account specified by address, label of index. Index start from 1. This can be showed by the 'list' command`,
			},
			{
				Action:    accountImport,
				Name:      "import",
				Usage:     "Import accounts of wallet to another",
				ArgsUsage: "[sub-command options] <address|label|index>",
				Flags: []cli.Flag{
					utils.WalletFileFlag,
					utils.AccountSourceFileFlag,
					utils.AccountWIFFlag,
				},
				Description: "Import accounts of wallet to another. If not specific accounts in args, all account in source will be import",
			},
			{
				Action:    accountExport,
				Name:      "export",
				Usage:     "Export accounts to a specified wallet file",
				ArgsUsage: "[sub-command options] <filename>",
				Flags: []cli.Flag{
					utils.WalletFileFlag,
					utils.AccountLowSecurityFlag,
				},
			},
			{
				Action:    genMultiAddress,
				Name:      "multisigaddr",
				Usage:     "Gen multi-signature address",
				ArgsUsage: "",
				Flags: []cli.Flag{
					utils.WalletFileFlag,
					utils.AccountMultiMFlag,
					utils.AccountMultiPubKeyFlag,
				},
			},
		},
	}
)
View Source
var AppHelpFlagGroups = []flagGroup{
	{
		Name: "ONTOLOGY",
		Flags: []cli.Flag{
			utils.ConfigFlag,
			utils.LogLevelFlag,
			utils.DisableEventLogFlag,
			utils.DataDirFlag,
			utils.ImportEnableFlag,
			utils.ImportHeightFlag,
			utils.ImportFileFlag,
		},
	},
	{
		Name: "ACCOUNT",
		Flags: []cli.Flag{
			utils.WalletFileFlag,
			utils.AccountAddressFlag,
			utils.AccountPassFlag,
			utils.AccountDefaultFlag,
			utils.AccountKeylenFlag,
			utils.AccountSetDefaultFlag,
			utils.AccountSigSchemeFlag,
			utils.AccountTypeFlag,
			utils.AccountVerboseFlag,
			utils.AccountLabelFlag,
			utils.AccountQuantityFlag,
			utils.AccountChangePasswdFlag,
			utils.AccountSourceFileFlag,
			utils.AccountWIFFlag,
			utils.AccountLowSecurityFlag,
			utils.AccountMultiMFlag,
			utils.AccountMultiPubKeyFlag,
			utils.IdentityFlag,
		},
	},
	{
		Name: "CONSENSUS",
		Flags: []cli.Flag{
			utils.EnableConsensusFlag,
			utils.MaxTxInBlockFlag,
		},
	},
	{
		Name: "TXPOOL",
		Flags: []cli.Flag{
			utils.GasPriceFlag,
			utils.GasLimitFlag,
			utils.TxpoolPreExecDisableFlag,
			utils.DisableSyncVerifyTxFlag,
		},
	},
	{
		Name: "P2P NODE",
		Flags: []cli.Flag{
			utils.ReservedPeersOnlyFlag,
			utils.ReservedPeersFileFlag,
			utils.NetworkIdFlag,
			utils.NodePortFlag,
			utils.DualPortSupportFlag,
			utils.ConsensusPortFlag,
			utils.MaxConnInBoundFlag,
			utils.MaxConnOutBoundFlag,
			utils.MaxConnInBoundForSingleIPFlag,
		},
	},
	{
		Name: "RPC",
		Flags: []cli.Flag{
			utils.RPCDisabledFlag,
			utils.RPCPortFlag,
			utils.RPCLocalEnableFlag,
			utils.RPCLocalProtFlag,
		},
	},
	{
		Name: "RESTFUL",
		Flags: []cli.Flag{
			utils.RestfulEnableFlag,
			utils.RestfulPortFlag,
		},
	},
	{
		Name: "WEB SOCKET",
		Flags: []cli.Flag{
			utils.WsEnabledFlag,
			utils.WsPortFlag,
		},
	},
	{
		Name: "TEST MODE",
		Flags: []cli.Flag{
			utils.EnableTestModeFlag,
			utils.TestModeGenBlockTimeFlag,
			utils.ClearTestModeDataFlag,
		},
	},
	{
		Name: "CONTRACT",
		Flags: []cli.Flag{
			utils.ContractPrepareDeployFlag,
			utils.ContractAddrFlag,
			utils.ContractAuthorFlag,
			utils.ContractCodeFileFlag,
			utils.ContractDescFlag,
			utils.ContractEmailFlag,
			utils.ContractNameFlag,
			utils.ContractVersionFlag,
			utils.ContractStorageFlag,
			utils.ContractPrepareInvokeFlag,
			utils.ContractParamsFlag,
			utils.ContractReturnTypeFlag,
		},
	},
	{
		Name: "TRANSACTION",
		Flags: []cli.Flag{
			utils.TransactionGasLimitFlag,
			utils.TransactionGasPriceFlag,
			utils.TransactionAssetFlag,
			utils.TransactionFromFlag,
			utils.TransactionToFlag,
			utils.TransactionAmountFlag,
			utils.TransactionHashFlag,
			utils.TransferFromSenderFlag,
			utils.ApproveAssetFlag,
			utils.ApproveAssetFromFlag,
			utils.ApproveAssetToFlag,
			utils.ApproveAmountFlag,
		},
	},
	{
		Name: "Approve",
		Flags: []cli.Flag{
			utils.ApproveAssetFromFlag,
			utils.ApproveAssetToFlag,
		},
	},
	{
		Name: "EXPORT",
		Flags: []cli.Flag{
			utils.ExportFileFlag,
			utils.ExportSpeedFlag,
			utils.ExportHeightFlag,
		},
	},
	{
		Name: "MISC",
	},
}
View Source
var AssetCommand = cli.Command{
	Name:        "asset",
	Usage:       "Handle assets",
	Description: "Asset management commands can check account balance, ONT/ONG transfers, extract ONGs, and view unbound ONGs, and so on.",
	Subcommands: []cli.Command{
		{
			Action:      transfer,
			Name:        "transfer",
			Usage:       "Transfer ont or ong to another account",
			ArgsUsage:   " ",
			Description: "Transfer ont or ong to another account. If from address does not specified, using default account",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.TransactionGasPriceFlag,
				utils.TransactionGasLimitFlag,
				utils.TransactionAssetFlag,
				utils.TransactionFromFlag,
				utils.TransactionToFlag,
				utils.TransactionAmountFlag,
				utils.WalletFileFlag,
			},
		},
		{
			Action:    approve,
			Name:      "approve",
			ArgsUsage: " ",
			Usage:     "Approve another user can transfer asset",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.TransactionGasPriceFlag,
				utils.TransactionGasLimitFlag,
				utils.ApproveAssetFlag,
				utils.ApproveAssetFromFlag,
				utils.ApproveAssetToFlag,
				utils.ApproveAmountFlag,
				utils.WalletFileFlag,
			},
		},
		{
			Action:    transferFrom,
			Name:      "transferfrom",
			ArgsUsage: " ",
			Usage:     "Using to transfer asset after approve",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.TransactionGasPriceFlag,
				utils.TransactionGasLimitFlag,
				utils.ApproveAssetFlag,
				utils.TransferFromSenderFlag,
				utils.ApproveAssetFromFlag,
				utils.ApproveAssetToFlag,
				utils.TransferFromAmountFlag,
				utils.WalletFileFlag,
			},
		},
		{
			Action:    getBalance,
			Name:      "balance",
			Usage:     "Show balance of ont and ong of specified account",
			ArgsUsage: "<address|label|index>",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.WalletFileFlag,
			},
		},
		{
			Action: getAllowance,
			Name:   "allowance",
			Usage:  "Show approve balance of ont or ong of specified account",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.ApproveAssetFlag,
				utils.ApproveAssetFromFlag,
				utils.ApproveAssetToFlag,
				utils.WalletFileFlag,
			},
		},
		{
			Action:    unboundOng,
			Name:      "unboundong",
			Usage:     "Show the balance of unbound ONG",
			ArgsUsage: "<address|label|index>",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.WalletFileFlag,
			},
		},
		{
			Action:    withdrawOng,
			Name:      "withdrawong",
			Usage:     "Withdraw ONG",
			ArgsUsage: "<address|label|index>",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
				utils.TransactionGasPriceFlag,
				utils.TransactionGasLimitFlag,
				utils.WalletFileFlag,
			},
		},
	},
}
View Source
var (
	ContractCommand = cli.Command{
		Name:        "contract",
		Action:      cli.ShowSubcommandHelp,
		Usage:       "Deploy or invoke smart contract",
		ArgsUsage:   " ",
		Description: `Smart contract operations support the deployment of NeoVM smart contract, and the pre-execution and execution of NeoVM smart contract.`,
		Subcommands: []cli.Command{
			{
				Action:    deployContract,
				Name:      "deploy",
				Usage:     "Deploy a smart contract to ontolgoy",
				ArgsUsage: " ",
				Flags: []cli.Flag{
					utils.RPCPortFlag,
					utils.TransactionGasPriceFlag,
					utils.TransactionGasLimitFlag,
					utils.ContractStorageFlag,
					utils.ContractCodeFileFlag,
					utils.ContractNameFlag,
					utils.ContractVersionFlag,
					utils.ContractAuthorFlag,
					utils.ContractEmailFlag,
					utils.ContractDescFlag,
					utils.ContractPrepareDeployFlag,
					utils.WalletFileFlag,
					utils.AccountAddressFlag,
				},
			},
			{
				Action:    invokeContract,
				Name:      "invoke",
				Usage:     "Invoke smart contract",
				ArgsUsage: " ",
				Flags: []cli.Flag{
					utils.RPCPortFlag,
					utils.TransactionGasPriceFlag,
					utils.TransactionGasLimitFlag,
					utils.ContractAddrFlag,
					utils.ContractParamsFlag,
					utils.ContractVersionFlag,
					utils.ContractPrepareInvokeFlag,
					utils.ContractReturnTypeFlag,
					utils.WalletFileFlag,
					utils.AccountAddressFlag,
				},
			},
			{
				Action:    invokeCodeContract,
				Name:      "invokeCode",
				Usage:     "Invoke smart contract by code",
				ArgsUsage: " ",
				Flags: []cli.Flag{
					utils.RPCPortFlag,
					utils.ContractCodeFileFlag,
					utils.TransactionGasPriceFlag,
					utils.TransactionGasLimitFlag,
					utils.WalletFileFlag,
					utils.ContractPrepareInvokeFlag,
					utils.AccountAddressFlag,
				},
			},
		},
	}
)
View Source
var ExportCommand = cli.Command{
	Name:      "export",
	Usage:     "Export blocks in DB to a file",
	ArgsUsage: "",
	Action:    exportBlocks,
	Flags: []cli.Flag{
		utils.RPCPortFlag,
		utils.ExportFileFlag,
		utils.ExportHeightFlag,
		utils.ExportSpeedFlag,
	},
	Description: "",
}
View Source
var InfoCommand = cli.Command{
	Name:  "info",
	Usage: "Display informations about the chain",
	Subcommands: []cli.Command{
		{
			Action: txInfo,
			Name:   "tx",
			Usage:  "Display transaction information",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
			},
			Description: "Display transaction information",
		},
		{
			Action: blockInfo,
			Name:   "block",
			Usage:  "Display block information",
			Flags: []cli.Flag{
				utils.RPCPortFlag,
			},
			Description: "Display block information",
		},
		{
			Action:      txStatus,
			Name:        "status",
			Usage:       "Display transaction status",
			ArgsUsage:   "<txhash>",
			Description: `Display status of transaction.`,
			Flags: []cli.Flag{
				utils.RPCPortFlag,
			},
		},
		{
			Action:      curBlockHeight,
			Name:        "curblockheight",
			Usage:       "Display the current block height",
			ArgsUsage:   "",
			Description: `Display the current block height.`,
			Flags: []cli.Flag{
				utils.RPCPortFlag,
			},
		},
	},
	Description: `Query information command can query information such as blocks, transactions, and transaction executions. 
You can use the ./Ontology info block --help command to view help information.`,
}

Functions

func SetOntologyConfig

func SetOntologyConfig(ctx *cli.Context) (*config.OntologyConfig, error)

func SetRpcPort added in v0.9.2

func SetRpcPort(ctx *cli.Context)

Types

This section is empty.

Directories

Path Synopsis
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
handlers
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL