Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 4,298 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"(possibly embedded in P2SH)."}, | "(possibly embedded in P2SH)."}, | ||||
{RPCResult::Type::OBJ, | {RPCResult::Type::OBJ, | ||||
"embedded", | "embedded", | ||||
/* optional */ true, | /* optional */ true, | ||||
"Information about the address embedded in P2SH, if " | "Information about the address embedded in P2SH, if " | ||||
"relevant and known.", | "relevant and known.", | ||||
{ | { | ||||
{RPCResult::Type::ELISION, "", | {RPCResult::Type::ELISION, "", | ||||
"Includes all\n" | "Includes all getaddressinfo output fields for the " | ||||
" " | "embedded address excluding metadata (timestamp, " | ||||
" getaddressinfo output fields for the embedded address, " | "hdkeypath, hdseedid)\n" | ||||
"excluding metadata (timestamp, hdkeypath,\n" | "and relation to the wallet (ismine, iswatchonly)."}, | ||||
"hdseedid) and relation to the wallet (ismine, " | |||||
"iswatchonly)."}, | |||||
}}, | }}, | ||||
{RPCResult::Type::BOOL, "iscompressed", /* optional */ true, | {RPCResult::Type::BOOL, "iscompressed", /* optional */ true, | ||||
"If the pubkey is compressed."}, | "If the pubkey is compressed."}, | ||||
{RPCResult::Type::STR, "label", | |||||
"DEPRECATED. The label associated with the address. Defaults " | |||||
"to \"\". Replaced by the labels array below."}, | |||||
{RPCResult::Type::NUM_TIME, "timestamp", /* optional */ true, | {RPCResult::Type::NUM_TIME, "timestamp", /* optional */ true, | ||||
"The creation time of the key, if available, expressed in " + | "The creation time of the key, if available, expressed in " + | ||||
UNIX_EPOCH_TIME + "."}, | UNIX_EPOCH_TIME + "."}, | ||||
{RPCResult::Type::STR, "hdkeypath", /* optional */ true, | {RPCResult::Type::STR, "hdkeypath", /* optional */ true, | ||||
"The HD keypath, if the key is HD and available."}, | "The HD keypath, if the key is HD and available."}, | ||||
{RPCResult::Type::STR_HEX, "hdseedid", /* optional */ true, | {RPCResult::Type::STR_HEX, "hdseedid", /* optional */ true, | ||||
"The Hash160 of the HD seed."}, | "The Hash160 of the HD seed."}, | ||||
{RPCResult::Type::STR_HEX, "hdmasterfingerprint", | {RPCResult::Type::STR_HEX, "hdmasterfingerprint", | ||||
/* optional */ true, "The fingerprint of the master key."}, | /* optional */ true, "The fingerprint of the master key."}, | ||||
{RPCResult::Type::ARR, | {RPCResult::Type::ARR, | ||||
"labels", | "labels", | ||||
"Array of labels associated with the address. Currently " | "Array of labels associated with the address. Currently " | ||||
"limited to one label but returned\n" | "limited to one label but returned\n" | ||||
"as an array to keep the API stable if multiple labels are " | "as an array to keep the API stable if multiple labels are " | ||||
"enabled in the future.", | "enabled in the future.", | ||||
{ | { | ||||
{RPCResult::Type::STR, "label name", | {RPCResult::Type::STR, "label name", | ||||
"The label name. Defaults to \"\"."}, | "Label name (defaults to \"\")."}, | ||||
{RPCResult::Type::OBJ, | |||||
"", | |||||
"DEPRECATED, will be removed in a future version. To " | |||||
"re-enable, launch bitcoind with " | |||||
"`-deprecatedrpc=labelspurpose`", | |||||
{ | |||||
{RPCResult::Type::STR, "name", | |||||
"The label name. Defaults to \"\"."}, | |||||
{RPCResult::Type::STR, "purpose", | |||||
"The purpose of the associated address (send or " | |||||
"receive)."}, | |||||
}}, | |||||
}}, | }}, | ||||
}}, | }}, | ||||
RPCExamples{HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) + | RPCExamples{HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) + | ||||
HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS)}, | HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS)}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
Show All 32 Lines | if (solvable) { | ||||
InferDescriptor(scriptPubKey, *provider)->ToString()); | InferDescriptor(scriptPubKey, *provider)->ToString()); | ||||
} | } | ||||
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); | ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); | ||||
UniValue detail = DescribeWalletAddress(pwallet, dest); | UniValue detail = DescribeWalletAddress(pwallet, dest); | ||||
ret.pushKVs(detail); | ret.pushKVs(detail); | ||||
// DEPRECATED: Return label field if existing. Currently only one label can | |||||
// be associated with an address, so the label should be equivalent to the | |||||
// value of the name key/value pair in the labels array below. | |||||
const auto *address_book_entry = pwallet->FindAddressBookEntry(dest); | |||||
if (pwallet->chain().rpcEnableDeprecated("label") && address_book_entry) { | |||||
ret.pushKV("label", address_book_entry->GetLabel()); | |||||
} | |||||
ret.pushKV("ischange", pwallet->IsChange(scriptPubKey)); | ret.pushKV("ischange", pwallet->IsChange(scriptPubKey)); | ||||
ScriptPubKeyMan *spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey); | ScriptPubKeyMan *spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey); | ||||
if (spk_man) { | if (spk_man) { | ||||
if (const std::unique_ptr<CKeyMetadata> meta = | if (const std::unique_ptr<CKeyMetadata> meta = | ||||
spk_man->GetMetadata(dest)) { | spk_man->GetMetadata(dest)) { | ||||
ret.pushKV("timestamp", meta->nCreateTime); | ret.pushKV("timestamp", meta->nCreateTime); | ||||
if (meta->has_key_origin) { | if (meta->has_key_origin) { | ||||
ret.pushKV("hdkeypath", WriteHDKeypath(meta->key_origin.path)); | ret.pushKV("hdkeypath", WriteHDKeypath(meta->key_origin.path)); | ||||
ret.pushKV("hdseedid", meta->hd_seed_id.GetHex()); | ret.pushKV("hdseedid", meta->hd_seed_id.GetHex()); | ||||
ret.pushKV("hdmasterfingerprint", | ret.pushKV("hdmasterfingerprint", | ||||
HexStr(meta->key_origin.fingerprint)); | HexStr(meta->key_origin.fingerprint)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Return a `labels` array containing the label associated with the address, | // Return a `labels` array containing the label associated with the address, | ||||
// equivalent to the `label` field above. Currently only one label can be | // equivalent to the `label` field above. Currently only one label can be | ||||
// associated with an address, but we return an array so the API remains | // associated with an address, but we return an array so the API remains | ||||
// stable if we allow multiple labels to be associated with an address in | // stable if we allow multiple labels to be associated with an address in | ||||
// the future. | // the future. | ||||
UniValue labels(UniValue::VARR); | UniValue labels(UniValue::VARR); | ||||
const auto *address_book_entry = pwallet->FindAddressBookEntry(dest); | |||||
if (address_book_entry) { | if (address_book_entry) { | ||||
// DEPRECATED: The previous behavior of returning an array containing a | |||||
// JSON object of `name` and `purpose` key/value pairs is deprecated. | |||||
if (pwallet->chain().rpcEnableDeprecated("labelspurpose")) { | |||||
labels.push_back(AddressBookDataToJSON(*address_book_entry, true)); | |||||
} else { | |||||
labels.push_back(address_book_entry->GetLabel()); | labels.push_back(address_book_entry->GetLabel()); | ||||
} | } | ||||
} | |||||
ret.pushKV("labels", std::move(labels)); | ret.pushKV("labels", std::move(labels)); | ||||
return ret; | return ret; | ||||
} | } | ||||
UniValue getaddressesbylabel(const Config &config, | UniValue getaddressesbylabel(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
▲ Show 20 Lines • Show All 586 Lines • Show Last 20 Lines |