From 59f811a095a92e50540bb84a16bab73cde5b2b2b Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sun, 13 May 2012 15:35:58 -0700 Subject: [PATCH] Have wallet_claim construct transaction. --- src/RPCServer.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 6d73f740e..3934a6af9 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -592,24 +592,25 @@ Json::Value RPCServer::doValidatorCreate(Json::Value& params) { return obj; } -// wallet_claim [] +// wallet_claim [] [] // // To provide an example to client writers, we do everything we expect a client to do here. Json::Value RPCServer::doWalletClaim(Json::Value& params) { - if (2 != params.size() && 3 != params.size()) + if (params.size() < 2 || params.size() > 4) { return "invalid params"; } else { // Trying to build: - // peer_wallet_claim [] + // peer_wallet_claim [] [] // // Which has no confidential information. // XXX Annotation is ignored. - std::string strAnnotation = (params.size() == 2) ? "" : params[2u].asString(); + uint32 uSourceTag = (params.size() == 2) ? 0 : params[2u].asUInt(); + std::string strAnnotation = (params.size() == 3) ? "" : params[3u].asString(); NewcoinAddress naMasterSeed; NewcoinAddress naMasterGenerator; @@ -619,13 +620,16 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) NewcoinAddress naRegularReservedPublic; NewcoinAddress naRegularReservedPrivate; - NewcoinAddress naAccount; + NewcoinAddress naAccountPublic; + NewcoinAddress naAccountPrivate; + NewcoinAddress naUnset; naMasterSeed.setFamilySeedGeneric(params[0u].asString()); naRegularSeed.setFamilySeedGeneric(params[1u].asString()); naMasterGenerator.setFamilyGenerator(naMasterSeed); - naAccount.setAccountPublic(naMasterGenerator, 0); + naAccountPublic.setAccountPublic(naMasterGenerator, 0); + naAccountPrivate.setAccountPrivate(naMasterGenerator, naMasterSeed, 0); naRegularGenerator.setFamilyGenerator(naRegularSeed); @@ -636,6 +640,15 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) uint160 uGeneratorID = naRegularReservedPublic.getAccountID(); std::vector vucGeneratorCipher = naRegularReservedPrivate.accountPrivateEncrypt(naRegularReservedPublic, naMasterGenerator.getFamilyGenerator()); + + Transaction::pointer trns = boost::make_shared( + naAccountPublic, naAccountPrivate, + naAccountPublic, naUnset, + 0, // Free + 0, // Seq + uSourceTag, // Source tag + 0); // Ledger not specified. + Json::Value obj(Json::objectValue); // We "echo" the seeds so they can be checked. @@ -644,7 +657,7 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) obj["regular_seed"] = naRegularSeed.humanFamilySeed(); obj["regular_key"] = naRegularSeed.humanFamilySeed1751(); - obj["account_id"] = naAccount.humanAccountID(); + obj["account_id"] = naAccountPublic.humanAccountID(); obj["generator_id"] = strHex(uGeneratorID); obj["generator"] = strHex(vucGeneratorCipher); obj["annotation"] = strAnnotation; @@ -750,9 +763,9 @@ Json::Value RPCServer::doUnlDefault(Json::Value& params) { // unl_delete Json::Value RPCServer::doUnlDelete(Json::Value& params) { - if (params.size()==1) + if (1 == params.size()) { - std::string strNodePublic=params[0u].asString(); + std::string strNodePublic = params[0u].asString(); NewcoinAddress naNodePublic;