Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show All 9 Lines | |||||
#include "consensus/validation.h" | #include "consensus/validation.h" | ||||
#include "core_io.h" | #include "core_io.h" | ||||
#include "dstencode.h" | #include "dstencode.h" | ||||
#include "net.h" | #include "net.h" | ||||
#include "policy/fees.h" | #include "policy/fees.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "rpc/mining.h" | #include "rpc/mining.h" | ||||
#include "rpc/misc.h" | #include "rpc/misc.h" | ||||
#include "rpc/rawtransaction.h" | |||||
#include "rpc/safemode.h" | #include "rpc/safemode.h" | ||||
#include "rpc/server.h" | #include "rpc/server.h" | ||||
#include "timedata.h" | #include "timedata.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilmoneystr.h" | #include "utilmoneystr.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#include "wallet.h" | #include "wallet.h" | ||||
#include "wallet/coincontrol.h" | #include "wallet/coincontrol.h" | ||||
▲ Show 20 Lines • Show All 3,479 Lines • ▼ Show 20 Lines | static UniValue fundrawtransaction(const Config &config, | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("hex", EncodeHexTx(CTransaction(tx))); | result.pushKV("hex", EncodeHexTx(CTransaction(tx))); | ||||
result.pushKV("changepos", changePosition); | result.pushKV("changepos", changePosition); | ||||
result.pushKV("fee", ValueFromAmount(nFeeOut)); | result.pushKV("fee", ValueFromAmount(nFeeOut)); | ||||
return result; | return result; | ||||
} | } | ||||
UniValue signrawtransactionwithwallet(const Config &config, | |||||
const JSONRPCRequest &request) { | |||||
CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | |||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | |||||
return NullUniValue; | |||||
} | |||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) | |||||
deadalnix: braces | |||||
throw std::runtime_error( | |||||
"signrawtransactionwithwallet \"hexstring\" ( " | |||||
"[{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\"," | |||||
"\"redeemScript\":\"hex\"},...] 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" + | |||||
HelpRequiringPassphrase(pwallet) + | |||||
"\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, " | |||||
"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" | |||||
"3. \"sighashtype\" (string, optional, " | |||||
"default=ALL) The signature hash type. Must be one of\n" | |||||
" \"ALL\"\n" | |||||
" \"NONE\"\n" | |||||
" \"SINGLE\"\n" | |||||
" \"ALL|ANYONECANPAY\"\n" | |||||
" \"NONE|ANYONECANPAY\"\n" | |||||
" \"SINGLE|ANYONECANPAY\"\n" | |||||
" \"ALL|FORKID\"\n" | |||||
" \"NONE|FORKID\"\n" | |||||
" \"SINGLE|FORKID\"\n" | |||||
" \"ALL|FORKID|ANYONECANPAY\"\n" | |||||
" \"NONE|FORKID|ANYONECANPAY\"\n" | |||||
" \"SINGLE|FORKID|ANYONECANPAY\"\n" | |||||
"\nResult:\n" | |||||
"{\n" | |||||
" \"hex\" : \"value\", (string) The hex-encoded " | |||||
"raw transaction with signature(s)\n" | |||||
" \"complete\" : true|false, (boolean) If the " | |||||
"transaction has a complete set of signatures\n" | |||||
" \"errors\" : [ (json array of objects) " | |||||
"Script verification errors (if there are any)\n" | |||||
" {\n" | |||||
" \"txid\" : \"hash\", (string) The hash of the " | |||||
"referenced, previous transaction\n" | |||||
" \"vout\" : n, (numeric) The index of the " | |||||
"output to spent and used as input\n" | |||||
" \"scriptSig\" : \"hex\", (string) The hex-encoded " | |||||
"signature script\n" | |||||
" \"sequence\" : n, (numeric) Script sequence " | |||||
"number\n" | |||||
" \"error\" : \"text\" (string) Verification or " | |||||
"signing error related to the input\n" | |||||
" }\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
"}\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | |||||
HelpExampleRpc("signrawtransactionwithwallet", "\"myhex\"")); | |||||
RPCTypeCheck(request.params, | |||||
{UniValue::VSTR, UniValue::VARR, UniValue::VSTR}, true); | |||||
CMutableTransaction mtx; | |||||
if (!DecodeHexTx(mtx, request.params[0].get_str())) { | |||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | |||||
} | |||||
// Sign the transaction | |||||
LOCK2(cs_main, pwallet->cs_wallet); | |||||
return SignTransaction(mtx, request.params[1], pwallet, false, | |||||
request.params[2]); | |||||
} | |||||
static UniValue generate(const Config &config, const JSONRPCRequest &request) { | static UniValue generate(const Config &config, const JSONRPCRequest &request) { | ||||
CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | UniValue rescanblockchain(const Config &config, const JSONRPCRequest &request) { | ||||
UniValue response(UniValue::VOBJ); | UniValue response(UniValue::VOBJ); | ||||
response.pushKV("start_height", pindexStart->nHeight); | response.pushKV("start_height", pindexStart->nHeight); | ||||
response.pushKV("stop_height", stopBlock->nHeight); | response.pushKV("stop_height", stopBlock->nHeight); | ||||
return response; | return response; | ||||
} | } | ||||
// clang-format off | // clang-format off | ||||
static const ContextFreeRPCCommand commands[] = { | static const ContextFreeRPCCommand commands[] = { | ||||
// category name actor (function) argNames | // category name actor (function) argNames | ||||
// ------------------- ------------------------ ---------------------- ---------- | // ------------------- ------------------------ ---------------------- ---------- | ||||
{ "rawtransactions", "fundrawtransaction", fundrawtransaction, {"hexstring","options"} }, | { "rawtransactions", "fundrawtransaction", fundrawtransaction, {"hexstring","options"} }, | ||||
{ "hidden", "resendwallettransactions", resendwallettransactions, {} }, | { "hidden", "resendwallettransactions", resendwallettransactions, {} }, | ||||
{ "wallet", "abandontransaction", abandontransaction, {"txid"} }, | { "wallet", "abandontransaction", abandontransaction, {"txid"} }, | ||||
{ "wallet", "addmultisigaddress", addmultisigaddress, {"nrequired","keys","label|account"} }, | { "wallet", "addmultisigaddress", addmultisigaddress, {"nrequired","keys","label|account"} }, | ||||
{ "wallet", "backupwallet", backupwallet, {"destination"} }, | { "wallet", "backupwallet", backupwallet, {"destination"} }, | ||||
{ "wallet", "encryptwallet", encryptwallet, {"passphrase"} }, | { "wallet", "encryptwallet", encryptwallet, {"passphrase"} }, | ||||
{ "wallet", "getaccountaddress", getlabeladdress, {"account"} }, | { "wallet", "getaccountaddress", getlabeladdress, {"account"} }, | ||||
{ "wallet", "getlabeladdress", getlabeladdress, {"label"} }, | { "wallet", "getlabeladdress", getlabeladdress, {"label"} }, | ||||
{ "wallet", "getaccount", getaccount, {"address"} }, | { "wallet", "getaccount", getaccount, {"address"} }, | ||||
{ "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, | { "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, | ||||
{ "wallet", "getbalance", getbalance, {"account","minconf","include_watchonly"} }, | { "wallet", "getbalance", getbalance, {"account","minconf","include_watchonly"} }, | ||||
{ "wallet", "getnewaddress", getnewaddress, {"label|account"} }, | { "wallet", "getnewaddress", getnewaddress, {"label|account"} }, | ||||
{ "wallet", "getrawchangeaddress", getrawchangeaddress, {} }, | { "wallet", "getrawchangeaddress", getrawchangeaddress, {} }, | ||||
{ "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | { "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | ||||
{ "wallet", "getreceivedbyaccount", getreceivedbylabel, {"account","minconf"} }, | { "wallet", "getreceivedbyaccount", getreceivedbylabel, {"account","minconf"} }, | ||||
{ "wallet", "getreceivedbyaddress", getreceivedbyaddress, {"address","minconf"} }, | { "wallet", "getreceivedbyaddress", getreceivedbyaddress, {"address","minconf"} }, | ||||
{ "wallet", "gettransaction", gettransaction, {"txid","include_watchonly"} }, | { "wallet", "gettransaction", gettransaction, {"txid","include_watchonly"} }, | ||||
{ "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, | { "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, | ||||
{ "wallet", "getwalletinfo", getwalletinfo, {} }, | { "wallet", "getwalletinfo", getwalletinfo, {} }, | ||||
{ "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, | { "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, | ||||
{ "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, | { "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, | ||||
{ "wallet", "listaddressgroupings", listaddressgroupings, {} }, | { "wallet", "listaddressgroupings", listaddressgroupings, {} }, | ||||
{ "wallet", "listlockunspent", listlockunspent, {} }, | { "wallet", "listlockunspent", listlockunspent, {} }, | ||||
{ "wallet", "listreceivedbylabel", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | { "wallet", "listreceivedbylabel", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | ||||
{ "wallet", "listreceivedbyaccount", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | { "wallet", "listreceivedbyaccount", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | ||||
{ "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} }, | { "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} }, | ||||
{ "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly"} }, | { "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly"} }, | ||||
{ "wallet", "listtransactions", listtransactions, {"account","count","skip","include_watchonly"} }, | { "wallet", "listtransactions", listtransactions, {"account","count","skip","include_watchonly"} }, | ||||
{ "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, | { "wallet", "listunspent", listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} }, | ||||
{ "wallet", "listwallets", listwallets, {} }, | { "wallet", "listwallets", listwallets, {} }, | ||||
{ "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | { "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | ||||
{ "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, | { "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, | ||||
{ "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | { "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | ||||
{ "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | { "wallet", "sendfrom", sendfrom, {"fromaccount","toaddress","amount","minconf","comment","comment_to"} }, | ||||
{ "wallet", "sendmany", sendmany, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, | { "wallet", "sendmany", sendmany, {"fromaccount","amounts","minconf","comment","subtractfeefrom"} }, | ||||
{ "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | { "wallet", "sendtoaddress", sendtoaddress, {"address","amount","comment","comment_to","subtractfeefromamount"} }, | ||||
{ "wallet", "setlabel", setlabel, {"address","label"} }, | { "wallet", "setlabel", setlabel, {"address","label"} }, | ||||
{ "wallet", "setaccount", setlabel, {"address","account"} }, | { "wallet", "setaccount", setlabel, {"address","account"} }, | ||||
{ "wallet", "settxfee", settxfee, {"amount"} }, | { "wallet", "settxfee", settxfee, {"amount"} }, | ||||
{ "wallet", "signmessage", signmessage, {"address","message"} }, | { "wallet", "signmessage", signmessage, {"address","message"} }, | ||||
{ "wallet", "signrawtransactionwithwallet", signrawtransactionwithwallet, {"hextring","prevtxs","sighashtype"} }, | |||||
deadalnixUnsubmitted Not Done Inline Actionsdito, it seems that there are more spaces than required in there deadalnix: dito, it seems that there are more spaces than required in there | |||||
{ "wallet", "walletlock", walletlock, {} }, | { "wallet", "walletlock", walletlock, {} }, | ||||
{ "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, | { "wallet", "walletpassphrasechange", walletpassphrasechange, {"oldpassphrase","newpassphrase"} }, | ||||
{ "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, | { "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, | ||||
{ "generating", "generate", generate, {"nblocks","maxtries"} }, | { "generating", "generate", generate, {"nblocks","maxtries"} }, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
void RegisterWalletRPCCommands(CRPCTable &t) { | void RegisterWalletRPCCommands(CRPCTable &t) { | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | ||||
t.appendCommand(commands[vcidx].name, &commands[vcidx]); | t.appendCommand(commands[vcidx].name, &commands[vcidx]); | ||||
} | } | ||||
} | } |
braces