1#include <xrpld/app/main/Application.h>
2#include <xrpld/app/misc/LoadFeeTrack.h>
3#include <xrpld/app/paths/TrustLine.h>
4#include <xrpld/rpc/Context.h>
5#include <xrpld/rpc/detail/RPCHelpers.h>
6#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
7#include <xrpld/rpc/detail/Tuning.h>
9#include <xrpl/ledger/ReadView.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>
26 txArray[
"Account"] =
toBase58(accountID);
27 auto& fees = ledger.
fees();
46 auto const& params(context.
params);
47 if (!params.isMember(jss::account))
50 if (!params.isMember(
"role"))
53 if (!params[jss::account].isString())
56 bool roleGateway =
false;
59 if (role ==
"gateway")
61 else if (role !=
"user")
69 bool transactions =
false;
70 if (params.isMember(jss::transactions))
71 transactions = params[
"transactions"].asBool();
77 if (context.
apiVersion > 1u && params.isMember(jss::transactions) &&
78 !params[jss::transactions].isBool())
92 auto id = parseBase58<AccountID>(params[jss::account].asString());
98 auto const accountID{std::move(
id.value())};
109 if (bDefaultRipple & !roleGateway)
112 "You appear to have set your default ripple flag even though you "
113 "are not a gateway. This is not recommended unless you are "
116 else if (roleGateway & !bDefaultRipple)
118 problems.
append(
"You should immediately set your default ripple flag");
122 tx[
"TransactionType"] = jss::AccountSet;
135 if (ownedItem->getType() == ltRIPPLE_STATE)
137 bool const bLow = accountID ==
138 ownedItem->getFieldAmount(sfLowLimit).getIssuer();
140 bool const bNoRipple = ownedItem->getFieldU32(sfFlags) &
141 (bLow ? lsfLowNoRipple : lsfHighNoRipple);
144 bool needFix = false;
145 if (bNoRipple & roleGateway)
147 problem =
"You should clear the no ripple flag on your ";
150 else if (!roleGateway & !bNoRipple)
153 "You should probably set the no ripple flag on your ";
160 ->getFieldAmount(bLow ? sfHighLimit : sfLowLimit)
162 STAmount peerLimit = ownedItem->getFieldAmount(
163 bLow ? sfHighLimit : sfLowLimit);
165 problem +=
" line to ";
169 STAmount limitAmount(ownedItem->getFieldAmount(
170 bLow ? sfLowLimit : sfHighLimit));
174 tx[
"TransactionType"] = jss::TrustSet;
Value & append(Value const &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=JsonOptions::none) 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
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.
std::string to_string(base_uint< Bits, Tag > const &a)
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)