Skip to content

Commit 7af55a5

Browse files
committed
chore: extract ScriptHash specialization of operator() to function
We didn't need this as we don't support SegWit but we should be aligned with upstream regardless, it will help with the next step.
1 parent 4653ea3 commit 7af55a5

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

src/wallet/rpc/addresses.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,29 @@ class DescribeWalletAddressVisitor
342342
public:
343343
const SigningProvider * const provider;
344344

345+
void ProcessSubScript(const CScript& subscript, UniValue& obj) const
346+
{
347+
// Always present: script type and redeemscript
348+
std::vector<std::vector<unsigned char>> solutions_data;
349+
TxoutType whichType = Solver(subscript, solutions_data);
350+
obj.pushKV("script", GetTxnOutputType(whichType));
351+
obj.pushKV("hex", HexStr(subscript));
352+
353+
if (whichType == TxoutType::MULTISIG) {
354+
// Also report some information on multisig scripts (which do not have a corresponding address).
355+
UniValue pubkeys(UniValue::VARR);
356+
UniValue addresses(UniValue::VARR);
357+
for (size_t i = 1; i < solutions_data.size() - 1; ++i) {
358+
CPubKey pubkey(solutions_data[i]);
359+
pubkeys.push_back(HexStr(pubkey));
360+
addresses.push_back(EncodeDestination(PKHash(pubkey)));
361+
}
362+
obj.pushKV("pubkeys", std::move(pubkeys));
363+
obj.pushKV("addresses", std::move(addresses));
364+
obj.pushKV("sigsrequired", solutions_data[0][0]);
365+
}
366+
}
367+
345368
explicit DescribeWalletAddressVisitor(const SigningProvider * const _provider) : provider(_provider) {}
346369

347370
UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
@@ -362,24 +385,7 @@ class DescribeWalletAddressVisitor
362385
UniValue obj(UniValue::VOBJ);
363386
CScript subscript;
364387
if (provider && provider->GetCScript(scriptID, subscript)) {
365-
// Always present: script type and redeemscript
366-
std::vector<std::vector<unsigned char>> solutions_data;
367-
TxoutType whichType = Solver(subscript, solutions_data);
368-
obj.pushKV("script", GetTxnOutputType(whichType));
369-
obj.pushKV("hex", HexStr(subscript));
370-
if (whichType == TxoutType::MULTISIG) {
371-
// Also report some information on multisig scripts (which do not have a corresponding address).
372-
UniValue pubkeys(UniValue::VARR);
373-
UniValue addresses(UniValue::VARR);
374-
for (size_t i = 1; i < solutions_data.size() - 1; ++i) {
375-
CPubKey pubkey(solutions_data[i]);
376-
pubkeys.push_back(HexStr(pubkey));
377-
addresses.push_back(EncodeDestination(PKHash(pubkey)));
378-
}
379-
obj.pushKV("pubkeys", std::move(pubkeys));
380-
obj.pushKV("addresses", std::move(addresses));
381-
obj.pushKV("sigsrequired", solutions_data[0][0]);
382-
}
388+
ProcessSubScript(subscript, obj);
383389
}
384390
return obj;
385391
}

0 commit comments

Comments
 (0)