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/Tuning.h>
7#include <xrpl/json/json_forwards.h>
8#include <xrpl/json/json_value.h>
9#include <xrpl/ledger/ReadView.h>
10#include <xrpl/ledger/helpers/DirectoryHelpers.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/ErrorCodes.h>
13#include <xrpl/protocol/Indexes.h>
14#include <xrpl/protocol/LedgerFormats.h>
15#include <xrpl/protocol/RPCErr.h>
16#include <xrpl/protocol/SField.h>
17#include <xrpl/protocol/TxFlags.h>
18#include <xrpl/protocol/UintTypes.h>
19#include <xrpl/protocol/jss.h>
20#include <xrpl/server/LoadFeeTrack.h>
36 txArray[
"Account"] =
toBase58(accountID);
37 auto& fees = ledger.
fees();
54 auto const& params(context.
params);
55 if (!params.isMember(jss::account))
58 if (!params.isMember(
"role"))
61 if (!params[jss::account].isString())
64 bool roleGateway =
false;
67 if (role ==
"gateway")
71 else if (role !=
"user")
77 unsigned int limit = 0;
82 if (params.isMember(jss::transactions))
89 if (context.
apiVersion > 1u && params.isMember(jss::transactions) &&
90 !params[jss::transactions].isBool())
110 auto const accountID{
id.value()};
119 bool const bDefaultRipple = sle->isFlag(lsfDefaultRipple);
121 if (bDefaultRipple && !roleGateway)
124 "You appear to have set your default ripple flag even though you "
125 "are not a gateway. This is not recommended unless you are "
128 else if (roleGateway && !bDefaultRipple)
130 problems.
append(
"You should immediately set your default ripple flag");
134 tx[
"TransactionType"] = jss::AccountSet;
141 if (ownedItem->getType() == ltRIPPLE_STATE)
143 bool const bLow = accountID == ownedItem->getFieldAmount(sfLowLimit).getIssuer();
145 bool const bNoRipple = ownedItem->isFlag(bLow ? lsfLowNoRipple : lsfHighNoRipple);
148 bool needFix =
false;
149 if (bNoRipple && roleGateway)
151 problem =
"You should clear the no ripple flag on your ";
154 else if (!roleGateway && !bNoRipple)
156 problem =
"You should probably set the no ripple flag on your ";
162 ownedItem->getFieldAmount(bLow ? sfHighLimit : sfLowLimit).getIssuer();
164 ownedItem->getFieldAmount(bLow ? sfHighLimit : sfLowLimit);
166 problem +=
" line to ";
170 STAmount limitAmount(ownedItem->getFieldAmount(bLow ? sfLowLimit : sfHighLimit));
171 limitAmount.
get<
Issue>().account = peer;
174 tx[
"TransactionType"] = jss::TrustSet;
176 tx[
"Flags"] = bNoRipple ? tfClearNoRipple : tfSetNoRipple;
Value & append(Value const &value)
Append value to array at the end.
A currency issued by an account.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
constexpr TIss const & get() const
json::Value getJson(JsonOptions=JsonOptions::Values::None) const override
AccountID const & getIssuer() const
std::shared_ptr< STLedgerEntry const > const & const_ref
virtual LoadFeeTrack & getFeeTrack()=0
json::Value jsonClipped() const
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
static constexpr LimitRange kNoRippleCheck
Limits for the no_ripple_check command.
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.
void injectError(ErrorCodeI code, json::Value &json)
Add or update the json update to reflect the error code.
json::Value invalidFieldError(std::string const &name)
json::Value missingFieldError(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::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
json::Value doNoRippleCheck(RPC::JsonContext &context)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string to_string(BaseUInt< Bits, Tag > const &a)
json::Value rpcError(ErrorCodeI iError)
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
static void fillTransaction(RPC::JsonContext &context, json::Value &txArray, AccountID const &accountID, std::uint32_t &sequence, ReadView const &ledger)
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(SLE::const_ref)> const &f)
Iterate all items after an item in the given directory.