1#include <xrpld/app/main/Application.h>
2#include <xrpld/rpc/Context.h>
3#include <xrpld/rpc/detail/RPCHelpers.h>
4#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
5#include <xrpld/rpc/detail/TrustLine.h>
6#include <xrpld/rpc/detail/Tuning.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/ledger/helpers/DirectoryHelpers.h>
10#include <xrpl/protocol/ErrorCodes.h>
11#include <xrpl/protocol/RPCErr.h>
12#include <xrpl/protocol/TxFlags.h>
13#include <xrpl/protocol/jss.h>
14#include <xrpl/server/LoadFeeTrack.h>
27 txArray[
"Account"] =
toBase58(accountID);
28 auto& fees = ledger.
fees();
45 auto const& params(context.
params);
46 if (!params.isMember(jss::account))
49 if (!params.isMember(
"role"))
52 if (!params[jss::account].isString())
55 bool roleGateway =
false;
58 if (role ==
"gateway")
62 else if (role !=
"user")
68 unsigned int limit = 0;
72 bool transactions =
false;
73 if (params.isMember(jss::transactions))
74 transactions = params[
"transactions"].asBool();
80 if (context.
apiVersion > 1u && params.isMember(jss::transactions) &&
81 !params[jss::transactions].isBool())
95 auto id = parseBase58<AccountID>(params[jss::account].asString());
101 auto const accountID{
id.value()};
110 bool const bDefaultRipple = (sle->getFieldU32(sfFlags) & lsfDefaultRipple) != 0u;
112 if ((
static_cast<int>(bDefaultRipple) &
static_cast<int>(!roleGateway)) != 0)
115 "You appear to have set your default ripple flag even though you "
116 "are not a gateway. This is not recommended unless you are "
119 else if ((
static_cast<int>(roleGateway) &
static_cast<int>(!bDefaultRipple)) != 0)
121 problems.
append(
"You should immediately set your default ripple flag");
125 tx[
"TransactionType"] = jss::AccountSet;
133 if (ownedItem->getType() == ltRIPPLE_STATE)
135 bool const bLow = accountID == ownedItem->getFieldAmount(sfLowLimit).getIssuer();
137 bool const bNoRipple =
138 ownedItem->getFieldU32(sfFlags) & (bLow ? lsfLowNoRipple : lsfHighNoRipple);
141 bool needFix = false;
142 if (bNoRipple & roleGateway)
144 problem =
"You should clear the no ripple flag on your ";
147 else if (!roleGateway & !bNoRipple)
149 problem =
"You should probably set the no ripple flag on your ";
155 ownedItem->getFieldAmount(bLow ? sfHighLimit : sfLowLimit).getIssuer();
157 ownedItem->getFieldAmount(bLow ? sfHighLimit : sfLowLimit);
159 problem +=
" line to ";
164 ownedItem->getFieldAmount(bLow ? sfLowLimit : sfHighLimit));
168 tx[
"TransactionType"] = jss::TrustSet;
170 tx[
"Flags"] = bNoRipple ? tfClearNoRipple : tfSetNoRipple;
Value & append(Value const &value)
Append value to array at the end.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
Json::Value getJson(JsonOptions=JsonOptions::none) const override
void setIssuer(AccountID const &uIssuer)
Currency const & getCurrency() const
AccountID const & getIssuer() const
virtual LoadFeeTrack & getFeeTrack()=0
Json::Value jsonClipped() const
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
static LimitRange constexpr noRippleCheck
Limits for the no_ripple_check command.
Json::Value invalid_field_error(std::string const &name)
Json::Value missing_field_error(std::string const &name)
void inject_error(error_code_i code, Json::Value &json)
Add or update the json update to reflect the error code.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, Json::Value &result)
Looks up a ledger from a request and fills a Json::Value with ledger data.
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(base_uint< Bits, Tag > const &a)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Json::Value doNoRippleCheck(RPC::JsonContext &context)
Json::Value rpcError(error_code_i iError)
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
static void fillTransaction(RPC::JsonContext &context, Json::Value &txArray, AccountID const &accountID, std::uint32_t &sequence, ReadView const &ledger)