X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=09bacfc789cba725d48530396d9a77b939ecfbbd;hp=61ee9e9b76efdbffb302bf90f0fd6ec79b200ccc;hb=9e58e0a8ca28b15a4bfa677f5b23891972db40fd;hpb=db1eaec482383385156b3e7cb6b2baa9454975f0 diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 61ee9e9..09bacfc 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -173,7 +173,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false) if (!pwalletMain->GetKeyFromPool(account.vchPubKey, false)) throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); - pwalletMain->SetAddressBookName(CBitcoinAddress(account.vchPubKey.GetID()), strAccount); + pwalletMain->SetAddressBookName(account.vchPubKey.GetID(), strAccount); walletdb.WriteAccount(strAccount, account); } @@ -451,11 +451,11 @@ Value verifymessage(const Array& params, bool fHelp) ss << strMessageMagic; ss << strMessage; - CKey key; + CPubKey key; if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) return false; - return (key.GetPubKey().GetID() == keyID); + return (key.GetID() == keyID); } @@ -843,7 +843,7 @@ Value addmultisigaddress(const Array& params, bool fHelp) "(got %" PRIszu " keys, but need at least %d to redeem)", keys.size(), nRequired)); if (keys.size() > 16) throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number"); - std::vector pubkeys; + std::vector pubkeys; pubkeys.resize(keys.size()); for (unsigned int i = 0; i < keys.size(); i++) { @@ -861,16 +861,18 @@ Value addmultisigaddress(const Array& params, bool fHelp) 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.IsValid()) 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.IsValid()) throw runtime_error(" Invalid public key: "+ks); + pubkeys[i] = vchPubKey; } else { @@ -1511,7 +1513,7 @@ void ThreadCleanWalletPassphrase(void* parg) { nWalletUnlockTime = nMyWakeTime; - do + for ( ; ; ) { if (nWalletUnlockTime==0) break; @@ -1523,7 +1525,7 @@ void ThreadCleanWalletPassphrase(void* parg) Sleep(nToSleep); ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); - } while(1); + }; if (nWalletUnlockTime) { @@ -1690,7 +1692,7 @@ public: obj.push_back(Pair("isscript", false)); if (mine == MINE_SPENDABLE) { pwalletMain->GetPubKey(keyID, vchPubKey); - obj.push_back(Pair("pubkey", HexStr(vchPubKey.Raw()))); + obj.push_back(Pair("pubkey", HexStr(vchPubKey.begin(), vchPubKey.end()))); obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); } return obj; @@ -1886,20 +1888,23 @@ Value makekeypair(const Array& params, bool fHelp) bool fCompressed; CSecret vchSecret = key.GetSecret(fCompressed); + CPubKey vchPubKey = key.GetPubKey(); result.push_back(Pair("Secret", HexStr(vchSecret.begin(), vchSecret.end()))); - result.push_back(Pair("PublicKey", HexStr(key.GetPubKey().Raw()))); + result.push_back(Pair("PublicKey", HexStr(vchPubKey.begin(), vchPubKey.end()))); return result; } Value newmalleablekey(const Array& params, bool fHelp) { - if (fHelp || params.size() > 0) + if (fHelp || params.size() > 1) throw runtime_error( "newmalleablekey\n" "Make a malleable public/private key pair.\n"); - if (!(fDebug || fTestNet) && GetTime() < SMALLDATA_SWITCH_TIME) - throw runtime_error("This feature has been disabled for mainNet clients"); + // Parse the account first so we don't generate a key if there's an error + string strAccount; + if (params.size() > 0) + strAccount = AccountFromValue(params[0]); CMalleableKeyView keyView = pwalletMain->GenerateNewMalleableKey(); @@ -1908,11 +1913,14 @@ Value newmalleablekey(const Array& params, bool fHelp) throw runtime_error("Unable to generate new malleable key"); CMalleablePubKey mPubKey = mKey.GetMalleablePubKey(); + CBitcoinAddress address(mPubKey); + + pwalletMain->SetAddressBookName(address, strAccount); Object result; result.push_back(Pair("PublicPair", mPubKey.ToString())); result.push_back(Pair("PublicBytes", HexStr(mPubKey.Raw()))); - result.push_back(Pair("Address", CBitcoinAddress(mPubKey).ToString())); + result.push_back(Pair("Address", address.ToString())); result.push_back(Pair("KeyView", keyView.ToString())); return result; @@ -1965,8 +1973,8 @@ Value adjustmalleablepubkey(const Array& params, bool fHelp) malleablePubKey.GetVariant(R, vchPubKeyVariant); Object result; - result.push_back(Pair("R", HexStr(R.Raw()))); - result.push_back(Pair("PubkeyVariant", HexStr(vchPubKeyVariant.Raw()))); + result.push_back(Pair("R", HexStr(R.begin(), R.end()))); + result.push_back(Pair("PubkeyVariant", HexStr(vchPubKeyVariant.begin(), vchPubKeyVariant.end()))); result.push_back(Pair("KeyVariantID", CBitcoinAddress(vchPubKeyVariant.GetID()).ToString())); return result;