malleableKey.MakeNewKeys();
CMalleablePubKey malleablePubKey = malleableKey.GetMalleablePubKey();
+ CDataStream ssPublicBytes(SER_NETWORK, PROTOCOL_VERSION);
+ ssPublicBytes << malleablePubKey;
+
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())));
return result;
}
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");
}
"adjustmalleablepubkey <Malleable public key data>\n"
"Calculate new public key using provided malleable public key data.\n");
+ string pubKeyPair = params[0].get_str();
CMalleablePubKey malleablePubKey;
- malleablePubKey.SetString(params[0].get_str());
+
+ if (pubKeyPair.size() == 138) {
+ CDataStream ssPublicBytes(ParseHex(pubKeyPair), SER_NETWORK, PROTOCOL_VERSION);
+ ssPublicBytes >> malleablePubKey;
+ } else
+ malleablePubKey.SetString(pubKeyPair);
CPubKey R, vchPubKeyVariant;
malleablePubKey.GetVariant(R, vchPubKeyVariant);
result.push_back(Pair("PubkeyVariant", HexStr(vchPubKeyVariant.Raw())));
result.push_back(Pair("KeyVariantID", CBitcoinAddress(vchPubKeyVariant.GetID()).ToString()));
+
+ return result;
+}
+
+Value listmalleablepubkeys(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 0)
+ throw runtime_error(
+ "listmalleablepubkeys\n"
+ "Get list of malleable public keys.\n");
+
+ std::list<CMalleablePubKey> keyList;
+ pwalletMain->ListMalleablePubKeys(keyList);
+
+ Array result;
+ BOOST_FOREACH(const CMalleablePubKey &key, keyList)
+ {
+ result.push_back(key.ToString());
+ }
+
return result;
}