rippled
ripple
rpc
handlers
SignFor.cpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012-2015 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/protocol/Feature.h>
23
#include <ripple/resource/Fees.h>
24
#include <ripple/rpc/Context.h>
25
#include <ripple/rpc/impl/TransactionSign.h>
26
27
namespace
ripple
{
28
29
// {
30
// tx_json: <object>,
31
// account: <signing account>
32
// secret: <secret of signing account>
33
// }
34
Json::Value
35
doSignFor
(
RPC::JsonContext
& context)
36
{
37
if
(context.
role
!=
Role::ADMIN
&& !context.
app
.
config
().
canSign
())
38
{
39
return
RPC::make_error
(
40
rpcNOT_SUPPORTED
,
"Signing is not supported by this server."
);
41
}
42
43
context.
loadType
=
Resource::feeHighBurdenRPC
;
44
auto
const
failHard = context.
params
[jss::fail_hard].
asBool
();
45
auto
const
failType =
NetworkOPs::doFailHard
(failHard);
46
47
auto
ret =
RPC::transactionSignFor
(
48
context.
params
,
49
failType,
50
context.
role
,
51
context.
ledgerMaster
.
getValidatedLedgerAge
(),
52
context.
app
);
53
54
ret[jss::deprecated] =
55
"This command has been deprecated and will be "
56
"removed in a future version of the server. Please "
57
"migrate to a standalone signing tool."
;
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::transactionSignFor
Json::Value transactionSignFor(Json::Value jvRequest, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app)
Returns a Json::objectValue.
Definition:
TransactionSign.cpp:928
ripple::doSignFor
Json::Value doSignFor(RPC::JsonContext &)
Definition:
SignFor.cpp:35
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
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
ripple::Config::canSign
bool canSign() const
Definition:
Config.h:361
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::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
Generated by
1.8.17