rippled
SignHandler.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012-2014 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/protocol/ErrorCodes.h>
22 #include <ripple/resource/Fees.h>
23 #include <ripple/rpc/Context.h>
24 #include <ripple/rpc/impl/TransactionSign.h>
25 
26 namespace ripple {
27 
28 // {
29 // tx_json: <object>,
30 // secret: <secret>
31 // }
34 {
35  if (context.role != Role::ADMIN && !context.app.config().canSign())
36  {
37  return RPC::make_error(
38  rpcNOT_SUPPORTED, "Signing is not supported by this server.");
39  }
40 
43  context.params.isMember(jss::fail_hard) &&
44  context.params[jss::fail_hard].asBool());
45 
46  auto ret = RPC::transactionSign(
47  context.params,
48  failType,
49  context.role,
51  context.app);
52 
53  ret[jss::deprecated] =
54  "This command has been deprecated and will be "
55  "removed in a future version of the server. Please "
56  "migrate to a standalone signing tool.";
57 
58  return ret;
59 }
60 
61 } // namespace ripple
ripple::RPC::JsonContext
Definition: Context.h:53
ripple::rpcNOT_SUPPORTED
@ rpcNOT_SUPPORTED
Definition: ErrorCodes.h:132
ripple::RPC::Context::loadType
Resource::Charge & loadType
Definition: Context.h:43
ripple::RPC::Context::ledgerMaster
LedgerMaster & ledgerMaster
Definition: Context.h:45
ripple::RPC::Context::role
Role role
Definition: Context.h:47
ripple::RPC::transactionSign
Json::Value transactionSign(Json::Value jvRequest, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app)
Returns a Json::objectValue.
Definition: TransactionSign.cpp:762
Json::Value::asBool
bool asBool() const
Definition: json_value.cpp:619
ripple::Role::ADMIN
@ ADMIN
ripple::Application::config
virtual Config & config()=0
ripple::RPC::Context::app
Application & app
Definition: Context.h:42
Json::Value::isMember
bool isMember(const char *key) const
Return true if the object has a member named key.
Definition: json_value.cpp:932
ripple::Config::canSign
bool canSign() const
Definition: Config.h:361
ripple::NetworkOPs::FailHard
FailHard
Definition: NetworkOPs.h:91
ripple::LedgerMaster::getValidatedLedgerAge
std::chrono::seconds getValidatedLedgerAge()
Definition: LedgerMaster.cpp:274
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::doSign
Json::Value doSign(RPC::JsonContext &)
Definition: SignHandler.cpp:33
ripple::NetworkOPs::doFailHard
static FailHard doFailHard(bool noMeansDont)
Definition: NetworkOPs.h:93
ripple::RPC::JsonContext::params
Json::Value params
Definition: Context.h:64
ripple::Resource::feeHighBurdenRPC
const Charge feeHighBurdenRPC
ripple::RPC::make_error
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
Definition: ErrorCodes.cpp:178
Json::Value
Represents a JSON value.
Definition: json_value.h:145