--- /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);
DbEnv(0).remove(strPath.c_str(), 0);
}
-CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS), fDetachDB(false), fDbEnvInit(false), fMockDb(false) { }
+CDBEnv::CDBEnv() : fDetachDB(false), fDbEnvInit(false), fMockDb(false), dbenv(DB_CXX_NO_EXCEPTIONS) { }
CDBEnv::~CDBEnv()
{
}
Dbc* pcursor = db.GetCursor();
- if (pcursor)
+ if (pcursor) {
+ size_t pszSkipLen = strlen(pszSkip);
while (fSuccess)
{
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
break;
}
if (pszSkip &&
- strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
+ strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), pszSkipLen)) == 0)
continue;
if (strncmp(&ssKey[0], "\x07version", 8) == 0)
{
if (ret2 > 0)
fSuccess = false;
}
+ }
if (fSuccess)
{
db.Close();
Reset();
CKey L, H;
- if (pvchSecretL.size() != 32 || !pvchSecretH.size() != 32 || !L.SetSecret(pvchSecretL, true) || !H.SetSecret(pvchSecretH, true))
+ if (pvchSecretL.size() != 32 || pvchSecretH.size() != 32 || !L.SetSecret(pvchSecretL, true) || !H.SetSecret(pvchSecretH, true))
{
nVersion = 0;
return false;
public:
CMalleablePubKey() { nVersion = CMalleablePubKey::CURRENT_VERSION; }
+ CMalleablePubKey(const CMalleablePubKey& mpk)
+ {
+ nVersion = mpk.nVersion;
+ pubKeyL = mpk.pubKeyL;
+ pubKeyH = mpk.pubKeyH;
+ }
CMalleablePubKey(const std::string& strMalleablePubKey) { SetString(strMalleablePubKey); }
CMalleablePubKey(const CPubKey &pubKeyInL, const CPubKey &pubKeyInH) : pubKeyL(pubKeyInL), pubKeyH(pubKeyInH) { nVersion = CMalleablePubKey::CURRENT_VERSION; }
CMalleablePubKey(const std::vector<unsigned char> &pubKeyInL, const std::vector<unsigned char> &pubKeyInH) : pubKeyL(pubKeyInL), pubKeyH(pubKeyInH) { nVersion = CMalleablePubKey::CURRENT_VERSION; }
std::string ToString() const
{
return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016" PRIx64 ", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)",
- pprev, pnext, nFile, nBlockPos, nHeight,
+ (const void*)pprev, (const void*)pnext, nFile, nBlockPos, nHeight,
FormatMoney(nMint).c_str(), FormatMoney(nMoneySupply).c_str(),
GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW",
- nStakeModifier, nStakeModifierChecksum,
+ nStakeModifier, nStakeModifierChecksum,
hashProofOfStake.ToString().c_str(),
prevoutStake.ToString().c_str(), nStakeTime,
hashMerkleRoot.ToString().c_str(),
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());
+}