diff --git a/src/keystore.h b/src/keystore.h index 3b6869b4..6080d7d7 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -14,11 +14,15 @@ public: { return (mapKeys.count(vchPubKey) > 0); } - CPrivKey GetPrivKey(const std::vector &vchPubKey) const + bool GetPrivKey(const std::vector &vchPubKey, CPrivKey& keyOut) const { std::map, CPrivKey>::const_iterator mi = mapKeys.find(vchPubKey); if (mi != mapKeys.end()) - return (*mi).second; + { + keyOut = (*mi).second; + return true; + } + return false; } std::vector GenerateNewKey(); }; diff --git a/src/script.cpp b/src/script.cpp index e1b5ae89..bd1b5b3c 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1038,12 +1038,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash { // Sign const valtype& vchPubKey = item.second; - if (!keystore.HaveKey(vchPubKey)) + CPrivKey privkey; + if (!keystore.GetPrivKey(vchPubKey, privkey)) return false; if (hash != 0) { vector vchSig; - if (!CKey::Sign(keystore.GetPrivKey(vchPubKey), hash, vchSig)) + if (!CKey::Sign(privkey, hash, vchSig)) return false; vchSig.push_back((unsigned char)nHashType); scriptSigRet << vchSig; @@ -1056,12 +1057,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash if (mi == mapPubKeys.end()) return false; const vector& vchPubKey = (*mi).second; - if (!keystore.HaveKey(vchPubKey)) + CPrivKey privkey; + if (!keystore.GetPrivKey(vchPubKey, privkey)) return false; if (hash != 0) { vector vchSig; - if (!CKey::Sign(keystore.GetPrivKey(vchPubKey), hash, vchSig)) + if (!CKey::Sign(privkey, hash, vchSig)) return false; vchSig.push_back((unsigned char)nHashType); scriptSigRet << vchSig << vchPubKey; diff --git a/src/wallet.cpp b/src/wallet.cpp index 7a65b2a5..b06187a4 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1006,8 +1006,8 @@ bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx) wtx = (*mi).second; return true; } - return false; } + return false; } bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut) diff --git a/src/wallet.h b/src/wallet.h index b14a2e82..cda4293b 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -96,7 +96,7 @@ public: { if (!MoneyRange(txout.nValue)) throw std::runtime_error("CWallet::GetChange() : value out of range"); - if (IsChange(txout) ? txout.nValue : 0); + return (IsChange(txout) ? txout.nValue : 0); } bool IsMine(const CTransaction& tx) const {