mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 14:14:00 +01:00
Abstract out IsSegWitOutput from utxoupdatepsbt
This is not a pure refactor; additional functionality is added in IsSegWitOutput which lets it recurse into P2SH when a SigningProvider is provided that knows about the inner script.
This commit is contained in:
@@ -505,3 +505,19 @@ FlatSigningProvider Merge(const FlatSigningProvider& a, const FlatSigningProvide
|
||||
ret.origins.insert(b.origins.begin(), b.origins.end());
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool IsSegWitOutput(const SigningProvider& provider, const CScript& script)
|
||||
{
|
||||
std::vector<valtype> solutions;
|
||||
auto whichtype = Solver(script, solutions);
|
||||
if (whichtype == TX_WITNESS_V0_SCRIPTHASH || whichtype == TX_WITNESS_V0_KEYHASH || whichtype == TX_WITNESS_UNKNOWN) return true;
|
||||
if (whichtype == TX_SCRIPTHASH) {
|
||||
auto h160 = uint160(solutions[0]);
|
||||
CScript subscript;
|
||||
if (provider.GetCScript(h160, subscript)) {
|
||||
whichtype = Solver(subscript, solutions);
|
||||
if (whichtype == TX_WITNESS_V0_SCRIPTHASH || whichtype == TX_WITNESS_V0_KEYHASH || whichtype == TX_WITNESS_UNKNOWN) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user