{"modulePath":"github.com/DNAProject/DNA","version":"v0.7.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\nSPDX-License-Identifier: LGPL-3.0-or-later Copyright 2019 DNA Dev team\n\n  - Copyright (C) 2018 The ontology Authors\n  - This file is part of The ontology library. \\*\n  - The ontology is free software: you can redistribute it and/or modify\n  - it under the terms of the GNU Lesser General Public License as published by\n  - the Free Software Foundation, either version 3 of the License, or\n  - (at your option) any later version. \\*\n  - The ontology is distributed in the hope that it will be useful,\n  - but WITHOUT ANY WARRANTY; without even the implied warranty of\n  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  - GNU Lesser General Public License for more details. \\*\n  - You should have received a copy of the GNU Lesser General Public License\n  - along with The ontology.  If not, see \\\u003c[http://www.gnu.org/licenses/](http://www.gnu.org/licenses/)\u003e.\n\n## Constants\n\n```go\nconst (\n\tDEFAULT_COMPRESS_TYPE         = COMPRESS_TYPE_ZLIB\n\tEXPORT_BLOCK_METADATA_LEN     = 256\n\tEXPORT_BLOCK_METADATA_VERSION = 1\n)\n```\n\n```go\nconst (\n\tDEFAULT_EXPORT_FILE   = \"./Blocks.dat\"\n\tDEFAULT_ABI_PATH      = \"./abi\"\n\tDEFAULT_EXPORT_HEIGHT = 0\n\tDEFAULT_WALLET_PATH   = \"./wallet_data\"\n)\n```\n\n```go\nconst (\n\tVERSION_TRANSACTION    = byte(0)\n\tVERSION_CONTRACT_GAS   = byte(0)\n\tCONTRACT_TRANSFER      = \"transfer\"\n\tCONTRACT_TRANSFER_FROM = \"transferFrom\"\n\tCONTRACT_APPROVE       = \"approve\"\n\n\tASSET_GAS = \"gas\"\n)\n```\n\n```go\nconst (\n\tPARAMS_SPLIT          = \",\"\n\tPARAM_TYPE_SPLIT      = \":\"\n\tPARAM_TYPE_ARRAY      = \"array\"\n\tPARAM_TYPE_BYTE_ARRAY = \"bytearray\"\n\tPARAM_TYPE_STRING     = \"string\"\n\tPARAM_TYPE_INTEGER    = \"int\"\n\tPARAM_TYPE_BOOLEAN    = \"bool\"\n\tPARAM_TYPE_ADDRESS    = \"address\"\n\tPARAM_LEFT_BRACKET    = \"[\"\n\tPARAM_RIGHT_BRACKET   = \"]\"\n\tPARAM_ESC_CHAR        = `/`\n)\n```\n\n```go\nconst (\n\tERROR_INVALID_PARAMS = rpcerr.INVALID_PARAMS\n\tERROR_RPC_COMMON     = 10000\n\tERROR_RPC_SUCCESS    = 0\n)\n```\n\n```go\nconst (\n\tPRECISION_ONG = 9\n\tPRECISION_ONT = 0\n)\n```\n\n```go\nconst (\n\tCOMPRESS_TYPE_ZLIB = iota\n)\n```\n\n```go\nconst JSON_RPC_VERSION = \"2.0\"\n```\nJsonRpc version\n\n## Variables\n\n```go\nvar (\n\t//Blockchain setting\n\tConfigFlag = cli.StringFlag{\n\t\tName:  \"config\",\n\t\tUsage: \"Genesis block config `\u003cfile\u003e`. If doesn't specifies, use main net config as default.\",\n\t\tValue: config.DEFAULT_CONFIG_FILE_NAME,\n\t}\n\tLogLevelFlag = cli.UintFlag{\n\t\tName:  \"loglevel\",\n\t\tUsage: \"Set the log level to `\u003clevel\u003e` (0~6). 0:Trace 1:Debug 2:Info 3:Warn 4:Error 5:Fatal 6:MaxLevel\",\n\t\tValue: config.DEFAULT_LOG_LEVEL,\n\t}\n\tDisableLogFileFlag = cli.BoolFlag{\n\t\tName:  \"disable-log-file\",\n\t\tUsage: \"Discard log output to file\",\n\t}\n\tDisableEventLogFlag = cli.BoolFlag{\n\t\tName:  \"disable-event-log\",\n\t\tUsage: \"Discard event log output by smart contract execution\",\n\t}\n\tWalletFileFlag = cli.StringFlag{\n\t\tName:  \"wallet,w\",\n\t\tValue: config.DEFAULT_WALLET_FILE_NAME,\n\t\tUsage: \"Wallet `\u003cfile\u003e`\",\n\t}\n\tImportFileFlag = cli.StringFlag{\n\t\tName:  \"import-file\",\n\t\tUsage: \"Path of import `\u003cfile\u003e`\",\n\t\tValue: DEFAULT_EXPORT_FILE,\n\t}\n\tImportEndHeightFlag = cli.UintFlag{\n\t\tName:  \"end-height\",\n\t\tUsage: \"Stop import block `\u003cheight\u003e` of the import.\",\n\t\tValue: DEFAULT_EXPORT_HEIGHT,\n\t}\n\tDataDirFlag = cli.StringFlag{\n\t\tName:  \"data-dir\",\n\t\tUsage: \"Block data storage `\u003cpath\u003e`\",\n\t\tValue: config.DEFAULT_DATA_DIR,\n\t}\n\n\t//Consensus setting\n\tEnableConsensusFlag = cli.BoolFlag{\n\t\tName:  \"enable-consensus\",\n\t\tUsage: \"Start consensus module\",\n\t}\n\tMaxTxInBlockFlag = cli.IntFlag{\n\t\tName:  \"max-tx-in-block\",\n\t\tUsage: \"Max transaction `\u003cnumber\u003e` in block\",\n\t\tValue: config.DEFAULT_MAX_TX_IN_BLOCK,\n\t}\n\tGasLimitFlag = cli.Uint64Flag{\n\t\tName:  \"gaslimit\",\n\t\tUsage: \"Min gas limit `\u003cvalue\u003e` of transaction to be accepted by tx pool.\",\n\t\tValue: neovm.MIN_TRANSACTION_GAS,\n\t}\n\tGasPriceFlag = cli.Uint64Flag{\n\t\tName:  \"gasprice\",\n\t\tUsage: \"Min gas price `\u003cvalue\u003e` of transaction to be accepted by tx pool.\",\n\t\tValue: config.DEFAULT_GAS_PRICE,\n\t}\n\n\t//Test Mode setting\n\tEnableTestModeFlag = cli.BoolFlag{\n\t\tName:  \"testmode\",\n\t\tUsage: \"Single node network for testing. In test mode, will start rpc, rest, web socket server, and set default gasprice to 0\",\n\t}\n\tTestModeGenBlockTimeFlag = cli.UintFlag{\n\t\tName:  \"testmode-gen-block-time\",\n\t\tUsage: \"Block-out `\u003ctime\u003e`(s) in test mode.\",\n\t\tValue: config.DEFAULT_GEN_BLOCK_TIME,\n\t}\n\n\t//P2P setting\n\tReservedPeersOnlyFlag = cli.BoolFlag{\n\t\tName:  \"reserved-only\",\n\t\tUsage: \"Connect reserved peers only. Reserved peers are configured with --reserved-file.\",\n\t}\n\tReservedPeersFileFlag = cli.StringFlag{\n\t\tName:  \"reserved-file\",\n\t\tUsage: \"Reserved peers `\u003cfile\u003e`\",\n\t\tValue: config.DEFAULT_RESERVED_FILE,\n\t}\n\tNetworkIdFlag = cli.UintFlag{\n\t\tName:  \"networkid\",\n\t\tUsage: \"Network id `\u003cnumber\u003e`\",\n\t\tValue: config.NETWORK_ID_MAIN_NET,\n\t}\n\tNodePortFlag = cli.UintFlag{\n\t\tName:  \"nodeport\",\n\t\tUsage: \"P2P network port `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_NODE_PORT,\n\t}\n\tHttpInfoPortFlag = cli.UintFlag{\n\t\tName:  \"httpinfo-port\",\n\t\tUsage: \"The listening port of http server for viewing node information `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_HTTP_INFO_PORT,\n\t}\n\tMaxConnInBoundFlag = cli.UintFlag{\n\t\tName:  \"max-conn-in-bound\",\n\t\tUsage: \"Max connection `\u003cnumber\u003e` in bound\",\n\t\tValue: config.DEFAULT_MAX_CONN_IN_BOUND,\n\t}\n\tMaxConnOutBoundFlag = cli.UintFlag{\n\t\tName:  \"max-conn-out-bound\",\n\t\tUsage: \"Max connection `\u003cnumber\u003e` out bound\",\n\t\tValue: config.DEFAULT_MAX_CONN_OUT_BOUND,\n\t}\n\tMaxConnInBoundForSingleIPFlag = cli.UintFlag{\n\t\tName:  \"max-conn-in-bound-single-ip\",\n\t\tUsage: \"Max connection `\u003cnumber\u003e` in bound for single ip\",\n\t\tValue: config.DEFAULT_MAX_CONN_IN_BOUND_FOR_SINGLE_IP,\n\t}\n\t// RPC settings\n\tRPCDisabledFlag = cli.BoolFlag{\n\t\tName:  \"disable-rpc\",\n\t\tUsage: \"Shut down the rpc server.\",\n\t}\n\tRPCPortFlag = cli.UintFlag{\n\t\tName:  \"rpcport\",\n\t\tUsage: \"Json rpc server listening port `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_RPC_PORT,\n\t}\n\tRPCLocalEnableFlag = cli.BoolFlag{\n\t\tName:  \"localrpc\",\n\t\tUsage: \"Enable local rpc server\",\n\t}\n\tRPCLocalProtFlag = cli.UintFlag{\n\t\tName:  \"localrpcport\",\n\t\tUsage: \"Json rpc local server listening port `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_RPC_LOCAL_PORT,\n\t}\n\n\t//Websocket setting\n\tWsEnabledFlag = cli.BoolFlag{\n\t\tName:  \"ws\",\n\t\tUsage: \"Enable web socket server\",\n\t}\n\tWsPortFlag = cli.UintFlag{\n\t\tName:  \"wsport\",\n\t\tUsage: \"Ws server listening port `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_WS_PORT,\n\t}\n\n\t//Restful setting\n\tRestfulEnableFlag = cli.BoolFlag{\n\t\tName:  \"rest\",\n\t\tUsage: \"Enable restful api server\",\n\t}\n\tRestfulPortFlag = cli.UintFlag{\n\t\tName:  \"restport\",\n\t\tUsage: \"Restful server listening port `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_REST_PORT,\n\t}\n\tRestfulMaxConnsFlag = cli.UintFlag{\n\t\tName:  \"restmaxconns\",\n\t\tUsage: \"Restful server maximum connections `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_REST_MAX_CONN,\n\t}\n\n\t//Account setting\n\tAccountPassFlag = cli.StringFlag{\n\t\tName:   \"password,p\",\n\t\tHidden: true,\n\t\tUsage:  \"Account `\u003cpassword\u003e` when blockchain node starts.\",\n\t}\n\tAccountAddressFlag = cli.StringFlag{\n\t\tName:  \"account,a\",\n\t\tUsage: \"Account `\u003caddress\u003e` when the blockchain node starts. If not specific, using default account instead\",\n\t}\n\tAccountDefaultFlag = cli.BoolFlag{\n\t\tName:  \"default,d\",\n\t\tUsage: \"Default settings to create a new account (equal to '-t ecdsa -b 256 -s SHA256withECDSA')\",\n\t}\n\tAccountTypeFlag = cli.StringFlag{\n\t\tName:  \"type,t\",\n\t\tUsage: \"Specifies the `\u003ckey-type\u003e` by signature algorithm.\",\n\t}\n\tAccountKeylenFlag = cli.StringFlag{\n\t\tName:  \"bit-length,b\",\n\t\tUsage: \"Specifies the `\u003cbit-length\u003e` of key\",\n\t}\n\tAccountSigSchemeFlag = cli.StringFlag{\n\t\tName:  \"signature-scheme,s\",\n\t\tUsage: \"Specifies the signature scheme `\u003cscheme\u003e`\",\n\t}\n\tAccountSetDefaultFlag = cli.BoolFlag{\n\t\tName:  \"as-default,d\",\n\t\tUsage: \"Set the specified account to default account of wallet\",\n\t}\n\tAccountQuantityFlag = cli.UintFlag{\n\t\tName:  \"number,n\",\n\t\tValue: 1,\n\t\tUsage: \"Specifies the `\u003cquantity\u003e` of account to create.\",\n\t}\n\tAccountSourceFileFlag = cli.StringFlag{\n\t\tName:  \"source,s\",\n\t\tUsage: \"Source wallet `\u003cfile\u003e` to import\",\n\t}\n\tAccountLabelFlag = cli.StringFlag{\n\t\tName:  \"label,l\",\n\t\tUsage: \"Set account `\u003clabel\u003e` for easy and fast use of accounts.\",\n\t}\n\tAccountKeyFlag = cli.StringFlag{\n\t\tName:  \"key,k\",\n\t\tUsage: \"Use `\u003cprivate key\u003e` (hex encoding) of the account\",\n\t}\n\tAccountVerboseFlag = cli.BoolFlag{\n\t\tName:  \"verbose,v\",\n\t\tUsage: \"Display accounts with details\",\n\t}\n\tAccountChangePasswdFlag = cli.BoolFlag{\n\t\tName:  \"change-passwd\",\n\t\tUsage: \"Change account password\",\n\t}\n\tAccountLowSecurityFlag = cli.BoolFlag{\n\t\tName:  \"low-security\",\n\t\tUsage: \"Change account to low protection strength for low performance devices\",\n\t}\n\tAccountWIFFlag = cli.BoolFlag{\n\t\tName:  \"wif\",\n\t\tUsage: \"Import WIF keys from the source file specified by --source option\",\n\t}\n\tAccountMultiMFlag = cli.UintFlag{\n\t\tName:  \"m\",\n\t\tUsage: \"Min signature `\u003cnumber\u003e` of multi signature address\",\n\t\tValue: 1,\n\t}\n\tAccountMultiPubKeyFlag = cli.StringFlag{\n\t\tName:  \"pubkey\",\n\t\tUsage: \"Pub key list of multi `\u003caddresses\u003e`, separate addreses with comma `,`\",\n\t}\n\tIdentityFlag = cli.BoolFlag{\n\t\tName:  \"did\",\n\t\tUsage: \"create an DID instead of account\",\n\t}\n\n\t//SmartContract setting\n\tContractAddrFlag = cli.StringFlag{\n\t\tName:  \"address\",\n\t\tUsage: \"Contract `\u003caddress\u003e`\",\n\t}\n\tContractVmTypeFlag = cli.UintFlag{\n\t\tName:  \"vmtype\",\n\t\tUsage: \"The Contract type: 1 for Neovm ,3 for Wasmvm\",\n\t\tValue: 1,\n\t}\n\tContractCodeFileFlag = cli.StringFlag{\n\t\tName:  \"code\",\n\t\tUsage: \"File path of contract code `\u003cpath\u003e`\",\n\t}\n\tContractNameFlag = cli.StringFlag{\n\t\tName:  \"name\",\n\t\tUsage: \"Specifies contract name to `\u003cname\u003e`\",\n\t}\n\tContractVersionFlag = cli.StringFlag{\n\t\tName:  \"version\",\n\t\tUsage: \"Specifies contract version to `\u003cver\u003e`\",\n\t}\n\tContractAuthorFlag = cli.StringFlag{\n\t\tName:  \"author\",\n\t\tUsage: \"Set `\u003caddress\u003e` as the contract owner\",\n\t\tValue: \"\",\n\t}\n\tContractEmailFlag = cli.StringFlag{\n\t\tName:  \"email\",\n\t\tUsage: \"Set `\u003cemail\u003e` owner's email address\",\n\t\tValue: \"\",\n\t}\n\tContractDescFlag = cli.StringFlag{\n\t\tName:  \"desc\",\n\t\tUsage: \"Set `\u003ctext\u003e` as the description of the contract\",\n\t\tValue: \"\",\n\t}\n\tContractParamsFlag = cli.StringFlag{\n\t\tName:  \"params\",\n\t\tUsage: \"Contract parameters list to invoke. separate params with comma ','\",\n\t}\n\tContractPrepareDeployFlag = cli.BoolFlag{\n\t\tName:  \"prepare,p\",\n\t\tUsage: \"Prepare deploy contract without commit to ledger\",\n\t}\n\tContractPrepareInvokeFlag = cli.BoolFlag{\n\t\tName:  \"prepare,p\",\n\t\tUsage: \"Prepare invoke contract without commit to ledger\",\n\t}\n\tContractReturnTypeFlag = cli.StringFlag{\n\t\tName:  \"return\",\n\t\tUsage: \"Return `\u003ctype\u003e` of contract. bytearray(hexstring), string, int, boolean\",\n\t}\n\n\t//information cmd settings\n\tBlockHashInfoFlag = cli.StringFlag{\n\t\tName:  \"hash\",\n\t\tUsage: \"Get block info by block hash\",\n\t}\n\tBlockHeightInfoFlag = cli.UintFlag{\n\t\tName:  \"height\",\n\t\tUsage: \"Get block info by block height\",\n\t}\n\n\t//Transfer setting\n\tTransactionAssetFlag = cli.StringFlag{\n\t\tName:  \"asset\",\n\t\tUsage: \"Asset of ONT or ONG\",\n\t\tValue: ASSET_GAS,\n\t}\n\tTransactionFromFlag = cli.StringFlag{\n\t\tName:  \"from\",\n\t\tUsage: \"Transfer-out account `\u003caddress\u003e`\",\n\t}\n\tTransactionToFlag = cli.StringFlag{\n\t\tName:  \"to\",\n\t\tUsage: \"Transfer-in account `\u003caddress\u003e`\",\n\t}\n\tTransactionAmountFlag = cli.StringFlag{\n\t\tName:  \"amount\",\n\t\tUsage: \"Transfer `\u003camount\u003e`. Float number\",\n\t}\n\tTransactionHashFlag = cli.StringFlag{\n\t\tName:  \"hash\",\n\t\tUsage: \"Transaction `\u003chash\u003e`\",\n\t}\n\tTransactionGasPriceFlag = cli.Uint64Flag{\n\t\tName:  \"gasprice\",\n\t\tUsage: \"Gas price of transaction\",\n\t\tValue: config.DEFAULT_GAS_PRICE,\n\t}\n\tTransactionGasLimitFlag = cli.Uint64Flag{\n\t\tName:  \"gaslimit\",\n\t\tUsage: \"Gas limit of the transaction\",\n\t\tValue: neovm.MIN_TRANSACTION_GAS,\n\t}\n\tTransactionPayerFlag = cli.StringFlag{\n\t\tName:  \"payer\",\n\t\tUsage: \"Transaction fee payer `\u003caddress\u003e`,Default is the signer address\",\n\t}\n\n\t//Asset setting\n\tApproveAssetFromFlag = cli.StringFlag{\n\t\tName:  \"from\",\n\t\tUsage: \"Transfer-out account `\u003caddress\u003e`\",\n\t}\n\tApproveAssetToFlag = cli.StringFlag{\n\t\tName:  \"to\",\n\t\tUsage: \"Transfer-in account `\u003caddress\u003e`\",\n\t}\n\tApproveAssetFlag = cli.StringFlag{\n\t\tName:  \"asset\",\n\t\tUsage: \"Asset of ONT of ONG to approve\",\n\t\tValue: \"ont\",\n\t}\n\tApproveAmountFlag = cli.StringFlag{\n\t\tName:  \"amount\",\n\t\tUsage: \"Amount of approve. Float number\",\n\t}\n\tTransferFromAmountFlag = cli.StringFlag{\n\t\tName:  \"amount\",\n\t\tUsage: \"Amount of transfer from. Float number\",\n\t}\n\tTransferFromSenderFlag = cli.StringFlag{\n\t\tName:  \"sender\",\n\t\tUsage: \"Sender account `\u003caddress\u003e` of transfer from transaction, Default is transfer-to account\",\n\t}\n\tSendTxFlag = cli.BoolFlag{\n\t\tName:  \"send,s\",\n\t\tUsage: \"Send raw transaction to blockchain\",\n\t}\n\tForceSendTxFlag = cli.BoolFlag{\n\t\tName:  \"force,f\",\n\t\tUsage: \"Force to send transaction\",\n\t}\n\tRawTransactionFlag = cli.StringFlag{\n\t\tName:  \"raw-tx\",\n\t\tUsage: \"Raw `\u003ctransaction\u003e` encode with hex string\",\n\t}\n\tPrepareExecTransactionFlag = cli.BoolFlag{\n\t\tName:  \"prepare,p\",\n\t\tUsage: \"Prepare execute transaction, without commit to ledger\",\n\t}\n\tWithdrawONGReceiveAccountFlag = cli.StringFlag{\n\t\tName:  \"receive\",\n\t\tUsage: \"ONG receive `\u003caddress\u003e`，Default the same with owner account\",\n\t}\n\tWithdrawONGAmountFlag = cli.StringFlag{\n\t\tName:  \"amount\",\n\t\tUsage: \"Withdraw amount `\u003cnumber\u003e`, Float number. Default withdraw all\",\n\t}\n\tForceTxFlag = cli.BoolFlag{\n\t\tName:  \"force,f\",\n\t\tUsage: \"Force to send transaction\",\n\t}\n\n\t//Cli setting\n\tCliAddressFlag = cli.StringFlag{\n\t\tName:  \"cliaddress\",\n\t\tUsage: \"Rpc bind `\u003caddress\u003e`\",\n\t\tValue: config.DEFUALT_CLI_RPC_ADDRESS,\n\t}\n\tCliRpcPortFlag = cli.UintFlag{\n\t\tName:  \"cliport\",\n\t\tUsage: \"Rpc bind port `\u003cnumber\u003e`\",\n\t\tValue: config.DEFAULT_CLI_RPC_PORT,\n\t}\n\tCliABIPathFlag = cli.StringFlag{\n\t\tName:  \"abi\",\n\t\tUsage: \"Abi `\u003cfile\u003e` path\",\n\t\tValue: DEFAULT_ABI_PATH,\n\t}\n\tCliWalletDirFlag = cli.StringFlag{\n\t\tName:  \"walletdir\",\n\t\tUsage: \"Wallet data `\u003cpath\u003e`\",\n\t\tValue: DEFAULT_WALLET_PATH,\n\t}\n\n\t//Export setting\n\tExportFileFlag = cli.StringFlag{\n\t\tName:  \"export-file\",\n\t\tUsage: \"Export `\u003cfile\u003e` path\",\n\t\tValue: DEFAULT_EXPORT_FILE,\n\t}\n\tExportStartHeightFlag = cli.UintFlag{\n\t\tName:  \"start-height\",\n\t\tUsage: \"Start block height `\u003cnumber\u003e` to export\",\n\t\tValue: DEFAULT_EXPORT_HEIGHT,\n\t}\n\tExportEndHeightFlag = cli.UintFlag{\n\t\tName:  \"end-height\",\n\t\tUsage: \"Stop block height `\u003cnumber\u003e` to export\",\n\t\tValue: DEFAULT_EXPORT_HEIGHT,\n\t}\n\tExportSpeedFlag = cli.StringFlag{\n\t\tName:  \"export-speed\",\n\t\tUsage: \"Export block speed `\u003clevel\u003e` (h|m|l), h for high speed, m for middle speed and l for low speed\",\n\t\tValue: \"m\",\n\t}\n\n\t//PreExecute switcher\n\tTxpoolPreExecDisableFlag = cli.BoolFlag{\n\t\tName:  \"disable-tx-pool-pre-exec\",\n\t\tUsage: \"Disable preExecute in tx pool\",\n\t}\n\n\t//local PreExecute switcher\n\tDisableSyncVerifyTxFlag = cli.BoolFlag{\n\t\tName:  \"disable-sync-verify-tx\",\n\t\tUsage: \"Disable sync verify transaction in interface\",\n\t}\n\n\tDisableBroadcastNetTxFlag = cli.BoolFlag{\n\t\tName:  \"disable-broadcast-net-tx\",\n\t\tUsage: \"Disable broadcast tx from network in tx pool\",\n\t}\n\n\tNonOptionFlag = cli.StringFlag{\n\t\tName:  \"option\",\n\t\tUsage: \"this command does not need option, please run directly\",\n\t}\n)\n```\n\n```go\nvar (\n\tPARAM_TYPE_SPLIT_INC = string([]byte{0})\n\tPARAM_SPLIT_INC      = string([]byte{1})\n)\n```\n\n## Functions\n\n```go\nfunc Approve(gasPrice, gasLimit uint64, signer *account.Account, asset, from, to string, amount uint64) (string, error)\n```\n\n```go\nfunc ApproveTx(gasPrice, gasLimit uint64, asset string, from, to string, amount uint64) (*types.MutableTransaction, error)\n```\n\n```go\nfunc CheckAssetAmount(asset string, amount uint64) error\n```\n\n```go\nfunc CompressBlockData(data []byte, compressType byte) ([]byte, error)\n```\n\n```go\nfunc DecompressBlockData(data []byte, compressType byte) ([]byte, error)\n```\n\n```go\nfunc DeployContract(\n\tgasPrice,\n\tgasLimit uint64,\n\tsigner *account.Account,\n\tvmtype payload.VmType,\n\tcode,\n\tcname,\n\tcversion,\n\tcauthor,\n\tcemail,\n\tcdesc string) (string, error)\n```\n\n```go\nfunc FormatAssetAmount(amount uint64, precision byte) string\n```\nFormatAssetAmount return asset amount multiplied by math.Pow10(precision) to raw float string For example 1000000000123456789 =\u003e 1000000000.123456789\n\n```go\nfunc FormatOng(amount uint64) string\n```\n\n```go\nfunc FormatOnt(amount uint64) string\n```\n\n```go\nfunc GenExportBlocksFileName(name string, start, end uint32) string\n```\n\n```go\nfunc GetAccountBalance(address, asset string) (uint64, error)\n```\n\n```go\nfunc GetAllowance(asset, from, to string) (string, error)\n```\n\n```go\nfunc GetBalance(address string) (*httpcom.BalanceOfRsp, error)\n```\nReturn balance of address in base58 code\n\n```go\nfunc GetBlock(hashOrHeight interface{}) ([]byte, error)\n```\n\n```go\nfunc GetBlockCount() (uint32, error)\n```\n\n```go\nfunc GetBlockData(hashOrHeight interface{}) ([]byte, error)\n```\n\n```go\nfunc GetFlagName(flag cli.Flag) string\n```\nGetFlagName deal with short flag, and return the flag name whether flag name have short name\n\n```go\nfunc GetJsonObjectFromFile(filePath string, jsonObject interface{}) error\n```\n\n```go\nfunc GetNetworkId() (uint32, error)\n```\n\n```go\nfunc GetRawTransaction(txHash string) ([]byte, error)\n```\n\n```go\nfunc GetSmartContractEvent(txHash string) (*rpccommon.ExecuteNotify, error)\n```\nGetSmartContractEvent return smart contract event execute by invoke transaction by hex string code\n\n```go\nfunc GetSmartContractEventInfo(txHash string) ([]byte, error)\n```\n\n```go\nfunc GetStoreDirPath(dataDir, networkName string) string\n```\n\n```go\nfunc GetTxHeight(txHash string) (uint32, error)\n```\n\n```go\nfunc InvokeNeoVMContract(\n\tgasPrice,\n\tgasLimit uint64,\n\tsigner *account.Account,\n\tsmartcodeAddress common.Address,\n\tparams []interface{}) (string, error)\n```\nInvoke neo vm smart contract. if isPreExec is true, the invoke will not really execute\n\n```go\nfunc InvokeSmartContract(signer *account.Account, tx *types.MutableTransaction) (string, error)\n```\nInvokeSmartContract is low level method to invoke contact.\n\n```go\nfunc InvokeWasmVMContract(\n\tgasPrice,\n\tgasLimit uint64,\n\tsigner *account.Account,\n\tsmartcodeAddress common.Address,\n\tparams []interface{}) (string, error)\n```\nInvoke wasm vm smart contract. if isPreExec is true, the invoke will not really execute\n\n```go\nfunc MultiSigTransaction(mutTx *types.MutableTransaction, m uint16, pubKeys []keypair.PublicKey, signer *account.Account) error\n```\n\n```go\nfunc NewDeployCodeTransaction(gasPrice, gasLimit uint64, code []byte, vmType payload.VmType,\n\tcname, cversion, cauthor, cemail, cdesc string) (*types.MutableTransaction, error)\n```\nNewDeployCodeTransaction return a smart contract deploy transaction instance\n\n```go\nfunc NewInvokeTransaction(gasPrice, gasLimit uint64, invokeCode []byte) *types.MutableTransaction\n```\nNewInvokeTransaction return smart contract invoke transaction\n\n```go\nfunc NewNativeInvokeTransaction(gasPrice, gasLimit uint64, contractAddr common.Address, version byte,\n\tparams []interface{}, funcAbi *abi.NativeContractFunctionAbi) (*types.MutableTransaction, error)\n```\n\n```go\nfunc NewNeovmContractAbi(abiData []byte) (*abi.NeovmContractAbi, error)\n```\n\n```go\nfunc ParseAssetAmount(rawAmount string, precision byte) uint64\n```\nParseAssetAmount return raw float string to uint64 multiplied by math.Pow10(precision) For example 1000000000.123456789 =\u003e 1000000000123456789\n\n```go\nfunc ParseNativeFuncParam(builder *neovm.ParamsBuilder, funName string, params []interface{}, paramsAbi []*abi.NativeContractParamAbi) error\n```\n\n```go\nfunc ParseNativeParamAddress(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParamArray(builder *neovm.ParamsBuilder, param interface{}, arrayAbi *abi.NativeContractParamAbi) error\n```\n\n```go\nfunc ParseNativeParamBool(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParamByte(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParamByteArray(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParamInteger(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParamString(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParamStruct(builder *neovm.ParamsBuilder, param interface{}, structAbi *abi.NativeContractParamAbi) error\n```\n\n```go\nfunc ParseNativeParamUint256(builder *neovm.ParamsBuilder, param string) error\n```\n\n```go\nfunc ParseNativeParams(builder *neovm.ParamsBuilder, params []interface{}, paramsAbi []*abi.NativeContractParamAbi) error\n```\n\n```go\nfunc ParseNeoVMContractReturnTypeBool(hexStr string) (bool, error)\n```\nParseNeoVMContractReturnTypeBool return bool value of smart contract execute code.\n\n```go\nfunc ParseNeoVMContractReturnTypeByteArray(hexStr string) (string, error)\n```\nParseNeoVMContractReturnTypeByteArray return \\[]byte value of smart contract execute code.\n\n```go\nfunc ParseNeoVMContractReturnTypeInteger(hexStr string) (int64, error)\n```\nParseNeoVMContractReturnTypeInteger return integer value of smart contract execute code.\n\n```go\nfunc ParseNeoVMContractReturnTypeString(hexStr string) (string, error)\n```\nParseNeoVMContractReturnTypeString return string value of smart contract execute code.\n\n```go\nfunc ParseNeoVMInvokeParams(rawParams []interface{}) ([]interface{}, error)\n```\nParseNeoVMInvokeParams parse params to \\[]interface, rawParams is array of NeoVMInvokeParam\n\n```go\nfunc ParseNeovmFunc(rawParams []string, funcAbi *abi.NeovmContractFunctionAbi) ([]interface{}, error)\n```\n\n```go\nfunc ParseNeovmParam(params []string, paramsAbi []*abi.NeovmContractParamsAbi) ([]interface{}, error)\n```\n\n```go\nfunc ParseNeovmParamBoolean(param string) (interface{}, error)\n```\n\n```go\nfunc ParseNeovmParamByteArray(param string) (interface{}, error)\n```\n\n```go\nfunc ParseNeovmParamInteger(param string) (interface{}, error)\n```\n\n```go\nfunc ParseNeovmParamString(param string) (interface{}, error)\n```\n\n```go\nfunc ParseOng(rawAmount string) uint64\n```\n\n```go\nfunc ParseOnt(rawAmount string) uint64\n```\n\n```go\nfunc ParseParams(rawParamStr string) ([]interface{}, error)\n```\nParseParams return interface{} array of encode params item. A param item compose of type and value, type can be: bytearray, string, int, bool Param type and param value split with \":\", such as int:10 Param array can be express with \"\\[]\", such \\[int:10,string:foo], param array can be nested, such as \\[int:10,\\[int:12,bool:true]] A raw params example: string:foo,\\[int:0,\\[bool:true,string:bar],bool:false] Note that if string contain some special char like :,\\[,] and so one, please '/' char to escape. For example: string:did/:ed1e25c9dccae0c694ee892231407afa20b76008\n\n```go\nfunc ParseReturnValue(rawValue interface{}, rawReturnTypeStr string, vmtype payload.VmType) ([]interface{}, error)\n```\nParseReturnValue return the value of rawReturnTypeStr type. Return type can be: bytearray, string, int, bool. Types can be split with \",\" each other, such as int,string,bool Type array can be express with \"\\[]\", such \\[int,string], param array can be nested, such as \\[int,\\[int,bool]]\n\n```go\nfunc ParseWasmVMContractReturnTypeBool(hexStr string) (bool, error)\n```\nParseWasmVMContractReturnTypeBool return bool value of smart contract execute code.\n\n```go\nfunc ParseWasmVMContractReturnTypeByteArray(hexStr string) (string, error)\n```\n\n```go\nfunc ParseWasmVMContractReturnTypeInteger(hexStr string) (int64, error)\n```\nParseWasmVMContractReturnTypeInteger return integer value of smart contract execute code.\n\n```go\nfunc ParseWasmVMContractReturnTypeString(hexStr string) (string, error)\n```\nParseWasmVMContractReturnTypeString return string value of smart contract execute code.\n\n```go\nfunc PrepareDeployContract(\n\tvmtype payload.VmType,\n\tcode,\n\tcname,\n\tcversion,\n\tcauthor,\n\tcemail,\n\tcdesc string) (*rpccommon.PreExecuteResult, error)\n```\n\n```go\nfunc PrepareInvokeCodeNeoVMContract(code []byte) (*rpccommon.PreExecuteResult, error)\n```\n\n```go\nfunc PrepareInvokeNativeContract(\n\tcontractAddress common.Address,\n\tversion byte,\n\tmethod string,\n\tparams []interface{}) (*rpccommon.PreExecuteResult, error)\n```\n\n```go\nfunc PrepareInvokeNeoVMContract(\n\tcontractAddress common.Address,\n\tparams []interface{},\n) (*rpccommon.PreExecuteResult, error)\n```\n\n```go\nfunc PrepareInvokeWasmVMContract(contractAddress common.Address, params []interface{}) (*rpccommon.PreExecuteResult, error)\n```\nprepare invoke wasm\n\n```go\nfunc PrepareSendRawTransaction(txData string) (*rpccommon.PreExecuteResult, error)\n```\n\n```go\nfunc SendRawTransaction(tx *types.Transaction) (string, error)\n```\nSendRawTransaction send a transaction to blockchain network, and return hash of the transaction\n\n```go\nfunc SendRawTransactionData(txData string) (string, error)\n```\n\n```go\nfunc Sign(data []byte, signer *account.Account) ([]byte, error)\n```\nSign sign return the signature to the data of private key\n\n```go\nfunc SignTransaction(signer *account.Account, tx *types.MutableTransaction) error\n```\n\n```go\nfunc Transfer(gasPrice, gasLimit uint64, signer *account.Account, asset, from, to string, amount uint64) (string, error)\n```\nTransfer ont|ong from account to another account\n\n```go\nfunc TransferFrom(gasPrice, gasLimit uint64, signer *account.Account, asset, sender, from, to string, amount uint64) (string, error)\n```\n\n```go\nfunc TransferFromTx(gasPrice, gasLimit uint64, asset, sender, from, to string, amount uint64) (*types.MutableTransaction, error)\n```\n\n```go\nfunc TransferTx(gasPrice, gasLimit uint64, asset, from, to string, amount uint64) (*types.MutableTransaction, error)\n```\n\n```go\nfunc ZLibCompress(data []byte) ([]byte, error)\n```\n\n```go\nfunc ZLibDecompress(data []byte) ([]byte, error)\n```\n\n## Types\n\n```go\ntype ExportBlockMetadata struct {\n\tVersion          byte\n\tCompressType     byte\n\tStartBlockHeight uint32\n\tEndBlockHeight   uint32\n}\n```\n\n```go\nfunc NewExportBlockMetadata() *ExportBlockMetadata\n```\n\n```go\nfunc (this *ExportBlockMetadata) Deserialize(r io.Reader) error\n```\n\n```go\nfunc (this *ExportBlockMetadata) Serialize(w io.Writer) error\n```\n\n```go\ntype JsonRpcRequest struct {\n\tVersion string        `json:\"jsonrpc\"`\n\tId      string        `json:\"id\"`\n\tMethod  string        `json:\"method\"`\n\tParams  []interface{} `json:\"params\"`\n}\n```\nJsonRpcRequest object in rpc\n\n```go\ntype JsonRpcResponse struct {\n\tError  int64           `json:\"error\"`\n\tDesc   string          `json:\"desc\"`\n\tResult json.RawMessage `json:\"result\"`\n}\n```\nJsonRpcResponse object response for JsonRpcRequest\n\n```go\ntype NeoVMInvokeParam struct {\n\tType  string\n\tValue interface{} //string or []*NeoVMInvokeParam\n}\n```\nNeoVMInvokeParam use to express the param to invoke neovm contract. Type can be of array, bytearray, string, int and bool If type is one of bytearray, string, int and bool, value must be a string If Type is array, value must be \\[]\\*NeoVMInvokeParam Example:\n\n\t[]interface{}{\n\t\t\u0026NeoVMInvokeParam{\n\t\t\tType:  \"string\",\n\t\t\tValue: \"foo\",\n\t\t},\n\t\t\u0026NeoVMInvokeParam{\n\t\t\tType: \"array\",\n\t\t\tValue: []interface{}{\n\t\t\t\t\u0026NeoVMInvokeParam{\n\t\t\t\t\tType:  \"int\",\n\t\t\t\t\tValue: \"0\",\n\t\t\t\t},\n\t\t\t\t\u0026NeoVMInvokeParam{\n\t\t\t\t\tType:  \"bool\",\n\t\t\t\t\tValue: \"true\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n```go\ntype RpcError struct {\n\tErrorCode int64\n\tError     error\n}\n```\n\n```go\nfunc NewRpcError(err error, errCode ...int64) *RpcError\n```\n\n","path":"github.com/DNAProject/DNA/cmd/utils","name":"utils","synopsis":"SPDX-License-Identifier: LGPL-3.0-or-later Copyright 2019 DNA Dev team * Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.","isRedistributable":true}
