| 156 | } |
| 157 | |
| 158 | bool ExtractDestination(const CScript &scriptPubKey, |
| 159 | CTxDestination &addressRet) { |
| 160 | std::vector<valtype> vSolutions; |
| 161 | TxoutType whichType = Solver(scriptPubKey, vSolutions); |
| 162 | |
| 163 | if (whichType == TxoutType::PUBKEY) { |
| 164 | CPubKey pubKey(vSolutions[0]); |
| 165 | if (!pubKey.IsValid()) { |
| 166 | return false; |
| 167 | } |
| 168 | |
| 169 | addressRet = PKHash(pubKey); |
| 170 | return true; |
| 171 | } |
| 172 | if (whichType == TxoutType::PUBKEYHASH) { |
| 173 | addressRet = PKHash(uint160(vSolutions[0])); |
| 174 | return true; |
| 175 | } |
| 176 | if (whichType == TxoutType::SCRIPTHASH) { |
| 177 | addressRet = ScriptHash(uint160(vSolutions[0])); |
| 178 | return true; |
| 179 | } |
| 180 | // Multisig txns have more than one address... |
| 181 | return false; |
| 182 | } |
| 183 | |
| 184 | bool ExtractDestinations(const CScript &scriptPubKey, TxoutType &typeRet, |
| 185 | std::vector<CTxDestination> &addressRet, |