diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index d43bde4680..d530d87684 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -390,7 +390,7 @@ Json::Value RPCServer::doAccountEmailSet(Json::Value ¶ms) uEmailHash, false, uint256(), - std::vector()); + NewcoinAddress()); (void) mNetOps->processTransaction(trans); @@ -560,6 +560,7 @@ Json::Value RPCServer::doAccountMessageSet(Json::Value& params) { NewcoinAddress naSrcAccountID; NewcoinAddress naSeed; uint256 uLedger; + NewcoinAddress naMessagePubKey; if (params.size() != 3) { @@ -573,6 +574,10 @@ Json::Value RPCServer::doAccountMessageSet(Json::Value& params) { { return "source account id needed"; } + else if (!naMessagePubKey.setAccountPublic(params[2u].asString())) + { + return "public key needed"; + } else if (!mNetOps->available()) { return JSONRPCError(503, "network not available"); @@ -599,8 +604,6 @@ Json::Value RPCServer::doAccountMessageSet(Json::Value& params) { return JSONRPCError(500, "insufficent funds"); } - std::string strMessageKey = params[2u].asString(); - Transaction::pointer trans = Transaction::sharedAccountSet( naAccountPublic, naAccountPrivate, naSrcAccountID, @@ -611,13 +614,13 @@ Json::Value RPCServer::doAccountMessageSet(Json::Value& params) { uint128(), false, uint256(), - std::vector()); + naMessagePubKey); (void) mNetOps->processTransaction(trans); obj["transaction"] = trans->getSTransaction()->getJson(0); obj["status"] = trans->getStatus(); - // ret["MessageKey"] = strHex(vucMessageKey); + obj["MessageKey"] = naMessagePubKey.humanAccountPublic(); return obj; } @@ -681,7 +684,7 @@ Json::Value RPCServer::doAccountWalletSet(Json::Value& params) { uint128(), strWalletLocator.empty(), uWalletLocator, - std::vector()); + NewcoinAddress()); (void) mNetOps->processTransaction(trans); @@ -1506,11 +1509,20 @@ Json::Value RPCServer::doWalletPropose(Json::Value& params) naGenerator.setFamilyGenerator(naSeed); naAccount.setAccountPublic(naGenerator, 0); + // + // Extra functionality: generate a key pair + // + CKey key; + + key.MakeNewKey(); + Json::Value obj(Json::objectValue); obj["master_seed"] = naSeed.humanFamilySeed(); obj["master_key"] = naSeed.humanFamilySeed1751(); obj["account_id"] = naAccount.humanAccountID(); + obj["extra_public"] = NewcoinAddress::createHumanAccountPublic(key.GetPubKey()); + obj["extra_private"] = NewcoinAddress::createHumanAccountPrivate(key.GetSecret()); return obj; } diff --git a/src/Transaction.cpp b/src/Transaction.cpp index bea825cf4b..4a60814ffb 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -122,7 +122,7 @@ Transaction::pointer Transaction::setAccountSet( const uint128& uEmailHash, bool bUnsetWalletLocator, const uint256& uWalletLocator, - const std::vector& vucPubKey) + const NewcoinAddress& naMessagePublic) { mTransaction->setITFieldU32(sfFlags, (bUnsetEmailHash ? tfUnsetEmailHash : 0) @@ -134,8 +134,8 @@ Transaction::pointer Transaction::setAccountSet( if (!bUnsetWalletLocator && !!uWalletLocator) mTransaction->setITFieldH256(sfWalletLocator, uWalletLocator); - if (!vucPubKey.empty()) - mTransaction->setITFieldVL(sfMessageKey, vucPubKey); + if (naMessagePublic.isValid()) + mTransaction->setITFieldVL(sfMessageKey, naMessagePublic.getAccountPublic()); sign(naPrivateKey); @@ -152,11 +152,11 @@ Transaction::pointer Transaction::sharedAccountSet( const uint128& uEmailHash, bool bUnsetWalletLocator, const uint256& uWalletLocator, - const std::vector& vucPubKey) + const NewcoinAddress& naMessagePublic) { pointer tResult = boost::make_shared(ttACCOUNT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag); - return tResult->setAccountSet(naPrivateKey, bUnsetEmailHash, uEmailHash, bUnsetWalletLocator, uWalletLocator, vucPubKey); + return tResult->setAccountSet(naPrivateKey, bUnsetEmailHash, uEmailHash, bUnsetWalletLocator, uWalletLocator, naMessagePublic); } // diff --git a/src/Transaction.h b/src/Transaction.h index a0eb1a12ae..9f40951ee4 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -52,7 +52,7 @@ private: const uint128& uEmailHash, bool bUnsetWalletLocator, const uint256& uWalletLocator, - const std::vector& vucPubKey); + const NewcoinAddress& naMessagePublic); Transaction::pointer setClaim( const NewcoinAddress& naPrivateKey, @@ -115,7 +115,7 @@ public: const uint128& uEmailHash, bool bUnsetWalletLocator, const uint256& uWalletLocator, - const std::vector& vucPubKey); + const NewcoinAddress& naMessagePublic); // Claim a wallet. static Transaction::pointer sharedClaim(