From 110cc109d1d60157fa7273b6aaef46909df2f529 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 7 Jun 2013 22:58:39 -0700 Subject: [PATCH] Allow RPC sign to work when offline. --- src/cpp/ripple/RPCHandler.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index ceabea0ec..4edd35bac 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -109,8 +109,10 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit, Sco return rpcError(rpcINVALID_PARAMS); } - AccountState::pointer asSrc = mNetOps->getAccountState(mNetOps->getCurrentSnapshot(), raSrcAddressID); - if (!asSrc) + bool bOffline = mNetOps->getOperatingMode() < NetworkOPs::omSYNCING; + + AccountState::pointer asSrc = bOffline ? AccountState::pointer() : mNetOps->getAccountState(mNetOps->getCurrentSnapshot(), raSrcAddressID); + if (!bOffline && !asSrc) { WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("transactionSign: Failed to find source account in current ledger: %s") % raSrcAddressID.humanAccountID()); @@ -211,7 +213,18 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit, Sco txJSON["Fee"] = (int) theConfig.FEE_DEFAULT; } - if (!txJSON.isMember("Sequence")) txJSON["Sequence"] = asSrc->getSeq(); + if (!txJSON.isMember("Sequence")) + { + if (bOffline) + { + return rpcError(rpcINVALID_PARAMS); + } + else + { + txJSON["Sequence"] = asSrc->getSeq(); + } + } + if (!txJSON.isMember("Flags")) txJSON["Flags"] = 0; Ledger::pointer lpCurrent = mNetOps->getCurrentSnapshot();