Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 4,196 Lines • ▼ Show 20 Lines | |||||
class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue> { | class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue> { | ||||
public: | public: | ||||
const SigningProvider *const provider; | const SigningProvider *const provider; | ||||
void ProcessSubScript(const CScript &subscript, UniValue &obj) const { | void ProcessSubScript(const CScript &subscript, UniValue &obj) const { | ||||
// Always present: script type and redeemscript | // Always present: script type and redeemscript | ||||
std::vector<std::vector<uint8_t>> solutions_data; | std::vector<std::vector<uint8_t>> solutions_data; | ||||
txnouttype which_type = Solver(subscript, solutions_data); | TxoutType which_type = Solver(subscript, solutions_data); | ||||
obj.pushKV("script", GetTxnOutputType(which_type)); | obj.pushKV("script", GetTxnOutputType(which_type)); | ||||
obj.pushKV("hex", HexStr(subscript)); | obj.pushKV("hex", HexStr(subscript)); | ||||
CTxDestination embedded; | CTxDestination embedded; | ||||
if (ExtractDestination(subscript, embedded)) { | if (ExtractDestination(subscript, embedded)) { | ||||
// Only when the script corresponds to an address. | // Only when the script corresponds to an address. | ||||
UniValue subobj(UniValue::VOBJ); | UniValue subobj(UniValue::VOBJ); | ||||
UniValue detail = DescribeAddress(embedded); | UniValue detail = DescribeAddress(embedded); | ||||
subobj.pushKVs(detail); | subobj.pushKVs(detail); | ||||
UniValue wallet_detail = boost::apply_visitor(*this, embedded); | UniValue wallet_detail = boost::apply_visitor(*this, embedded); | ||||
subobj.pushKVs(wallet_detail); | subobj.pushKVs(wallet_detail); | ||||
subobj.pushKV("address", EncodeDestination(embedded, GetConfig())); | subobj.pushKV("address", EncodeDestination(embedded, GetConfig())); | ||||
subobj.pushKV("scriptPubKey", HexStr(subscript)); | subobj.pushKV("scriptPubKey", HexStr(subscript)); | ||||
// Always report the pubkey at the top level, so that | // Always report the pubkey at the top level, so that | ||||
// `getnewaddress()['pubkey']` always works. | // `getnewaddress()['pubkey']` always works. | ||||
if (subobj.exists("pubkey")) { | if (subobj.exists("pubkey")) { | ||||
obj.pushKV("pubkey", subobj["pubkey"]); | obj.pushKV("pubkey", subobj["pubkey"]); | ||||
} | } | ||||
obj.pushKV("embedded", std::move(subobj)); | obj.pushKV("embedded", std::move(subobj)); | ||||
} else if (which_type == TX_MULTISIG) { | } else if (which_type == TxoutType::MULTISIG) { | ||||
// Also report some information on multisig scripts (which do not | // Also report some information on multisig scripts (which do not | ||||
// have a corresponding address). | // have a corresponding address). | ||||
// TODO: abstract out the common functionality between this logic | // TODO: abstract out the common functionality between this logic | ||||
// and ExtractDestinations. | // and ExtractDestinations. | ||||
obj.pushKV("sigsrequired", solutions_data[0][0]); | obj.pushKV("sigsrequired", solutions_data[0][0]); | ||||
UniValue pubkeys(UniValue::VARR); | UniValue pubkeys(UniValue::VARR); | ||||
for (size_t i = 1; i < solutions_data.size() - 1; ++i) { | for (size_t i = 1; i < solutions_data.size() - 1; ++i) { | ||||
CPubKey key(solutions_data[i].begin(), solutions_data[i].end()); | CPubKey key(solutions_data[i].begin(), solutions_data[i].end()); | ||||
▲ Show 20 Lines • Show All 858 Lines • Show Last 20 Lines |