| 361 | } |
| 362 | |
| 363 | bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vector<CTxDestination>& addressRet, int& nRequiredRet) |
| 364 | { |
| 365 | addressRet.clear(); |
| 366 | typeRet = TX_NONSTANDARD; |
| 367 | vector<valtype> vSolutions; |
| 368 | if (!Solver(scriptPubKey, typeRet, vSolutions)) |
| 369 | return false; |
| 370 | if (typeRet == TX_NULL_DATA) { |
| 371 | // This is data, not addresses |
| 372 | return false; |
| 373 | } |
| 374 | |
| 375 | if (typeRet == TX_MULTISIG) { |
| 376 | nRequiredRet = vSolutions.front()[0]; |
| 377 | for (unsigned int i = 1; i < vSolutions.size()-1; i++) { |
| 378 | CPubKey pubKey(vSolutions[i]); |
| 379 | if (!pubKey.IsValid()) |
| 380 | continue; |
| 381 | |
| 382 | CTxDestination address = pubKey.GetID(); |
| 383 | addressRet.push_back(address); |
| 384 | } |
| 385 | |
| 386 | if (addressRet.empty()) |
| 387 | return false; |
| 388 | } else { |
| 389 | nRequiredRet = 1; |
| 390 | CTxDestination address; |
| 391 | if (!ExtractDestination(scriptPubKey, address)) |
| 392 | return false; |
| 393 | addressRet.push_back(address); |
| 394 | } |
| 395 | |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | namespace |
| 400 | { |