MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Solver

Function Solver

src/script/standard.cpp:90–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet)
91{
92 vSolutionsRet.clear();
93
94 // Shortcut for pay-to-script-hash, which are more constrained than the other types:
95 // it is always OP_HASH160 20 [20 byte hash] OP_EQUAL
96 if (scriptPubKey.IsPayToScriptHash())
97 {
98 typeRet = TX_SCRIPTHASH;
99 std::vector<unsigned char> hashBytes(scriptPubKey.begin()+2, scriptPubKey.begin()+22);
100 vSolutionsRet.push_back(hashBytes);
101 return true;
102 }
103
104 int witnessversion;
105 std::vector<unsigned char> witnessprogram;
106 if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
107 if (witnessversion == 0 && witnessprogram.size() == WITNESS_V0_KEYHASH_SIZE) {
108 typeRet = TX_WITNESS_V0_KEYHASH;
109 vSolutionsRet.push_back(witnessprogram);
110 return true;
111 }
112 if (witnessversion == 0 && witnessprogram.size() == WITNESS_V0_SCRIPTHASH_SIZE) {
113 typeRet = TX_WITNESS_V0_SCRIPTHASH;
114 vSolutionsRet.push_back(witnessprogram);
115 return true;
116 }
117 if (witnessversion != 0) {
118 typeRet = TX_WITNESS_UNKNOWN;
119 vSolutionsRet.push_back(std::vector<unsigned char>{(unsigned char)witnessversion});
120 vSolutionsRet.push_back(std::move(witnessprogram));
121 return true;
122 }
123 typeRet = TX_NONSTANDARD;
124 return false;
125 }
126
127 // Provably prunable, data-carrying output
128 //
129 // So long as script passes the IsUnspendable() test and all but the first
130 // byte passes the IsPushOnly() test we don't care what exactly is in the
131 // script.
132 if (scriptPubKey.size() >= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin()+1)) {
133 typeRet = TX_NULL_DATA;
134 return true;
135 }
136
137 std::vector<unsigned char> data;
138 if (MatchPayToPubkey(scriptPubKey, data)) {
139 typeRet = TX_PUBKEY;
140 vSolutionsRet.push_back(std::move(data));
141 return true;
142 }
143
144 if (MatchPayToPubkeyHash(scriptPubKey, data)) {
145 typeRet = TX_PUBKEYHASH;
146 vSolutionsRet.push_back(std::move(data));
147 return true;

Callers 13

ScriptToUnivFunction · 0.85
IsRelevantAndUpdateMethod · 0.85
IsStandardFunction · 0.85
AreInputsStandardFunction · 0.85
ProcessSubScriptMethod · 0.85
ExtractDestinationFunction · 0.85
ExtractDestinationsFunction · 0.85
GetScriptForWitnessFunction · 0.85
SignStepFunction · 0.85
DataFromTransactionFunction · 0.85
IsMineInnerFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 12

MatchPayToPubkeyFunction · 0.85
MatchPayToPubkeyHashFunction · 0.85
MatchMultisigFunction · 0.85
IsPayToScriptHashMethod · 0.80
IsWitnessProgramMethod · 0.80
IsPushOnlyMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68