| 210 | } |
| 211 | |
| 212 | bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet) |
| 213 | { |
| 214 | addressRet.clear(); |
| 215 | typeRet = TX_NONSTANDARD; |
| 216 | std::vector<valtype> vSolutions; |
| 217 | if (!Solver(scriptPubKey, typeRet, vSolutions)) |
| 218 | return false; |
| 219 | if (typeRet == TX_NULL_DATA){ |
| 220 | // This is data, not addresses |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | if (typeRet == TX_MULTISIG) |
| 225 | { |
| 226 | nRequiredRet = vSolutions.front()[0]; |
| 227 | for (unsigned int i = 1; i < vSolutions.size()-1; i++) |
| 228 | { |
| 229 | CPubKey pubKey(vSolutions[i]); |
| 230 | if (!pubKey.IsValid()) |
| 231 | continue; |
| 232 | |
| 233 | CTxDestination address = pubKey.GetID(); |
| 234 | addressRet.push_back(address); |
| 235 | } |
| 236 | |
| 237 | if (addressRet.empty()) |
| 238 | return false; |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | nRequiredRet = 1; |
| 243 | CTxDestination address; |
| 244 | if (!ExtractDestination(scriptPubKey, address)) |
| 245 | return false; |
| 246 | addressRet.push_back(address); |
| 247 | } |
| 248 | |
| 249 | return true; |
| 250 | } |
| 251 | |
| 252 | namespace |
| 253 | { |