Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 1,923 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"Get detailed information about in-wallet transaction <txid>\n", | "Get detailed information about in-wallet transaction <txid>\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, | {"txid", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The transaction id"}, | "The transaction id"}, | ||||
{"include_watchonly", RPCArg::Type::BOOL, | {"include_watchonly", RPCArg::Type::BOOL, | ||||
/* default */ "true for watch-only wallets, otherwise false", | /* default */ "true for watch-only wallets, otherwise false", | ||||
"Whether to include watch-only addresses in balance calculation " | "Whether to include watch-only addresses in balance calculation " | ||||
"and details[]"}, | "and details[]"}, | ||||
{"decode", RPCArg::Type::BOOL, /* default */ "false", | |||||
"Whether to add a field with the decoded transaction"}, | |||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"amount\" : x.xxx, (numeric) The transaction amount " | " \"amount\" : x.xxx, (numeric) The transaction amount " | ||||
"in " + | "in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
"\n" | "\n" | ||||
" \"fee\": x.xxx, (numeric) The amount of the fee in " + | " \"fee\": x.xxx, (numeric) The amount of the fee in " + | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"transaction has been abandoned (inputs are respendable). Only " | "transaction has been abandoned (inputs are respendable). Only " | ||||
"available for the \n" | "available for the \n" | ||||
" 'send' category of " | " 'send' category of " | ||||
"transactions.\n" | "transactions.\n" | ||||
" }\n" | " }\n" | ||||
" ,...\n" | " ,...\n" | ||||
" ],\n" | " ],\n" | ||||
" \"hex\" : \"data\" (string) Raw data for transaction\n" | " \"hex\" : \"data\" (string) Raw data for transaction\n" | ||||
" \"decoded\" : transaction (json object) Optional, the " | |||||
"decoded transaction\n" | |||||
"}\n"}, | "}\n"}, | ||||
RPCExamples{HelpExampleCli("gettransaction", | RPCExamples{HelpExampleCli("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\"") + | "5cf302fc80e9d5fbf5d48d\"") + | ||||
HelpExampleCli("gettransaction", | HelpExampleCli("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\" true") + | "5cf302fc80e9d5fbf5d48d\" true") + | ||||
HelpExampleCli("gettransaction", | |||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | |||||
"5cf302fc80e9d5fbf5d48d\" false true") + | |||||
HelpExampleRpc("gettransaction", | HelpExampleRpc("gettransaction", | ||||
"\"1075db55d416d3ca199f55b6084e2115b9345e16c" | "\"1075db55d416d3ca199f55b6084e2115b9345e16c" | ||||
"5cf302fc80e9d5fbf5d48d\"")}, | "5cf302fc80e9d5fbf5d48d\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
TxId txid(ParseHashV(request.params[0], "txid")); | TxId txid(ParseHashV(request.params[0], "txid")); | ||||
isminefilter filter = ISMINE_SPENDABLE; | isminefilter filter = ISMINE_SPENDABLE; | ||||
if (ParseIncludeWatchonly(request.params[1], *pwallet)) { | if (ParseIncludeWatchonly(request.params[1], *pwallet)) { | ||||
filter |= ISMINE_WATCH_ONLY; | filter |= ISMINE_WATCH_ONLY; | ||||
} | } | ||||
bool decode_tx = | |||||
request.params[2].isNull() ? false : request.params[2].get_bool(); | |||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
auto it = pwallet->mapWallet.find(txid); | auto it = pwallet->mapWallet.find(txid); | ||||
if (it == pwallet->mapWallet.end()) { | if (it == pwallet->mapWallet.end()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid or non-wallet transaction id"); | "Invalid or non-wallet transaction id"); | ||||
} | } | ||||
const CWalletTx &wtx = it->second; | const CWalletTx &wtx = it->second; | ||||
Show All 14 Lines | static UniValue gettransaction(const Config &config, | ||||
ListTransactions(*locked_chain, pwallet, wtx, 0, false, details, filter, | ListTransactions(*locked_chain, pwallet, wtx, 0, false, details, filter, | ||||
nullptr /* filter_label */); | nullptr /* filter_label */); | ||||
entry.pushKV("details", details); | entry.pushKV("details", details); | ||||
std::string strHex = | std::string strHex = | ||||
EncodeHexTx(*wtx.tx, pwallet->chain().rpcSerializationFlags()); | EncodeHexTx(*wtx.tx, pwallet->chain().rpcSerializationFlags()); | ||||
entry.pushKV("hex", strHex); | entry.pushKV("hex", strHex); | ||||
if (decode_tx) { | |||||
UniValue decoded(UniValue::VOBJ); | |||||
TxToUniv(*wtx.tx, uint256(), decoded, false); | |||||
entry.pushKV("decoded", decoded); | |||||
} | |||||
return entry; | return entry; | ||||
} | } | ||||
static UniValue abandontransaction(const Config &config, | static UniValue abandontransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
▲ Show 20 Lines • Show All 2,672 Lines • ▼ Show 20 Lines | static const CRPCCommand commands[] = { | ||||
{ "wallet", "encryptwallet", encryptwallet, {"passphrase"} }, | { "wallet", "encryptwallet", encryptwallet, {"passphrase"} }, | ||||
{ "wallet", "getaddressesbylabel", getaddressesbylabel, {"label"} }, | { "wallet", "getaddressesbylabel", getaddressesbylabel, {"label"} }, | ||||
{ "wallet", "getaddressinfo", getaddressinfo, {"address"} }, | { "wallet", "getaddressinfo", getaddressinfo, {"address"} }, | ||||
{ "wallet", "getbalance", getbalance, {"dummy","minconf","include_watchonly","avoid_reuse"} }, | { "wallet", "getbalance", getbalance, {"dummy","minconf","include_watchonly","avoid_reuse"} }, | ||||
{ "wallet", "getnewaddress", getnewaddress, {"label", "address_type"} }, | { "wallet", "getnewaddress", getnewaddress, {"label", "address_type"} }, | ||||
{ "wallet", "getrawchangeaddress", getrawchangeaddress, {"address_type"} }, | { "wallet", "getrawchangeaddress", getrawchangeaddress, {"address_type"} }, | ||||
{ "wallet", "getreceivedbyaddress", getreceivedbyaddress, {"address","minconf"} }, | { "wallet", "getreceivedbyaddress", getreceivedbyaddress, {"address","minconf"} }, | ||||
{ "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | { "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | ||||
{ "wallet", "gettransaction", gettransaction, {"txid","include_watchonly"} }, | { "wallet", "gettransaction", gettransaction, {"txid","include_watchonly","decode"} }, | ||||
{ "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, | { "wallet", "getunconfirmedbalance", getunconfirmedbalance, {} }, | ||||
{ "wallet", "getbalances", getbalances, {} }, | { "wallet", "getbalances", getbalances, {} }, | ||||
{ "wallet", "getwalletinfo", getwalletinfo, {} }, | { "wallet", "getwalletinfo", getwalletinfo, {} }, | ||||
{ "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, | { "wallet", "keypoolrefill", keypoolrefill, {"newsize"} }, | ||||
{ "wallet", "listaddressgroupings", listaddressgroupings, {} }, | { "wallet", "listaddressgroupings", listaddressgroupings, {} }, | ||||
{ "wallet", "listlabels", listlabels, {"purpose"} }, | { "wallet", "listlabels", listlabels, {"purpose"} }, | ||||
{ "wallet", "listlockunspent", listlockunspent, {} }, | { "wallet", "listlockunspent", listlockunspent, {} }, | ||||
{ "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} }, | { "wallet", "listreceivedbyaddress", listreceivedbyaddress, {"minconf","include_empty","include_watchonly","address_filter"} }, | ||||
Show All 35 Lines |