aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2011-06-19 18:32:36 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2011-06-20 20:07:28 +0200
commit98705aa51cbfee81ecd2498a014c285ac677ba69 (patch)
treedcd42eff69a50111b29f7bdb7cad396dd49c6b7b /src
parent04e442070d3db1abb761d3e04d80d6ece6d5602b (diff)
Bugfixes walletclass
Some problems found by ius: * compiler complains with no return after critical section block * CKeyStore::GetPrivKey(key) was undefined for unknown key * missing return statement in GetChange()
Diffstat (limited to 'src')
-rw-r--r--src/keystore.h8
-rw-r--r--src/script.cpp10
-rw-r--r--src/wallet.cpp2
-rw-r--r--src/wallet.h2
4 files changed, 14 insertions, 8 deletions
diff --git a/src/keystore.h b/src/keystore.h
index 3b6869b42d..6080d7d7f5 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -14,11 +14,15 @@ public:
{
return (mapKeys.count(vchPubKey) > 0);
}
- CPrivKey GetPrivKey(const std::vector<unsigned char> &vchPubKey) const
+ bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const
{
std::map<std::vector<unsigned char>, CPrivKey>::const_iterator mi = mapKeys.find(vchPubKey);
if (mi != mapKeys.end())
- return (*mi).second;
+ {
+ keyOut = (*mi).second;
+ return true;
+ }
+ return false;
}
std::vector<unsigned char> GenerateNewKey();
};
diff --git a/src/script.cpp b/src/script.cpp
index e1b5ae8959..bd1b5b3c5f 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<unsigned char> 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<unsigned char>& vchPubKey = (*mi).second;
- if (!keystore.HaveKey(vchPubKey))
+ CPrivKey privkey;
+ if (!keystore.GetPrivKey(vchPubKey, privkey))
return false;
if (hash != 0)
{
vector<unsigned char> 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 7a65b2a572..b06187a4b2 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 b14a2e8264..cda4293bd2 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
{