Browse Source

Merge pull request #334 from sipa/walletclass

Bugfixes walletclass
0.8
Pieter Wuille 14 years ago
parent
commit
1179257bfd
  1. 8
      src/keystore.h
  2. 10
      src/script.cpp
  3. 2
      src/wallet.cpp
  4. 2
      src/wallet.h

8
src/keystore.h

@ -14,11 +14,15 @@ public: @@ -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();
};

10
src/script.cpp

@ -1038,12 +1038,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash @@ -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 @@ -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;

2
src/wallet.cpp

@ -1006,8 +1006,8 @@ bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx) @@ -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)

2
src/wallet.h

@ -96,7 +96,7 @@ public: @@ -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
{

Loading…
Cancel
Save