1// Copyright (c) 2015-2017 The btcsuite developers 2// Copyright (c) 2015-2017 The Decred developers 3// Use of this source code is governed by an ISC 4// license that can be found in the LICENSE file. 5 6package main 7 8import ( 9 "errors" 10 "sort" 11 "strings" 12 "sync" 13 14 "github.com/btcsuite/btcd/btcjson" 15) 16 17// helpDescsEnUS defines the English descriptions used for the help strings. 18var helpDescsEnUS = map[string]string{ 19 // DebugLevelCmd help. 20 "debuglevel--synopsis": "Dynamically changes the debug logging level.\n" + 21 "The levelspec can either a debug level or of the form:\n" + 22 "<subsystem>=<level>,<subsystem2>=<level2>,...\n" + 23 "The valid debug levels are trace, debug, info, warn, error, and critical.\n" + 24 "The valid subsystems are AMGR, ADXR, BCDB, BMGR, BTCD, CHAN, DISC, PEER, RPCS, SCRP, SRVR, and TXMP.\n" + 25 "Finally the keyword 'show' will return a list of the available subsystems.", 26 "debuglevel-levelspec": "The debug level(s) to use or the keyword 'show'", 27 "debuglevel--condition0": "levelspec!=show", 28 "debuglevel--condition1": "levelspec=show", 29 "debuglevel--result0": "The string 'Done.'", 30 "debuglevel--result1": "The list of subsystems", 31 32 // AddNodeCmd help. 33 "addnode--synopsis": "Attempts to add or remove a persistent peer.", 34 "addnode-addr": "IP address and port of the peer to operate on", 35 "addnode-subcmd": "'add' to add a persistent peer, 'remove' to remove a persistent peer, or 'onetry' to try a single connection to a peer", 36 37 // NodeCmd help. 38 "node--synopsis": "Attempts to add or remove a peer.", 39 "node-subcmd": "'disconnect' to remove all matching non-persistent peers, 'remove' to remove a persistent peer, or 'connect' to connect to a peer", 40 "node-target": "Either the IP address and port of the peer to operate on, or a valid peer ID.", 41 "node-connectsubcmd": "'perm' to make the connected peer a permanent one, 'temp' to try a single connect to a peer", 42 43 // TransactionInput help. 44 "transactioninput-txid": "The hash of the input transaction", 45 "transactioninput-vout": "The specific output of the input transaction to redeem", 46 47 // CreateRawTransactionCmd help. 48 "createrawtransaction--synopsis": "Returns a new transaction spending the provided inputs and sending to the provided addresses.\n" + 49 "The transaction inputs are not signed in the created transaction.\n" + 50 "The signrawtransaction RPC command provided by wallet must be used to sign the resulting transaction.", 51 "createrawtransaction-inputs": "The inputs to the transaction", 52 "createrawtransaction-amounts": "JSON object with the destination addresses as keys and amounts as values", 53 "createrawtransaction-amounts--key": "address", 54 "createrawtransaction-amounts--value": "n.nnn", 55 "createrawtransaction-amounts--desc": "The destination address as the key and the amount in BTC as the value", 56 "createrawtransaction-locktime": "Locktime value; a non-zero value will also locktime-activate the inputs", 57 "createrawtransaction--result0": "Hex-encoded bytes of the serialized transaction", 58 59 // ScriptSig help. 60 "scriptsig-asm": "Disassembly of the script", 61 "scriptsig-hex": "Hex-encoded bytes of the script", 62 63 // PrevOut help. 64 "prevout-addresses": "previous output addresses", 65 "prevout-value": "previous output value", 66 67 // VinPrevOut help. 68 "vinprevout-coinbase": "The hex-encoded bytes of the signature script (coinbase txns only)", 69 "vinprevout-txid": "The hash of the origin transaction (non-coinbase txns only)", 70 "vinprevout-vout": "The index of the output being redeemed from the origin transaction (non-coinbase txns only)", 71 "vinprevout-scriptSig": "The signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)", 72 "vinprevout-txinwitness": "The witness stack of the passed input, encoded as a JSON string array", 73 "vinprevout-prevOut": "Data from the origin transaction output with index vout.", 74 "vinprevout-sequence": "The script sequence number", 75 76 // Vin help. 77 "vin-coinbase": "The hex-encoded bytes of the signature script (coinbase txns only)", 78 "vin-txid": "The hash of the origin transaction (non-coinbase txns only)", 79 "vin-vout": "The index of the output being redeemed from the origin transaction (non-coinbase txns only)", 80 "vin-scriptSig": "The signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)", 81 "vin-txinwitness": "The witness used to redeem the input encoded as a string array of its items", 82 "vin-sequence": "The script sequence number", 83 84 // ScriptPubKeyResult help. 85 "scriptpubkeyresult-asm": "Disassembly of the script", 86 "scriptpubkeyresult-hex": "Hex-encoded bytes of the script", 87 "scriptpubkeyresult-reqSigs": "The number of required signatures", 88 "scriptpubkeyresult-type": "The type of the script (e.g. 'pubkeyhash')", 89 "scriptpubkeyresult-addresses": "The bitcoin addresses associated with this script", 90 91 // Vout help. 92 "vout-value": "The amount in BTC", 93 "vout-n": "The index of this transaction output", 94 "vout-scriptPubKey": "The public key script used to pay coins as a JSON object", 95 96 // TxRawDecodeResult help. 97 "txrawdecoderesult-txid": "The hash of the transaction", 98 "txrawdecoderesult-version": "The transaction version", 99 "txrawdecoderesult-locktime": "The transaction lock time", 100 "txrawdecoderesult-vin": "The transaction inputs as JSON objects", 101 "txrawdecoderesult-vout": "The transaction outputs as JSON objects", 102 103 // DecodeRawTransactionCmd help. 104 "decoderawtransaction--synopsis": "Returns a JSON object representing the provided serialized, hex-encoded transaction.", 105 "decoderawtransaction-hextx": "Serialized, hex-encoded transaction", 106 107 // DecodeScriptResult help. 108 "decodescriptresult-asm": "Disassembly of the script", 109 "decodescriptresult-reqSigs": "The number of required signatures", 110 "decodescriptresult-type": "The type of the script (e.g. 'pubkeyhash')", 111 "decodescriptresult-addresses": "The bitcoin addresses associated with this script", 112 "decodescriptresult-p2sh": "The script hash for use in pay-to-script-hash transactions (only present if the provided redeem script is not already a pay-to-script-hash script)", 113 114 // DecodeScriptCmd help. 115 "decodescript--synopsis": "Returns a JSON object with information about the provided hex-encoded script.", 116 "decodescript-hexscript": "Hex-encoded script", 117 118 // EstimateFeeCmd help. 119 "estimatefee--synopsis": "Estimate the fee per kilobyte in satoshis " + 120 "required for a transaction to be mined before a certain number of " + 121 "blocks have been generated.", 122 "estimatefee-numblocks": "The maximum number of blocks which can be " + 123 "generated before the transaction is mined.", 124 "estimatefee--result0": "Estimated fee per kilobyte in satoshis for a block to " + 125 "be mined in the next NumBlocks blocks.", 126 127 // GenerateCmd help 128 "generate--synopsis": "Generates a set number of blocks (simnet or regtest only) and returns a JSON\n" + 129 " array of their hashes.", 130 "generate-numblocks": "Number of blocks to generate", 131 "generate--result0": "The hashes, in order, of blocks generated by the call", 132 133 // GetAddedNodeInfoResultAddr help. 134 "getaddednodeinforesultaddr-address": "The ip address for this DNS entry", 135 "getaddednodeinforesultaddr-connected": "The connection 'direction' (inbound/outbound/false)", 136 137 // GetAddedNodeInfoResult help. 138 "getaddednodeinforesult-addednode": "The ip address or domain of the added peer", 139 "getaddednodeinforesult-connected": "Whether or not the peer is currently connected", 140 "getaddednodeinforesult-addresses": "DNS lookup and connection information about the peer", 141 142 // GetAddedNodeInfo help. 143 "getaddednodeinfo--synopsis": "Returns information about manually added (persistent) peers.", 144 "getaddednodeinfo-dns": "Specifies whether the returned data is a JSON object including DNS and connection information, or just a list of added peers", 145 "getaddednodeinfo-node": "Only return information about this specific peer instead of all added peers", 146 "getaddednodeinfo--condition0": "dns=false", 147 "getaddednodeinfo--condition1": "dns=true", 148 "getaddednodeinfo--result0": "List of added peers", 149 150 // GetBestBlockResult help. 151 "getbestblockresult-hash": "Hex-encoded bytes of the best block hash", 152 "getbestblockresult-height": "Height of the best block", 153 154 // GetBestBlockCmd help. 155 "getbestblock--synopsis": "Get block height and hash of best block in the main chain.", 156 "getbestblock--result0": "Get block height and hash of best block in the main chain.", 157 158 // GetBestBlockHashCmd help. 159 "getbestblockhash--synopsis": "Returns the hash of the of the best (most recent) block in the longest block chain.", 160 "getbestblockhash--result0": "The hex-encoded block hash", 161 162 // GetBlockCmd help. 163 "getblock--synopsis": "Returns information about a block given its hash.", 164 "getblock-hash": "The hash of the block", 165 "getblock-verbose": "Specifies the block is returned as a JSON object instead of hex-encoded string", 166 "getblock-verbosetx": "Specifies that each transaction is returned as a JSON object and only applies if the verbose flag is true (btcd extension)", 167 "getblock--condition0": "verbose=false", 168 "getblock--condition1": "verbose=true", 169 "getblock--result0": "Hex-encoded bytes of the serialized block", 170 171 // GetBlockChainInfoCmd help. 172 "getblockchaininfo--synopsis": "Returns information about the current blockchain state and the status of any active soft-fork deployments.", 173 174 // GetBlockChainInfoResult help. 175 "getblockchaininforesult-chain": "The name of the chain the daemon is on (testnet, mainnet, etc)", 176 "getblockchaininforesult-blocks": "The number of blocks in the best known chain", 177 "getblockchaininforesult-headers": "The number of headers that we've gathered for in the best known chain", 178 "getblockchaininforesult-bestblockhash": "The block hash for the latest block in the main chain", 179 "getblockchaininforesult-difficulty": "The current chain difficulty", 180 "getblockchaininforesult-mediantime": "The median time from the PoV of the best block in the chain", 181 "getblockchaininforesult-verificationprogress": "An estimate for how much of the best chain we've verified", 182 "getblockchaininforesult-pruned": "A bool that indicates if the node is pruned or not", 183 "getblockchaininforesult-pruneheight": "The lowest block retained in the current pruned chain", 184 "getblockchaininforesult-chainwork": "The total cumulative work in the best chain", 185 "getblockchaininforesult-softforks": "The status of the super-majority soft-forks", 186 "getblockchaininforesult-unifiedsoftforks": "The status of the super-majority soft-forks used by bitcoind on or after v0.19.0", 187 188 // SoftForkDescription help. 189 "softforkdescription-reject": "The current activation status of the softfork", 190 "softforkdescription-version": "The block version that signals enforcement of this softfork", 191 "softforkdescription-id": "The string identifier for the soft fork", 192 "-status": "A bool which indicates if the soft fork is active", 193 194 // SoftForks help. 195 "softforks-softforks": "The status of the super-majority soft-forks", 196 "softforks-bip9_softforks": "JSON object describing active BIP0009 deployments", 197 "softforks-bip9_softforks--key": "bip9_softforks", 198 "softforks-bip9_softforks--value": "An object describing a particular BIP009 deployment", 199 "softforks-bip9_softforks--desc": "The status of any defined BIP0009 soft-fork deployments", 200 201 // UnifiedSoftForks help. 202 "unifiedsoftforks-softforks": "The status of the super-majority soft-forks used by bitcoind on or after v0.19.0", 203 "unifiedsoftforks-softforks--key": "softforks", 204 "unifiedsoftforks-softforks--value": "An object describing an active softfork deployment used by bitcoind on or after v0.19.0", 205 "unifiedsoftforks-softforks--desc": "JSON object describing an active softfork deployment used by bitcoind on or after v0.19.0", 206 207 // TxRawResult help. 208 "txrawresult-hex": "Hex-encoded transaction", 209 "txrawresult-txid": "The hash of the transaction", 210 "txrawresult-version": "The transaction version", 211 "txrawresult-locktime": "The transaction lock time", 212 "txrawresult-vin": "The transaction inputs as JSON objects", 213 "txrawresult-vout": "The transaction outputs as JSON objects", 214 "txrawresult-blockhash": "Hash of the block the transaction is part of", 215 "txrawresult-confirmations": "Number of confirmations of the block", 216 "txrawresult-time": "Transaction time in seconds since 1 Jan 1970 GMT", 217 "txrawresult-blocktime": "Block time in seconds since the 1 Jan 1970 GMT", 218 "txrawresult-size": "The size of the transaction in bytes", 219 "txrawresult-vsize": "The virtual size of the transaction in bytes", 220 "txrawresult-weight": "The transaction's weight (between vsize*4-3 and vsize*4)", 221 "txrawresult-hash": "The wtxid of the transaction", 222 223 // SearchRawTransactionsResult help. 224 "searchrawtransactionsresult-hex": "Hex-encoded transaction", 225 "searchrawtransactionsresult-txid": "The hash of the transaction", 226 "searchrawtransactionsresult-hash": "The wxtid of the transaction", 227 "searchrawtransactionsresult-version": "The transaction version", 228 "searchrawtransactionsresult-locktime": "The transaction lock time", 229 "searchrawtransactionsresult-vin": "The transaction inputs as JSON objects", 230 "searchrawtransactionsresult-vout": "The transaction outputs as JSON objects", 231 "searchrawtransactionsresult-blockhash": "Hash of the block the transaction is part of", 232 "searchrawtransactionsresult-confirmations": "Number of confirmations of the block", 233 "searchrawtransactionsresult-time": "Transaction time in seconds since 1 Jan 1970 GMT", 234 "searchrawtransactionsresult-blocktime": "Block time in seconds since the 1 Jan 1970 GMT", 235 "searchrawtransactionsresult-size": "The size of the transaction in bytes", 236 "searchrawtransactionsresult-vsize": "The virtual size of the transaction in bytes", 237 "searchrawtransactionsresult-weight": "The transaction's weight (between vsize*4-3 and vsize*4)", 238 239 // GetBlockVerboseResult help. 240 "getblockverboseresult-hash": "The hash of the block (same as provided)", 241 "getblockverboseresult-confirmations": "The number of confirmations", 242 "getblockverboseresult-size": "The size of the block", 243 "getblockverboseresult-height": "The height of the block in the block chain", 244 "getblockverboseresult-version": "The block version", 245 "getblockverboseresult-versionHex": "The block version in hexadecimal", 246 "getblockverboseresult-merkleroot": "Root hash of the merkle tree", 247 "getblockverboseresult-tx": "The transaction hashes (only when verbosetx=false)", 248 "getblockverboseresult-rawtx": "The transactions as JSON objects (only when verbosetx=true)", 249 "getblockverboseresult-time": "The block time in seconds since 1 Jan 1970 GMT", 250 "getblockverboseresult-nonce": "The block nonce", 251 "getblockverboseresult-bits": "The bits which represent the block difficulty", 252 "getblockverboseresult-difficulty": "The proof-of-work difficulty as a multiple of the minimum difficulty", 253 "getblockverboseresult-previousblockhash": "The hash of the previous block", 254 "getblockverboseresult-nextblockhash": "The hash of the next block (only if there is one)", 255 "getblockverboseresult-strippedsize": "The size of the block without witness data", 256 "getblockverboseresult-weight": "The weight of the block", 257 258 // GetBlockCountCmd help. 259 "getblockcount--synopsis": "Returns the number of blocks in the longest block chain.", 260 "getblockcount--result0": "The current block count", 261 262 // GetBlockHashCmd help. 263 "getblockhash--synopsis": "Returns hash of the block in best block chain at the given height.", 264 "getblockhash-index": "The block height", 265 "getblockhash--result0": "The block hash", 266 267 // GetBlockHeaderCmd help. 268 "getblockheader--synopsis": "Returns information about a block header given its hash.", 269 "getblockheader-hash": "The hash of the block", 270 "getblockheader-verbose": "Specifies the block header is returned as a JSON object instead of hex-encoded string", 271 "getblockheader--condition0": "verbose=false", 272 "getblockheader--condition1": "verbose=true", 273 "getblockheader--result0": "The block header hash", 274 275 // GetBlockHeaderVerboseResult help. 276 "getblockheaderverboseresult-hash": "The hash of the block (same as provided)", 277 "getblockheaderverboseresult-confirmations": "The number of confirmations", 278 "getblockheaderverboseresult-height": "The height of the block in the block chain", 279 "getblockheaderverboseresult-version": "The block version", 280 "getblockheaderverboseresult-versionHex": "The block version in hexadecimal", 281 "getblockheaderverboseresult-merkleroot": "Root hash of the merkle tree", 282 "getblockheaderverboseresult-time": "The block time in seconds since 1 Jan 1970 GMT", 283 "getblockheaderverboseresult-nonce": "The block nonce", 284 "getblockheaderverboseresult-bits": "The bits which represent the block difficulty", 285 "getblockheaderverboseresult-difficulty": "The proof-of-work difficulty as a multiple of the minimum difficulty", 286 "getblockheaderverboseresult-previousblockhash": "The hash of the previous block", 287 "getblockheaderverboseresult-nextblockhash": "The hash of the next block (only if there is one)", 288 289 // TemplateRequest help. 290 "templaterequest-mode": "This is 'template', 'proposal', or omitted", 291 "templaterequest-capabilities": "List of capabilities", 292 "templaterequest-longpollid": "The long poll ID of a job to monitor for expiration; required and valid only for long poll requests ", 293 "templaterequest-sigoplimit": "Number of signature operations allowed in blocks (this parameter is ignored)", 294 "templaterequest-sizelimit": "Number of bytes allowed in blocks (this parameter is ignored)", 295 "templaterequest-maxversion": "Highest supported block version number (this parameter is ignored)", 296 "templaterequest-target": "The desired target for the block template (this parameter is ignored)", 297 "templaterequest-data": "Hex-encoded block data (only for mode=proposal)", 298 "templaterequest-workid": "The server provided workid if provided in block template (not applicable)", 299 300 // GetBlockTemplateResultTx help. 301 "getblocktemplateresulttx-data": "Hex-encoded transaction data (byte-for-byte)", 302 "getblocktemplateresulttx-hash": "Hex-encoded transaction hash (little endian if treated as a 256-bit number)", 303 "getblocktemplateresulttx-depends": "Other transactions before this one (by 1-based index in the 'transactions' list) that must be present in the final block if this one is", 304 "getblocktemplateresulttx-fee": "Difference in value between transaction inputs and outputs (in Satoshi)", 305 "getblocktemplateresulttx-sigops": "Total number of signature operations as counted for purposes of block limits", 306 "getblocktemplateresulttx-weight": "The weight of the transaction", 307 308 // GetBlockTemplateResultAux help. 309 "getblocktemplateresultaux-flags": "Hex-encoded byte-for-byte data to include in the coinbase signature script", 310 311 // GetBlockTemplateResult help. 312 "getblocktemplateresult-bits": "Hex-encoded compressed difficulty", 313 "getblocktemplateresult-curtime": "Current time as seen by the server (recommended for block time); must fall within mintime/maxtime rules", 314 "getblocktemplateresult-height": "Height of the block to be solved", 315 "getblocktemplateresult-previousblockhash": "Hex-encoded big-endian hash of the previous block", 316 "getblocktemplateresult-sigoplimit": "Number of sigops allowed in blocks ", 317 "getblocktemplateresult-sizelimit": "Number of bytes allowed in blocks", 318 "getblocktemplateresult-transactions": "Array of transactions as JSON objects", 319 "getblocktemplateresult-version": "The block version", 320 "getblocktemplateresult-coinbaseaux": "Data that should be included in the coinbase signature script", 321 "getblocktemplateresult-coinbasetxn": "Information about the coinbase transaction", 322 "getblocktemplateresult-coinbasevalue": "Total amount available for the coinbase in Satoshi", 323 "getblocktemplateresult-workid": "This value must be returned with result if provided (not provided)", 324 "getblocktemplateresult-longpollid": "Identifier for long poll request which allows monitoring for expiration", 325 "getblocktemplateresult-longpolluri": "An alternate URI to use for long poll requests if provided (not provided)", 326 "getblocktemplateresult-submitold": "Not applicable", 327 "getblocktemplateresult-target": "Hex-encoded big-endian number which valid results must be less than", 328 "getblocktemplateresult-expires": "Maximum number of seconds (starting from when the server sent the response) this work is valid for", 329 "getblocktemplateresult-maxtime": "Maximum allowed time", 330 "getblocktemplateresult-mintime": "Minimum allowed time", 331 "getblocktemplateresult-mutable": "List of mutations the server explicitly allows", 332 "getblocktemplateresult-noncerange": "Two concatenated hex-encoded big-endian 32-bit integers which represent the valid ranges of nonces the miner may scan", 333 "getblocktemplateresult-capabilities": "List of server capabilities including 'proposal' to indicate support for block proposals", 334 "getblocktemplateresult-reject-reason": "Reason the proposal was invalid as-is (only applies to proposal responses)", 335 "getblocktemplateresult-default_witness_commitment": "The witness commitment itself. Will be populated if the block has witness data", 336 "getblocktemplateresult-weightlimit": "The current limit on the max allowed weight of a block", 337 338 // GetBlockTemplateCmd help. 339 "getblocktemplate--synopsis": "Returns a JSON object with information necessary to construct a block to mine or accepts a proposal to validate.\n" + 340 "See BIP0022 and BIP0023 for the full specification.", 341 "getblocktemplate-request": "Request object which controls the mode and several parameters", 342 "getblocktemplate--condition0": "mode=template", 343 "getblocktemplate--condition1": "mode=proposal, rejected", 344 "getblocktemplate--condition2": "mode=proposal, accepted", 345 "getblocktemplate--result1": "An error string which represents why the proposal was rejected or nothing if accepted", 346 347 // GetCFilterCmd help. 348 "getcfilter--synopsis": "Returns a block's committed filter given its hash.", 349 "getcfilter-filtertype": "The type of filter to return (0=regular)", 350 "getcfilter-hash": "The hash of the block", 351 "getcfilter--result0": "The block's committed filter", 352 353 // GetCFilterHeaderCmd help. 354 "getcfilterheader--synopsis": "Returns a block's compact filter header given its hash.", 355 "getcfilterheader-filtertype": "The type of filter header to return (0=regular)", 356 "getcfilterheader-hash": "The hash of the block", 357 "getcfilterheader--result0": "The block's gcs filter header", 358 359 // GetConnectionCountCmd help. 360 "getconnectioncount--synopsis": "Returns the number of active connections to other peers.", 361 "getconnectioncount--result0": "The number of connections", 362 363 // GetCurrentNetCmd help. 364 "getcurrentnet--synopsis": "Get bitcoin network the server is running on.", 365 "getcurrentnet--result0": "The network identifer", 366 367 // GetDifficultyCmd help. 368 "getdifficulty--synopsis": "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.", 369 "getdifficulty--result0": "The difficulty", 370 371 // GetGenerateCmd help. 372 "getgenerate--synopsis": "Returns if the server is set to generate coins (mine) or not.", 373 "getgenerate--result0": "True if mining, false if not", 374 375 // GetHashesPerSecCmd help. 376 "gethashespersec--synopsis": "Returns a recent hashes per second performance measurement while generating coins (mining).", 377 "gethashespersec--result0": "The number of hashes per second", 378 379 // InfoChainResult help. 380 "infochainresult-version": "The version of the server", 381 "infochainresult-protocolversion": "The latest supported protocol version", 382 "infochainresult-blocks": "The number of blocks processed", 383 "infochainresult-timeoffset": "The time offset", 384 "infochainresult-connections": "The number of connected peers", 385 "infochainresult-proxy": "The proxy used by the server", 386 "infochainresult-difficulty": "The current target difficulty", 387 "infochainresult-testnet": "Whether or not server is using testnet", 388 "infochainresult-relayfee": "The minimum relay fee for non-free transactions in BTC/KB", 389 "infochainresult-errors": "Any current errors", 390 391 // InfoWalletResult help. 392 "infowalletresult-version": "The version of the server", 393 "infowalletresult-protocolversion": "The latest supported protocol version", 394 "infowalletresult-walletversion": "The version of the wallet server", 395 "infowalletresult-balance": "The total bitcoin balance of the wallet", 396 "infowalletresult-blocks": "The number of blocks processed", 397 "infowalletresult-timeoffset": "The time offset", 398 "infowalletresult-connections": "The number of connected peers", 399 "infowalletresult-proxy": "The proxy used by the server", 400 "infowalletresult-difficulty": "The current target difficulty", 401 "infowalletresult-testnet": "Whether or not server is using testnet", 402 "infowalletresult-keypoololdest": "Seconds since 1 Jan 1970 GMT of the oldest pre-generated key in the key pool", 403 "infowalletresult-keypoolsize": "The number of new keys that are pre-generated", 404 "infowalletresult-unlocked_until": "The timestamp in seconds since 1 Jan 1970 GMT that the wallet is unlocked for transfers, or 0 if the wallet is locked", 405 "infowalletresult-paytxfee": "The transaction fee set in BTC/KB", 406 "infowalletresult-relayfee": "The minimum relay fee for non-free transactions in BTC/KB", 407 "infowalletresult-errors": "Any current errors", 408 409 // GetHeadersCmd help. 410 "getheaders--synopsis": "Returns block headers starting with the first known block hash from the request", 411 "getheaders-blocklocators": "JSON array of hex-encoded hashes of blocks. Headers are returned starting from the first known hash in this list", 412 "getheaders-hashstop": "Block hash to stop including block headers for; if not found, all headers to the latest known block are returned.", 413 "getheaders--result0": "Serialized block headers of all located blocks, limited to some arbitrary maximum number of hashes (currently 2000, which matches the wire protocol headers message, but this is not guaranteed)", 414 415 // GetInfoCmd help. 416 "getinfo--synopsis": "Returns a JSON object containing various state info.", 417 418 // GetMempoolInfoCmd help. 419 "getmempoolinfo--synopsis": "Returns memory pool information", 420 421 // GetMempoolInfoResult help. 422 "getmempoolinforesult-bytes": "Size in bytes of the mempool", 423 "getmempoolinforesult-size": "Number of transactions in the mempool", 424 425 // GetMiningInfoResult help. 426 "getmininginforesult-blocks": "Height of the latest best block", 427 "getmininginforesult-currentblocksize": "Size of the latest best block", 428 "getmininginforesult-currentblockweight": "Weight of the latest best block", 429 "getmininginforesult-currentblocktx": "Number of transactions in the latest best block", 430 "getmininginforesult-difficulty": "Current target difficulty", 431 "getmininginforesult-errors": "Any current errors", 432 "getmininginforesult-generate": "Whether or not server is set to generate coins", 433 "getmininginforesult-genproclimit": "Number of processors to use for coin generation (-1 when disabled)", 434 "getmininginforesult-hashespersec": "Recent hashes per second performance measurement while generating coins", 435 "getmininginforesult-networkhashps": "Estimated network hashes per second for the most recent blocks", 436 "getmininginforesult-pooledtx": "Number of transactions in the memory pool", 437 "getmininginforesult-testnet": "Whether or not server is using testnet", 438 439 // GetMiningInfoCmd help. 440 "getmininginfo--synopsis": "Returns a JSON object containing mining-related information.", 441 442 // GetNetworkHashPSCmd help. 443 "getnetworkhashps--synopsis": "Returns the estimated network hashes per second for the block heights provided by the parameters.", 444 "getnetworkhashps-blocks": "The number of blocks, or -1 for blocks since last difficulty change", 445 "getnetworkhashps-height": "Perform estimate ending with this height or -1 for current best chain block height", 446 "getnetworkhashps--result0": "Estimated hashes per second", 447 448 // GetNetTotalsCmd help. 449 "getnettotals--synopsis": "Returns a JSON object containing network traffic statistics.", 450 451 // GetNetTotalsResult help. 452 "getnettotalsresult-totalbytesrecv": "Total bytes received", 453 "getnettotalsresult-totalbytessent": "Total bytes sent", 454 "getnettotalsresult-timemillis": "Number of milliseconds since 1 Jan 1970 GMT", 455 456 // GetPeerInfoResult help. 457 "getpeerinforesult-id": "A unique node ID", 458 "getpeerinforesult-addr": "The ip address and port of the peer", 459 "getpeerinforesult-addrlocal": "Local address", 460 "getpeerinforesult-services": "Services bitmask which represents the services supported by the peer", 461 "getpeerinforesult-relaytxes": "Peer has requested transactions be relayed to it", 462 "getpeerinforesult-lastsend": "Time the last message was received in seconds since 1 Jan 1970 GMT", 463 "getpeerinforesult-lastrecv": "Time the last message was sent in seconds since 1 Jan 1970 GMT", 464 "getpeerinforesult-bytessent": "Total bytes sent", 465 "getpeerinforesult-bytesrecv": "Total bytes received", 466 "getpeerinforesult-conntime": "Time the connection was made in seconds since 1 Jan 1970 GMT", 467 "getpeerinforesult-timeoffset": "The time offset of the peer", 468 "getpeerinforesult-pingtime": "Number of microseconds the last ping took", 469 "getpeerinforesult-pingwait": "Number of microseconds a queued ping has been waiting for a response", 470 "getpeerinforesult-version": "The protocol version of the peer", 471 "getpeerinforesult-subver": "The user agent of the peer", 472 "getpeerinforesult-inbound": "Whether or not the peer is an inbound connection", 473 "getpeerinforesult-startingheight": "The latest block height the peer knew about when the connection was established", 474 "getpeerinforesult-currentheight": "The current height of the peer", 475 "getpeerinforesult-banscore": "The ban score", 476 "getpeerinforesult-feefilter": "The requested minimum fee a transaction must have to be announced to the peer", 477 "getpeerinforesult-syncnode": "Whether or not the peer is the sync peer", 478 479 // GetPeerInfoCmd help. 480 "getpeerinfo--synopsis": "Returns data about each connected network peer as an array of json objects.", 481 482 // GetRawMempoolVerboseResult help. 483 "getrawmempoolverboseresult-size": "Transaction size in bytes", 484 "getrawmempoolverboseresult-fee": "Transaction fee in bitcoins", 485 "getrawmempoolverboseresult-time": "Local time transaction entered pool in seconds since 1 Jan 1970 GMT", 486 "getrawmempoolverboseresult-height": "Block height when transaction entered the pool", 487 "getrawmempoolverboseresult-startingpriority": "Priority when transaction entered the pool", 488 "getrawmempoolverboseresult-currentpriority": "Current priority", 489 "getrawmempoolverboseresult-depends": "Unconfirmed transactions used as inputs for this transaction", 490 "getrawmempoolverboseresult-vsize": "The virtual size of a transaction", 491 "getrawmempoolverboseresult-weight": "The transaction's weight (between vsize*4-3 and vsize*4)", 492 493 // GetRawMempoolCmd help. 494 "getrawmempool--synopsis": "Returns information about all of the transactions currently in the memory pool.", 495 "getrawmempool-verbose": "Returns JSON object when true or an array of transaction hashes when false", 496 "getrawmempool--condition0": "verbose=false", 497 "getrawmempool--condition1": "verbose=true", 498 "getrawmempool--result0": "Array of transaction hashes", 499 500 // GetRawTransactionCmd help. 501 "getrawtransaction--synopsis": "Returns information about a transaction given its hash.", 502 "getrawtransaction-txid": "The hash of the transaction", 503 "getrawtransaction-verbose": "Specifies the transaction is returned as a JSON object instead of a hex-encoded string", 504 "getrawtransaction--condition0": "verbose=false", 505 "getrawtransaction--condition1": "verbose=true", 506 "getrawtransaction--result0": "Hex-encoded bytes of the serialized transaction", 507 508 // GetTxOutResult help. 509 "gettxoutresult-bestblock": "The block hash that contains the transaction output", 510 "gettxoutresult-confirmations": "The number of confirmations", 511 "gettxoutresult-value": "The transaction amount in BTC", 512 "gettxoutresult-scriptPubKey": "The public key script used to pay coins as a JSON object", 513 "gettxoutresult-version": "The transaction version", 514 "gettxoutresult-coinbase": "Whether or not the transaction is a coinbase", 515 516 // GetTxOutCmd help. 517 "gettxout--synopsis": "Returns information about an unspent transaction output..", 518 "gettxout-txid": "The hash of the transaction", 519 "gettxout-vout": "The index of the output", 520 "gettxout-includemempool": "Include the mempool when true", 521 522 // HelpCmd help. 523 "help--synopsis": "Returns a list of all commands or help for a specified command.", 524 "help-command": "The command to retrieve help for", 525 "help--condition0": "no command provided", 526 "help--condition1": "command specified", 527 "help--result0": "List of commands", 528 "help--result1": "Help for specified command", 529 530 // PingCmd help. 531 "ping--synopsis": "Queues a ping to be sent to each connected peer.\n" + 532 "Ping times are provided by getpeerinfo via the pingtime and pingwait fields.", 533 534 // SearchRawTransactionsCmd help. 535 "searchrawtransactions--synopsis": "Returns raw data for transactions involving the passed address.\n" + 536 "Returned transactions are pulled from both the database, and transactions currently in the mempool.\n" + 537 "Transactions pulled from the mempool will have the 'confirmations' field set to 0.\n" + 538 "Usage of this RPC requires the optional --addrindex flag to be activated, otherwise all responses will simply return with an error stating the address index has not yet been built.\n" + 539 "Similarly, until the address index has caught up with the current best height, all requests will return an error response in order to avoid serving stale data.", 540 "searchrawtransactions-address": "The Bitcoin address to search for", 541 "searchrawtransactions-verbose": "Specifies the transaction is returned as a JSON object instead of hex-encoded string", 542 "searchrawtransactions--condition0": "verbose=0", 543 "searchrawtransactions--condition1": "verbose=1", 544 "searchrawtransactions-skip": "The number of leading transactions to leave out of the final response", 545 "searchrawtransactions-count": "The maximum number of transactions to return", 546 "searchrawtransactions-vinextra": "Specify that extra data from previous output will be returned in vin", 547 "searchrawtransactions-reverse": "Specifies that the transactions should be returned in reverse chronological order", 548 "searchrawtransactions-filteraddrs": "Address list. Only inputs or outputs with matching address will be returned", 549 "searchrawtransactions--result0": "Hex-encoded serialized transaction", 550 551 // SendRawTransactionCmd help. 552 "sendrawtransaction--synopsis": "Submits the serialized, hex-encoded transaction to the local peer and relays it to the network.", 553 "sendrawtransaction-hextx": "Serialized, hex-encoded signed transaction", 554 "sendrawtransaction-allowhighfees": "Whether or not to allow insanely high fees (btcd does not yet implement this parameter, so it has no effect)", 555 "sendrawtransaction-maxfeerate": "Used by bitcoind on or after v0.19.0", 556 "sendrawtransaction--result0": "The hash of the transaction", 557 558 // SetGenerateCmd help. 559 "setgenerate--synopsis": "Set the server to generate coins (mine) or not.", 560 "setgenerate-generate": "Use true to enable generation, false to disable it", 561 "setgenerate-genproclimit": "The number of processors (cores) to limit generation to or -1 for default", 562 563 // StopCmd help. 564 "stop--synopsis": "Shutdown btcd.", 565 "stop--result0": "The string 'btcd stopping.'", 566 567 // SubmitBlockOptions help. 568 "submitblockoptions-workid": "This parameter is currently ignored", 569 570 // SubmitBlockCmd help. 571 "submitblock--synopsis": "Attempts to submit a new serialized, hex-encoded block to the network.", 572 "submitblock-hexblock": "Serialized, hex-encoded block", 573 "submitblock-options": "This parameter is currently ignored", 574 "submitblock--condition0": "Block successfully submitted", 575 "submitblock--condition1": "Block rejected", 576 "submitblock--result1": "The reason the block was rejected", 577 578 // ValidateAddressResult help. 579 "validateaddresschainresult-isvalid": "Whether or not the address is valid", 580 "validateaddresschainresult-address": "The bitcoin address (only when isvalid is true)", 581 582 // ValidateAddressCmd help. 583 "validateaddress--synopsis": "Verify an address is valid.", 584 "validateaddress-address": "Bitcoin address to validate", 585 586 // VerifyChainCmd help. 587 "verifychain--synopsis": "Verifies the block chain database.\n" + 588 "The actual checks performed by the checklevel parameter are implementation specific.\n" + 589 "For btcd this is:\n" + 590 "checklevel=0 - Look up each block and ensure it can be loaded from the database.\n" + 591 "checklevel=1 - Perform basic context-free sanity checks on each block.", 592 "verifychain-checklevel": "How thorough the block verification is", 593 "verifychain-checkdepth": "The number of blocks to check", 594 "verifychain--result0": "Whether or not the chain verified", 595 596 // VerifyMessageCmd help. 597 "verifymessage--synopsis": "Verify a signed message.", 598 "verifymessage-address": "The bitcoin address to use for the signature", 599 "verifymessage-signature": "The base-64 encoded signature provided by the signer", 600 "verifymessage-message": "The signed message", 601 "verifymessage--result0": "Whether or not the signature verified", 602 603 // -------- Websocket-specific help -------- 604 605 // Session help. 606 "session--synopsis": "Return details regarding a websocket client's current connection session.", 607 "sessionresult-sessionid": "The unique session ID for a client's websocket connection.", 608 609 // NotifyBlocksCmd help. 610 "notifyblocks--synopsis": "Request notifications for whenever a block is connected or disconnected from the main (best) chain.", 611 612 // StopNotifyBlocksCmd help. 613 "stopnotifyblocks--synopsis": "Cancel registered notifications for whenever a block is connected or disconnected from the main (best) chain.", 614 615 // NotifyNewTransactionsCmd help. 616 "notifynewtransactions--synopsis": "Send either a txaccepted or a txacceptedverbose notification when a new transaction is accepted into the mempool.", 617 "notifynewtransactions-verbose": "Specifies which type of notification to receive. If verbose is true, then the caller receives txacceptedverbose, otherwise the caller receives txaccepted", 618 619 // StopNotifyNewTransactionsCmd help. 620 "stopnotifynewtransactions--synopsis": "Stop sending either a txaccepted or a txacceptedverbose notification when a new transaction is accepted into the mempool.", 621 622 // NotifyReceivedCmd help. 623 "notifyreceived--synopsis": "Send a recvtx notification when a transaction added to mempool or appears in a newly-attached block contains a txout pkScript sending to any of the passed addresses.\n" + 624 "Matching outpoints are automatically registered for redeemingtx notifications.", 625 "notifyreceived-addresses": "List of address to receive notifications about", 626 627 // StopNotifyReceivedCmd help. 628 "stopnotifyreceived--synopsis": "Cancel registered receive notifications for each passed address.", 629 "stopnotifyreceived-addresses": "List of address to cancel receive notifications for", 630 631 // OutPoint help. 632 "outpoint-hash": "The hex-encoded bytes of the outpoint hash", 633 "outpoint-index": "The index of the outpoint", 634 635 // NotifySpentCmd help. 636 "notifyspent--synopsis": "Send a redeemingtx notification when a transaction spending an outpoint appears in mempool (if relayed to this btcd instance) and when such a transaction first appears in a newly-attached block.", 637 "notifyspent-outpoints": "List of transaction outpoints to monitor.", 638 639 // StopNotifySpentCmd help. 640 "stopnotifyspent--synopsis": "Cancel registered spending notifications for each passed outpoint.", 641 "stopnotifyspent-outpoints": "List of transaction outpoints to stop monitoring.", 642 643 // LoadTxFilterCmd help. 644 "loadtxfilter--synopsis": "Load, add to, or reload a websocket client's transaction filter for mempool transactions, new blocks and rescanblocks.", 645 "loadtxfilter-reload": "Load a new filter instead of adding data to an existing one", 646 "loadtxfilter-addresses": "Array of addresses to add to the transaction filter", 647 "loadtxfilter-outpoints": "Array of outpoints to add to the transaction filter", 648 649 // Rescan help. 650 "rescan--synopsis": "Rescan block chain for transactions to addresses.\n" + 651 "When the endblock parameter is omitted, the rescan continues through the best block in the main chain.\n" + 652 "Rescan results are sent as recvtx and redeemingtx notifications.\n" + 653 "This call returns once the rescan completes.", 654 "rescan-beginblock": "Hash of the first block to begin rescanning", 655 "rescan-addresses": "List of addresses to include in the rescan", 656 "rescan-outpoints": "List of transaction outpoints to include in the rescan", 657 "rescan-endblock": "Hash of final block to rescan", 658 659 // RescanBlocks help. 660 "rescanblocks--synopsis": "Rescan blocks for transactions matching the loaded transaction filter.", 661 "rescanblocks-blockhashes": "List of hashes to rescan. Each next block must be a child of the previous.", 662 "rescanblocks--result0": "List of matching blocks.", 663 664 // RescannedBlock help. 665 "rescannedblock-hash": "Hash of the matching block.", 666 "rescannedblock-transactions": "List of matching transactions, serialized and hex-encoded.", 667 668 // Uptime help. 669 "uptime--synopsis": "Returns the total uptime of the server.", 670 "uptime--result0": "The number of seconds that the server has been running", 671 672 // Version help. 673 "version--synopsis": "Returns the JSON-RPC API version (semver)", 674 "version--result0--desc": "Version objects keyed by the program or API name", 675 "version--result0--key": "Program or API name", 676 "version--result0--value": "Object containing the semantic version", 677 678 // VersionResult help. 679 "versionresult-versionstring": "The JSON-RPC API version (semver)", 680 "versionresult-major": "The major component of the JSON-RPC API version", 681 "versionresult-minor": "The minor component of the JSON-RPC API version", 682 "versionresult-patch": "The patch component of the JSON-RPC API version", 683 "versionresult-prerelease": "Prerelease info about the current build", 684 "versionresult-buildmetadata": "Metadata about the current build", 685} 686 687// rpcResultTypes specifies the result types that each RPC command can return. 688// This information is used to generate the help. Each result type must be a 689// pointer to the type (or nil to indicate no return value). 690var rpcResultTypes = map[string][]interface{}{ 691 "addnode": nil, 692 "createrawtransaction": {(*string)(nil)}, 693 "debuglevel": {(*string)(nil), (*string)(nil)}, 694 "decoderawtransaction": {(*btcjson.TxRawDecodeResult)(nil)}, 695 "decodescript": {(*btcjson.DecodeScriptResult)(nil)}, 696 "estimatefee": {(*float64)(nil)}, 697 "generate": {(*[]string)(nil)}, 698 "getaddednodeinfo": {(*[]string)(nil), (*[]btcjson.GetAddedNodeInfoResult)(nil)}, 699 "getbestblock": {(*btcjson.GetBestBlockResult)(nil)}, 700 "getbestblockhash": {(*string)(nil)}, 701 "getblock": {(*string)(nil), (*btcjson.GetBlockVerboseResult)(nil)}, 702 "getblockcount": {(*int64)(nil)}, 703 "getblockhash": {(*string)(nil)}, 704 "getblockheader": {(*string)(nil), (*btcjson.GetBlockHeaderVerboseResult)(nil)}, 705 "getblocktemplate": {(*btcjson.GetBlockTemplateResult)(nil), (*string)(nil), nil}, 706 "getblockchaininfo": {(*btcjson.GetBlockChainInfoResult)(nil)}, 707 "getcfilter": {(*string)(nil)}, 708 "getcfilterheader": {(*string)(nil)}, 709 "getconnectioncount": {(*int32)(nil)}, 710 "getcurrentnet": {(*uint32)(nil)}, 711 "getdifficulty": {(*float64)(nil)}, 712 "getgenerate": {(*bool)(nil)}, 713 "gethashespersec": {(*float64)(nil)}, 714 "getheaders": {(*[]string)(nil)}, 715 "getinfo": {(*btcjson.InfoChainResult)(nil)}, 716 "getmempoolinfo": {(*btcjson.GetMempoolInfoResult)(nil)}, 717 "getmininginfo": {(*btcjson.GetMiningInfoResult)(nil)}, 718 "getnettotals": {(*btcjson.GetNetTotalsResult)(nil)}, 719 "getnetworkhashps": {(*int64)(nil)}, 720 "getpeerinfo": {(*[]btcjson.GetPeerInfoResult)(nil)}, 721 "getrawmempool": {(*[]string)(nil), (*btcjson.GetRawMempoolVerboseResult)(nil)}, 722 "getrawtransaction": {(*string)(nil), (*btcjson.TxRawResult)(nil)}, 723 "gettxout": {(*btcjson.GetTxOutResult)(nil)}, 724 "node": nil, 725 "help": {(*string)(nil), (*string)(nil)}, 726 "ping": nil, 727 "searchrawtransactions": {(*string)(nil), (*[]btcjson.SearchRawTransactionsResult)(nil)}, 728 "sendrawtransaction": {(*string)(nil)}, 729 "setgenerate": nil, 730 "stop": {(*string)(nil)}, 731 "submitblock": {nil, (*string)(nil)}, 732 "uptime": {(*int64)(nil)}, 733 "validateaddress": {(*btcjson.ValidateAddressChainResult)(nil)}, 734 "verifychain": {(*bool)(nil)}, 735 "verifymessage": {(*bool)(nil)}, 736 "version": {(*map[string]btcjson.VersionResult)(nil)}, 737 738 // Websocket commands. 739 "loadtxfilter": nil, 740 "session": {(*btcjson.SessionResult)(nil)}, 741 "notifyblocks": nil, 742 "stopnotifyblocks": nil, 743 "notifynewtransactions": nil, 744 "stopnotifynewtransactions": nil, 745 "notifyreceived": nil, 746 "stopnotifyreceived": nil, 747 "notifyspent": nil, 748 "stopnotifyspent": nil, 749 "rescan": nil, 750 "rescanblocks": {(*[]btcjson.RescannedBlock)(nil)}, 751} 752 753// helpCacher provides a concurrent safe type that provides help and usage for 754// the RPC server commands and caches the results for future calls. 755type helpCacher struct { 756 sync.Mutex 757 usage string 758 methodHelp map[string]string 759} 760 761// rpcMethodHelp returns an RPC help string for the provided method. 762// 763// This function is safe for concurrent access. 764func (c *helpCacher) rpcMethodHelp(method string) (string, error) { 765 c.Lock() 766 defer c.Unlock() 767 768 // Return the cached method help if it exists. 769 if help, exists := c.methodHelp[method]; exists { 770 return help, nil 771 } 772 773 // Look up the result types for the method. 774 resultTypes, ok := rpcResultTypes[method] 775 if !ok { 776 return "", errors.New("no result types specified for method " + 777 method) 778 } 779 780 // Generate, cache, and return the help. 781 help, err := btcjson.GenerateHelp(method, helpDescsEnUS, resultTypes...) 782 if err != nil { 783 return "", err 784 } 785 c.methodHelp[method] = help 786 return help, nil 787} 788 789// rpcUsage returns one-line usage for all support RPC commands. 790// 791// This function is safe for concurrent access. 792func (c *helpCacher) rpcUsage(includeWebsockets bool) (string, error) { 793 c.Lock() 794 defer c.Unlock() 795 796 // Return the cached usage if it is available. 797 if c.usage != "" { 798 return c.usage, nil 799 } 800 801 // Generate a list of one-line usage for every command. 802 usageTexts := make([]string, 0, len(rpcHandlers)) 803 for k := range rpcHandlers { 804 usage, err := btcjson.MethodUsageText(k) 805 if err != nil { 806 return "", err 807 } 808 usageTexts = append(usageTexts, usage) 809 } 810 811 // Include websockets commands if requested. 812 if includeWebsockets { 813 for k := range wsHandlers { 814 usage, err := btcjson.MethodUsageText(k) 815 if err != nil { 816 return "", err 817 } 818 usageTexts = append(usageTexts, usage) 819 } 820 } 821 822 sort.Sort(sort.StringSlice(usageTexts)) 823 c.usage = strings.Join(usageTexts, "\n") 824 return c.usage, nil 825} 826 827// newHelpCacher returns a new instance of a help cacher which provides help and 828// usage for the RPC server commands and caches the results for future calls. 829func newHelpCacher() *helpCacher { 830 return &helpCacher{ 831 methodHelp: make(map[string]string), 832 } 833} 834