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/beast/utility/instrumentation.h>
8#include <xrpl/json/json_forwards.h>
9#include <xrpl/json/json_value.h>
10#include <xrpl/ledger/ReadView.h>
11#include <xrpl/ledger/helpers/DirectoryHelpers.h>
12#include <xrpl/protocol/AccountID.h>
13#include <xrpl/protocol/ErrorCodes.h>
14#include <xrpl/protocol/Indexes.h>
15#include <xrpl/protocol/LedgerFormats.h>
16#include <xrpl/protocol/RPCErr.h>
17#include <xrpl/protocol/SField.h>
18#include <xrpl/protocol/TxFlags.h>
19#include <xrpl/protocol/UintTypes.h>
20#include <xrpl/protocol/jss.h>
21#include <xrpl/resource/Fees.h>
22#include <xrpl/server/LoadFeeTrack.h>
39 txArray[jss::Sequence] =
json::UInt(sequence++);
40 txArray[jss::Account] =
toBase58(accountID);
41 auto& fees = ledger.
fees();
59 auto const& params(context.
params);
60 if (!params.isMember(jss::account))
63 if (!params[jss::account].isString())
71 auto const accountID{
id.value()};
73 if (!params.isMember(jss::role))
76 bool roleGateway =
false;
78 if (!params[jss::role].isString())
80 std::string const role = params[jss::role].asString();
81 if (role == jss::gateway)
85 else if (role != jss::user)
91 unsigned int limit = 0;
96 if (context.
apiVersion > 1u && params.isMember(jss::transactions) &&
97 !params[jss::transactions].isBool())
103 if (params.isMember(jss::transactions))
119 bool const defaultRipple = sle->isFlag(lsfDefaultRipple);
123 if (defaultRipple && !roleGateway)
126 "You appear to have set your default ripple flag even though you "
127 "are not a gateway. This is not recommended unless you are "
130 else if (roleGateway && !defaultRipple)
132 problems.
append(
"You should immediately set your default ripple flag");
136 tx[jss::TransactionType] = jss::AccountSet;
137 tx[jss::SetFlag] = 8;
146 UNREACHABLE(
"xrpl::doNoRippleCheck : null SLE");
151 if (ownedItem->getType() == ltRIPPLE_STATE)
153 bool const low = accountID == ownedItem->getFieldAmount(sfLowLimit).getIssuer();
155 bool const noRipple = ownedItem->isFlag(low ? lsfLowNoRipple : lsfHighNoRipple);
158 bool needFix =
false;
159 if (noRipple && roleGateway)
161 problem =
"You should clear the no ripple flag on your ";
164 else if (!roleGateway && !noRipple)
166 problem =
"You should probably set the no ripple flag on your ";
172 ownedItem->getFieldAmount(low ? sfHighLimit : sfLowLimit).getIssuer();
174 ownedItem->getFieldAmount(low ? sfHighLimit : sfLowLimit);
176 problem +=
" line to ";
180 STAmount limitAmount(ownedItem->getFieldAmount(low ? sfLowLimit : sfHighLimit));
181 limitAmount.
get<
Issue>().account = peer;
186 tx[jss::TransactionType] = jss::TrustSet;
188 tx[jss::Flags] = noRipple ? tfClearNoRipple : tfSetNoRipple;
199 result[jss::transactions] = std::move(jvTransactions);
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 & ConstRef
virtual LoadFeeTrack & getFeeTrack()=0
json::Value jsonClipped() const
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
Keylet account(AccountID const &id) noexcept
AccountID root.
Charge const kFeeMediumBurdenRpc
static constexpr LimitRange kNoRippleCheck
Limits for the no_ripple_check command.
json::Value expectedFieldError(std::string const &name, std::string const &type)
json::Value invalidFieldError(std::string const &name)
::rpc::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.
json::Value missingFieldError(std::string const &name)
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.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
json::Value doNoRippleCheck(rpc::JsonContext &context)
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.
bool forEachItemAfter(ReadView const &view, Keylet const &root, UInt256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(SLE::ConstRef)> const &f)
Iterate all items after an item in the given directory.
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)
resource::Charge & loadType