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