--- /dev/null
+> getnewaddress
+4GELig4Rh4VZVnEnvp4v9cN29SH8F3JEeT
+> validateaddress 4GELig4Rh4VZVnEnvp4v9cN29SH8F3JEeT
+{
+"isvalid" : true,
+"address" : "4GELig4Rh4VZVnEnvp4v9cN29SH8F3JEeT",
+"ismine" : true,
+"watchonly" : false,
+"isscript" : false,
+"pubkey" : "027742dfa3fd23b86f4fd6bfa4707da5dfe433db609d7d458f6576b7c84f20dcef",
+"iscompressed" : true,
+"account" : ""
+}
+
+> encryptmessage 027742dfa3fd23b86f4fd6bfa4707da5dfe433db609d7d458f6576b7c84f20dcef "Hello world!"
+BHzjL9u1h8K1f5pqEZ4KLzmYXLD4qdZWWPnQPJdRgttWJ8QU4LbZLu4KxZpYcNNrgePkxVv2Ps8XV1AC34VCt3oBMdMW7HuaSB6
+
+> decryptmessage 4GELig4Rh4VZVnEnvp4v9cN29SH8F3JEeT BHzjL9u1h8K1f5pqEZ4KLzmYXLD4qdZWWPnQPJdRgttWJ8QU4LbZLu4KxZpYcNNrgePkxVv2Ps8XV1AC34VCt3oBMdMW7HuaSB6
+Hello world!
{ "dumpmalleablekey", &dumpmalleablekey, false, false},
{ "encryptdata", &encryptdata, false, false },
{ "decryptdata", &decryptdata, false, false },
+ { "encryptmessage", &encryptmessage, false, false },
+ { "decryptmessage", &decryptmessage, false, false },
{ "sendalert", &sendalert, false, false},
};
extern json_spirit::Value encryptdata(const json_spirit::Array& params, bool fHelp); // in rpccrypt.cpp
extern json_spirit::Value decryptdata(const json_spirit::Array& params, bool fHelp);
+extern json_spirit::Value encryptmessage(const json_spirit::Array& params, bool fHelp);
+extern json_spirit::Value decryptmessage(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp
extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp);
return HexStr(vchDecrypted);
}
+
+Value encryptmessage(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 2)
+ throw runtime_error(
+ "encryptmessage <public key> <message string>\n"
+ "Encrypt message with provided public key.\n");
+
+ CPubKey pubKey(ParseHex(params[0].get_str()));
+
+ vector<unsigned char> vchEncrypted;
+ string strData = params[1].get_str();
+ pubKey.EncryptData(vector<unsigned char>(strData.begin(), strData.end()), vchEncrypted);
+
+ return EncodeBase58Check(vchEncrypted);
+}
+
+Value decryptmessage(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 2)
+ throw runtime_error(
+ "decryptdata <novacoin address> <encrypted message>\n"
+ "Decrypt message string.\n");
+
+ EnsureWalletIsUnlocked();
+ CBitcoinAddress addr(params[0].get_str());
+
+ CKeyID keyID;
+ addr.GetKeyID(keyID);
+
+ CKey key;
+ pwalletMain->GetKey(keyID, key);
+
+ vector<unsigned char> vchEncrypted;
+ if (!DecodeBase58Check(params[1].get_str(), vchEncrypted))
+ throw runtime_error("Incorrect string");
+ vector<unsigned char> vchDecrypted;
+ key.DecryptData(vchEncrypted, vchDecrypted);
+
+ return std::string((const char*)&vchDecrypted[0], vchDecrypted.size());
+}