Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | |||||
static UniValue getlabeladdress(const Config &config, | static UniValue getlabeladdress(const Config &config, | ||||
const JSONRPCRequest &request) { | 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 || | ||||
request.params.size() > 2) { | |||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getlabeladdress \"label\"\n" | "getlabeladdress \"label\" ( force ) \n" | ||||
"\nReturns the current Bitcoin address for receiving payments to " | "\nReturns the default receiving address for this label. This will " | ||||
"this label.\n" | "reset to a fresh address once there's a transaction that spends " | ||||
"to it.\n" | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"label\" (string, required) The label name for the " | "1. \"label\" (string, required) The label for the " | ||||
"address. It can also be set to the empty string \"\" to represent " | "address. It can also be set to the empty string \"\" to represent " | ||||
"the default label. The label does not need to exist, it will be " | "the default label.\n" | ||||
"created and a new address created if there is no label by the " | "2. \"force\" (bool, optional) Whether the label should be " | ||||
"given name.\n" | "created if it does not yet exist. If False, the RPC will return " | ||||
"an error if called with a label that doesn't exist.\n" | |||||
" Defaults to false (unless the " | |||||
"getaccountaddress method alias is being called, in which case " | |||||
"defaults to true for backwards compatibility).\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"address\" (string) The label bitcoin address\n" | "\"address\" (string) The current receiving address for " | ||||
"the label.\n" | |||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getlabeladdress", "") + | HelpExampleCli("getlabeladdress", "") + | ||||
HelpExampleCli("getlabeladdress", "\"\"") + | HelpExampleCli("getlabeladdress", "\"\"") + | ||||
HelpExampleCli("getlabeladdress", "\"mylabel\"") + | HelpExampleCli("getlabeladdress", "\"mylabel\"") + | ||||
HelpExampleRpc("getlabeladdress", "\"mylabel\"")); | HelpExampleRpc("getlabeladdress", "\"mylabel\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
// Parse the label first so we don't generate a key if there's an error | // Parse the label first so we don't generate a key if there's an error | ||||
std::string label = LabelFromValue(request.params[0]); | std::string label = LabelFromValue(request.params[0]); | ||||
bool force = request.strMethod == "getaccountaddress" ? true : false; | |||||
if (!request.params[1].isNull()) { | |||||
force = request.params[1].get_bool(); | |||||
} | |||||
bool label_found = false; | |||||
for (const std::pair<CTxDestination, CAddressBookData> &item : | |||||
pwallet->mapAddressBook) { | |||||
if (item.second.name == label) { | |||||
label_found = true; | |||||
break; | |||||
} | |||||
} | |||||
if (!force && !label_found) { | |||||
throw JSONRPCError(RPC_WALLET_INVALID_LABEL_NAME, | |||||
std::string("No addresses with label " + label)); | |||||
} | |||||
UniValue ret(UniValue::VSTR); | UniValue ret(UniValue::VSTR); | ||||
ret = EncodeDestination(GetLabelDestination(pwallet, label), config); | ret = EncodeDestination(GetLabelDestination(pwallet, label), config); | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue getrawchangeaddress(const Config &config, | static UniValue getrawchangeaddress(const Config &config, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static UniValue setlabel(const Config &config, const JSONRPCRequest &request) { | static UniValue setlabel(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() != 2) { | ||||
request.params.size() > 2) { | |||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"setlabel \"address\" \"label\"\n" | "setlabel \"address\" \"label\"\n" | ||||
"\nSets the label associated with the given address.\n" | "\nSets the label associated with the given address.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"address\" (string, required) The bitcoin address to " | "1. \"address\" (string, required) The bitcoin address to " | ||||
"be associated with a label.\n" | "be associated with a label.\n" | ||||
"2. \"label\" (string, required) The label to assign the " | "2. \"label\" (string, required) The label to assign to " | ||||
"address to.\n" | "the address.\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("setlabel", | HelpExampleCli("setlabel", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | ||||
HelpExampleRpc( | HelpExampleRpc( | ||||
"setlabel", | "setlabel", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")); | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
CTxDestination dest = | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | ||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid Bitcoin address"); | "Invalid Bitcoin address"); | ||||
} | } | ||||
std::string label; | std::string label = LabelFromValue(request.params[1]); | ||||
if (!request.params[1].isNull()) { | |||||
label = LabelFromValue(request.params[1]); | |||||
} | |||||
// Only add the label if the address is yours. | |||||
if (IsMine(*pwallet, dest)) { | if (IsMine(*pwallet, dest)) { | ||||
// Detect when changing the label of an address that is the 'unused | // Detect when changing the label of an address that is the receiving | ||||
// current key' of another label: | // address of another label: If so, delete the account record for it. | ||||
Fabien: Nit: `:` => `.`, or remove uppercase `If` => `if` | |||||
// Labels, unlike addresses, can be deleted, and if we wouldn't do this, | |||||
// the record would stick around forever. | |||||
if (pwallet->mapAddressBook.count(dest)) { | if (pwallet->mapAddressBook.count(dest)) { | ||||
std::string old_label = pwallet->mapAddressBook[dest].name; | std::string old_label = pwallet->mapAddressBook[dest].name; | ||||
if (dest == GetLabelDestination(pwallet, old_label)) { | if (old_label != label && | ||||
GetLabelDestination(pwallet, old_label, true); | dest == GetLabelDestination(pwallet, old_label)) { | ||||
pwallet->DeleteLabel(old_label); | |||||
} | } | ||||
} | } | ||||
pwallet->SetAddressBook(dest, label, "receive"); | pwallet->SetAddressBook(dest, label, "receive"); | ||||
} else { | } else { | ||||
throw JSONRPCError(RPC_MISC_ERROR, | pwallet->SetAddressBook(dest, label, "send"); | ||||
"setlabel can only be used with own address"); | |||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue getaccount(const Config &config, | static UniValue getaccount(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | ||||
▲ Show 20 Lines • Show All 3,798 Lines • ▼ Show 20 Lines | static UniValue DescribeWalletAddress(CWallet *pwallet, | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
UniValue detail = DescribeAddress(dest); | UniValue detail = DescribeAddress(dest); | ||||
ret.pushKVs(detail); | ret.pushKVs(detail); | ||||
ret.pushKVs( | ret.pushKVs( | ||||
boost::apply_visitor(DescribeWalletAddressVisitor(pwallet), dest)); | boost::apply_visitor(DescribeWalletAddressVisitor(pwallet), dest)); | ||||
return ret; | return ret; | ||||
} | } | ||||
/** Convert CAddressBookData to JSON record. */ | |||||
static UniValue AddressBookDataToJSON(const CAddressBookData &data, | |||||
const bool verbose) { | |||||
UniValue ret(UniValue::VOBJ); | |||||
if (verbose) { | |||||
ret.pushKV("name", data.name); | |||||
} | |||||
ret.pushKV("purpose", data.purpose); | |||||
return ret; | |||||
} | |||||
UniValue getaddressinfo(const Config &config, const JSONRPCRequest &request) { | UniValue getaddressinfo(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) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"associated with the address, \"\" is the default account\n" | "associated with the address, \"\" is the default account\n" | ||||
" \"timestamp\" : timestamp, (number, optional) The creation " | " \"timestamp\" : timestamp, (number, optional) The creation " | ||||
"time of the key if available in seconds since epoch (Jan 1 1970 " | "time of the key if available in seconds since epoch (Jan 1 1970 " | ||||
"GMT)\n" | "GMT)\n" | ||||
" \"hdkeypath\" : \"keypath\" (string, optional) The HD " | " \"hdkeypath\" : \"keypath\" (string, optional) The HD " | ||||
"keypath if the key is HD and available\n" | "keypath if the key is HD and available\n" | ||||
" \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The " | " \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The " | ||||
"Hash160 of the HD master pubkey\n" | "Hash160 of the HD master pubkey\n" | ||||
" \"labels\" (object) Array of labels " | |||||
"associated with the address.\n" | |||||
" [\n" | |||||
" { (json object of label data)\n" | |||||
" \"name\": \"labelname\" (string) The label\n" | |||||
" \"purpose\": \"string\" (string) Purpose of address " | |||||
"(\"send\" for sending address, \"receive\" for receiving " | |||||
"address)\n" | |||||
" },...\n" | |||||
" ]\n" | |||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getaddressinfo", | HelpExampleCli("getaddressinfo", | ||||
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + | "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + | ||||
HelpExampleRpc("getaddressinfo", | HelpExampleRpc("getaddressinfo", | ||||
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")); | "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")); | ||||
} | } | ||||
Show All 39 Lines | UniValue getaddressinfo(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
if (meta) { | if (meta) { | ||||
ret.pushKV("timestamp", meta->nCreateTime); | ret.pushKV("timestamp", meta->nCreateTime); | ||||
if (!meta->hdKeypath.empty()) { | if (!meta->hdKeypath.empty()) { | ||||
ret.pushKV("hdkeypath", meta->hdKeypath); | ret.pushKV("hdkeypath", meta->hdKeypath); | ||||
ret.pushKV("hdmasterkeyid", meta->hdMasterKeyID.GetHex()); | ret.pushKV("hdmasterkeyid", meta->hdMasterKeyID.GetHex()); | ||||
} | } | ||||
} | } | ||||
// Currently only one label can be associated with an address, return an | |||||
// array so the API remains stable if we allow multiple labels to be | |||||
// associated with an address. | |||||
UniValue labels(UniValue::VARR); | |||||
std::map<CTxDestination, CAddressBookData>::iterator mi = | |||||
pwallet->mapAddressBook.find(dest); | |||||
if (mi != pwallet->mapAddressBook.end()) { | |||||
labels.push_back(AddressBookDataToJSON(mi->second, true)); | |||||
} | |||||
ret.pushKV("labels", std::move(labels)); | |||||
return ret; | |||||
} | |||||
UniValue getaddressesbylabel(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) | |||||
throw std::runtime_error( | |||||
"getaddressesbylabel \"label\"\n" | |||||
"\nReturns the list of addresses assigned the specified label.\n" | |||||
"\nArguments:\n" | |||||
"1. \"label\" (string, required) The label.\n" | |||||
"\nResult:\n" | |||||
"{ (json object with addresses as keys)\n" | |||||
" \"address\": { (json object with information about address)\n" | |||||
" \"purpose\": \"string\" (string) Purpose of address " | |||||
"(\"send\" for sending address, \"receive\" for receiving " | |||||
"address)\n" | |||||
" },...\n" | |||||
"}\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("getaddressesbylabel", "\"tabby\"") + | |||||
HelpExampleRpc("getaddressesbylabel", "\"tabby\"")); | |||||
LOCK(pwallet->cs_wallet); | |||||
std::string label = LabelFromValue(request.params[0]); | |||||
// Find all addresses that have the given label | |||||
UniValue ret(UniValue::VOBJ); | |||||
for (const std::pair<CTxDestination, CAddressBookData> &item : | |||||
pwallet->mapAddressBook) { | |||||
if (item.second.name == label) { | |||||
ret.pushKV(EncodeDestination(item.first, config), | |||||
AddressBookDataToJSON(item.second, false)); | |||||
} | |||||
} | |||||
if (ret.empty()) { | |||||
throw JSONRPCError(RPC_WALLET_INVALID_LABEL_NAME, | |||||
std::string("No addresses with label " + label)); | |||||
} | |||||
return ret; | |||||
} | |||||
UniValue listlabels(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) | |||||
throw std::runtime_error( | |||||
"listlabels ( \"purpose\" )\n" | |||||
"\nReturns the list of all labels, or labels that are assigned to " | |||||
"addresses with a specific purpose.\n" | |||||
"\nArguments:\n" | |||||
"1. \"purpose\" (string, optional) Address purpose to list " | |||||
"labels for ('send','receive'). An empty string is the same as not " | |||||
"providing this argument.\n" | |||||
"\nResult:\n" | |||||
"[ (json array of string)\n" | |||||
" \"label\", (string) Label name\n" | |||||
" ...\n" | |||||
"]\n" | |||||
"\nExamples:\n" | |||||
"\nList all labels\n" + | |||||
HelpExampleCli("listlabels", "") + | |||||
"\nList labels that have receiving addresses\n" + | |||||
HelpExampleCli("listlabels", "receive") + | |||||
"\nList labels that have sending addresses\n" + | |||||
HelpExampleCli("listlabels", "send") + "\nAs json rpc call\n" + | |||||
HelpExampleRpc("listlabels", "receive")); | |||||
LOCK(pwallet->cs_wallet); | |||||
std::string purpose; | |||||
if (!request.params[0].isNull()) { | |||||
purpose = request.params[0].get_str(); | |||||
} | |||||
// Add to a set to sort by label name, then insert into Univalue array | |||||
std::set<std::string> label_set; | |||||
for (const std::pair<CTxDestination, CAddressBookData> &entry : | |||||
pwallet->mapAddressBook) { | |||||
if (purpose.empty() || entry.second.purpose == purpose) { | |||||
label_set.insert(entry.second.name); | |||||
} | |||||
} | |||||
UniValue ret(UniValue::VARR); | |||||
for (const std::string &name : label_set) { | |||||
ret.push_back(name); | |||||
} | |||||
return ret; | return ret; | ||||
} | } | ||||
// 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", "getlabeladdress", getlabeladdress, {"label"} }, | |||||
{ "wallet", "getaccount", getaccount, {"address"} }, | |||||
{ "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, | |||||
{ "wallet", "getaddressinfo", getaddressinfo, {"address"} }, | { "wallet", "getaddressinfo", getaddressinfo, {"address"} }, | ||||
{ "wallet", "getbalance", getbalance, {"account","minconf","include_watchonly"} }, | { "wallet", "getbalance", getbalance, {"account","minconf","include_watchonly"} }, | ||||
{ "wallet", "getnewaddress", getnewaddress, {"label|account", "address_type"} }, | { "wallet", "getnewaddress", getnewaddress, {"label|account", "address_type"} }, | ||||
{ "wallet", "getrawchangeaddress", getrawchangeaddress, {"address_type"} }, | { "wallet", "getrawchangeaddress", getrawchangeaddress, {"address_type"} }, | ||||
{ "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","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", "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","include_removed"} }, | { "wallet", "listsinceblock", listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} }, | ||||
{ "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", "loadwallet", loadwallet, {"filename"} }, | { "wallet", "loadwallet", loadwallet, {"filename"} }, | ||||
{ "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | { "wallet", "lockunspent", lockunspent, {"unlock","transactions"} }, | ||||
{ "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, | |||||
{ "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | { "wallet", "rescanblockchain", rescanblockchain, {"start_height", "stop_height"} }, | ||||
/** Account functions (deprecated) */ | |||||
FabienUnsubmitted Not Done Inline ActionsMove the block between walletpassphrase and generate. Fabien: Move the block between `walletpassphrase` and `generate`. | |||||
nakihitoAuthorUnsubmitted Done Inline ActionsSo it should look like: { "wallet", "walletpassphrase", walletpassphrase, {"passphrase","timeout"} }, /** Account functions (deprecated) */ { "wallet", "getaccountaddress", getlabeladdress, {"account"} }, ... { "wallet", "setlabel", setlabel, {"address","label"} }, { "generating", "generate", generate, {"nblocks","maxtries"} }, }; ? nakihito: So it should look like:
```
{ "wallet", "walletpassphrase"… | |||||
FabienUnsubmitted Not Done Inline ActionsAlmost, look at what core does, you are missing the empty lines as a separator. Fabien: Almost, look at what core does, you are missing the empty lines as a separator. | |||||
{ "wallet", "getaccountaddress", getlabeladdress, {"account"} }, | |||||
{ "wallet", "getaccount", getaccount, {"address"} }, | |||||
{ "wallet", "getaddressesbyaccount", getaddressesbyaccount, {"account"} }, | |||||
{ "wallet", "getreceivedbyaccount", getreceivedbylabel, {"account","minconf"} }, | |||||
{ "wallet", "listaccounts", listaccounts, {"minconf","include_watchonly"} }, | |||||
{ "wallet", "listreceivedbyaccount", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | |||||
{ "wallet", "setaccount", setlabel, {"address","account"} }, | |||||
{ "wallet", "move", movecmd, {"fromaccount","toaccount","amount","minconf","comment"} }, | |||||
/** Label functions (to replace non-balance account functions) */ | |||||
{ "wallet", "getlabeladdress", getlabeladdress, {"label","force"} }, | |||||
{ "wallet", "getaddressesbylabel", getaddressesbylabel, {"label"} }, | |||||
{ "wallet", "getaddressesbylabel", getlabeladdress, {"label"} }, | |||||
{ "wallet", "getreceivedbylabel", getreceivedbylabel, {"label","minconf"} }, | |||||
{ "wallet", "listlabels", listlabels, {"purpose"} }, | |||||
{ "wallet", "listreceivedbylabel", listreceivedbylabel, {"minconf","include_empty","include_watchonly"} }, | |||||
{ "wallet", "setlabel", setlabel, {"address","label"} }, | |||||
{ "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", "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"} }, | { "wallet", "signrawtransactionwithwallet", signrawtransactionwithwallet, {"hextring","prevtxs","sighashtype"} }, | ||||
{ "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]); | ||||
} | } | ||||
} | } |
Nit: : => ., or remove uppercase If => if