diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -577,22 +577,9 @@ } static bool ExtractPubKey(const CScript &dest, CPubKey &pubKeyOut) { - // TODO: Use Solver to extract this? - CScript::const_iterator pc = dest.begin(); - opcodetype opcode; - std::vector vch; - if (!dest.GetOp(pc, opcode, vch) || !CPubKey::ValidSize(vch)) { - return false; - } - pubKeyOut = CPubKey(vch); - if (!pubKeyOut.IsFullyValid()) { - return false; - } - if (!dest.GetOp(pc, opcode, vch) || opcode != OP_CHECKSIG || - dest.GetOp(pc, opcode, vch)) { - return false; - } - return true; + std::vector> solutions; + return Solver(dest, solutions) == TX_PUBKEY && + (pubKeyOut = CPubKey(solutions[0])).IsFullyValid(); } bool CWallet::AddWatchOnlyInMem(const CScript &dest) {