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