Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static void TxToJSON(const CTransaction &tx, const BlockHash &hashBlock, | ||||
} | } | ||||
} | } | ||||
static UniValue getrawtransaction(const Config &config, | static UniValue getrawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"getrawtransaction", | RPCHelpMan{ | ||||
"getrawtransaction", | |||||
"\nNOTE: By default this function only works for " | "\nNOTE: By default this function only works for " | ||||
"mempool transactions. If the -txindex option is\n" | "mempool transactions. If the -txindex option is\n" | ||||
"enabled, it also works for blockchain transactions. If " | "enabled, it also works for blockchain transactions. If " | ||||
"the block which contains the transaction\n" | "the block which contains the transaction\n" | ||||
"is known, its hash can be provided even for nodes " | "is known, its hash can be provided even for nodes " | ||||
"without -txindex. Note that if a blockhash is\n" | "without -txindex. Note that if a blockhash is\n" | ||||
"provided, only that block will be searched and if the " | "provided, only that block will be searched and if the " | ||||
"transaction is in the mempool or other\n" | "transaction is in the mempool or other\n" | ||||
"blocks, or if this node does not have the given block " | "blocks, or if this node does not have the given block " | ||||
"available, the transaction will not be found.\n", | "available, the transaction will not be found.\n" | ||||
{ | "DEPRECATED: for now, it also works for transactions with " | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | "unspent outputs.\n" | ||||
{"verbose", RPCArg::Type::BOOL, true}, | |||||
{"blockhash", RPCArg::Type::STR_HEX, true}, | |||||
}} | |||||
.ToString() + | |||||
"DEPRECATED: for now, it also works for transactions with unspent " | |||||
"outputs.\n" | |||||
"\nReturn the raw transaction data.\n" | "\nReturn the raw transaction data.\n" | ||||
"\nIf verbose is 'true', returns an Object with information about " | "\nIf verbose is 'true', returns an Object with information " | ||||
"'txid'.\n" | "about 'txid'.\n" | ||||
"If verbose is 'false' or omitted, returns a string that is " | "If verbose is 'false' or omitted, returns a string that is " | ||||
"serialized, hex-encoded data for 'txid'.\n" | "serialized, hex-encoded data for 'txid'.\n", | ||||
{ | |||||
"\nArguments:\n" | {"txid", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
"1. \"txid\" (string, required) The transaction id\n" | /* default_val */ "", "The transaction id"}, | ||||
"2. verbose (bool, optional, default=false) If false, return a " | {"verbose", RPCArg::Type::BOOL, /* opt */ true, | ||||
"string, otherwise return a json object\n" | /* default_val */ "false", | ||||
"3. \"blockhash\" (string, optional) The block in which to look " | "If false, return a string, otherwise return a json " | ||||
"for the transaction\n" | "object"}, | ||||
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, | |||||
/* default_val */ "", | |||||
"The block in which to look for the transaction"}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult (if verbose is not set or set to false):\n" | "\nResult (if verbose is not set or set to false):\n" | ||||
"\"data\" (string) The serialized, hex-encoded data for " | "\"data\" (string) The serialized, hex-encoded data for " | ||||
"'txid'\n" | "'txid'\n" | ||||
"\nResult (if verbose is set to true):\n" | "\nResult (if verbose is set to true):\n" | ||||
"{\n" | "{\n" | ||||
" \"in_active_chain\": b, (bool) Whether specified block is in " | " \"in_active_chain\": b, (bool) Whether specified block is in " | ||||
"the active chain or not (only present with explicit \"blockhash\" " | "the active chain or not (only present with explicit \"blockhash\" " | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | static UniValue getrawtransaction(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue gettxoutproof(const Config &config, | static UniValue gettxoutproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || | if (request.fHelp || | ||||
(request.params.size() != 1 && request.params.size() != 2)) { | (request.params.size() != 1 && request.params.size() != 2)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"gettxoutproof", | RPCHelpMan{ | ||||
"gettxoutproof", | |||||
"\nReturns a hex-encoded proof that \"txid\" was " | "\nReturns a hex-encoded proof that \"txid\" was " | ||||
"included in a block.\n" | "included in a block.\n" | ||||
"\nNOTE: By default this function only works sometimes. " | "\nNOTE: By default this function only works sometimes. " | ||||
"This is when there is an\n" | "This is when there is an\n" | ||||
"unspent output in the utxo for this transaction. To " | "unspent output in the utxo for this transaction. To " | ||||
"make it always work,\n" | "make it always work,\n" | ||||
"you need to maintain a transaction index, using the " | "you need to maintain a transaction index, using the " | ||||
"-txindex command line option or\n" | "-txindex command line option or\n" | ||||
"specify the block in which the transaction is included " | "specify the block in which the transaction is included " | ||||
"manually (by blockhash).\n", | "manually (by blockhash).\n", | ||||
{ | { | ||||
{"txids", | { | ||||
"txids", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json array of txids to filter", | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | {"txid", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "A transaction hash"}, | |||||
}, | |||||
}, | }, | ||||
false}, | {"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, | ||||
{"blockhash", RPCArg::Type::STR_HEX, true}, | /* default_val */ "", | ||||
"If specified, looks for txid in the block with this " | |||||
"hash"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"txids\" (string) A json array of txids to filter\n" | |||||
" [\n" | |||||
" \"txid\" (string) A transaction hash\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"2. \"blockhash\" (string, optional) If specified, looks for " | |||||
"txid in the block with this hash\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"data\" (string) A string that is a serialized, " | "\"data\" (string) A string that is a serialized, " | ||||
"hex-encoded data for the proof.\n"); | "hex-encoded data for the proof.\n"); | ||||
} | } | ||||
std::set<TxId> setTxIds; | std::set<TxId> setTxIds; | ||||
TxId oneTxId; | TxId oneTxId; | ||||
UniValue txids = request.params[0].get_array(); | UniValue txids = request.params[0].get_array(); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | static UniValue verifytxoutproof(const Config &config, | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"verifytxoutproof", | RPCHelpMan{"verifytxoutproof", | ||||
"\nVerifies that a proof points to a transaction in a " | "\nVerifies that a proof points to a transaction in a " | ||||
"block, returning the transaction it commits to\n" | "block, returning the transaction it commits to\n" | ||||
"and throwing an RPC error if the block is not in our " | "and throwing an RPC error if the block is not in our " | ||||
"best chain\n", | "best chain\n", | ||||
{ | { | ||||
{"proof", RPCArg::Type::STR_HEX, false}, | {"proof", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", | |||||
"The hex-encoded proof generated by gettxoutproof"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"proof\" (string, required) The hex-encoded proof " | |||||
"generated by gettxoutproof\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[\"txid\"] (array, strings) The txid(s) which the proof " | "[\"txid\"] (array, strings) The txid(s) which the proof " | ||||
"commits to, or empty array if the proof can not be validated.\n"); | "commits to, or empty array if the proof can not be validated.\n"); | ||||
} | } | ||||
CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, | CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, | ||||
PROTOCOL_VERSION); | PROTOCOL_VERSION); | ||||
CMerkleBlock merkleBlock; | CMerkleBlock merkleBlock; | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | CMutableTransaction ConstructTransaction(const CChainParams ¶ms, | ||||
return rawTx; | return rawTx; | ||||
} | } | ||||
static UniValue createrawtransaction(const Config &config, | static UniValue createrawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
// clang-format off | RPCHelpMan{ | ||||
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime )\n" | "createrawtransaction", | ||||
"\nCreate a transaction spending the given inputs and creating new outputs.\n" | "\nCreate a transaction spending the given inputs and creating " | ||||
"new outputs.\n" | |||||
"Outputs can be addresses or data.\n" | "Outputs can be addresses or data.\n" | ||||
"Returns hex-encoded raw transaction.\n" | "Returns hex-encoded raw transaction.\n" | ||||
"Note that the transaction's inputs are not signed, and\n" | "Note that the transaction's inputs are not signed, and\n" | ||||
"it is not stored in the wallet or transmitted to the network.\n" | "it is not stored in the wallet or transmitted to the " | ||||
"network.\n", | |||||
"\nArguments:\n" | { | ||||
"1. \"inputs\" (array, required) A json array of " | { | ||||
"json objects\n" | "inputs", | ||||
" [\n" | RPCArg::Type::ARR, | ||||
" {\n" | /* opt */ false, | ||||
" \"txid\":\"id\", (string, required) The transaction id\n" | /* default_val */ "", | ||||
" \"vout\":n, (numeric, required) The output number\n" | "A json array of json objects", | ||||
" \"sequence\":n (numeric, optional) The sequence number\n" | { | ||||
" } \n" | { | ||||
" ,...\n" | "", | ||||
" ]\n" | RPCArg::Type::OBJ, | ||||
"2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n" | /* opt */ false, | ||||
" [\n" | /* default_val */ "", | ||||
" {\n" | "", | ||||
" \"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT + "\n" | { | ||||
" },\n" | {"txid", RPCArg::Type::STR_HEX, | ||||
" {\n" | /* opt */ false, /* default_val */ "", | ||||
" \"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex-encoded data\n" | "The transaction id"}, | ||||
" }\n" | {"vout", RPCArg::Type::NUM, /* opt */ false, | ||||
" ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" | /* default_val */ "", "The output number"}, | ||||
" accepted as second parameter.\n" | {"sequence", RPCArg::Type::NUM, | ||||
" ]\n" | /* opt */ true, /* default_val */ "", | ||||
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" | "The sequence number"}, | ||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
{ | |||||
"outputs", | |||||
RPCArg::Type::ARR, | |||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"a json array with outputs (key-value pairs).\n" | |||||
"For compatibility reasons, a dictionary, which holds " | |||||
"the key-value pairs directly, is also\n" | |||||
" accepted as second " | |||||
"parameter.", | |||||
{ | |||||
{ | |||||
"", | |||||
RPCArg::Type::OBJ, | |||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"address", RPCArg::Type::AMOUNT, | |||||
/* opt */ false, /* default_val */ "", | |||||
"A key-value pair. The key (string) is " | |||||
"the bitcoin address, the value (float or " | |||||
"string) is the amount in " + | |||||
CURRENCY_UNIT}, | |||||
}, | |||||
}, | |||||
{ | |||||
"", | |||||
RPCArg::Type::OBJ, | |||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"data", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"A key-value pair. The key must be " | |||||
"\"data\", the value is hex-encoded data"}, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
{"locktime", RPCArg::Type::NUM, /* opt */ true, | |||||
/* default_val */ "0", | |||||
"Raw locktime. Non-0 value also locktime-activates " | |||||
"inputs"}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"transaction\" (string) hex string of the transaction\n" | "\"transaction\" (string) hex string of the " | ||||
"transaction\n" | |||||
"\nExamples:\n" | "\nExamples:\n" + | ||||
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"") | HelpExampleCli("createrawtransaction", | ||||
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") | "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | ||||
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"") | "\"[{\\\"address\\\":0.01}]\"") + | ||||
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"") | HelpExampleCli("createrawtransaction", | ||||
// clang-format on | "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | ||||
); | "\"[{\\\"data\\\":\\\"00010203\\\"}]\"") + | ||||
HelpExampleRpc("createrawtransaction", | |||||
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", " | |||||
"\"[{\\\"address\\\":0.01}]\"") + | |||||
HelpExampleRpc("createrawtransaction", | |||||
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", " | |||||
"\"[{\\\"data\\\":\\\"00010203\\\"}]\"")); | |||||
} | } | ||||
RPCTypeCheck(request.params, | RPCTypeCheck(request.params, | ||||
{UniValue::VARR, | {UniValue::VARR, | ||||
UniValueType(), // ARR or OBJ, checked later | UniValueType(), // ARR or OBJ, checked later | ||||
UniValue::VNUM}, | UniValue::VNUM}, | ||||
true); | true); | ||||
CMutableTransaction rawTx = | CMutableTransaction rawTx = | ||||
ConstructTransaction(config.GetChainParams(), request.params[0], | ConstructTransaction(config.GetChainParams(), request.params[0], | ||||
request.params[1], request.params[2]); | request.params[1], request.params[2]); | ||||
return EncodeHexTx(CTransaction(rawTx)); | return EncodeHexTx(CTransaction(rawTx)); | ||||
} | } | ||||
static UniValue decoderawtransaction(const Config &config, | static UniValue decoderawtransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"decoderawtransaction", | RPCHelpMan{"decoderawtransaction", | ||||
"\nReturn a JSON object representing the serialized, " | "\nReturn a JSON object representing the serialized, " | ||||
"hex-encoded transaction.\n", | "hex-encoded transaction.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "The transaction hex string"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"hexstring\" (string, required) The transaction hex " | |||||
"string\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"txid\" : \"id\", (string) The transaction id\n" | " \"txid\" : \"id\", (string) The transaction id\n" | ||||
" \"hash\" : \"id\", (string) The transaction hash " | " \"hash\" : \"id\", (string) The transaction hash " | ||||
"(differs from txid for witness transactions)\n" | "(differs from txid for witness transactions)\n" | ||||
" \"size\" : n, (numeric) The transaction size\n" | " \"size\" : n, (numeric) The transaction size\n" | ||||
" \"version\" : n, (numeric) The version\n" | " \"version\" : n, (numeric) The version\n" | ||||
" \"locktime\" : ttt, (numeric) The lock time\n" | " \"locktime\" : ttt, (numeric) The lock time\n" | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
static UniValue decodescript(const Config &config, | static UniValue decodescript(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"decodescript", | RPCHelpMan{"decodescript", | ||||
"\nDecode a hex-encoded script.\n", | "\nDecode a hex-encoded script.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "the hex-encoded script"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"hexstring\" (string) the hex-encoded script\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"asm\":\"asm\", (string) Script public key\n" | " \"asm\":\"asm\", (string) Script public key\n" | ||||
" \"hex\":\"hex\", (string) hex-encoded public key\n" | " \"hex\":\"hex\", (string) hex-encoded public key\n" | ||||
" \"type\":\"type\", (string) The output type\n" | " \"type\":\"type\", (string) The output type\n" | ||||
" \"reqSigs\": n, (numeric) The required signatures\n" | " \"reqSigs\": n, (numeric) The required signatures\n" | ||||
" \"addresses\": [ (json array of string)\n" | " \"addresses\": [ (json array of string)\n" | ||||
" \"address\" (string) bitcoin address\n" | " \"address\" (string) bitcoin address\n" | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"combinerawtransaction", | RPCHelpMan{"combinerawtransaction", | ||||
"\nCombine multiple partially signed transactions into " | "\nCombine multiple partially signed transactions into " | ||||
"one transaction.\n" | "one transaction.\n" | ||||
"The combined transaction may be another partially " | "The combined transaction may be another partially " | ||||
"signed transaction or a \n" | "signed transaction or a \n" | ||||
"fully signed transaction.", | "fully signed transaction.", | ||||
{ | { | ||||
{"txs", | |||||
RPCArg::Type::ARR, | |||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | "txs", | ||||
RPCArg::Type::ARR, | |||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json array of hex strings of partially " | |||||
"signed transactions", | |||||
{ | |||||
{"hexstring", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"A transaction hash"}, | |||||
}, | |||||
}, | }, | ||||
false}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"txs\" (string) A json array of hex strings of " | |||||
"partially signed transactions\n" | |||||
" [\n" | |||||
" \"hexstring\" (string) A transaction hash\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hex\" (string) The hex-encoded raw transaction with " | "\"hex\" (string) The hex-encoded raw transaction with " | ||||
"signature(s)\n" | "signature(s)\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("combinerawtransaction", | HelpExampleCli("combinerawtransaction", | ||||
"[\"myhex1\", \"myhex2\", \"myhex3\"]")); | "[\"myhex1\", \"myhex2\", \"myhex3\"]")); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
"The second argument is an array of base58-encoded private\n" | "The second argument is an array of base58-encoded private\n" | ||||
"keys that will be the only keys used to sign the " | "keys that will be the only keys used to sign the " | ||||
"transaction.\n" | "transaction.\n" | ||||
"The third optional argument (may be null) is an array of " | "The third optional argument (may be null) is an array of " | ||||
"previous transaction outputs that\n" | "previous transaction outputs that\n" | ||||
"this transaction depends on but may not yet be in the block " | "this transaction depends on but may not yet be in the block " | ||||
"chain.\n", | "chain.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR, /* opt */ false, | ||||
{"privkyes", | /* default_val */ "", "The transaction hex string"}, | ||||
RPCArg::Type::ARR, | |||||
{ | { | ||||
{"privatekey", RPCArg::Type::STR_HEX, false}, | "privkeys", | ||||
RPCArg::Type::ARR, | |||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json array of base58-encoded private keys for " | |||||
"signing", | |||||
{ | |||||
{"privatekey", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"private key in base58-encoding"}, | |||||
}, | |||||
}, | }, | ||||
false}, | { | ||||
{"prevtxs", | "prevtxs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"A json array of previous dependent transaction " | |||||
"outputs", | |||||
{ | { | ||||
{"", | |||||
RPCArg::Type::OBJ, | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | "", | ||||
{"vout", RPCArg::Type::NUM, false}, | RPCArg::Type::OBJ, | ||||
{"scriptPubKey", RPCArg::Type::STR_HEX, false}, | /* opt */ true, | ||||
{"redeemScript", RPCArg::Type::STR_HEX, false}, | /* default_val */ "", | ||||
{"amount", RPCArg::Type::AMOUNT, false}, | "", | ||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The transaction id"}, | |||||
{"vout", RPCArg::Type::NUM, /* opt */ false, | |||||
/* default_val */ "", "The output number"}, | |||||
{"scriptPubKey", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"script key"}, | |||||
{"redeemScript", RPCArg::Type::STR_HEX, | |||||
/* opt */ true, /* default_val */ "", | |||||
"(required for P2SH) redeem script"}, | |||||
{"amount", RPCArg::Type::AMOUNT, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The amount spent"}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
true}, | }, | ||||
{"sighashtype", RPCArg::Type::STR, true}, | }, | ||||
}} | {"sighashtype", RPCArg::Type::STR, /* opt */ true, | ||||
.ToString() + | /* default_val */ "ALL|FORKID", | ||||
"The signature hash type. Must be one of:\n" | |||||
"\nArguments:\n" | |||||
"1. \"hexstring\" (string, required) The " | |||||
"transaction hex string\n" | |||||
"2. \"privkeys\" (string, required) 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" | |||||
"3. \"prevtxs\" (string, optional) An json " | |||||
"array of previous dependent transaction outputs\n" | |||||
" [ (json array of json objects, " | |||||
"or 'null' if none provided)\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 for " | |||||
"P2SH) redeem script\n" | |||||
" \"amount\": value (numeric, required) The " | |||||
"amount spent\n" | |||||
" }\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"4. \"sighashtype\" (string, optional, " | |||||
"default=ALL|FORKID) The signature hash type. Must be one of:\n" | |||||
" \"ALL|FORKID\"\n" | " \"ALL|FORKID\"\n" | ||||
" \"NONE|FORKID\"\n" | " \"NONE|FORKID\"\n" | ||||
" \"SINGLE|FORKID\"\n" | " \"SINGLE|FORKID\"\n" | ||||
" \"ALL|FORKID|ANYONECANPAY\"\n" | " \"ALL|FORKID|ANYONECANPAY\"\n" | ||||
" \"NONE|FORKID|ANYONECANPAY\"\n" | " \"NONE|FORKID|ANYONECANPAY\"\n" | ||||
" \"SINGLE|FORKID|ANYONECANPAY\"\n" | " \"SINGLE|FORKID|ANYONECANPAY\"\n"}, | ||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"hex\" : \"value\", (string) The hex-encoded " | " \"hex\" : \"value\", (string) The hex-encoded " | ||||
"raw transaction with signature(s)\n" | "raw transaction with signature(s)\n" | ||||
" \"complete\" : true|false, (boolean) If the " | " \"complete\" : true|false, (boolean) If the " | ||||
"transaction has a complete set of signatures\n" | "transaction has a complete set of signatures\n" | ||||
" \"errors\" : [ (json array of objects) " | " \"errors\" : [ (json array of objects) " | ||||
"Script verification errors (if there are any)\n" | "Script verification errors (if there are any)\n" | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"sendrawtransaction", | RPCHelpMan{"sendrawtransaction", | ||||
"\nSubmits raw transaction (serialized, hex-encoded) to " | "\nSubmits raw transaction (serialized, hex-encoded) to " | ||||
"local node and network.\n" | "local node and network.\n" | ||||
"\nAlso see createrawtransaction and " | "\nAlso see createrawtransaction and " | ||||
"signrawtransactionwithkey calls.\n", | "signrawtransactionwithkey calls.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
{"allowhighfees", RPCArg::Type::BOOL, true}, | /* default_val */ "", | ||||
"The hex string of the raw transaction"}, | |||||
{"allowhighfees", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", "Allow high fees"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\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" | "\nResult:\n" | ||||
"\"hex\" (string) The transaction hash in hex\n" | "\"hex\" (string) The transaction hash in hex\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nCreate a transaction\n" + | "\nCreate a transaction\n" + | ||||
HelpExampleCli( | HelpExampleCli( | ||||
"createrawtransaction", | "createrawtransaction", | ||||
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " | "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " | ||||
"\"{\\\"myaddress\\\":0.01}\"") + | "\"{\\\"myaddress\\\":0.01}\"") + | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | static UniValue sendrawtransaction(const Config &config, | ||||
return txid.GetHex(); | return txid.GetHex(); | ||||
} | } | ||||
static UniValue testmempoolaccept(const Config &config, | static UniValue testmempoolaccept(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
// clang-format off | RPCHelpMan{"testmempoolaccept", | ||||
"testmempoolaccept [\"rawtxs\"] ( allowhighfees )\n" | "\nReturns if raw transaction (serialized, hex-encoded) " | ||||
"\nReturns if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n" | "would be accepted by mempool.\n" | ||||
"\nThis checks if the transaction violates the consensus or policy rules.\n" | "\nThis checks if the transaction violates the " | ||||
"\nSee sendrawtransaction call.\n" | "consensus or policy rules.\n" | ||||
"\nArguments:\n" | "\nSee sendrawtransaction call.\n", | ||||
"1. [\"rawtxs\"] (array, required) An array of hex strings of raw transactions.\n" | { | ||||
" Length must be one for now.\n" | { | ||||
"2. allowhighfees (boolean, optional, default=false) Allow high fees\n" | "rawtxs", | ||||
RPCArg::Type::ARR, | |||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"An array of hex strings of raw transactions.\n" | |||||
" Length " | |||||
"must be one for now.", | |||||
{ | |||||
{"rawtx", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", ""}, | |||||
}, | |||||
}, | |||||
{"allowhighfees", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", "Allow high fees"}, | |||||
}} | |||||
.ToString() + | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[ (array) The result of the mempool acceptance test for each raw transaction in the input array.\n" | "[ (array) The result of the mempool acceptance " | ||||
"test for each raw transaction in the input array.\n" | |||||
" Length is exactly one for now.\n" | " Length is exactly one for now.\n" | ||||
" {\n" | " {\n" | ||||
" \"txid\" (string) The transaction hash in hex\n" | " \"txid\" (string) The transaction hash in hex\n" | ||||
" \"allowed\" (boolean) If the mempool allows this tx to be inserted\n" | " \"allowed\" (boolean) If the mempool allows this tx to " | ||||
" \"reject-reason\" (string) Rejection string (only present when 'allowed' is false)\n" | "be inserted\n" | ||||
" \"reject-reason\" (string) Rejection string (only present when " | |||||
"'allowed' is false)\n" | |||||
" }\n" | " }\n" | ||||
"]\n" | "]\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nCreate a transaction\n" | "\nCreate a transaction\n" + | ||||
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") + | HelpExampleCli( | ||||
"Sign the transaction, and get back the hex\n" | "createrawtransaction", | ||||
+ HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " | ||||
"\nTest acceptance of the transaction (signed hex)\n" | "\"{\\\"myaddress\\\":0.01}\"") + | ||||
+ HelpExampleCli("testmempoolaccept", "\"signedhex\"") + | "Sign the transaction, and get back the hex\n" + | ||||
"\nAs a JSON-RPC call\n" | HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | ||||
+ HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]") | "\nTest acceptance of the transaction (signed hex)\n" + | ||||
// clang-format on | HelpExampleCli("testmempoolaccept", "\"signedhex\"") + | ||||
); | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")); | |||||
} | } | ||||
RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VBOOL}); | RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VBOOL}); | ||||
if (request.params[0].get_array().size() != 1) { | if (request.params[0].get_array().size() != 1) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"Array must contain exactly one raw transaction for now"); | "Array must contain exactly one raw transaction for now"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
static UniValue decodepsbt(const Config &config, | static UniValue decodepsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"decodepsbt", | RPCHelpMan{"decodepsbt", | ||||
"\nReturn a JSON object representing the serialized, " | "\nReturn a JSON object representing the serialized, " | ||||
"base64-encoded partially signed Bitcoin transaction.\n", | "base64-encoded partially signed Bitcoin transaction.\n", | ||||
{ | { | ||||
{"psbt", RPCArg::Type::STR, false}, | {"psbt", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The PSBT base64 string"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"psbt\" (string, required) The PSBT base64 string\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"tx\" : { (json object) The decoded " | " \"tx\" : { (json object) The decoded " | ||||
"network-serialized unsigned transaction.\n" | "network-serialized unsigned transaction.\n" | ||||
" ... The layout is the " | " ... The layout is the " | ||||
"same as the output of decoderawtransaction.\n" | "same as the output of decoderawtransaction.\n" | ||||
" },\n" | " },\n" | ||||
" \"unknown\" : { (json object) The unknown global " | " \"unknown\" : { (json object) The unknown global " | ||||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | static UniValue decodepsbt(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue combinepsbt(const Config &config, | static UniValue combinepsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"combinepsbt", | RPCHelpMan{ | ||||
"\nCombine multiple partially signed Bitcoin " | "combinepsbt", | ||||
"transactions into one transaction.\n" | "\nCombine multiple partially signed Bitcoin transactions into " | ||||
"one transaction.\n" | |||||
"Implements the Combiner role.\n", | "Implements the Combiner role.\n", | ||||
{ | { | ||||
{"txs", | { | ||||
"txs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json array of base64 strings of partially signed " | |||||
"transactions", | |||||
{ | { | ||||
{"psbt", RPCArg::Type::STR, false}, | {"psbt", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "A base64 string of a PSBT"}, | |||||
}, | |||||
}, | }, | ||||
false}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"txs\" (string) A json array of base64 " | |||||
"strings of partially signed transactions\n" | |||||
" [\n" | |||||
" \"psbt\" (string) A base64 string of a PSBT\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
" \"psbt\" (string) The base64-encoded partially signed " | " \"psbt\" (string) The base64-encoded partially signed " | ||||
"transaction\n" | "transaction\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("combinepsbt", | HelpExampleCli("combinepsbt", | ||||
"[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]")); | "[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]")); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"Finalize the inputs of a PSBT. If the transaction is " | "Finalize the inputs of a PSBT. If the transaction is " | ||||
"fully signed, it will produce a\n" | "fully signed, it will produce a\n" | ||||
"network serialized transaction which can be broadcast " | "network serialized transaction which can be broadcast " | ||||
"with sendrawtransaction. Otherwise a PSBT will be\n" | "with sendrawtransaction. Otherwise a PSBT will be\n" | ||||
"created which has the final_scriptSigfields filled for " | "created which has the final_scriptSigfields filled for " | ||||
"inputs that are complete.\n" | "inputs that are complete.\n" | ||||
"Implements the Finalizer and Extractor roles.\n", | "Implements the Finalizer and Extractor roles.\n", | ||||
{ | { | ||||
{"psbt", RPCArg::Type::STR, false}, | {"psbt", RPCArg::Type::STR, /* opt */ false, | ||||
{"extract", RPCArg::Type::BOOL, true}, | /* default_val */ "", "A base64 string of a PSBT"}, | ||||
{"extract", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "true", | |||||
"If true and the transaction is complete,\n" | |||||
" extract and return " | |||||
"the complete transaction in normal network " | |||||
"serialization instead of the PSBT."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"psbt\" (string) A base64 string of a PSBT\n" | |||||
"2. \"extract\" (boolean, optional, default=true) If " | |||||
"true and the transaction is complete, \n" | |||||
" extract and return the complete " | |||||
"transaction in normal network serialization instead of the PSBT.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"psbt\" : \"value\", (string) The base64-encoded " | " \"psbt\" : \"value\", (string) The base64-encoded " | ||||
"partially signed transaction if not extracted\n" | "partially signed transaction if not extracted\n" | ||||
" \"hex\" : \"value\", (string) The hex-encoded network " | " \"hex\" : \"value\", (string) The hex-encoded network " | ||||
"transaction if extracted\n" | "transaction if extracted\n" | ||||
" \"complete\" : true|false, (boolean) If the transaction has a " | " \"complete\" : true|false, (boolean) If the transaction has a " | ||||
"complete set of signatures\n" | "complete set of signatures\n" | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static UniValue finalizepsbt(const Config &config, | ||||
return result; | return result; | ||||
} | } | ||||
static UniValue createpsbt(const Config &config, | static UniValue createpsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"createpsbt", | RPCHelpMan{ | ||||
"createpsbt", | |||||
"\nCreates a transaction in the Partially Signed " | "\nCreates a transaction in the Partially Signed " | ||||
"Transaction format.\n" | "Transaction format.\n" | ||||
"Implements the Creator role.\n", | "Implements the Creator role.\n", | ||||
{ | { | ||||
{"inputs", | { | ||||
"inputs", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"A json array of json objects", | |||||
{ | { | ||||
{"", | |||||
RPCArg::Type::OBJ, | |||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | "", | ||||
{"vout", RPCArg::Type::NUM, false}, | RPCArg::Type::OBJ, | ||||
{"sequence", RPCArg::Type::NUM, true}, | /* opt */ false, | ||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"txid", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"The transaction id"}, | |||||
{"vout", RPCArg::Type::NUM, /* opt */ false, | |||||
/* default_val */ "", "The output number"}, | |||||
{"sequence", RPCArg::Type::NUM, | |||||
/* opt */ true, /* default_val */ "", | |||||
"The sequence number"}, | |||||
}, | |||||
}, | |||||
}, | }, | ||||
false}, | |||||
}, | }, | ||||
false}, | { | ||||
{"outputs", | "outputs", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
/* opt */ false, | |||||
/* default_val */ "", | |||||
"a json array with outputs (key-value pairs).\n" | |||||
"For compatibility reasons, a dictionary, which holds " | |||||
"the key-value pairs directly, is also\n" | |||||
" accepted as second " | |||||
"parameter.", | |||||
{ | { | ||||
{"", | |||||
RPCArg::Type::OBJ, | |||||
{ | { | ||||
{"address", RPCArg::Type::AMOUNT, false}, | "", | ||||
}, | |||||
true}, | |||||
{"", | |||||
RPCArg::Type::OBJ, | RPCArg::Type::OBJ, | ||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"address", RPCArg::Type::AMOUNT, | |||||
/* opt */ false, /* default_val */ "", | |||||
"A key-value pair. The key (string) is " | |||||
"the bitcoin address, the value (float or " | |||||
"string) is the amount in " + | |||||
CURRENCY_UNIT}, | |||||
}, | |||||
}, | |||||
{ | { | ||||
{"data", RPCArg::Type::STR_HEX, false}, | "", | ||||
RPCArg::Type::OBJ, | |||||
/* opt */ true, | |||||
/* default_val */ "", | |||||
"", | |||||
{ | |||||
{"data", RPCArg::Type::STR_HEX, | |||||
/* opt */ false, /* default_val */ "", | |||||
"A key-value pair. The key must be " | |||||
"\"data\", the value is hex-encoded data"}, | |||||
}, | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
false}, | {"locktime", RPCArg::Type::NUM, /* opt */ true, | ||||
{"locktime", RPCArg::Type::NUM, true}, | /* default_val */ "0", | ||||
"Raw locktime. Non-0 value also locktime-activates " | |||||
"inputs"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"inputs\" (array, 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" | |||||
" \"sequence\":n (numeric, optional) The sequence " | |||||
"number\n" | |||||
" } \n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"2. \"outputs\" (array, required) a json array with " | |||||
"outputs (key-value pairs)\n" | |||||
" [\n" | |||||
" {\n" | |||||
" \"address\": x.xxx, (obj, optional) A key-value pair. " | |||||
"The key (string) is the bitcoin address, the value (float or " | |||||
"string) is the amount in " + | |||||
CURRENCY_UNIT + | |||||
"\n" | |||||
" },\n" | |||||
" {\n" | |||||
" \"data\": \"hex\" (obj, optional) A key-value pair. " | |||||
"The key must be \"data\", the value is hex-encoded data\n" | |||||
" }\n" | |||||
" ,... More key-value pairs of the above " | |||||
"form. For compatibility reasons, a dictionary, which holds the " | |||||
"key-value pairs directly, is also\n" | |||||
" accepted as second parameter.\n" | |||||
" ]\n" | |||||
"3. locktime (numeric, optional, default=0) Raw " | |||||
"locktime. Non-0 value also locktime-activates inputs\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
" \"psbt\" (string) The resulting raw transaction " | " \"psbt\" (string) The resulting raw transaction " | ||||
"(base64-encoded string)\n" | "(base64-encoded string)\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("createpsbt", | HelpExampleCli("createpsbt", | ||||
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | ||||
"\"[{\\\"data\\\":\\\"00010203\\\"}]\"")); | "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")); | ||||
} | } | ||||
Show All 27 Lines | static UniValue createpsbt(const Config &config, | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | ||||
} | } | ||||
static UniValue converttopsbt(const Config &config, | static UniValue converttopsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"converttopsbt", | RPCHelpMan{ | ||||
"converttopsbt", | |||||
"\nConverts a network serialized transaction to a PSBT. " | "\nConverts a network serialized transaction to a PSBT. " | ||||
"This should be used only with createrawtransaction and " | "This should be used only with createrawtransaction and " | ||||
"fundrawtransaction\n" | "fundrawtransaction\n" | ||||
"createpsbt and walletcreatefundedpsbt should be used " | "createpsbt and walletcreatefundedpsbt should be used " | ||||
"for new applications.\n", | "for new applications.\n", | ||||
{ | { | ||||
{"hexstring", RPCArg::Type::STR_HEX, false}, | {"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
{"permitsigdata", RPCArg::Type::BOOL, true}, | /* default_val */ "", | ||||
"The hex string of a raw transaction"}, | |||||
{"permitsigdata", RPCArg::Type::BOOL, /* opt */ true, | |||||
/* default_val */ "false", | |||||
"If true, any signatures in the input will be discarded " | |||||
"and conversion\n" | |||||
" will continue. If false, " | |||||
"RPC will fail if any signatures are present."}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"hexstring\" (string, required) The hex string " | |||||
"of a raw transaction\n" | |||||
"2. permitsigdata (boolean, optional, default=false) If " | |||||
"true, any signatures in the input will be discarded and " | |||||
"conversion.\n" | |||||
" will continue. If false, RPC will " | |||||
"fail if any signatures are present.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
" \"psbt\" (string) The resulting raw transaction " | " \"psbt\" (string) The resulting raw transaction " | ||||
"(base64-encoded string)\n" | "(base64-encoded string)\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nCreate a transaction\n" + | "\nCreate a transaction\n" + | ||||
HelpExampleCli("createrawtransaction", | HelpExampleCli("createrawtransaction", | ||||
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" " | ||||
"\"[{\\\"data\\\":\\\"00010203\\\"}]\"") + | "\"[{\\\"data\\\":\\\"00010203\\\"}]\"") + | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |