From 329b1437b04fc76173c42a43308ded95f6200954 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 15 May 2012 13:04:02 -0700 Subject: [PATCH] Improve feedback for RPC wallet_claim. --- src/RPCServer.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 5c23706bf0..b0a7536c0a 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -645,10 +645,26 @@ Json::Value RPCServer::doValidatorCreate(Json::Value& params) { // To provide an example to client writers, we do everything we expect a client to do here. Json::Value RPCServer::doWalletClaim(Json::Value& params) { + NewcoinAddress naTemp; + if (params.size() < 2 || params.size() > 4) { return "invalid params"; } + else if (naTemp.setAccountID(params[0u].asString()) + || naTemp.setAccountPublic(params[0u].asString()) + || naTemp.setAccountPrivate(params[0u].asString())) + { + // Should also not allow account id's as seeds. + return "master seed expected"; + } + else if (naTemp.setAccountID(params[1u].asString()) + || naTemp.setAccountPublic(params[1u].asString()) + || naTemp.setAccountPrivate(params[1u].asString())) + { + // Should also not allow account id's as seeds. + return "regular seed expected"; + } else { // Trying to build: @@ -671,7 +687,6 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) NewcoinAddress naAccountPublic; NewcoinAddress naAccountPrivate; - NewcoinAddress naUnset; naMasterSeed.setFamilySeedGeneric(params[0u].asString()); naRegularSeed.setFamilySeedGeneric(params[1u].asString()); @@ -689,7 +704,6 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) uint160 uGeneratorID = naRegularReservedPublic.getAccountID(); std::vector vucGeneratorCipher = naRegularReservedPrivate.accountPrivateEncrypt(naRegularReservedPublic, naMasterGenerator.getFamilyGenerator()); - Transaction::pointer trns = Transaction::sharedClaim( naAccountPublic, naAccountPrivate, naAccountPublic, @@ -697,6 +711,8 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) naRegularReservedPublic, // GeneratorID vucGeneratorCipher); + (void) theApp->getOPs().processTransaction(trns); + Json::Value obj(Json::objectValue); // We "echo" the seeds so they can be checked. @@ -711,6 +727,7 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) obj["annotation"] = strAnnotation; obj["transaction"] = trns->getSTransaction()->getJson(0); + obj["status"] = trns->getStatus(); return obj; }