X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Frpcwallet.cpp;fp=src%2Frpcwallet.cpp;h=757e7f48f7597c385f80e6ba99bd9ccc9800d9d3;hb=d2a1ea23d1f40ea70be9c835f2ec949bca3713ea;hp=ba586e990243777cc293d20297526f34b32d0b38;hpb=27e35b80c7f1b1bbf43f1d7b719a2569e8149f9f;p=novacoin.git diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index ba586e9..757e7f4 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1744,6 +1744,7 @@ Value validateaddress(const Array& params, bool fHelp) CMalleableKeyView view; bool isMine = pwalletMain->GetMalleableView(mpk, view); ret.push_back(Pair("ismine", isMine)); + ret.push_back(Pair("PubkeyPair", mpk.ToString())); if (isMine) ret.push_back(Pair("KeyView", view.ToString())); @@ -1981,16 +1982,34 @@ Value adjustmalleablepubkey(const Array& params, bool fHelp) { if (fHelp || params.size() > 2 || params.size() == 0) throw runtime_error( - "adjustmalleablepubkey \n" - "Calculate new public key using provided malleable public key data.\n"); + "adjustmalleablepubkey \n" + "Calculate new public key using provided data.\n"); - string pubKeyPair = params[0].get_str(); + string strData = params[0].get_str(); CMalleablePubKey malleablePubKey; - if (pubKeyPair.size() == 136) { - malleablePubKey.setvch(ParseHex(pubKeyPair)); - } else - malleablePubKey.SetString(pubKeyPair); + do + { + CBitcoinAddress addr(strData); + if (addr.IsValid() && addr.IsPair()) + { + // Initialize malleable pubkey with address data + malleablePubKey = CMalleablePubKey(addr.GetData()); + break; + } + CMalleableKeyView viewTmp(strData); + if (viewTmp.IsValid()) + { + // Shazaam, we have a valid key view here. + malleablePubKey = viewTmp.GetMalleablePubKey(); + break; + } + if (malleablePubKey.SetString(strData)) + break; // A valid public key pair + + throw runtime_error("Though your data seems a valid Base58 string, we were unable to recognize it."); + } + while(false); CPubKey R, vchPubKeyVariant; malleablePubKey.GetVariant(R, vchPubKeyVariant);