14 typedef std::vector<unsigned char>
valtype;
43 static std::multimap <txnouttype, CScript> mTemplates;
44 if (mTemplates.empty()) {
61 std::vector<unsigned char> hashBytes(scriptPubKey.
begin() + 2, scriptPubKey.
begin() + 22);
62 vSolutionsRet.push_back(hashBytes);
77 const CScript &script1 = scriptPubKey;
80 const CScript &script2 = tplate.second;
81 vSolutionsRet.
clear();
84 std::vector<unsigned char> vch1, vch2;
90 if (pc1 == script1.
end() && pc2 == script2.
end()) {
92 typeRet = tplate.first;
95 unsigned char m = vSolutionsRet.front()[0];
96 unsigned char n = vSolutionsRet.back()[0];
97 if (m < 1 || n < 1 || m > n || vSolutionsRet.size() - 2 != n)
102 if (!script1.
GetOp(pc1, opcode1, vch1))
104 if (!script2.
GetOp(pc2, opcode2, vch2))
109 while (vch1.size() >= 33 && vch1.size() <= 65) {
110 vSolutionsRet.push_back(vch1);
111 if (!script1.
GetOp(pc1, opcode1, vch1))
114 if (!script2.
GetOp(pc2, opcode2, vch2))
121 if (vch1.size() < 33 || vch1.size() > 65)
123 vSolutionsRet.push_back(vch1);
125 if (vch1.size() !=
sizeof(
uint160))
127 vSolutionsRet.push_back(vch1);
129 if (opcode1 ==
OP_0 ||
132 vSolutionsRet.push_back(
valtype(1, n));
135 }
else if (opcode1 != opcode2 || vch1 != vch2) {
142 vSolutionsRet.clear();
156 if (vSolutions.size() < 1 || vSolutions[0].size() < 1)
158 return vSolutions[0][0] + 1;
166 std::vector<valtype> vSolutions;
167 if (!
Solver(scriptPubKey, whichType, vSolutions))
171 unsigned char m = vSolutions.front()[0];
172 unsigned char n = vSolutions.back()[0];
186 std::vector<valtype> vSolutions;
188 if (!
Solver(scriptPubKey, whichType, vSolutions))
200 std::vector<valtype> vSolutions;
202 if (!
Solver(scriptPubKey, whichType, vSolutions))
210 addressRet = pubKey.
GetID();
227 std::vector<valtype> vSolutions;
228 if (!
Solver(scriptPubKey, typeRet, vSolutions))
236 nRequiredRet = vSolutions.front()[0];
237 for (
unsigned int i = 1; i < vSolutions.size() - 1; i++) {
243 addressRet.push_back(address);
246 if (addressRet.empty())
253 addressRet.push_back(address);
260 class CScriptVisitor :
public boost::static_visitor<bool> {
264 CScriptVisitor(
CScript *scriptin) { script = scriptin; }
271 bool operator()(
const CKeyID &keyID)
const {
277 bool operator()(
const CScriptID &scriptID)
const {
288 boost::apply_visitor(CScriptVisitor(&script), dest);