20#include <xrpld/app/main/Application.h>
21#include <xrpld/app/misc/LoadFeeTrack.h>
22#include <xrpld/app/paths/TrustLine.h>
23#include <xrpld/ledger/ReadView.h>
24#include <xrpld/rpc/Context.h>
25#include <xrpld/rpc/detail/RPCHelpers.h>
26#include <xrpld/rpc/detail/Tuning.h>
27#include <xrpl/protocol/ErrorCodes.h>
28#include <xrpl/protocol/RPCErr.h>
29#include <xrpl/protocol/TxFlags.h>
30#include <xrpl/protocol/jss.h>
43 txArray[
"Account"] =
toBase58(accountID);
44 auto& fees = ledger.
fees();
63 auto const& params(context.
params);
64 if (!params.isMember(jss::account))
67 if (!params.isMember(
"role"))
70 if (!params[jss::account].isString())
73 bool roleGateway =
false;
76 if (role ==
"gateway")
78 else if (role !=
"user")
86 bool transactions =
false;
87 if (params.isMember(jss::transactions))
88 transactions = params[
"transactions"].asBool();
94 if (context.
apiVersion > 1u && params.isMember(jss::transactions) &&
95 !params[jss::transactions].isBool())
109 auto id = parseBase58<AccountID>(params[jss::account].asString());
115 auto const accountID{std::move(
id.value())};
126 if (bDefaultRipple & !roleGateway)
129 "You appear to have set your default ripple flag even though you "
130 "are not a gateway. This is not recommended unless you are "
133 else if (roleGateway & !bDefaultRipple)
135 problems.
append(
"You should immediately set your default ripple flag");
139 tx[
"TransactionType"] = jss::AccountSet;
152 if (ownedItem->getType() == ltRIPPLE_STATE)
154 bool const bLow = accountID ==
155 ownedItem->getFieldAmount(sfLowLimit).getIssuer();
157 bool const bNoRipple = ownedItem->getFieldU32(sfFlags) &
158 (bLow ? lsfLowNoRipple : lsfHighNoRipple);
161 bool needFix = false;
162 if (bNoRipple & roleGateway)
164 problem =
"You should clear the no ripple flag on your ";
167 else if (!roleGateway & !bNoRipple)
170 "You should probably set the no ripple flag on your ";
177 ->getFieldAmount(bLow ? sfHighLimit : sfLowLimit)
179 STAmount peerLimit = ownedItem->getFieldAmount(
180 bLow ? sfHighLimit : sfLowLimit);
182 problem +=
" line to ";
186 STAmount limitAmount(ownedItem->getFieldAmount(
187 bLow ? sfLowLimit : sfHighLimit));
191 tx[
"TransactionType"] = jss::TrustSet;
Value & append(const Value &value)
Append value to array at the end.
virtual LoadFeeTrack & getFeeTrack()=0
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
Json::Value getJson(JsonOptions) const override
void setIssuer(AccountID const &uIssuer)
Currency const & getCurrency() const
AccountID const & getIssuer() const
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)
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext &context, Json::Value &result)
Look up a ledger from a request and fill a Json::Result with the data representing a ledger.
Json::Value missing_field_error(std::string const &name)
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Json::Value doNoRippleCheck(RPC::JsonContext &)
Json::Value rpcError(int iError)
constexpr std::uint32_t tfClearNoRipple
std::string to_string(base_uint< Bits, Tag > const &a)
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.
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
constexpr std::uint32_t tfSetNoRipple
static void fillTransaction(RPC::JsonContext &context, Json::Value &txArray, AccountID const &accountID, std::uint32_t &sequence, ReadView const &ledger)