X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Frpcwallet.cpp;h=8b3780ecbc29f79ece87bb1b2d1657a65d9c7e34;hb=7f70ddc68f4afa4a87a15e620ba519afbc5c8b15;hp=22beb606d513390a38a90e9f752d675c93733692;hpb=a4bd78df61a14ec83f4a2f71edb0e18b434a8779;p=novacoin.git diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 22beb60..8b3780e 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1866,17 +1866,39 @@ Value newmalleablekey(const Array& params, bool fHelp) "newmalleablekey\n" "Make a malleable public/private key pair.\n"); - CMalleableKey malleableKey; - malleableKey.MakeNewKeys(); - CMalleablePubKey malleablePubKey = malleableKey.GetMalleablePubKey(); + if (!fTestNet) + throw runtime_error("This feature has been disabled for mainNet clients"); + + CMalleableKeyView keyView = pwalletMain->GenerateNewMalleableKey(); - CDataStream ssPublicBytes(SER_NETWORK, PROTOCOL_VERSION); - ssPublicBytes << malleablePubKey; + CMalleableKey mKey; + if (!pwalletMain->GetMalleableKey(keyView, mKey)) + throw runtime_error("Unable to generate new malleable key"); Object result; - result.push_back(Pair("PrivatePair", malleableKey.ToString())); - result.push_back(Pair("PublicPair", malleablePubKey.ToString())); - result.push_back(Pair("PublicBytes", HexStr(ssPublicBytes.begin(), ssPublicBytes.end()))); + result.push_back(Pair("PublicPair", mKey.GetMalleablePubKey().ToString())); + result.push_back(Pair("KeyView", keyView.ToString())); + + return result; +} + +Value dumpmalleablekey(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error ( + "dumpmalleablekey \n" + "Dump the private and public key pairs, which correspond to provided key view.\n"); + + CMalleableKey mKey; + CMalleableKeyView keyView; + keyView.SetString(params[0].get_str()); + + if (!pwalletMain->GetMalleableKey(keyView, mKey)) + throw runtime_error("There is no such item in the wallet"); + + Object result; + result.push_back(Pair("PrivatePair", mKey.ToString())); + result.push_back(Pair("PublicPair", mKey.GetMalleablePubKey().ToString())); return result; } @@ -1893,9 +1915,10 @@ Value adjustmalleablekey(const Array& params, bool fHelp) CKey privKeyVariant; CPubKey vchPubKeyVariant = CPubKey(ParseHex(params[1].get_str())); - CPubKey vchR = CPubKey(ParseHex(params[2].get_str())); - if (!malleableKey.CheckKeyVariant(vchR,vchPubKeyVariant, privKeyVariant)) { + CPubKey R(ParseHex(params[2].get_str())); + + if (!malleableKey.CheckKeyVariant(R,vchPubKeyVariant, privKeyVariant)) { throw runtime_error("Unable to calculate the private key"); } @@ -1934,3 +1957,23 @@ Value adjustmalleablepubkey(const Array& params, bool fHelp) return result; } + +Value listmalleableviews(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "listmalleableviews\n" + "Get list of views for generated malleable keys.\n"); + + std::list keyViewList; + pwalletMain->ListMalleableViews(keyViewList); + + Array result; + BOOST_FOREACH(const CMalleableKeyView &keyView, keyViewList) + { + result.push_back(keyView.ToString()); + } + + return result; +} +