aboutsummaryrefslogtreecommitdiff
path: root/src/rpcrawtransaction.cpp
diff options
context:
space:
mode:
authorsje <sje3000@gmail.com>2013-10-29 22:29:44 +1100
committerWladimir J. van der Laan <laanwj@gmail.com>2013-11-13 14:54:29 +0100
commita6099ef319a73e2255dca77065600abb22c4f5f8 (patch)
tree4b02c150d44351ceac018a0557667f242ea68f22 /src/rpcrawtransaction.cpp
parent2830a9051d19fa8ba29e26ef0440107a13b15975 (diff)
Issue #1865 - Clean up RPC help messages
Based on the proposal, update the help message of rpc methods - strings arguments are in double quotes rather than square brackets - numeric arguments have no quotes (and no default value) - optional parameters are surrounded by round brackets - json arguments are strings but don't use double quotes Added 3 sections for the details - Arguments: lists each argument, it's type, required or not, a default, and a description - Result: The method result, with json format if applicable, type, and a description - Examples: examples calls using bitcoin-cli and curl for json rpc call Problems - maybe this is too verbose - lines might be too long - description are not good or complete - examples may be too much
Diffstat (limited to 'src/rpcrawtransaction.cpp')
-rw-r--r--src/rpcrawtransaction.cpp276
1 files changed, 246 insertions, 30 deletions
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index 4912f71f9d..2225e216d3 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -109,11 +109,64 @@ Value getrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "getrawtransaction <txid> [verbose=0]\n"
- "If verbose=0, returns a string that is\n"
- "serialized, hex-encoded data for <txid>.\n"
- "If verbose is non-zero, returns an Object\n"
- "with information about <txid>.");
+ "getrawtransaction \"txid\" ( verbose )\n"
+ "\nReturn the raw transaction data.\n"
+ "\nIf verbose=0, returns a string that is serialized, hex-encoded data for 'txid'.\n"
+ "If verbose is non-zero, returns an Object with information about 'txid'.\n"
+
+ "\nArguments:\n"
+ "1. \"txid\" (string, required) The transaction id\n"
+ "2. verbose (numeric, optional, default=0) If 0, return a string, other return a json object\n"
+
+ "\nResult (if verbose is not set or set to 0):\n"
+ "\"data\" (string) The serialized, hex-encoded data for 'txid'\n"
+
+ "\nResult (if verbose > 0):\n"
+ "{\n"
+ " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n"
+ " \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
+ " \"version\" : n, (numeric) The version\n"
+ " \"locktime\" : ttt, (numeric) The lock time\n"
+ " \"vin\" : [ (array of json objects)\n"
+ " {\n"
+ " \"txid\": \"id\", (string) The transaction id\n"
+ " \"vout\": n, (numeric) \n"
+ " \"scriptSig\": { (json object) The script\n"
+ " \"asm\": \"asm\", (string) asm\n"
+ " \"hex\": \"hex\" (string) hex\n"
+ " },\n"
+ " \"sequence\": n (numeric) The script sequence number\n"
+ " }\n"
+ " ,...\n"
+ " ],\n"
+ " \"vout\" : [ (array of json objects)\n"
+ " {\n"
+ " \"value\" : x.xxx, (numeric) The value in btc\n"
+ " \"n\" : n, (numeric) index\n"
+ " \"scriptPubKey\" : { (json object)\n"
+ " \"asm\" : \"asm\", (string) the asm\n"
+ " \"hex\" : \"hex\", (string) the hex\n"
+ " \"reqSigs\" : n, (numeric) The required sigs\n"
+ " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
+ " \"addresses\" : [ (json array of string)\n"
+ " \"bitcoinaddress\" (string) bitcoin address\n"
+ " ,...\n"
+ " ]\n"
+ " }\n"
+ " }\n"
+ " ,...\n"
+ " ],\n"
+ " \"blockhash\" : \"hash\", (string) the block hash\n"
+ " \"confirmations\" : n, (numeric) The confirmations\n"
+ " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n"
+ " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
+ "}\n"
+
+ "\nExamples:\n"
+ + HelpExampleCli("getrawtransaction", "\"mytxid\"")
+ + HelpExampleCli("getrawtransaction", "\"mytxid\" 1")
+ + HelpExampleRpc("getrawtransaction", "\"mytxid\", 1")
+ );
uint256 hash = ParseHashV(params[0], "parameter 1");
@@ -143,12 +196,39 @@ Value listunspent(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 3)
throw runtime_error(
- "listunspent [minconf=1] [maxconf=9999999] [\"address\",...]\n"
- "Returns array of unspent transaction outputs\n"
+ "listunspent ( minconf maxconf [\"address\",...] )\n"
+ "\nReturns array of unspent transaction outputs\n"
"with between minconf and maxconf (inclusive) confirmations.\n"
- "Optionally filtered to only include txouts paid to specified addresses.\n"
+ "Optionally filter to only include txouts paid to specified addresses.\n"
"Results are an array of Objects, each of which has:\n"
- "{txid, vout, scriptPubKey, amount, confirmations}");
+ "{txid, vout, scriptPubKey, amount, confirmations}\n"
+ "\nArguments:\n"
+ "1. minconf (numeric, optional, default=1) The minimum confirmationsi to filter\n"
+ "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n"
+ "3. \"addresses\" (string) A json array of bitcoin addresses to filter\n"
+ " [\n"
+ " \"address\" (string) bitcoin address\n"
+ " ,...\n"
+ " ]\n"
+ "\nResult\n"
+ "[ (array of json object)\n"
+ " {\n"
+ " \"txid\" : \"txid\", (string) the transaction id \n"
+ " \"vout\" : n, (numeric) the vout value\n"
+ " \"address\" : \"address\", (string) the bitcoin address\n"
+ " \"account\" : \"account\", (string) The associated account, or \"\" for the default account\n"
+ " \"scriptPubKey\" : \"key\", (string) the script key\n"
+ " \"amount\" : x.xxx, (numeric) the transaction amount in btc\n"
+ " \"confirmations\" : n (numeric) The number of confirmations\n"
+ " }\n"
+ " ,...\n"
+ "]\n"
+
+ "\nExamples\n"
+ + HelpExampleCli("listunspent", "")
+ + HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
+ + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
+ );
RPCTypeCheck(params, list_of(int_type)(int_type)(array_type));
@@ -230,13 +310,34 @@ Value createrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 2)
throw runtime_error(
- "createrawtransaction [{\"txid\":txid,\"vout\":n},...] {address:amount,...}\n"
- "Create a transaction spending given inputs\n"
- "(array of objects containing transaction id and output number),\n"
- "sending to given address(es).\n"
+ "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...}\n"
+ "\nCreate a transaction spending the given inputs and sending to the given addresses.\n"
"Returns hex-encoded raw transaction.\n"
"Note that the transaction's inputs are not signed, and\n"
- "it is not stored in the wallet or transmitted to the network.");
+ "it is not stored in the wallet or transmitted to the network.\n"
+
+ "\nArguments:\n"
+ "1. \"transactions\" (string, required) A json array of json objects\n"
+ " [\n"
+ " {\n"
+ " \"txid\":\"id\", (string, required) The transaction id\n"
+ " \"vout\":n (numeric, required) The output number\n"
+ " }\n"
+ " ,...\n"
+ " ]\n"
+ "2. \"addresses\" (string, required) a json object with addresses as keys and amounts as values\n"
+ " {\n"
+ " \"address\": x.xxx (numeric, required) The key is the bitcoin address, the value is the btc amount\n"
+ " ,...\n"
+ " }\n"
+
+ "\nResult:\n"
+ "\"transaction\" (string) hex string of the transaction\n"
+
+ "\nExamples\n"
+ + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":0.01}\"")
+ + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"")
+ );
RPCTypeCheck(params, list_of(array_type)(obj_type));
@@ -290,8 +391,57 @@ Value decoderawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
- "decoderawtransaction <hex string>\n"
- "Return a JSON object representing the serialized, hex-encoded transaction.");
+ "decoderawtransaction \"hexstring\"\n"
+ "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n"
+
+ "\nArguments:\n"
+ "1. \"txid\" (string, required) The transaction hex string\n"
+
+ "\nResult:\n"
+ "{\n"
+ " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n"
+ " \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
+ " \"version\" : n, (numeric) The version\n"
+ " \"locktime\" : ttt, (numeric) The lock time\n"
+ " \"vin\" : [ (array of json objects)\n"
+ " {\n"
+ " \"txid\": \"id\", (string) The transaction id\n"
+ " \"vout\": n, (numeric) The output number\n"
+ " \"scriptSig\": { (json object) The script\n"
+ " \"asm\": \"asm\", (string) asm\n"
+ " \"hex\": \"hex\" (string) hex\n"
+ " },\n"
+ " \"sequence\": n (numeric) The script sequence number\n"
+ " }\n"
+ " ,...\n"
+ " ],\n"
+ " \"vout\" : [ (array of json objects)\n"
+ " {\n"
+ " \"value\" : x.xxx, (numeric) The value in btc\n"
+ " \"n\" : n, (numeric) index\n"
+ " \"scriptPubKey\" : { (json object)\n"
+ " \"asm\" : \"asm\", (string) the asm\n"
+ " \"hex\" : \"hex\", (string) the hex\n"
+ " \"reqSigs\" : n, (numeric) The required sigs\n"
+ " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
+ " \"addresses\" : [ (json array of string)\n"
+ " \"12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) bitcoin address\n"
+ " ,...\n"
+ " ]\n"
+ " }\n"
+ " }\n"
+ " ,...\n"
+ " ],\n"
+ " \"blockhash\" : \"hash\", (string) the block hash\n"
+ " \"confirmations\" : n, (numeric) The confirmations\n"
+ " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n"
+ " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
+ "}\n"
+
+ "\nExamples:\n"
+ + HelpExampleCli("decoderawtransaction", "\"hexstring\"")
+ + HelpExampleRpc("decoderawtransaction", "\"hexstring\"")
+ );
vector<unsigned char> txData(ParseHexV(params[0], "argument"));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
@@ -313,8 +463,26 @@ Value decodescript(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
- "decodescript <hex string>\n"
- "Decode a hex-encoded script.");
+ "decodescript \"hex\"\n"
+ "\nDecode a hex-encoded script.\n"
+ "\nArguments:\n"
+ "1. \"hex\" (string) the hex encoded script\n"
+ "\nResult:\n"
+ "{\n"
+ " \"asm\":\"asm\", (string) Script public key\n"
+ " \"hex\":\"hex\", (string) hex encoded public key\n"
+ " \"type\":\"type\", (string) The output type\n"
+ " \"reqSigs\": n, (numeric) The required signatures\n"
+ " \"addresses\": [ (json array of string)\n"
+ " \"address\" (string) bitcoin address\n"
+ " ,...\n"
+ " ],\n"
+ " \"p2sh\",\"address\" (string) script address\n"
+ "}\n"
+ "\nExamples:\n"
+ + HelpExampleCli("decodescript", "\"hexstring\"")
+ + HelpExampleRpc("decodescript", "\"hexstring\"")
+ );
RPCTypeCheck(params, list_of(str_type));
@@ -336,18 +504,49 @@ Value signrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 4)
throw runtime_error(
- "signrawtransaction <hex string> [{\"txid\":txid,\"vout\":n,\"scriptPubKey\":hex,\"redeemScript\":hex},...] [<privatekey1>,...] [sighashtype=\"ALL\"]\n"
- "Sign inputs for raw transaction (serialized, hex-encoded).\n"
- "Second optional argument (may be null) is an array of previous transaction outputs that\n"
+ "signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n"
+ "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
+ "The second optional argument (may be null) is an array of previous transaction outputs that\n"
"this transaction depends on but may not yet be in the block chain.\n"
- "Third optional argument (may be null) is an array of base58-encoded private\n"
+ "The third optional argument (may be null) is an array of base58-encoded private\n"
"keys that, if given, will be the only keys used to sign the transaction.\n"
- "Fourth optional argument is a string that is one of six values; ALL, NONE, SINGLE or\n"
- "ALL|ANYONECANPAY, NONE|ANYONECANPAY, SINGLE|ANYONECANPAY.\n"
- "Returns json object with keys:\n"
- " hex : raw transaction with signature(s) (hex-encoded string)\n"
- " complete : 1 if transaction has a complete set of signature (0 if not)"
- + HelpRequiringPassphrase());
+ + HelpRequiringPassphrase() + "\n"
+
+ "\nArguments:\n"
+ "1. \"hexstring\" (string, required) The transaction hex string\n"
+ "2. \"prevtxs\" (string, optional) An json array of previous dependent transaction outputs\n"
+ " [ (json array of json objects)\n"
+ " {\n"
+ " \"txid\":\"id\", (string, required) The transaction id\n"
+ " \"vout\":n, (numeric, required) The output number\n"
+ " \"scriptPubKey\": \"hex\", (string, required) script key\n"
+ " \"redeemScript\": \"hex\" (string, required) redeem script\n"
+ " }\n"
+ " ,...\n"
+ " ]\n"
+ "3. \"privatekeys\" (string, optional) A json array of base58-encoded private keys for signing\n"
+ " [ (json array of strings)\n"
+ " \"privatekey\" (string) private key in base58-encoding\n"
+ " ,...\n"
+ " ]\n"
+ "4. \"sighashtype\" (string, optional, default=ALL) The signature has type. Must be one of\n"
+ " \"ALL\"\n"
+ " \"NONE\"\n"
+ " \"SINGLE\"\n"
+ " \"ALL|ANYONECANPAY\"\n"
+ " \"NONE|ANYONECANPAY\"\n"
+ " \"SINGLE|ANYONECANPAY\"\n"
+
+ "\nResult:\n"
+ "{\n"
+ " \"hex\": \"value\", (string) The raw transaction with signature(s) (hex-encoded string)\n"
+ " \"complete\": n (numeric) if transaction has a complete set of signature (0 if not)\n"
+ "}\n"
+
+ "\nExamples:\n"
+ + HelpExampleCli("signrawtransaction", "\"myhex\"")
+ + HelpExampleRpc("signrawtransaction", "\"myhex\"")
+ );
RPCTypeCheck(params, list_of(str_type)(array_type)(array_type)(str_type), true);
@@ -527,8 +726,25 @@ Value sendrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "sendrawtransaction <hex string> [allowhighfees=false]\n"
- "Submits raw transaction (serialized, hex-encoded) to local node and network.");
+ "sendrawtransaction \"hexstring\" ( allowhighfees )\n"
+ "\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
+ "\nAlso see createrawtransaction and signrawtransaction calls.\n"
+ "\nArguments:\n"
+ "1. \"hexstring\" (string, required) The hex string of the raw transaction)\n"
+ "2. allowhighfees (boolean, optional, default=false) Allow high fees\n"
+ "\nResult:\n"
+ "\"hex\" (string) The transaction hash in hex\n"
+ "\nExamples:\n"
+ "\nCreate a transaction\n"
+ + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
+ "Sign the transaction, and get back the hex\n"
+ + HelpExampleCli("signrawtransaction", "\"myhex\"") +
+ "\nSend the transaction (signed hex)\n"
+ + HelpExampleCli("sendrawtransaction", "\"signedhex\"") +
+ "\nAs a json rpc call\n"
+ + HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
+ );
+
// parse hex string from parameter
vector<unsigned char> txData(ParseHexV(params[0], "parameter"));