MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ProcessSubScript

Method ProcessSubScript

src/wallet/rpc/addresses.cpp:266–297  ·  view source on GitHub ↗

NOLINTNEXTLINE(misc-no-recursion)

Source from the content-addressed store, hash-verified

264
265 // NOLINTNEXTLINE(misc-no-recursion)
266 void ProcessSubScript(const CScript& subscript, UniValue& obj) const
267 {
268 // Always present: script type and redeemscript
269 std::vector<std::vector<unsigned char>> solutions_data;
270 TxoutType which_type = Solver(subscript, solutions_data);
271 obj.pushKV("script", GetTxnOutputType(which_type));
272 obj.pushKV("hex", HexStr(subscript));
273
274 CTxDestination embedded;
275 if (ExtractDestination(subscript, embedded)) {
276 // Only when the script corresponds to an address.
277 UniValue subobj(UniValue::VOBJ);
278 UniValue detail = DescribeAddress(embedded);
279 subobj.pushKVs(std::move(detail));
280 UniValue wallet_detail = std::visit(*this, embedded);
281 subobj.pushKVs(std::move(wallet_detail));
282 subobj.pushKV("address", EncodeDestination(embedded));
283 subobj.pushKV("scriptPubKey", HexStr(subscript));
284 // Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works.
285 if (subobj.exists("pubkey")) obj.pushKV("pubkey", subobj["pubkey"]);
286 obj.pushKV("embedded", std::move(subobj));
287 } else if (which_type == TxoutType::MULTISIG) {
288 // Also report some information on multisig scripts (which do not have a corresponding address).
289 obj.pushKV("sigsrequired", solutions_data[0][0]);
290 UniValue pubkeys(UniValue::VARR);
291 for (size_t i = 1; i < solutions_data.size() - 1; ++i) {
292 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
293 pubkeys.push_back(HexStr(key));
294 }
295 obj.pushKV("pubkeys", std::move(pubkeys));
296 }
297 }
298
299 explicit DescribeWalletAddressVisitor(const SigningProvider* _provider) : provider(_provider) {}
300

Callers

nothing calls this directly

Calls 13

SolverFunction · 0.85
GetTxnOutputTypeFunction · 0.85
ExtractDestinationFunction · 0.85
DescribeAddressFunction · 0.85
EncodeDestinationFunction · 0.85
pushKVMethod · 0.80
pushKVsMethod · 0.80
HexStrFunction · 0.50
existsMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected