aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-05-14 19:07:52 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-05-24 19:58:12 +0200
commitfd61d6f5068cf92d34569862b4225f177049a4f0 (patch)
tree5556094bda3a7162535b9352b67016e620bb9a77 /src/bitcoinrpc.cpp
parentf04017f702e36563b9ba05b3fede216767de580a (diff)
Encapsulate public keys in CPubKey
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r--src/bitcoinrpc.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 8f4fb93a5a..f227e363c3 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -590,7 +590,7 @@ Value getnewaddress(const Array& params, bool fHelp)
pwalletMain->TopUpKeyPool();
// Generate a new key that is added to wallet
- std::vector<unsigned char> newKey;
+ CPubKey newKey;
if (!pwalletMain->GetKeyFromPool(newKey, false))
throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first");
CBitcoinAddress address(newKey);
@@ -611,12 +611,12 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
bool bKeyUsed = false;
// Check if the current key has been used
- if (!account.vchPubKey.empty())
+ if (account.vchPubKey.IsValid())
{
CScript scriptPubKey;
scriptPubKey.SetBitcoinAddress(account.vchPubKey);
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin();
- it != pwalletMain->mapWallet.end() && !account.vchPubKey.empty();
+ it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid();
++it)
{
const CWalletTx& wtx = (*it).second;
@@ -627,7 +627,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
}
// Generate a new key
- if (account.vchPubKey.empty() || bForceNew || bKeyUsed)
+ if (!account.vchPubKey.IsValid() || bForceNew || bKeyUsed)
{
if (!pwalletMain->GetKeyFromPool(account.vchPubKey, false))
throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first");
@@ -1203,19 +1203,19 @@ Value addmultisigaddress(const Array& params, bool fHelp)
if (address.IsScript())
throw runtime_error(
strprintf("%s is a pay-to-script address",ks.c_str()));
- std::vector<unsigned char> vchPubKey;
+ CPubKey vchPubKey;
if (!pwalletMain->GetPubKey(address, vchPubKey))
throw runtime_error(
strprintf("no full public key for address %s",ks.c_str()));
- if (vchPubKey.empty() || !pubkeys[i].SetPubKey(vchPubKey))
+ if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey))
throw runtime_error(" Invalid public key: "+ks);
}
// Case 2: hex public key
else if (IsHex(ks))
{
- vector<unsigned char> vchPubKey = ParseHex(ks);
- if (vchPubKey.empty() || !pubkeys[i].SetPubKey(vchPubKey))
+ CPubKey vchPubKey(ParseHex(ks));
+ if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey))
throw runtime_error(" Invalid public key: "+ks);
}
else
@@ -1954,9 +1954,9 @@ Value validateaddress(const Array& params, bool fHelp)
if (pwalletMain->HaveKey(address))
{
ret.push_back(Pair("ismine", true));
- std::vector<unsigned char> vchPubKey;
+ CPubKey vchPubKey;
pwalletMain->GetPubKey(address, vchPubKey);
- ret.push_back(Pair("pubkey", HexStr(vchPubKey)));
+ ret.push_back(Pair("pubkey", HexStr(vchPubKey.Raw())));
CKey key;
key.SetPubKey(vchPubKey);
ret.push_back(Pair("iscompressed", key.IsCompressed()));