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