CSecret/CKey -> CKey/CPubKey split/refactor

This commit is contained in:
Pieter Wuille
2013-05-01 06:52:05 +02:00
committed by Pieter Wuille
parent 5d891489ab
commit dfa23b94c2
26 changed files with 578 additions and 609 deletions

View File

@@ -374,11 +374,11 @@ Value verifymessage(const Array& params, bool fHelp)
ss << strMessageMagic;
ss << strMessage;
CKey key;
if (!key.SetCompactSignature(ss.GetHash(), vchSig))
CPubKey pubkey;
if (!pubkey.RecoverCompact(ss.GetHash(), vchSig))
return false;
return (key.GetPubKey().GetID() == keyID);
return (pubkey.GetID() == keyID);
}
@@ -719,7 +719,7 @@ static CScript _createmultisig(const Array& params)
throw runtime_error(
strprintf("not enough keys supplied "
"(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CKey> pubkeys;
std::vector<CPubKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
{
@@ -737,16 +737,18 @@ static CScript _createmultisig(const Array& params)
if (!pwalletMain->GetPubKey(keyID, vchPubKey))
throw runtime_error(
strprintf("no full public key for address %s",ks.c_str()));
if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey))
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
}
// Case 2: hex public key
else if (IsHex(ks))
{
CPubKey vchPubKey(ParseHex(ks));
if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey))
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
}
else
{