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>
37 txArray[jss::Sequence] =
json::UInt(sequence++);
38 txArray[jss::Account] =
toBase58(accountID);
39 auto& fees = ledger.
fees();
57 auto const& params(context.
params);
58 if (!params.isMember(jss::account))
61 if (!params[jss::account].isString())
69 auto const accountID{
id.value()};
71 if (!params.isMember(jss::role))
74 bool roleGateway =
false;
76 if (!params[jss::role].isString())
78 std::string const role = params[jss::role].asString();
79 if (role == jss::gateway)
83 else if (role != jss::user)
89 unsigned int limit = 0;
94 if (context.
apiVersion > 1u && params.isMember(jss::transactions) &&
95 !params[jss::transactions].isBool())
101 if (params.isMember(jss::transactions))
117 bool const defaultRipple = sle->isFlag(lsfDefaultRipple);
121 if (defaultRipple && !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 && !defaultRipple)
130 problems.
append(
"You should immediately set your default ripple flag");
134 tx[jss::TransactionType] = jss::AccountSet;
135 tx[jss::SetFlag] = 8;
141 if (ownedItem->getType() == ltRIPPLE_STATE)
143 bool const low = accountID == ownedItem->getFieldAmount(sfLowLimit).getIssuer();
145 bool const noRipple = ownedItem->isFlag(low ? lsfLowNoRipple : lsfHighNoRipple);
148 bool needFix =
false;
149 if (noRipple && roleGateway)
151 problem =
"You should clear the no ripple flag on your ";
154 else if (!roleGateway && !noRipple)
156 problem =
"You should probably set the no ripple flag on your ";
162 ownedItem->getFieldAmount(low ? sfHighLimit : sfLowLimit).getIssuer();
164 ownedItem->getFieldAmount(low ? sfHighLimit : sfLowLimit);
166 problem +=
" line to ";
170 STAmount limitAmount(ownedItem->getFieldAmount(low ? sfLowLimit : sfHighLimit));
171 limitAmount.
get<
Issue>().account = peer;
176 tx[jss::TransactionType] = jss::TrustSet;
178 tx[jss::Flags] = noRipple ? tfClearNoRipple : tfSetNoRipple;
189 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.
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)
json::Value missingFieldError(std::string const &name)
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.
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)