mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-06 10:16:45 +00:00
Merge develop into confidential MPT
This commit is contained in:
@@ -8,21 +8,21 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
std::uint16_t constexpr kTRADING_FEE_THRESHOLD = 1000; // 1%
|
||||
constexpr std::uint16_t kTradingFeeThreshold = 1000; // 1%
|
||||
|
||||
// Auction slot
|
||||
std::uint32_t constexpr kTOTAL_TIME_SLOT_SECS = 24 * 3600;
|
||||
std::uint16_t constexpr kAUCTION_SLOT_TIME_INTERVALS = 20;
|
||||
std::uint16_t constexpr kAUCTION_SLOT_MAX_AUTH_ACCOUNTS = 4;
|
||||
std::uint32_t constexpr kAUCTION_SLOT_FEE_SCALE_FACTOR = 100000;
|
||||
std::uint32_t constexpr kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION = 10;
|
||||
std::uint32_t constexpr kAUCTION_SLOT_MIN_FEE_FRACTION = 25;
|
||||
std::uint32_t constexpr kAUCTION_SLOT_INTERVAL_DURATION =
|
||||
kTOTAL_TIME_SLOT_SECS / kAUCTION_SLOT_TIME_INTERVALS;
|
||||
constexpr std::uint32_t kTotalTimeSlotSecs = 24 * 3600;
|
||||
constexpr std::uint16_t kAuctionSlotTimeIntervals = 20;
|
||||
constexpr std::uint16_t kAuctionSlotMaxAuthAccounts = 4;
|
||||
constexpr std::uint32_t kAuctionSlotFeeScaleFactor = 100000;
|
||||
constexpr std::uint32_t kAuctionSlotDiscountedFeeFraction = 10;
|
||||
constexpr std::uint32_t kAuctionSlotMinFeeFraction = 25;
|
||||
constexpr std::uint32_t kAuctionSlotIntervalDuration =
|
||||
kTotalTimeSlotSecs / kAuctionSlotTimeIntervals;
|
||||
|
||||
// Votes
|
||||
std::uint16_t constexpr kVOTE_MAX_SLOTS = 8;
|
||||
std::uint32_t constexpr kVOTE_WEIGHT_SCALE_FACTOR = 100000;
|
||||
constexpr std::uint16_t kVoteMaxSlots = 8;
|
||||
constexpr std::uint32_t kVoteWeightScaleFactor = 100000;
|
||||
|
||||
class STObject;
|
||||
class STAmount;
|
||||
@@ -77,7 +77,7 @@ ammEnabled(Rules const&);
|
||||
inline Number
|
||||
getFee(std::uint16_t tfee)
|
||||
{
|
||||
return Number{tfee} / kAUCTION_SLOT_FEE_SCALE_FACTOR;
|
||||
return Number{tfee} / kAuctionSlotFeeScaleFactor;
|
||||
}
|
||||
|
||||
/** Get fee multiplier (1 - tfee)
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
} // namespace detail
|
||||
|
||||
/** A 160-bit unsigned that uniquely identifies an account. */
|
||||
using AccountID = BaseUint<160, detail::AccountIDTag>;
|
||||
using AccountID = BaseUInt<160, detail::AccountIDTag>;
|
||||
|
||||
/** Convert AccountID to base58 checked string */
|
||||
std::string
|
||||
@@ -69,7 +69,7 @@ toIssuer(AccountID&, std::string const&);
|
||||
inline bool
|
||||
isXRP(AccountID const& c)
|
||||
{
|
||||
return c == beast::kZERO;
|
||||
return c == beast::kZero;
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
|
||||
@@ -96,9 +96,9 @@ inline MPTAmount
|
||||
toAmount<MPTAmount>(STAmount const& amt)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
amt.holds<MPTIssue>() && amt.mantissa() <= kMAX_MP_TOKEN_AMOUNT && amt.exponent() == 0,
|
||||
amt.holds<MPTIssue>() && amt.mantissa() <= kMaxMpTokenAmount && amt.exponent() == 0,
|
||||
"xrpl::toAmount<MPTAmount> : maximum mantissa");
|
||||
if (amt.mantissa() > kMAX_MP_TOKEN_AMOUNT || amt.exponent() != 0)
|
||||
if (amt.mantissa() > kMaxMpTokenAmount || amt.exponent() != 0)
|
||||
Throw<std::runtime_error>("toAmount<MPTAmount>: invalid mantissa or exponent");
|
||||
bool const isNeg = amt.negative();
|
||||
std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa();
|
||||
@@ -167,8 +167,8 @@ toAmount(Asset const& asset, Number const& n, Number::RoundingMode mode = Number
|
||||
}
|
||||
else
|
||||
{
|
||||
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
|
||||
static_assert(kALWAYS_FALSE, "Unsupported type for toAmount");
|
||||
static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
|
||||
static_assert(kAlwaysFalse, "Unsupported type for toAmount");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,30 +178,30 @@ toMaxAmount(Asset const& asset)
|
||||
{
|
||||
if constexpr (std::is_same_v<IOUAmount, T>)
|
||||
{
|
||||
return IOUAmount(STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET);
|
||||
return IOUAmount(STAmount::kMaxValue, STAmount::kMaxOffset);
|
||||
}
|
||||
else if constexpr (std::is_same_v<XRPAmount, T>)
|
||||
{
|
||||
return XRPAmount(static_cast<std::int64_t>(STAmount::kMAX_NATIVE_N));
|
||||
return XRPAmount(static_cast<std::int64_t>(STAmount::kMaxNativeN));
|
||||
}
|
||||
else if constexpr (std::is_same_v<MPTAmount, T>)
|
||||
{
|
||||
return MPTAmount(kMAX_MP_TOKEN_AMOUNT);
|
||||
return MPTAmount(kMaxMpTokenAmount);
|
||||
}
|
||||
else if constexpr (std::is_same_v<STAmount, T>)
|
||||
{
|
||||
return asset.visit(
|
||||
[](Issue const& issue) {
|
||||
if (isXRP(issue))
|
||||
return STAmount(issue, static_cast<std::int64_t>(STAmount::kMAX_NATIVE_N));
|
||||
return STAmount(issue, STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET);
|
||||
return STAmount(issue, static_cast<std::int64_t>(STAmount::kMaxNativeN));
|
||||
return STAmount(issue, STAmount::kMaxValue, STAmount::kMaxOffset);
|
||||
},
|
||||
[](MPTIssue const& issue) { return STAmount(issue, kMAX_MP_TOKEN_AMOUNT); });
|
||||
[](MPTIssue const& issue) { return STAmount(issue, kMaxMpTokenAmount); });
|
||||
}
|
||||
else
|
||||
{
|
||||
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
|
||||
static_assert(kALWAYS_FALSE, "Unsupported type for toMaxAmount");
|
||||
static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
|
||||
static_assert(kAlwaysFalse, "Unsupported type for toMaxAmount");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,8 +233,8 @@ getAsset(T const& amt)
|
||||
}
|
||||
else
|
||||
{
|
||||
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
|
||||
static_assert(kALWAYS_FALSE, "Unsupported type for getIssue");
|
||||
static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
|
||||
static_assert(kAlwaysFalse, "Unsupported type for getIssue");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ get(STAmount const& a)
|
||||
}
|
||||
else
|
||||
{
|
||||
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
|
||||
static_assert(kALWAYS_FALSE, "Unsupported type for get");
|
||||
constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
|
||||
static_assert(kAlwaysFalse, "Unsupported type for get");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,49 +35,49 @@ namespace xrpl {
|
||||
namespace RPC {
|
||||
|
||||
template <unsigned int Version>
|
||||
constexpr static std::integral_constant<unsigned, Version> kAPI_VERSION = {};
|
||||
static constexpr std::integral_constant<unsigned, Version> kApiVersion = {};
|
||||
|
||||
constexpr static auto kAPI_INVALID_VERSION = kAPI_VERSION<0>;
|
||||
constexpr static auto kAPI_MINIMUM_SUPPORTED_VERSION = kAPI_VERSION<1>;
|
||||
constexpr static auto kAPI_MAXIMUM_SUPPORTED_VERSION = kAPI_VERSION<2>;
|
||||
constexpr static auto kAPI_VERSION_IF_UNSPECIFIED = kAPI_VERSION<1>;
|
||||
constexpr static auto kAPI_COMMAND_LINE_VERSION = kAPI_VERSION<1>; // TODO Bump to 2 later
|
||||
constexpr static auto kAPI_BETA_VERSION = kAPI_VERSION<3>;
|
||||
constexpr static auto kAPI_MAXIMUM_VALID_VERSION = kAPI_BETA_VERSION;
|
||||
static constexpr auto kApiInvalidVersion = kApiVersion<0>;
|
||||
static constexpr auto kApiMinimumSupportedVersion = kApiVersion<1>;
|
||||
static constexpr auto kApiMaximumSupportedVersion = kApiVersion<2>;
|
||||
static constexpr auto kApiVersionIfUnspecified = kApiVersion<1>;
|
||||
static constexpr auto kApiCommandLineVersion = kApiVersion<1>; // TODO Bump to 2 later
|
||||
static constexpr auto kApiBetaVersion = kApiVersion<3>;
|
||||
static constexpr auto kApiMaximumValidVersion = kApiBetaVersion;
|
||||
|
||||
static_assert(kAPI_INVALID_VERSION < kAPI_MINIMUM_SUPPORTED_VERSION);
|
||||
static_assert(kApiInvalidVersion < kApiMinimumSupportedVersion);
|
||||
static_assert(
|
||||
kAPI_VERSION_IF_UNSPECIFIED >= kAPI_MINIMUM_SUPPORTED_VERSION &&
|
||||
kAPI_VERSION_IF_UNSPECIFIED <= kAPI_MAXIMUM_SUPPORTED_VERSION);
|
||||
kApiVersionIfUnspecified >= kApiMinimumSupportedVersion &&
|
||||
kApiVersionIfUnspecified <= kApiMaximumSupportedVersion);
|
||||
static_assert(
|
||||
kAPI_COMMAND_LINE_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION &&
|
||||
kAPI_COMMAND_LINE_VERSION <= kAPI_MAXIMUM_SUPPORTED_VERSION);
|
||||
static_assert(kAPI_MAXIMUM_SUPPORTED_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION);
|
||||
static_assert(kAPI_BETA_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION);
|
||||
static_assert(kAPI_MAXIMUM_VALID_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION);
|
||||
kApiCommandLineVersion >= kApiMinimumSupportedVersion &&
|
||||
kApiCommandLineVersion <= kApiMaximumSupportedVersion);
|
||||
static_assert(kApiMaximumSupportedVersion >= kApiMinimumSupportedVersion);
|
||||
static_assert(kApiBetaVersion >= kApiMaximumSupportedVersion);
|
||||
static_assert(kApiMaximumValidVersion >= kApiMaximumSupportedVersion);
|
||||
|
||||
inline void
|
||||
setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
|
||||
{
|
||||
XRPL_ASSERT(apiVersion != kAPI_INVALID_VERSION, "xrpl::RPC::setVersion : input is valid");
|
||||
XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::RPC::setVersion : input is valid");
|
||||
|
||||
auto& retObj = parent[jss::version] = json::ObjectValue;
|
||||
auto& retObj = parent[jss::version] = json::ValueType::Object;
|
||||
|
||||
if (apiVersion == kAPI_VERSION_IF_UNSPECIFIED)
|
||||
if (apiVersion == kApiVersionIfUnspecified)
|
||||
{
|
||||
// API version numbers used in API version 1
|
||||
static beast::SemanticVersion const kFIRST_VERSION{"1.0.0"};
|
||||
static beast::SemanticVersion const kGOOD_VERSION{"1.0.0"};
|
||||
static beast::SemanticVersion const kLAST_VERSION{"1.0.0"};
|
||||
static beast::SemanticVersion const kFirstVersion{"1.0.0"};
|
||||
static beast::SemanticVersion const kGoodVersion{"1.0.0"};
|
||||
static beast::SemanticVersion const kLastVersion{"1.0.0"};
|
||||
|
||||
retObj[jss::first] = kFIRST_VERSION.print();
|
||||
retObj[jss::good] = kGOOD_VERSION.print();
|
||||
retObj[jss::last] = kLAST_VERSION.print();
|
||||
retObj[jss::first] = kFirstVersion.print();
|
||||
retObj[jss::good] = kGoodVersion.print();
|
||||
retObj[jss::last] = kLastVersion.print();
|
||||
}
|
||||
else
|
||||
{
|
||||
retObj[jss::first] = kAPI_MINIMUM_SUPPORTED_VERSION.value;
|
||||
retObj[jss::last] = betaEnabled ? kAPI_BETA_VERSION : kAPI_MAXIMUM_SUPPORTED_VERSION;
|
||||
retObj[jss::first] = kApiMinimumSupportedVersion.value;
|
||||
retObj[jss::last] = betaEnabled ? kApiBetaVersion : kApiMaximumSupportedVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
|
||||
inline unsigned int
|
||||
getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
|
||||
{
|
||||
static json::Value const kMIN_VERSION(RPC::kAPI_MINIMUM_SUPPORTED_VERSION);
|
||||
static json::Value const kMinVersion(RPC::kApiMinimumSupportedVersion);
|
||||
json::Value const maxVersion(
|
||||
betaEnabled ? RPC::kAPI_BETA_VERSION : RPC::kAPI_MAXIMUM_SUPPORTED_VERSION);
|
||||
betaEnabled ? RPC::kApiBetaVersion : RPC::kApiMaximumSupportedVersion);
|
||||
|
||||
if (jv.isObject())
|
||||
{
|
||||
@@ -109,18 +109,18 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
|
||||
auto const specifiedVersion = jv[jss::api_version];
|
||||
if (!specifiedVersion.isInt() && !specifiedVersion.isUInt())
|
||||
{
|
||||
return RPC::kAPI_INVALID_VERSION;
|
||||
return RPC::kApiInvalidVersion;
|
||||
}
|
||||
auto const specifiedVersionInt = specifiedVersion.asInt();
|
||||
if (specifiedVersionInt < kMIN_VERSION || specifiedVersionInt > maxVersion)
|
||||
if (specifiedVersionInt < kMinVersion || specifiedVersionInt > maxVersion)
|
||||
{
|
||||
return RPC::kAPI_INVALID_VERSION;
|
||||
return RPC::kApiInvalidVersion;
|
||||
}
|
||||
return specifiedVersionInt;
|
||||
}
|
||||
}
|
||||
|
||||
return RPC::kAPI_VERSION_IF_UNSPECIFIED;
|
||||
return RPC::kApiVersionIfUnspecified;
|
||||
}
|
||||
|
||||
} // namespace RPC
|
||||
@@ -128,33 +128,33 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
|
||||
template <unsigned MinVer, unsigned MaxVer, typename Fn, typename... Args>
|
||||
void
|
||||
forApiVersions(Fn const& fn, Args&&... args)
|
||||
requires //
|
||||
(MaxVer >= MinVer) && //
|
||||
(MinVer >= RPC::kAPI_MINIMUM_SUPPORTED_VERSION) && //
|
||||
(RPC::kAPI_MAXIMUM_VALID_VERSION >= MaxVer) && requires {
|
||||
requires //
|
||||
(MaxVer >= MinVer) && //
|
||||
(MinVer >= RPC::kApiMinimumSupportedVersion) && //
|
||||
(RPC::kApiMaximumValidVersion >= MaxVer) && requires {
|
||||
fn(std::integral_constant<unsigned int, MinVer>{}, std::forward<Args>(args)...);
|
||||
fn(std::integral_constant<unsigned int, MaxVer>{}, std::forward<Args>(args)...);
|
||||
}
|
||||
{
|
||||
constexpr auto kSIZE = MaxVer + 1 - MinVer;
|
||||
static constexpr auto kSize = MaxVer + 1 - MinVer;
|
||||
[&]<std::size_t... Offset>(std::index_sequence<Offset...>) {
|
||||
// NOLINTBEGIN(bugprone-use-after-move)
|
||||
(((void)fn(
|
||||
std::integral_constant<unsigned int, MinVer + Offset>{}, std::forward<Args>(args)...)),
|
||||
...);
|
||||
// NOLINTEND(bugprone-use-after-move)
|
||||
}(std::make_index_sequence<kSIZE>{});
|
||||
}(std::make_index_sequence<kSize>{});
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
void
|
||||
forAllApiVersions(Fn const& fn, Args&&... args)
|
||||
requires requires {
|
||||
forApiVersions<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>(
|
||||
forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
|
||||
fn, std::forward<Args>(args)...);
|
||||
}
|
||||
{
|
||||
forApiVersions<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>(
|
||||
forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
|
||||
fn, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,10 +148,10 @@ public:
|
||||
};
|
||||
|
||||
template <ValidIssueType TIss>
|
||||
constexpr bool kIS_ISSUE_V = std::is_same_v<TIss, Issue>;
|
||||
constexpr bool kIsIssueV = std::is_same_v<TIss, Issue>;
|
||||
|
||||
template <ValidIssueType TIss>
|
||||
constexpr bool kIS_MPTISSUE_V = std::is_same_v<TIss, MPTIssue>;
|
||||
constexpr bool kIsMptissueV = std::is_same_v<TIss, MPTIssue>;
|
||||
|
||||
inline json::Value
|
||||
toJson(Asset const& asset)
|
||||
@@ -242,7 +242,7 @@ operator<=>(Asset const& lhs, Asset const& rhs)
|
||||
{
|
||||
return std::weak_ordering(lhs <=> rhs);
|
||||
}
|
||||
else if constexpr (kIS_ISSUE_V<TLhs> && kIS_MPTISSUE_V<TRhs>)
|
||||
else if constexpr (kIsIssueV<TLhs> && kIsMptissueV<TRhs>)
|
||||
{
|
||||
return std::weak_ordering::greater;
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ private:
|
||||
using issue_hasher = std::hash<xrpl::Issue>;
|
||||
using mptissue_hasher = std::hash<xrpl::MPTIssue>;
|
||||
|
||||
issue_hasher m_issue_hasher_;
|
||||
mptissue_hasher m_mptissue_hasher_;
|
||||
issue_hasher mIssueHasher_;
|
||||
mptissue_hasher mMptissueHasher_;
|
||||
|
||||
public:
|
||||
explicit hash() = default;
|
||||
@@ -151,11 +151,11 @@ public:
|
||||
{
|
||||
return asset.visit(
|
||||
[&](xrpl::Issue const& issue) {
|
||||
value_type const result(m_issue_hasher_(issue));
|
||||
value_type const result(mIssueHasher_(issue));
|
||||
return result;
|
||||
},
|
||||
[&](xrpl::MPTIssue const& issue) {
|
||||
value_type const result(m_mptissue_hasher_(issue));
|
||||
value_type const result(mMptissueHasher_(issue));
|
||||
return result;
|
||||
});
|
||||
}
|
||||
@@ -170,8 +170,8 @@ private:
|
||||
using asset_hasher = std::hash<xrpl::Asset>;
|
||||
using uint256_hasher = xrpl::uint256::hasher;
|
||||
|
||||
asset_hasher issue_hasher_;
|
||||
uint256_hasher uint256_hasher_;
|
||||
asset_hasher issueHasher_;
|
||||
uint256_hasher uint256Hasher_;
|
||||
|
||||
public:
|
||||
hash() = default;
|
||||
@@ -182,11 +182,11 @@ public:
|
||||
value_type
|
||||
operator()(argument_type const& value) const
|
||||
{
|
||||
value_type result(issue_hasher_(value.in));
|
||||
boost::hash_combine(result, issue_hasher_(value.out));
|
||||
value_type result(issueHasher_(value.in));
|
||||
boost::hash_combine(result, issueHasher_(value.out));
|
||||
|
||||
if (value.domain)
|
||||
boost::hash_combine(result, uint256_hasher_(*value.domain));
|
||||
boost::hash_combine(result, uint256Hasher_(*value.domain));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -172,24 +172,24 @@ struct ErrorInfo
|
||||
{
|
||||
// Default ctor needed to produce an empty std::array during constexpr eval.
|
||||
constexpr ErrorInfo()
|
||||
: code(RpcUnknown), token("unknown"), message("An unknown error code."), http_status(200)
|
||||
: code(RpcUnknown), token("unknown"), message("An unknown error code."), httpStatus(200)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr ErrorInfo(ErrorCodeI code, char const* token, char const* message)
|
||||
: code(code), token(token), message(message), http_status(200)
|
||||
: code(code), token(token), message(message), httpStatus(200)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr ErrorInfo(ErrorCodeI code, char const* token, char const* message, int httpStatus)
|
||||
: code(code), token(token), message(message), http_status(httpStatus)
|
||||
: code(code), token(token), message(message), httpStatus(httpStatus)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorCodeI code;
|
||||
json::StaticString token;
|
||||
json::StaticString message;
|
||||
int http_status;
|
||||
int httpStatus;
|
||||
};
|
||||
|
||||
/** Returns an ErrorInfo that reflects the error code. */
|
||||
|
||||
@@ -65,11 +65,11 @@
|
||||
namespace xrpl {
|
||||
|
||||
// Feature names must not exceed this length (in characters, excluding the null terminator).
|
||||
static constexpr std::size_t kMAX_FEATURE_NAME_SIZE = 63;
|
||||
static constexpr std::size_t kMaxFeatureNameSize = 63;
|
||||
// Reserve this exact feature-name length (in characters/bytes, excluding the null terminator)
|
||||
// so that a 32-byte uint256 (for example, in WASM or other interop contexts) can be used
|
||||
// as a compact, fixed-size feature selector without conflicting with human-readable names.
|
||||
static constexpr std::size_t kRESERVED_FEATURE_NAME_SIZE = 32;
|
||||
static constexpr std::size_t kReservedFeatureNameSize = 32;
|
||||
|
||||
// Both validFeatureNameSize and validFeatureName are consteval functions that can be used in
|
||||
// static_asserts to validate feature names at compile time. They are only used inside
|
||||
@@ -81,14 +81,14 @@ validFeatureNameSize(auto fn) -> bool
|
||||
{
|
||||
constexpr char const* kN = fn();
|
||||
// Note, std::strlen is not constexpr, we need to implement our own here.
|
||||
constexpr std::size_t kLEN = [](auto n) {
|
||||
constexpr std::size_t kLen = [](auto n) {
|
||||
std::size_t ret = 0;
|
||||
for (auto ptr = n; *ptr != '\0'; ret++, ++ptr)
|
||||
;
|
||||
return ret;
|
||||
}(kN);
|
||||
return kLEN != kRESERVED_FEATURE_NAME_SIZE && //
|
||||
kLEN <= kMAX_FEATURE_NAME_SIZE;
|
||||
return kLen != kReservedFeatureNameSize && //
|
||||
kLen <= kMaxFeatureNameSize;
|
||||
}
|
||||
|
||||
consteval auto
|
||||
@@ -136,7 +136,7 @@ namespace detail {
|
||||
// Feature.cpp. Because it's only used to reserve storage, and determine how
|
||||
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
|
||||
// the actual number of amendments. A LogicError on startup will verify this.
|
||||
static constexpr std::size_t kNUM_FEATURES =
|
||||
static constexpr std::size_t kNumFeatures =
|
||||
(0 +
|
||||
#include <xrpl/protocol/detail/features.macro>
|
||||
);
|
||||
@@ -184,9 +184,9 @@ bitsetIndexToFeature(size_t i);
|
||||
std::string
|
||||
featureToName(uint256 const& f);
|
||||
|
||||
class FeatureBitset : private std::bitset<detail::kNUM_FEATURES>
|
||||
class FeatureBitset : private std::bitset<detail::kNumFeatures>
|
||||
{
|
||||
using base = std::bitset<detail::kNUM_FEATURES>;
|
||||
using base = std::bitset<detail::kNumFeatures>;
|
||||
|
||||
template <class... Fs>
|
||||
void
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace xrpl {
|
||||
|
||||
// Deprecated constant for backwards compatibility with pre-XRPFees amendment.
|
||||
// This was the reference fee units used in the old fee calculation.
|
||||
inline constexpr std::uint32_t kFEE_UNITS_DEPRECATED = 10;
|
||||
inline constexpr std::uint32_t kFeeUnitsDeprecated = 10;
|
||||
|
||||
/** Reflects the fee settings for a particular ledger.
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
inline IOUAmount::IOUAmount(beast::Zero)
|
||||
{
|
||||
*this = beast::kZERO;
|
||||
*this = beast::kZero;
|
||||
}
|
||||
|
||||
inline IOUAmount::IOUAmount(mantissa_type mantissa, exponent_type exponent)
|
||||
|
||||
@@ -82,7 +82,7 @@ struct BookT
|
||||
Keylet
|
||||
operator()(Book const& b) const;
|
||||
};
|
||||
static BookT const kBOOK{};
|
||||
static BookT const kBook{};
|
||||
|
||||
/** The index of a trust line for a given currency
|
||||
|
||||
@@ -126,7 +126,7 @@ struct NextT
|
||||
Keylet
|
||||
operator()(Keylet const& k) const;
|
||||
};
|
||||
static NextT const kNEXT{};
|
||||
static NextT const kNext{};
|
||||
|
||||
/** A ticket belonging to an account */
|
||||
struct TicketT
|
||||
@@ -145,7 +145,7 @@ struct TicketT
|
||||
return {ltTICKET, key};
|
||||
}
|
||||
};
|
||||
static TicketT const kTICKET{};
|
||||
static TicketT const kTicket{};
|
||||
|
||||
/** A SignerList */
|
||||
Keylet
|
||||
@@ -373,7 +373,7 @@ struct KeyletDesc
|
||||
|
||||
// This list should include all of the keylet functions that take a single
|
||||
// AccountID parameter.
|
||||
std::array<KeyletDesc<AccountID const&>, 6> const kDIRECT_ACCOUNT_KEYLETS{
|
||||
std::array<KeyletDesc<AccountID const&>, 6> const kDirectAccountKeylets{
|
||||
{{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false},
|
||||
{.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true},
|
||||
{.function = &keylet::signers, .expectedLEName = jss::SignerList, .includeInTests = true},
|
||||
|
||||
@@ -96,16 +96,16 @@ operator<=>(Issue const& lhs, Issue const& rhs)
|
||||
inline Issue const&
|
||||
xrpIssue()
|
||||
{
|
||||
static Issue const kISSUE{xrpCurrency(), xrpAccount()};
|
||||
return kISSUE;
|
||||
static Issue const kIssue{xrpCurrency(), xrpAccount()};
|
||||
return kIssue;
|
||||
}
|
||||
|
||||
/** Returns an asset specifier that represents no account and currency. */
|
||||
inline Issue const&
|
||||
noIssue()
|
||||
{
|
||||
static Issue const kISSUE{noCurrency(), noAccount()};
|
||||
return kISSUE;
|
||||
static Issue const kIssue{noCurrency(), noAccount()};
|
||||
return kIssue;
|
||||
}
|
||||
|
||||
inline bool
|
||||
|
||||
@@ -26,12 +26,12 @@ struct LedgerHeader
|
||||
//
|
||||
|
||||
// Closed means "tx set already determined"
|
||||
uint256 hash = beast::kZERO;
|
||||
uint256 txHash = beast::kZERO;
|
||||
uint256 accountHash = beast::kZERO;
|
||||
uint256 parentHash = beast::kZERO;
|
||||
uint256 hash = beast::kZero;
|
||||
uint256 txHash = beast::kZero;
|
||||
uint256 accountHash = beast::kZero;
|
||||
uint256 parentHash = beast::kZero;
|
||||
|
||||
XRPAmount drops = beast::kZERO;
|
||||
XRPAmount drops = beast::kZero;
|
||||
|
||||
// If validated is false, it means "not yet validated."
|
||||
// Once validated is true, it will never be set false at a later time.
|
||||
@@ -53,12 +53,12 @@ struct LedgerHeader
|
||||
};
|
||||
|
||||
// ledger close flags
|
||||
static std::uint32_t const kS_LCF_NO_CONSENSUS_TIME = 0x01;
|
||||
static std::uint32_t const kSLcfNoConsensusTime = 0x01;
|
||||
|
||||
inline bool
|
||||
getCloseAgree(LedgerHeader const& info)
|
||||
{
|
||||
return (info.closeFlags & kS_LCF_NO_CONSENSUS_TIME) == 0;
|
||||
return (info.closeFlags & kSLcfNoConsensusTime) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -88,7 +88,7 @@ constexpr MPTAmount::MPTAmount(value_type value) : value_(value)
|
||||
|
||||
constexpr MPTAmount::MPTAmount(beast::Zero)
|
||||
{
|
||||
*this = beast::kZERO;
|
||||
*this = beast::kZero;
|
||||
}
|
||||
|
||||
constexpr MPTAmount&
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
constexpr bool kIS_INTEGRAL_CONSTANT = false;
|
||||
constexpr bool kIsIntegralConstant = false;
|
||||
template <typename I, auto A>
|
||||
constexpr bool kIS_INTEGRAL_CONSTANT<std::integral_constant<I, A>&> = true;
|
||||
constexpr bool kIsIntegralConstant<std::integral_constant<I, A>&> = true;
|
||||
template <typename I, auto A>
|
||||
constexpr bool kIS_INTEGRAL_CONSTANT<std::integral_constant<I, A> const&> = true;
|
||||
constexpr bool kIsIntegralConstant<std::integral_constant<I, A> const&> = true;
|
||||
|
||||
template <typename T>
|
||||
concept some_integral_constant = detail::kIS_INTEGRAL_CONSTANT<T&>;
|
||||
concept some_integral_constant = detail::kIsIntegralConstant<T&>;
|
||||
|
||||
// This class is designed to wrap a collection of _almost_ identical json::Value
|
||||
// objects, indexed by version (i.e. there is some mapping of version to object
|
||||
@@ -47,8 +47,8 @@ struct MultiApiJson
|
||||
return (v < MinVer) ? 0 : static_cast<std::size_t>(v - MinVer);
|
||||
}
|
||||
|
||||
constexpr static std::size_t kSIZE = MaxVer + 1 - MinVer;
|
||||
std::array<json::Value, kSIZE> val = {};
|
||||
static constexpr std::size_t kSize = MaxVer + 1 - MinVer;
|
||||
std::array<json::Value, kSize> val = {};
|
||||
|
||||
explicit MultiApiJson(json::Value const& init = {})
|
||||
{
|
||||
@@ -80,7 +80,7 @@ struct MultiApiJson
|
||||
|
||||
if (count == 0)
|
||||
return IsMemberResult::None;
|
||||
return count < kSIZE ? IsMemberResult::Some : IsMemberResult::All;
|
||||
return count < kSize ? IsMemberResult::Some : IsMemberResult::All;
|
||||
}
|
||||
|
||||
static constexpr struct VisitorT final
|
||||
@@ -100,7 +100,7 @@ struct MultiApiJson
|
||||
std::integral_constant<unsigned int, Version>,
|
||||
Args&&...>
|
||||
{
|
||||
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE);
|
||||
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSize);
|
||||
return std::invoke(fn, json.val[index(Version)], version, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ struct MultiApiJson
|
||||
operator()(Json& json, std::integral_constant<unsigned int, Version> const, Fn fn) const
|
||||
-> std::invoke_result_t<Fn, decltype(json.val[0])>
|
||||
{
|
||||
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE);
|
||||
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSize);
|
||||
return std::invoke(fn, json.val[index(Version)]);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ struct MultiApiJson
|
||||
-> std::invoke_result_t<Fn, decltype(json.val[0]), Version, Args&&...>
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
valid(version) && index(version) >= 0 && index(version) < kSIZE,
|
||||
valid(version) && index(version) >= 0 && index(version) < kSize,
|
||||
"xrpl::detail::MultiApijson::operator<Args...>() : valid "
|
||||
"version");
|
||||
return std::invoke(fn, json.val[index(version)], version, std::forward<Args>(args)...);
|
||||
@@ -139,20 +139,20 @@ struct MultiApiJson
|
||||
-> std::invoke_result_t<Fn, decltype(json.val[0])>
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
valid(version) && index(version) >= 0 && index(version) < kSIZE,
|
||||
valid(version) && index(version) >= 0 && index(version) < kSize,
|
||||
"xrpl::detail::MultiApijson::operator() : valid version");
|
||||
return std::invoke(fn, json.val[index(version)]);
|
||||
}
|
||||
} kVISITOR = {};
|
||||
} kVisitor = {};
|
||||
|
||||
auto
|
||||
visit()
|
||||
{
|
||||
return [self = this](auto... args)
|
||||
requires requires {
|
||||
kVISITOR(std::declval<MultiApiJson&>(), std::declval<decltype(args)>()...);
|
||||
kVisitor(std::declval<MultiApiJson&>(), std::declval<decltype(args)>()...);
|
||||
}
|
||||
{ return kVISITOR(*self, std::forward<decltype(args)>(args)...); };
|
||||
{ return kVisitor(*self, std::forward<decltype(args)>(args)...); };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto
|
||||
@@ -160,27 +160,27 @@ struct MultiApiJson
|
||||
{
|
||||
return [self = this](auto... args)
|
||||
requires requires {
|
||||
kVISITOR(std::declval<MultiApiJson const&>(), std::declval<decltype(args)>()...);
|
||||
kVisitor(std::declval<MultiApiJson const&>(), std::declval<decltype(args)>()...);
|
||||
}
|
||||
{ return kVISITOR(*self, std::forward<decltype(args)>(args)...); };
|
||||
{ return kVisitor(*self, std::forward<decltype(args)>(args)...); };
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto
|
||||
visit(Args... args) -> std::invoke_result_t<VisitorT, MultiApiJson&, Args...>
|
||||
requires(sizeof...(args) > 0) &&
|
||||
requires { kVISITOR(*this, std::forward<decltype(args)>(args)...); }
|
||||
requires { kVisitor(*this, std::forward<decltype(args)>(args)...); }
|
||||
{
|
||||
return kVISITOR(*this, std::forward<decltype(args)>(args)...);
|
||||
return kVisitor(*this, std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
[[nodiscard]] auto
|
||||
visit(Args... args) const -> std::invoke_result_t<VisitorT, MultiApiJson const&, Args...>
|
||||
requires(sizeof...(args) > 0) &&
|
||||
requires { kVISITOR(*this, std::forward<decltype(args)>(args)...); }
|
||||
requires { kVisitor(*this, std::forward<decltype(args)>(args)...); }
|
||||
{
|
||||
return kVISITOR(*this, std::forward<decltype(args)>(args)...);
|
||||
return kVisitor(*this, std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -188,6 +188,6 @@ struct MultiApiJson
|
||||
|
||||
// Wrapper for Json for all supported API versions.
|
||||
using MultiApiJson =
|
||||
detail::MultiApiJson<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>;
|
||||
detail::MultiApiJson<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>;
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -52,10 +52,10 @@ public:
|
||||
};
|
||||
|
||||
template <ValidPathAsset PA>
|
||||
constexpr bool kIS_CURRENCY_V = std::is_same_v<PA, Currency>;
|
||||
constexpr bool kIsCurrencyV = std::is_same_v<PA, Currency>;
|
||||
|
||||
template <ValidPathAsset PA>
|
||||
constexpr bool kIS_MPTID_V = std::is_same_v<PA, MPTID>;
|
||||
constexpr bool kIsMptidV = std::is_same_v<PA, MPTID>;
|
||||
|
||||
inline PathAsset::PathAsset(Asset const& asset)
|
||||
{
|
||||
|
||||
@@ -19,40 +19,40 @@ namespace xrpl {
|
||||
@ingroup protocol
|
||||
*/
|
||||
/** Smallest legal byte size of a transaction. */
|
||||
std::size_t constexpr kTX_MIN_SIZE_BYTES = 32;
|
||||
constexpr std::size_t kTxMinSizeBytes = 32;
|
||||
|
||||
/** Largest legal byte size of a transaction. */
|
||||
std::size_t constexpr kTX_MAX_SIZE_BYTES = megabytes(1);
|
||||
constexpr std::size_t kTxMaxSizeBytes = megabytes(1);
|
||||
|
||||
/** The maximum number of unfunded offers to delete at once */
|
||||
std::size_t constexpr kUNFUNDED_OFFER_REMOVE_LIMIT = 1000;
|
||||
constexpr std::size_t kUnfundedOfferRemoveLimit = 1000;
|
||||
|
||||
/** The maximum number of expired offers to delete at once */
|
||||
std::size_t constexpr kEXPIRED_OFFER_REMOVE_LIMIT = 256;
|
||||
constexpr std::size_t kExpiredOfferRemoveLimit = 256;
|
||||
|
||||
/** The maximum number of metadata entries allowed in one transaction */
|
||||
std::size_t constexpr kOVERSIZE_META_DATA_CAP = 5200;
|
||||
constexpr std::size_t kOversizeMetaDataCap = 5200;
|
||||
|
||||
/** The maximum number of entries per directory page */
|
||||
std::size_t constexpr kDIR_NODE_MAX_ENTRIES = 32;
|
||||
constexpr std::size_t kDirNodeMaxEntries = 32;
|
||||
|
||||
/** The maximum number of pages allowed in a directory
|
||||
|
||||
Made obsolete by fixDirectoryLimit amendment.
|
||||
*/
|
||||
std::uint64_t constexpr kDIR_NODE_MAX_PAGES = 262144;
|
||||
constexpr std::uint64_t kDirNodeMaxPages = 262144;
|
||||
|
||||
/** The maximum number of items in an NFT page */
|
||||
std::size_t constexpr kDIR_MAX_TOKENS_PER_PAGE = 32;
|
||||
constexpr std::size_t kDirMaxTokensPerPage = 32;
|
||||
|
||||
/** The maximum number of owner directory entries for account to be deletable */
|
||||
std::size_t constexpr kMAX_DELETABLE_DIR_ENTRIES = 1000;
|
||||
constexpr std::size_t kMaxDeletableDirEntries = 1000;
|
||||
|
||||
/** The maximum number of token offers that can be canceled at once */
|
||||
std::size_t constexpr kMAX_TOKEN_OFFER_CANCEL_COUNT = 500;
|
||||
constexpr std::size_t kMaxTokenOfferCancelCount = 500;
|
||||
|
||||
/** The maximum number of offers in an offer directory for NFT to be burnable */
|
||||
std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500;
|
||||
constexpr std::size_t kMaxDeletableTokenOfferEntries = 500;
|
||||
|
||||
/** The maximum token transfer fee allowed.
|
||||
|
||||
@@ -63,7 +63,7 @@ std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500;
|
||||
Note that for extremely low transfer fees values, it is possible that the
|
||||
calculated fee will be 0.
|
||||
*/
|
||||
std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000;
|
||||
constexpr std::uint16_t kMaxTransferFee = 50000;
|
||||
|
||||
/** There are 10,000 basis points (bips) in 100%.
|
||||
*
|
||||
@@ -81,32 +81,32 @@ std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000;
|
||||
*
|
||||
* Example: 50% is 0.50 * bipsPerUnity = 5,000 bps.
|
||||
*/
|
||||
Bips32 constexpr kBIPS_PER_UNITY(100 * 100);
|
||||
static_assert(kBIPS_PER_UNITY == Bips32{10'000});
|
||||
TenthBips32 constexpr kTENTH_BIPS_PER_UNITY(kBIPS_PER_UNITY.value() * 10);
|
||||
static_assert(kTENTH_BIPS_PER_UNITY == TenthBips32(100'000));
|
||||
constexpr Bips32 kBipsPerUnity(100 * 100);
|
||||
static_assert(kBipsPerUnity == Bips32{10'000});
|
||||
constexpr TenthBips32 kTenthBipsPerUnity(kBipsPerUnity.value() * 10);
|
||||
static_assert(kTenthBipsPerUnity == TenthBips32(100'000));
|
||||
|
||||
constexpr Bips32
|
||||
percentageToBips(std::uint32_t percentage)
|
||||
{
|
||||
return Bips32(percentage * kBIPS_PER_UNITY.value() / 100);
|
||||
return Bips32(percentage * kBipsPerUnity.value() / 100);
|
||||
}
|
||||
constexpr TenthBips32
|
||||
percentageToTenthBips(std::uint32_t percentage)
|
||||
{
|
||||
return TenthBips32(percentage * kTENTH_BIPS_PER_UNITY.value() / 100);
|
||||
return TenthBips32(percentage * kTenthBipsPerUnity.value() / 100);
|
||||
}
|
||||
template <typename T, class TBips>
|
||||
constexpr T
|
||||
bipsOfValue(T value, Bips<TBips> bips)
|
||||
{
|
||||
return value * bips.value() / kBIPS_PER_UNITY.value();
|
||||
return value * bips.value() / kBipsPerUnity.value();
|
||||
}
|
||||
template <typename T, class TBips>
|
||||
constexpr T
|
||||
tenthBipsOfValue(T value, TenthBips<TBips> bips)
|
||||
{
|
||||
return value * bips.value() / kTENTH_BIPS_PER_UNITY.value();
|
||||
return value * bips.value() / kTenthBipsPerUnity.value();
|
||||
}
|
||||
|
||||
namespace Lending {
|
||||
@@ -114,54 +114,54 @@ namespace Lending {
|
||||
|
||||
Valid values are between 0 and 10% inclusive.
|
||||
*/
|
||||
TenthBips16 constexpr kMAX_MANAGEMENT_FEE_RATE(
|
||||
constexpr TenthBips16 kMaxManagementFeeRate(
|
||||
unsafeCast<std::uint16_t>(percentageToTenthBips(10).value()));
|
||||
static_assert(kMAX_MANAGEMENT_FEE_RATE == TenthBips16(std::uint16_t(10'000u)));
|
||||
static_assert(kMaxManagementFeeRate == TenthBips16(std::uint16_t(10'000u)));
|
||||
|
||||
/** The maximum coverage rate required of a loan broker in 1/10 bips.
|
||||
|
||||
Valid values are between 0 and 100% inclusive.
|
||||
*/
|
||||
TenthBips32 constexpr kMAX_COVER_RATE = percentageToTenthBips(100);
|
||||
static_assert(kMAX_COVER_RATE == TenthBips32(100'000u));
|
||||
constexpr TenthBips32 kMaxCoverRate = percentageToTenthBips(100);
|
||||
static_assert(kMaxCoverRate == TenthBips32(100'000u));
|
||||
|
||||
/** The maximum overpayment fee on a loan in 1/10 bips.
|
||||
*
|
||||
Valid values are between 0 and 100% inclusive.
|
||||
*/
|
||||
TenthBips32 constexpr kMAX_OVERPAYMENT_FEE = percentageToTenthBips(100);
|
||||
static_assert(kMAX_OVERPAYMENT_FEE == TenthBips32(100'000u));
|
||||
constexpr TenthBips32 kMaxOverpaymentFee = percentageToTenthBips(100);
|
||||
static_assert(kMaxOverpaymentFee == TenthBips32(100'000u));
|
||||
|
||||
/** Annualized interest rate of the Loan in 1/10 bips.
|
||||
*
|
||||
* Valid values are between 0 and 100% inclusive.
|
||||
*/
|
||||
TenthBips32 constexpr kMAX_INTEREST_RATE = percentageToTenthBips(100);
|
||||
static_assert(kMAX_INTEREST_RATE == TenthBips32(100'000u));
|
||||
constexpr TenthBips32 kMaxInterestRate = percentageToTenthBips(100);
|
||||
static_assert(kMaxInterestRate == TenthBips32(100'000u));
|
||||
|
||||
/** The maximum premium added to the interest rate for late payments on a loan
|
||||
* in 1/10 bips.
|
||||
*
|
||||
* Valid values are between 0 and 100% inclusive.
|
||||
*/
|
||||
TenthBips32 constexpr kMAX_LATE_INTEREST_RATE = percentageToTenthBips(100);
|
||||
static_assert(kMAX_LATE_INTEREST_RATE == TenthBips32(100'000u));
|
||||
constexpr TenthBips32 kMaxLateInterestRate = percentageToTenthBips(100);
|
||||
static_assert(kMaxLateInterestRate == TenthBips32(100'000u));
|
||||
|
||||
/** The maximum close interest rate charged for repaying a loan early in 1/10
|
||||
* bips.
|
||||
*
|
||||
* Valid values are between 0 and 100% inclusive.
|
||||
*/
|
||||
TenthBips32 constexpr kMAX_CLOSE_INTEREST_RATE = percentageToTenthBips(100);
|
||||
static_assert(kMAX_CLOSE_INTEREST_RATE == TenthBips32(100'000u));
|
||||
constexpr TenthBips32 kMaxCloseInterestRate = percentageToTenthBips(100);
|
||||
static_assert(kMaxCloseInterestRate == TenthBips32(100'000u));
|
||||
|
||||
/** The maximum overpayment interest rate charged on loan overpayments in 1/10
|
||||
* bips.
|
||||
*
|
||||
* Valid values are between 0 and 100% inclusive.
|
||||
*/
|
||||
TenthBips32 constexpr kMAX_OVERPAYMENT_INTEREST_RATE = percentageToTenthBips(100);
|
||||
static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u));
|
||||
constexpr TenthBips32 kMaxOverpaymentInterestRate = percentageToTenthBips(100);
|
||||
static_assert(kMaxOverpaymentInterestRate == TenthBips32(100'000u));
|
||||
|
||||
/** LoanPay transaction cost will be one base fee per X combined payments
|
||||
*
|
||||
@@ -172,7 +172,7 @@ static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u));
|
||||
* This number was chosen arbitrarily, but should not be changed once released
|
||||
* without an amendment
|
||||
*/
|
||||
static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5;
|
||||
static constexpr int kLoanPaymentsPerFeeIncrement = 5;
|
||||
|
||||
/** Maximum number of combined payments that a LoanPay transaction will process
|
||||
*
|
||||
@@ -196,65 +196,65 @@ static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5;
|
||||
* This number was chosen arbitrarily, but should not be changed once released
|
||||
* without an amendment
|
||||
*/
|
||||
static constexpr int kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION = 100;
|
||||
static constexpr int kLoanMaximumPaymentsPerTransaction = 100;
|
||||
} // namespace Lending
|
||||
|
||||
/** The maximum length of a URI inside an NFT */
|
||||
std::size_t constexpr kMAX_TOKEN_URI_LENGTH = 256;
|
||||
constexpr std::size_t kMaxTokenUriLength = 256;
|
||||
|
||||
/** The maximum length of a Data element inside a DID */
|
||||
std::size_t constexpr kMAX_DID_DOCUMENT_LENGTH = 256;
|
||||
constexpr std::size_t kMaxDidDocumentLength = 256;
|
||||
|
||||
/** The maximum length of a URI inside a DID */
|
||||
std::size_t constexpr kMAX_DIDURI_LENGTH = 256;
|
||||
constexpr std::size_t kMaxDidUriLength = 256;
|
||||
|
||||
/** The maximum length of an Attestation inside a DID */
|
||||
std::size_t constexpr kMAX_DID_DATA_LENGTH = 256;
|
||||
constexpr std::size_t kMaxDidDataLength = 256;
|
||||
|
||||
/** The maximum length of a domain */
|
||||
std::size_t constexpr kMAX_DOMAIN_LENGTH = 256;
|
||||
constexpr std::size_t kMaxDomainLength = 256;
|
||||
|
||||
/** The maximum length of a URI inside a Credential */
|
||||
std::size_t constexpr kMAX_CREDENTIAL_URI_LENGTH = 256;
|
||||
constexpr std::size_t kMaxCredentialUriLength = 256;
|
||||
|
||||
/** The maximum length of a CredentialType inside a Credential */
|
||||
std::size_t constexpr kMAX_CREDENTIAL_TYPE_LENGTH = 64;
|
||||
constexpr std::size_t kMaxCredentialTypeLength = 64;
|
||||
|
||||
/** The maximum number of credentials can be passed in array */
|
||||
std::size_t constexpr kMAX_CREDENTIALS_ARRAY_SIZE = 8;
|
||||
constexpr std::size_t kMaxCredentialsArraySize = 8;
|
||||
|
||||
/** The maximum number of credentials can be passed in array for permissioned
|
||||
* domain */
|
||||
std::size_t constexpr kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE = 10;
|
||||
constexpr std::size_t kMaxPermissionedDomainCredentialsArraySize = 10;
|
||||
|
||||
/** The maximum length of MPTokenMetadata */
|
||||
std::size_t constexpr kMAX_MP_TOKEN_METADATA_LENGTH = 1024;
|
||||
constexpr std::size_t kMaxMpTokenMetadataLength = 1024;
|
||||
|
||||
/** The maximum amount of MPTokenIssuance */
|
||||
std::uint64_t constexpr kMAX_MP_TOKEN_AMOUNT = 0x7FFF'FFFF'FFFF'FFFFull;
|
||||
static_assert(Number::kMAX_REP >= kMAX_MP_TOKEN_AMOUNT);
|
||||
constexpr std::uint64_t kMaxMpTokenAmount = 0x7FFF'FFFF'FFFF'FFFFull;
|
||||
static_assert(Number::kMaxRep >= kMaxMpTokenAmount);
|
||||
|
||||
/** The maximum length of Data payload */
|
||||
std::size_t constexpr kMAX_DATA_PAYLOAD_LENGTH = 256;
|
||||
constexpr std::size_t kMaxDataPayloadLength = 256;
|
||||
|
||||
/** Vault withdrawal policies */
|
||||
std::uint8_t constexpr kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE = 1;
|
||||
constexpr std::uint8_t kVaultStrategyFirstComeFirstServe = 1;
|
||||
|
||||
/** Default IOU scale factor for a Vault */
|
||||
std::uint8_t constexpr kVAULT_DEFAULT_IOU_SCALE = 6;
|
||||
constexpr std::uint8_t kVaultDefaultIouScale = 6;
|
||||
/** Maximum scale factor for a Vault. The number is chosen to ensure that
|
||||
1 IOU can be always converted to shares.
|
||||
10^19 > maxMPTokenAmount (2^64-1) > 10^18 */
|
||||
std::uint8_t constexpr kVAULT_MAXIMUM_IOU_SCALE = 18;
|
||||
constexpr std::uint8_t kVaultMaximumIouScale = 18;
|
||||
|
||||
/** Maximum recursion depth for vault shares being put as an asset inside
|
||||
* another vault; counted from 0 */
|
||||
std::uint8_t constexpr kMAX_ASSET_CHECK_DEPTH = 5;
|
||||
constexpr std::uint8_t kMaxAssetCheckDepth = 5;
|
||||
|
||||
/** A ledger index. */
|
||||
using LedgerIndex = std::uint32_t;
|
||||
|
||||
std::uint32_t constexpr kFLAG_LEDGER_INTERVAL = 256;
|
||||
constexpr std::uint32_t kFlagLedgerInterval = 256;
|
||||
|
||||
/** Returns true if the given ledgerIndex is a voting ledgerIndex */
|
||||
bool
|
||||
@@ -273,39 +273,39 @@ using TxID = uint256;
|
||||
/** The maximum number of trustlines to delete as part of AMM account
|
||||
* deletion cleanup.
|
||||
*/
|
||||
std::uint16_t constexpr kMAX_DELETABLE_AMM_TRUST_LINES = 512;
|
||||
constexpr std::uint16_t kMaxDeletableAmmTrustLines = 512;
|
||||
|
||||
/** The maximum length of a URI inside an Oracle */
|
||||
std::size_t constexpr kMAX_ORACLE_URI = 256;
|
||||
constexpr std::size_t kMaxOracleUri = 256;
|
||||
|
||||
/** The maximum length of a Provider inside an Oracle */
|
||||
std::size_t constexpr kMAX_ORACLE_PROVIDER = 256;
|
||||
constexpr std::size_t kMaxOracleProvider = 256;
|
||||
|
||||
/** The maximum size of a data series array inside an Oracle */
|
||||
std::size_t constexpr kMAX_ORACLE_DATA_SERIES = 10;
|
||||
constexpr std::size_t kMaxOracleDataSeries = 10;
|
||||
|
||||
/** The maximum length of a SymbolClass inside an Oracle */
|
||||
std::size_t constexpr kMAX_ORACLE_SYMBOL_CLASS = 16;
|
||||
constexpr std::size_t kMaxOracleSymbolClass = 16;
|
||||
|
||||
/** The maximum allowed time difference between lastUpdateTime and the time
|
||||
of the last closed ledger
|
||||
*/
|
||||
std::size_t constexpr kMAX_LAST_UPDATE_TIME_DELTA = 300;
|
||||
constexpr std::size_t kMaxLastUpdateTimeDelta = 300;
|
||||
|
||||
/** The maximum price scaling factor
|
||||
*/
|
||||
std::size_t constexpr kMAX_PRICE_SCALE = 20;
|
||||
constexpr std::size_t kMaxPriceScale = 20;
|
||||
|
||||
/** The maximum percentage of outliers to trim
|
||||
*/
|
||||
std::size_t constexpr kMAX_TRIM = 25;
|
||||
constexpr std::size_t kMaxTrim = 25;
|
||||
|
||||
/** The maximum number of delegate permissions an account can grant
|
||||
*/
|
||||
std::size_t constexpr kPERMISSION_MAX_SIZE = 10;
|
||||
constexpr std::size_t kPermissionMaxSize = 10;
|
||||
|
||||
/** The maximum number of transactions that can be in a batch. */
|
||||
std::size_t constexpr kMAX_BATCH_TX_COUNT = 8;
|
||||
constexpr std::size_t kMaxBatchTxCount = 8;
|
||||
|
||||
/** Length of one component of EC ElGamal ciphertext */
|
||||
std::size_t constexpr kEC_GAMAL_ENCRYPTED_LENGTH = 33;
|
||||
|
||||
@@ -43,8 +43,8 @@ class PublicKey
|
||||
protected:
|
||||
// All the constructed public keys are valid, non-empty and contain 33
|
||||
// bytes of data.
|
||||
static constexpr std::size_t kSIZE = 33;
|
||||
std::uint8_t buf_[kSIZE]{}; // should be large enough
|
||||
static constexpr std::size_t kSize = 33;
|
||||
std::uint8_t buf_[kSize]{}; // should be large enough
|
||||
|
||||
public:
|
||||
using const_iterator = std::uint8_t const*;
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
static std::size_t
|
||||
size() noexcept
|
||||
{
|
||||
return kSIZE;
|
||||
return kSize;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
@@ -90,19 +90,19 @@ public:
|
||||
[[nodiscard]] const_iterator
|
||||
end() const noexcept
|
||||
{
|
||||
return buf_ + kSIZE;
|
||||
return buf_ + kSize;
|
||||
}
|
||||
|
||||
[[nodiscard]] const_iterator
|
||||
cend() const noexcept
|
||||
{
|
||||
return buf_ + kSIZE;
|
||||
return buf_ + kSize;
|
||||
}
|
||||
|
||||
[[nodiscard]] Slice
|
||||
slice() const noexcept
|
||||
{
|
||||
return {buf_, kSIZE};
|
||||
return {buf_, kSize};
|
||||
}
|
||||
|
||||
operator Slice() const noexcept
|
||||
@@ -267,10 +267,10 @@ getOrThrow(json::Value const& v, xrpl::SField const& field)
|
||||
{
|
||||
using namespace xrpl;
|
||||
std::string const b58 = getOrThrow<std::string>(v, field);
|
||||
if (auto pubKeyBlob = strUnHex(b58); pubKeyBlob && publicKeyType(makeSlice(*pubKeyBlob)))
|
||||
if (auto pubKeyBlob = strUnHex(b58);
|
||||
pubKeyBlob.has_value() && publicKeyType(makeSlice(*pubKeyBlob)))
|
||||
{
|
||||
return PublicKey{makeSlice(
|
||||
*pubKeyBlob)}; // NOLINT(bugprone-unchecked-optional-access) checked in condition above
|
||||
return PublicKey{makeSlice(*pubKeyBlob)};
|
||||
}
|
||||
for (auto const tokenType : {TokenType::NodePublic, TokenType::AccountPublic})
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ struct TAmounts
|
||||
{
|
||||
TAmounts() = default;
|
||||
|
||||
TAmounts(beast::Zero, beast::Zero) : in(beast::kZERO), out(beast::kZERO)
|
||||
TAmounts(beast::Zero, beast::Zero) : in(beast::kZero), out(beast::kZero)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ struct TAmounts
|
||||
[[nodiscard]] bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return in <= beast::kZERO || out <= beast::kZERO;
|
||||
return in <= beast::kZero || out <= beast::kZero;
|
||||
}
|
||||
|
||||
TAmounts&
|
||||
@@ -94,8 +94,8 @@ public:
|
||||
// have lower unsigned integer representations.
|
||||
using value_type = std::uint64_t;
|
||||
|
||||
static int const kMIN_TICK_SIZE = 3;
|
||||
static int const kMAX_TICK_SIZE = 16;
|
||||
static int const kMinTickSize = 3;
|
||||
static int const kMaxTickSize = 16;
|
||||
|
||||
private:
|
||||
// This has the same representation as STAmount, see the comment on the
|
||||
@@ -316,10 +316,10 @@ TAmounts<In, Out>
|
||||
Quality::ceilIn(TAmounts<In, Out> const& amount, In const& limit) const
|
||||
{
|
||||
// Construct a function pointer to the function we want to call.
|
||||
static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&) const =
|
||||
static constexpr Amounts (Quality::*kCeilInFnPtr)(Amounts const&, STAmount const&) const =
|
||||
&Quality::ceilIn;
|
||||
|
||||
return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR);
|
||||
return ceilTAmountsHelper(amount, limit, amount.in, kCeilInFnPtr);
|
||||
}
|
||||
|
||||
template <class In, class Out>
|
||||
@@ -327,10 +327,10 @@ TAmounts<In, Out>
|
||||
Quality::ceilInStrict(TAmounts<In, Out> const& amount, In const& limit, bool roundUp) const
|
||||
{
|
||||
// Construct a function pointer to the function we want to call.
|
||||
static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&, bool)
|
||||
const = &Quality::ceilInStrict;
|
||||
static constexpr Amounts (Quality::*kCeilInFnPtr)(Amounts const&, STAmount const&, bool) const =
|
||||
&Quality::ceilInStrict;
|
||||
|
||||
return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR, roundUp);
|
||||
return ceilTAmountsHelper(amount, limit, amount.in, kCeilInFnPtr, roundUp);
|
||||
}
|
||||
|
||||
template <class In, class Out>
|
||||
@@ -338,10 +338,10 @@ TAmounts<In, Out>
|
||||
Quality::ceilOut(TAmounts<In, Out> const& amount, Out const& limit) const
|
||||
{
|
||||
// Construct a function pointer to the function we want to call.
|
||||
static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&) const =
|
||||
static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&) const =
|
||||
&Quality::ceilOut;
|
||||
|
||||
return ceil_TAmounts_helper(amount, limit, amount.out, kCEIL_OUT_FN_PTR);
|
||||
return ceil_TAmounts_helper(amount, limit, amount.out, kCeilOutFnPtr);
|
||||
}
|
||||
|
||||
template <class In, class Out>
|
||||
@@ -349,10 +349,10 @@ TAmounts<In, Out>
|
||||
Quality::ceilOutStrict(TAmounts<In, Out> const& amount, Out const& limit, bool roundUp) const
|
||||
{
|
||||
// Construct a function pointer to the function we want to call.
|
||||
static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&, bool)
|
||||
static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&, bool)
|
||||
const = &Quality::ceilOutStrict;
|
||||
|
||||
return ceilTAmountsHelper(amount, limit, amount.out, kCEIL_OUT_FN_PTR, roundUp);
|
||||
return ceilTAmountsHelper(amount, limit, amount.out, kCeilOutFnPtr, roundUp);
|
||||
}
|
||||
|
||||
/** Calculate the quality of a two-hop path given the two hops.
|
||||
|
||||
@@ -72,7 +72,7 @@ QualityFunction::QualityFunction(
|
||||
std::uint32_t tfee,
|
||||
QualityFunction::AMMTag)
|
||||
{
|
||||
if (amounts.in <= beast::kZERO || amounts.out <= beast::kZERO)
|
||||
if (amounts.in <= beast::kZero || amounts.out <= beast::kZero)
|
||||
Throw<std::runtime_error>("QualityFunction amounts are 0.");
|
||||
Number const cfee = feeMult(tfee);
|
||||
m_ = -cfee / amounts.in;
|
||||
|
||||
@@ -72,6 +72,6 @@ transferFeeAsRate(std::uint16_t fee);
|
||||
} // namespace nft
|
||||
|
||||
/** A transfer rate signifying a 1:1 exchange */
|
||||
extern Rate const kPARITY_RATE;
|
||||
extern Rate const kParityRate;
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -122,4 +122,17 @@ private:
|
||||
std::optional<Rules> saved_;
|
||||
};
|
||||
|
||||
class NumberSO;
|
||||
class NumberMantissaScaleGuard;
|
||||
|
||||
bool
|
||||
useRulesGuards(Rules const& rules);
|
||||
|
||||
void
|
||||
createGuards(
|
||||
Rules const& rules,
|
||||
std::optional<NumberSO>& stNumberSO,
|
||||
std::optional<CurrentTransactionRulesGuard>& rulesGuard,
|
||||
std::optional<NumberMantissaScaleGuard>& mantissaScaleGuard);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -92,7 +92,7 @@ class STCurrency;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum SerializedTypeID { XMACRO(TO_ENUM) };
|
||||
|
||||
static std::map<std::string, int> const kS_TYPE_MAP = {XMACRO(TO_MAP)};
|
||||
static std::map<std::string, int> const kSTypeMap = {XMACRO(TO_MAP)};
|
||||
|
||||
#undef XMACRO
|
||||
#undef TO_ENUM
|
||||
@@ -129,26 +129,23 @@ fieldCode(int id, int index)
|
||||
class SField
|
||||
{
|
||||
public:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
SMdNever = 0x00,
|
||||
SMdChangeOrig = 0x01, // original value when it changes
|
||||
SMdChangeNew = 0x02, // new value when it changes
|
||||
SMdDeleteFinal = 0x04, // final value when it is deleted
|
||||
SMdCreate = 0x08, // value when it's created
|
||||
SMdAlways = 0x10, // value when node containing it is affected at all
|
||||
SMdBaseTen = 0x20, // value is treated as base 10, overriding behavior
|
||||
SMdPseudoAccount = 0x40, // if this field is set in an ACCOUNT_ROOT
|
||||
// _only_, then it is a pseudo-account
|
||||
SMdNeedsAsset = 0x80, // This field needs to be associated with an
|
||||
// asset before it is serialized as a ledger
|
||||
// object. Intended for STNumber.
|
||||
SMdDefault = SMdChangeOrig | SMdChangeNew | SMdDeleteFinal | SMdCreate
|
||||
};
|
||||
static constexpr auto kSmdNever = 0x00;
|
||||
static constexpr auto kSmdChangeOrig = 0x01; // original value when it changes
|
||||
static constexpr auto kSmdChangeNew = 0x02; // new value when it changes
|
||||
static constexpr auto kSmdDeleteFinal = 0x04; // final value when it is deleted
|
||||
static constexpr auto kSmdCreate = 0x08; // value when it's created
|
||||
static constexpr auto kSmdAlways = 0x10; // value when node containing it is affected at all
|
||||
static constexpr auto kSmdBaseTen = 0x20; // value is treated as base 10, overriding behavior
|
||||
static constexpr auto kSmdPseudoAccount = 0x40; // if this field is set in an ACCOUNT_ROOT
|
||||
// _only_, then it is a pseudo-account
|
||||
static constexpr auto kSmdNeedsAsset = 0x80; // This field needs to be associated with an
|
||||
// asset before it is serialized as a ledger
|
||||
// object. Intended for STNumber.
|
||||
static constexpr auto kSmdDefault =
|
||||
kSmdChangeOrig | kSmdChangeNew | kSmdDeleteFinal | kSmdCreate;
|
||||
|
||||
enum class IsSigning : unsigned char { No, Yes };
|
||||
static IsSigning const kNOT_SIGNING = IsSigning::No;
|
||||
static IsSigning const kNotSigning = IsSigning::No;
|
||||
|
||||
int const fieldCodeMem; // (type<<16)|index // TODO: rename, clashes with function
|
||||
SerializedTypeID const fieldType; // STI_*
|
||||
@@ -175,7 +172,7 @@ public:
|
||||
SerializedTypeID tid,
|
||||
int fv,
|
||||
char const* fn,
|
||||
int meta = SMdDefault,
|
||||
int meta = kSmdDefault,
|
||||
IsSigning signing = IsSigning::Yes);
|
||||
explicit SField(PrivateAccessTagT, int fc, char const* fn);
|
||||
|
||||
@@ -368,8 +365,8 @@ using SF_XCHAIN_BRIDGE = TypedField<STXChainBridge>;
|
||||
#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SField const sfName;
|
||||
#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SF_##stiSuffix const sfName;
|
||||
|
||||
extern SField const kSF_INVALID;
|
||||
extern SField const kSF_GENERIC;
|
||||
extern SField const sfInvalid; // NOLINT(readability-identifier-naming)
|
||||
extern SField const sfGeneric; // NOLINT(readability-identifier-naming)
|
||||
|
||||
#include <xrpl/protocol/detail/sfields.macro>
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
#include <xrpl/basics/CountedObject.h>
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/protocol/Asset.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/MPTAmount.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STBase.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
@@ -42,24 +44,24 @@ private:
|
||||
public:
|
||||
using value_type = STAmount;
|
||||
|
||||
constexpr static int kMIN_OFFSET = -96;
|
||||
constexpr static int kMAX_OFFSET = 80;
|
||||
static constexpr int kMinOffset = -96;
|
||||
static constexpr int kMaxOffset = 80;
|
||||
|
||||
// Maximum native value supported by the code
|
||||
constexpr static std::uint64_t kMIN_VALUE = 1'000'000'000'000'000ull;
|
||||
static_assert(isPowerOfTen(kMIN_VALUE));
|
||||
constexpr static std::uint64_t kMAX_VALUE = (kMIN_VALUE * 10) - 1;
|
||||
static_assert(kMAX_VALUE == 9'999'999'999'999'999ull);
|
||||
constexpr static std::uint64_t kMAX_NATIVE = 9'000'000'000'000'000'000ull;
|
||||
static constexpr std::uint64_t kMinValue = 1'000'000'000'000'000ull;
|
||||
static_assert(isPowerOfTen(kMinValue));
|
||||
static constexpr std::uint64_t kMaxValue = (kMinValue * 10) - 1;
|
||||
static_assert(kMaxValue == 9'999'999'999'999'999ull);
|
||||
static constexpr std::uint64_t kMaxNative = 9'000'000'000'000'000'000ull;
|
||||
|
||||
// Max native value on network.
|
||||
constexpr static std::uint64_t kMAX_NATIVE_N = 100'000'000'000'000'000ull;
|
||||
constexpr static std::uint64_t kISSUED_CURRENCY = 0x8'000'000'000'000'000ull;
|
||||
constexpr static std::uint64_t kPOSITIVE = 0x4'000'000'000'000'000ull;
|
||||
constexpr static std::uint64_t kMP_TOKEN = 0x2'000'000'000'000'000ull;
|
||||
constexpr static std::uint64_t kVALUE_MASK = ~(kPOSITIVE | kMP_TOKEN);
|
||||
static constexpr std::uint64_t kMaxNativeN = 100'000'000'000'000'000ull;
|
||||
static constexpr std::uint64_t kIssuedCurrency = 0x8'000'000'000'000'000ull;
|
||||
static constexpr std::uint64_t kPositive = 0x4'000'000'000'000'000ull;
|
||||
static constexpr std::uint64_t kMpToken = 0x2'000'000'000'000'000ull;
|
||||
static constexpr std::uint64_t kValueMask = ~(kPositive | kMpToken);
|
||||
|
||||
static std::uint64_t const kU_RATE_ONE;
|
||||
static std::uint64_t const kURateOne;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
STAmount(SerialIter& sit, SField const& name);
|
||||
@@ -184,6 +186,23 @@ public:
|
||||
[[nodiscard]] STAmount const&
|
||||
value() const noexcept;
|
||||
|
||||
/**
|
||||
* Checks if this amount evaluates to zero when constrained to a specific
|
||||
* accounting scale.
|
||||
* For XRP and MPT `roundToScale` is a no-op, returns true only when the amount itself is zero.
|
||||
* The `scale` argument is ignored in that case.
|
||||
* For IOU, the amount is rounded to the given scale using Number::RoundingMode::ToNearest mode
|
||||
* and the result is checked for zero; if `scale <= exponent()`, `roundToScale` short-circuits
|
||||
* and returns the value unchanged, so this returns false for any non-zero amount.
|
||||
*
|
||||
* @param scale The target accounting scale to evaluate against.
|
||||
* @return `true` if this amount rounds to zero at the given scale, `false` otherwise.
|
||||
*
|
||||
* @see roundToScale
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
isZeroAtScale(int scale) const;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
// Operators
|
||||
@@ -241,7 +260,7 @@ public:
|
||||
[[nodiscard]] std::string
|
||||
getText() const override;
|
||||
|
||||
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::KNone) const override;
|
||||
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::Values::None) const override;
|
||||
|
||||
void
|
||||
add(Serializer& s) const override;
|
||||
@@ -356,7 +375,7 @@ STAmount::STAmount(A const& asset, int mantissa, int exponent)
|
||||
|
||||
// Legacy support for new-style amounts
|
||||
inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
|
||||
: asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZERO)
|
||||
: asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZero)
|
||||
{
|
||||
if (isNegative_)
|
||||
{
|
||||
@@ -371,7 +390,7 @@ inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
|
||||
}
|
||||
|
||||
inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue)
|
||||
: asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZERO)
|
||||
: asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZero)
|
||||
{
|
||||
if (isNegative_)
|
||||
{
|
||||
@@ -498,7 +517,7 @@ STAmount::zeroed() const
|
||||
inline STAmount::
|
||||
operator bool() const noexcept
|
||||
{
|
||||
return *this != beast::kZERO;
|
||||
return *this != beast::kZero;
|
||||
}
|
||||
|
||||
inline STAmount::
|
||||
@@ -540,7 +559,7 @@ STAmount::fromNumber(A const& a, Number const& number)
|
||||
return STAmount{asset, intValue, 0, negative};
|
||||
}
|
||||
|
||||
auto const [mantissa, exponent] = working.normalizeToRange(kMIN_VALUE, kMAX_VALUE);
|
||||
auto const [mantissa, exponent] = working.normalizeToRange<kMinValue, kMaxValue>();
|
||||
|
||||
return STAmount{asset, mantissa, exponent, negative};
|
||||
}
|
||||
@@ -548,7 +567,7 @@ STAmount::fromNumber(A const& a, Number const& number)
|
||||
inline void
|
||||
STAmount::negate()
|
||||
{
|
||||
if (*this != beast::kZERO)
|
||||
if (*this != beast::kZero)
|
||||
isNegative_ = !isNegative_;
|
||||
}
|
||||
|
||||
@@ -575,12 +594,25 @@ STAmount::value() const noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool
|
||||
[[nodiscard]] inline bool
|
||||
isLegalNet(STAmount const& value)
|
||||
{
|
||||
return !value.native() || (value.mantissa() <= STAmount::kMAX_NATIVE_N);
|
||||
return !value.native() || (value.mantissa() <= STAmount::kMaxNativeN);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool
|
||||
isLegalMPT(STAmount const& value)
|
||||
{
|
||||
return !value.holds<MPTIssue>() ||
|
||||
(!value.negative() && value.exponent() == 0 && value.mantissa() <= kMaxMpTokenAmount);
|
||||
}
|
||||
|
||||
/* Check recursively if an object has invalid MPTAmount or XRPAmount in STAmount field.
|
||||
* Calls isLegalNet() and isLegalMPT().
|
||||
*/
|
||||
[[nodiscard]] bool
|
||||
hasInvalidAmount(STBase const& field, beast::Journal j);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Operators
|
||||
|
||||
@@ -18,23 +18,23 @@ struct JsonOptions
|
||||
using underlying_t = unsigned int;
|
||||
underlying_t value;
|
||||
|
||||
// Bitwise flags with operator~
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum Values : underlying_t {
|
||||
// clang-format off
|
||||
KNone = 0b0000'0000,
|
||||
KIncludeDate = 0b0000'0001,
|
||||
KDisableApiPriorV2 = 0b0000'0010,
|
||||
enum class Values : underlying_t {
|
||||
None = 0b0000'0000,
|
||||
IncludeDate = 0b0000'0001,
|
||||
DisableApiPriorV2 = 0b0000'0010,
|
||||
|
||||
// IMPORTANT `kALL` must be union of all of the above; see also operator~
|
||||
KAll = 0b0000'0011
|
||||
// clang-format on
|
||||
// IMPORTANT `All` must be union of all of the above; see also operator~
|
||||
All = IncludeDate | DisableApiPriorV2 // 0b0000'0011
|
||||
};
|
||||
|
||||
constexpr JsonOptions(underlying_t v) noexcept : value(v)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr JsonOptions(Values v) noexcept : value(static_cast<JsonOptions::underlying_t>(v))
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr explicit
|
||||
operator underlying_t() const noexcept
|
||||
{
|
||||
@@ -65,22 +65,22 @@ struct JsonOptions
|
||||
}
|
||||
|
||||
/// Returns JsonOptions binary negation, can be used with & (above) for set
|
||||
/// difference e.g. `(options & ~JsonOptions::kINCLUDE_DATE)`
|
||||
/// difference e.g. `(options & ~JsonOptions::kIncludeDate)`
|
||||
[[nodiscard]] constexpr JsonOptions friend
|
||||
operator~(JsonOptions v) noexcept
|
||||
{
|
||||
return {~v.value & static_cast<underlying_t>(KAll)};
|
||||
return {~v.value & static_cast<underlying_t>(Values::All)};
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
requires requires(T const& t) {
|
||||
{ t.getJson(JsonOptions::KNone) } -> std::convertible_to<json::Value>;
|
||||
{ t.getJson(JsonOptions::Values::None) } -> std::convertible_to<json::Value>;
|
||||
}
|
||||
json::Value
|
||||
toJson(T const& t)
|
||||
{
|
||||
return t.getJson(JsonOptions::KNone);
|
||||
return t.getJson(JsonOptions::Values::None);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
[[nodiscard]] virtual std::string
|
||||
getText() const;
|
||||
|
||||
[[nodiscard]] virtual json::Value getJson(JsonOptions = JsonOptions::KNone) const;
|
||||
[[nodiscard]] virtual json::Value getJson(JsonOptions = JsonOptions::Values::None) const;
|
||||
|
||||
virtual void
|
||||
add(Serializer& s) const;
|
||||
|
||||
@@ -16,7 +16,7 @@ class STBitString final : public STBase, public CountedObject<STBitString<Bits>>
|
||||
static_assert(Bits > 0, "Number of bits must be positive");
|
||||
|
||||
public:
|
||||
using value_type = BaseUint<Bits>;
|
||||
using value_type = BaseUInt<Bits>;
|
||||
|
||||
private:
|
||||
value_type value_{};
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
template <typename Tag>
|
||||
void
|
||||
setValue(BaseUint<Bits, Tag> const& v);
|
||||
setValue(BaseUInt<Bits, Tag> const& v);
|
||||
|
||||
[[nodiscard]] value_type const&
|
||||
value() const;
|
||||
@@ -157,7 +157,7 @@ STBitString<Bits>::add(Serializer& s) const
|
||||
template <int Bits>
|
||||
template <typename Tag>
|
||||
void
|
||||
STBitString<Bits>::setValue(BaseUint<Bits, Tag> const& v)
|
||||
STBitString<Bits>::setValue(BaseUInt<Bits, Tag> const& v)
|
||||
{
|
||||
value_ = v;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ template <int Bits>
|
||||
bool
|
||||
STBitString<Bits>::isDefault() const
|
||||
{
|
||||
return value_ == beast::kZERO;
|
||||
return value_ == beast::kZero;
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
STBlob(SField const& f, void const* data, std::size_t size);
|
||||
STBlob(SField const& f, Buffer&& b);
|
||||
STBlob(SField const& n);
|
||||
STBlob(SerialIter&, SField const& name = kSF_GENERIC);
|
||||
STBlob(SerialIter&, SField const& name = sfGeneric);
|
||||
|
||||
[[nodiscard]] std::size_t
|
||||
size() const;
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
getText() const override;
|
||||
|
||||
[[nodiscard]] json::Value
|
||||
getJson(JsonOptions options = JsonOptions::KNone) const override;
|
||||
getJson(JsonOptions options = JsonOptions::Values::None) const override;
|
||||
|
||||
/** Returns the 'key' (or 'index') of this item.
|
||||
The key identifies this entry's position in
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
getText() const override;
|
||||
|
||||
// TODO(tom): options should be an enum.
|
||||
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::KNone) const override;
|
||||
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::Values::None) const override;
|
||||
|
||||
void
|
||||
addWithoutSigningFields(Serializer& s) const;
|
||||
@@ -381,7 +381,7 @@ public:
|
||||
|
||||
template <class Tag>
|
||||
void
|
||||
setFieldH160(SField const& field, BaseUint<160, Tag> const& v);
|
||||
setFieldH160(SField const& field, BaseUInt<160, Tag> const& v);
|
||||
|
||||
STObject&
|
||||
peekFieldObject(SField const& field);
|
||||
@@ -1143,7 +1143,7 @@ STObject::at(OptionaledField<T> const& of) -> OptionalProxy<T>
|
||||
|
||||
template <class Tag>
|
||||
void
|
||||
STObject::setFieldH160(SField const& field, BaseUint<160, Tag> const& v)
|
||||
STObject::setFieldH160(SField const& field, BaseUInt<160, Tag> const& v)
|
||||
{
|
||||
STBase* rf = getPField(field, true);
|
||||
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Maximum JSON object nesting depth permitted during parsing. */
|
||||
inline constexpr std::size_t kMaxParsedJsonDepth = 64;
|
||||
|
||||
/** Maximum number of elements permitted in any JSON array field during parsing.
|
||||
Requests exceeding this limit are rejected with an invalidParams error. */
|
||||
inline constexpr std::size_t kMaxParsedJsonArraySize = 512;
|
||||
|
||||
/** Holds the serialized result of parsing an input JSON object.
|
||||
This does validation and checking on the provided JSON.
|
||||
*/
|
||||
|
||||
@@ -21,8 +21,8 @@ class STPathElement final : public CountedObject<STPathElement>
|
||||
PathAsset assetID_;
|
||||
AccountID issuerID_;
|
||||
|
||||
bool is_offer_;
|
||||
std::size_t hash_value_;
|
||||
bool isOffer_;
|
||||
std::size_t hashValue_;
|
||||
|
||||
public:
|
||||
// Bitwise values (typeCurrency | typeMPT)
|
||||
@@ -235,9 +235,9 @@ private:
|
||||
|
||||
// ------------ STPathElement ------------
|
||||
|
||||
inline STPathElement::STPathElement() : type_(TypeNone), is_offer_(true)
|
||||
inline STPathElement::STPathElement() : type_(TypeNone), isOffer_(true)
|
||||
{
|
||||
hash_value_ = getHash(*this);
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
inline STPathElement::STPathElement(
|
||||
@@ -248,11 +248,11 @@ inline STPathElement::STPathElement(
|
||||
{
|
||||
if (!account)
|
||||
{
|
||||
is_offer_ = true;
|
||||
isOffer_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_offer_ = false;
|
||||
isOffer_ = false;
|
||||
accountID_ = *account;
|
||||
type_ |= TypeAccount;
|
||||
XRPL_ASSERT(
|
||||
@@ -272,7 +272,7 @@ inline STPathElement::STPathElement(
|
||||
XRPL_ASSERT(issuerID_ != noAccount(), "xrpl::STPathElement::STPathElement : issuer is set");
|
||||
}
|
||||
|
||||
hash_value_ = getHash(*this);
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
inline STPathElement::STPathElement(
|
||||
@@ -284,9 +284,9 @@ inline STPathElement::STPathElement(
|
||||
, accountID_(account)
|
||||
, assetID_(asset)
|
||||
, issuerID_(issuer)
|
||||
, is_offer_(isXRP(accountID_))
|
||||
, isOffer_(isXRP(accountID_))
|
||||
{
|
||||
if (!is_offer_)
|
||||
if (!isOffer_)
|
||||
type_ |= TypeAccount;
|
||||
|
||||
if (forceAsset || !isXRP(assetID_))
|
||||
@@ -295,7 +295,7 @@ inline STPathElement::STPathElement(
|
||||
if (!isXRP(issuer))
|
||||
type_ |= TypeIssuer;
|
||||
|
||||
hash_value_ = getHash(*this);
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
inline STPathElement::STPathElement(
|
||||
@@ -307,12 +307,12 @@ inline STPathElement::STPathElement(
|
||||
, accountID_(account)
|
||||
, assetID_(asset)
|
||||
, issuerID_(issuer)
|
||||
, is_offer_(isXRP(accountID_))
|
||||
, isOffer_(isXRP(accountID_))
|
||||
{
|
||||
assetID_.visit(
|
||||
[&](Currency const&) { type_ = type_ & (~Type::TypeMpt); },
|
||||
[&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); });
|
||||
hash_value_ = getHash(*this);
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
inline auto
|
||||
@@ -324,7 +324,7 @@ STPathElement::getNodeType() const
|
||||
inline bool
|
||||
STPathElement::isOffer() const
|
||||
{
|
||||
return is_offer_;
|
||||
return isOffer_;
|
||||
}
|
||||
|
||||
inline bool
|
||||
@@ -404,7 +404,7 @@ STPathElement::getIssuerID() const
|
||||
inline bool
|
||||
STPathElement::operator==(STPathElement const& t) const
|
||||
{
|
||||
return (type_ & TypeAccount) == (t.type_ & TypeAccount) && hash_value_ == t.hash_value_ &&
|
||||
return (type_ & TypeAccount) == (t.type_ & TypeAccount) && hashValue_ == t.hashValue_ &&
|
||||
accountID_ == t.accountID_ && assetID_ == t.assetID_ && issuerID_ == t.issuerID_;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ enum class TxnSql : char {
|
||||
class STTx final : public STObject, public CountedObject<STTx>
|
||||
{
|
||||
uint256 tid_;
|
||||
TxType tx_type_;
|
||||
TxType txType_;
|
||||
|
||||
public:
|
||||
static constexpr std::size_t kMIN_MULTI_SIGNERS = 1;
|
||||
static constexpr std::size_t kMAX_MULTI_SIGNERS = 32;
|
||||
static constexpr std::size_t kMinMultiSigners = 1;
|
||||
static constexpr std::size_t kMaxMultiSigners = 32;
|
||||
|
||||
STTx() = delete;
|
||||
STTx(STTx const& other) = default;
|
||||
@@ -187,7 +187,7 @@ inline STTx::STTx(SerialIter&& sit) // NOLINT(cppcoreguidelines-rvalue-referenc
|
||||
inline TxType
|
||||
STTx::getTxnType() const
|
||||
{
|
||||
return tx_type_;
|
||||
return txType_;
|
||||
}
|
||||
|
||||
inline Blob
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace xrpl {
|
||||
// Validation flags
|
||||
|
||||
// This is a full (as opposed to a partial) validation
|
||||
constexpr std::uint32_t kVF_FULL_VALIDATION = 0x00000001;
|
||||
constexpr std::uint32_t kVfFullValidation = 0x00000001;
|
||||
|
||||
// The signature is fully canonical
|
||||
constexpr std::uint32_t kVF_FULLY_CANONICAL_SIG = 0x80000000;
|
||||
constexpr std::uint32_t kVfFullyCanonicalSig = 0x80000000;
|
||||
|
||||
class STValidation final : public STObject, public CountedObject<STValidation>
|
||||
{
|
||||
@@ -161,7 +161,7 @@ STValidation::STValidation(SerialIter& sit, LookupNodeID&& lookupNodeID, bool ch
|
||||
if (checkSignature && !isValid())
|
||||
{
|
||||
JLOG(debugLog().error()) << "Invalid signature in validation: "
|
||||
<< getJson(JsonOptions::KNone);
|
||||
<< getJson(JsonOptions::Values::None);
|
||||
Throw<std::runtime_error>("Invalid signature in validation");
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ STValidation::STValidation(
|
||||
f(*this);
|
||||
|
||||
// Finally, sign the validation and mark it as trusted:
|
||||
setFlag(kVF_FULLY_CANONICAL_SIG);
|
||||
setFlag(kVfFullyCanonicalSig);
|
||||
setFieldVL(sfSignature, signDigest(pk, sk, getSigningHash()));
|
||||
setTrusted();
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace xrpl {
|
||||
class SecretKey
|
||||
{
|
||||
public:
|
||||
static constexpr std::size_t kSIZE = 32;
|
||||
static constexpr std::size_t kSize = 32;
|
||||
|
||||
private:
|
||||
std::uint8_t buf_[kSIZE]{};
|
||||
std::uint8_t buf_[kSize]{};
|
||||
|
||||
public:
|
||||
using const_iterator = std::uint8_t const*;
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
~SecretKey();
|
||||
|
||||
SecretKey(std::array<std::uint8_t, kSIZE> const& data);
|
||||
SecretKey(std::array<std::uint8_t, kSize> const& data);
|
||||
SecretKey(Slice const& slice);
|
||||
|
||||
[[nodiscard]] std::uint8_t const*
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
template <std::size_t Bits, class Tag>
|
||||
int
|
||||
addBitString(BaseUint<Bits, Tag> const& v)
|
||||
addBitString(BaseUInt<Bits, Tag> const& v)
|
||||
{
|
||||
return addRaw(v.data(), v.size());
|
||||
}
|
||||
@@ -134,13 +134,13 @@ public:
|
||||
bool
|
||||
getInteger(Integer& number, int offset)
|
||||
{
|
||||
static auto const kBYTES = sizeof(Integer);
|
||||
if ((offset + kBYTES) > data_.size())
|
||||
static auto const kBytes = sizeof(Integer);
|
||||
if ((offset + kBytes) > data_.size())
|
||||
return false;
|
||||
number = 0;
|
||||
|
||||
auto ptr = &data_[offset];
|
||||
for (auto i = 0; i < kBYTES; ++i)
|
||||
for (auto i = 0; i < kBytes; ++i)
|
||||
{
|
||||
if (i)
|
||||
number <<= 8;
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
template <std::size_t Bits, typename Tag = void>
|
||||
bool
|
||||
getBitString(BaseUint<Bits, Tag>& data, int offset) const
|
||||
getBitString(BaseUInt<Bits, Tag>& data, int offset) const
|
||||
{
|
||||
auto success = (offset + (Bits / 8)) <= data_.size();
|
||||
if (success)
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
geti64();
|
||||
|
||||
template <std::size_t Bits, class Tag = void>
|
||||
BaseUint<Bits, Tag>
|
||||
BaseUInt<Bits, Tag>
|
||||
getBitString();
|
||||
|
||||
uint128
|
||||
@@ -428,7 +428,7 @@ public:
|
||||
};
|
||||
|
||||
template <std::size_t Bits, class Tag>
|
||||
BaseUint<Bits, Tag>
|
||||
BaseUInt<Bits, Tag>
|
||||
SerialIter::getBitString()
|
||||
{
|
||||
auto const n = Bits / 8;
|
||||
@@ -442,7 +442,7 @@ SerialIter::getBitString()
|
||||
used_ += n;
|
||||
remain_ -= n;
|
||||
|
||||
return BaseUint<Bits, Tag>::fromVoid(x);
|
||||
return BaseUInt<Bits, Tag>::fromVoid(x);
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -14,22 +14,22 @@ namespace xrpl {
|
||||
static inline std::string const&
|
||||
systemName()
|
||||
{
|
||||
static std::string const kNAME = "xrpld";
|
||||
return kNAME;
|
||||
static std::string const kName = "xrpld";
|
||||
return kName;
|
||||
}
|
||||
|
||||
/** Configure the native currency. */
|
||||
|
||||
/** Number of drops in the genesis account. */
|
||||
constexpr XRPAmount kINITIAL_XRP{100'000'000'000 * kDROPS_PER_XRP};
|
||||
static_assert(kINITIAL_XRP.drops() == 100'000'000'000'000'000);
|
||||
static_assert(Number::kMAX_REP >= kINITIAL_XRP.drops());
|
||||
constexpr XRPAmount kInitialXrp{100'000'000'000 * kDropsPerXrp};
|
||||
static_assert(kInitialXrp.drops() == 100'000'000'000'000'000);
|
||||
static_assert(Number::kMaxRep >= kInitialXrp.drops());
|
||||
|
||||
/** Returns true if the amount does not exceed the initial XRP in existence. */
|
||||
inline bool
|
||||
isLegalAmount(XRPAmount const& amount)
|
||||
{
|
||||
return amount <= kINITIAL_XRP;
|
||||
return amount <= kInitialXrp;
|
||||
}
|
||||
|
||||
/** Returns true if the absolute value of the amount does not exceed the initial
|
||||
@@ -37,31 +37,31 @@ isLegalAmount(XRPAmount const& amount)
|
||||
inline bool
|
||||
isLegalAmountSigned(XRPAmount const& amount)
|
||||
{
|
||||
return amount >= -kINITIAL_XRP && amount <= kINITIAL_XRP;
|
||||
return amount >= -kInitialXrp && amount <= kInitialXrp;
|
||||
}
|
||||
|
||||
/* The currency code for the native currency. */
|
||||
static inline std::string const&
|
||||
systemCurrencyCode()
|
||||
{
|
||||
static std::string const kCODE = "XRP";
|
||||
return kCODE;
|
||||
static std::string const kCode = "XRP";
|
||||
return kCode;
|
||||
}
|
||||
|
||||
/** The XRP ledger network's earliest allowed sequence */
|
||||
static constexpr std::uint32_t kXRP_LEDGER_EARLIEST_SEQ{32570u};
|
||||
static constexpr std::uint32_t kXrpLedgerEarliestSeq{32570u};
|
||||
|
||||
/** The XRP Ledger mainnet's earliest ledger with a FeeSettings object. Only
|
||||
* used in asserts and tests. */
|
||||
static constexpr std::uint32_t kXRP_LEDGER_EARLIEST_FEES{562177u};
|
||||
static constexpr std::uint32_t kXrpLedgerEarliestFees{562177u};
|
||||
|
||||
/** The minimum amount of support an amendment should have. */
|
||||
constexpr std::ratio<80, 100> kAMENDMENT_MAJORITY_CALC_THRESHOLD;
|
||||
constexpr std::ratio<80, 100> kAmendmentMajorityCalcThreshold;
|
||||
|
||||
/** The minimum amount of time an amendment must hold a majority */
|
||||
constexpr std::chrono::seconds const kDEFAULT_AMENDMENT_MAJORITY_TIME = weeks{2};
|
||||
constexpr std::chrono::seconds const kDefaultAmendmentMajorityTime = weeks{2};
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
/** Default peer port (IANA registered) */
|
||||
inline std::uint16_t constexpr kDEFAULT_PEER_PORT{2459};
|
||||
inline constexpr std::uint16_t kDefaultPeerPort{2459};
|
||||
|
||||
@@ -30,21 +30,21 @@ public:
|
||||
|
||||
/** Directory is an index into the directory of offer books.
|
||||
The last 64 bits of this are the quality. */
|
||||
using Directory = BaseUint<256, detail::DirectoryTag>;
|
||||
using Directory = BaseUInt<256, detail::DirectoryTag>;
|
||||
|
||||
/** Currency is a hash representing a specific currency. */
|
||||
using Currency = BaseUint<160, detail::CurrencyTag>;
|
||||
using Currency = BaseUInt<160, detail::CurrencyTag>;
|
||||
|
||||
/** NodeID is a 160-bit hash representing one node. */
|
||||
using NodeID = BaseUint<160, detail::NodeIDTag>;
|
||||
using NodeID = BaseUInt<160, detail::NodeIDTag>;
|
||||
|
||||
/** MPTID is a 192-bit value representing MPT Issuance ID,
|
||||
* which is a concatenation of a 32-bit sequence (big endian)
|
||||
* and a 160-bit account */
|
||||
using MPTID = BaseUint<192>;
|
||||
using MPTID = BaseUInt<192>;
|
||||
|
||||
/** Domain is a 256-bit hash representing a specific domain. */
|
||||
using Domain = BaseUint<256>;
|
||||
using Domain = BaseUInt<256>;
|
||||
|
||||
/** XRP currency. */
|
||||
Currency const&
|
||||
@@ -62,7 +62,7 @@ badCurrency();
|
||||
inline bool
|
||||
isXRP(Currency const& c)
|
||||
{
|
||||
return c == beast::kZERO;
|
||||
return c == beast::kZero;
|
||||
}
|
||||
|
||||
/** Returns "", "XRP", or three letter ISO code. */
|
||||
|
||||
@@ -300,13 +300,13 @@ public:
|
||||
using jsontype =
|
||||
std::conditional_t<std::is_signed_v<value_type>, json::Int, json::UInt>;
|
||||
|
||||
constexpr auto kMIN = std::numeric_limits<jsontype>::min();
|
||||
constexpr auto kMAX = std::numeric_limits<jsontype>::max();
|
||||
constexpr auto kMin = std::numeric_limits<jsontype>::min();
|
||||
constexpr auto kMax = std::numeric_limits<jsontype>::max();
|
||||
|
||||
if (value_ < kMIN)
|
||||
return kMIN;
|
||||
if (value_ > kMAX)
|
||||
return kMAX;
|
||||
if (value_ < kMin)
|
||||
return kMin;
|
||||
if (value_ > kMax)
|
||||
return kMax;
|
||||
return static_cast<jsontype>(value_);
|
||||
}
|
||||
else
|
||||
@@ -392,14 +392,14 @@ mulDivU(Source1 value, Dest mul, Source2 div)
|
||||
}
|
||||
|
||||
using desttype = typename Dest::value_type;
|
||||
constexpr auto kMAX = std::numeric_limits<desttype>::max();
|
||||
constexpr auto kMax = std::numeric_limits<desttype>::max();
|
||||
|
||||
// Shortcuts, since these happen a lot in the real world
|
||||
if (value == div)
|
||||
return mul;
|
||||
if (mul.value() == div.value())
|
||||
{
|
||||
if (value.value() > kMAX)
|
||||
if (value.value() > kMax)
|
||||
return std::nullopt;
|
||||
return Dest{static_cast<desttype>(value.value())};
|
||||
}
|
||||
@@ -414,7 +414,7 @@ mulDivU(Source1 value, Dest mul, Source2 div)
|
||||
|
||||
auto quotient = product / div.value();
|
||||
|
||||
if (quotient > kMAX)
|
||||
if (quotient > kMax)
|
||||
return std::nullopt;
|
||||
|
||||
return Dest{static_cast<desttype>(quotient)};
|
||||
|
||||
@@ -357,7 +357,7 @@ private:
|
||||
// Set a max number of allowed attestations to limit the amount of memory
|
||||
// allocated and processing time. This number is much larger than the actual
|
||||
// number of attestation a server would ever expect.
|
||||
static constexpr std::uint32_t kMAX_ATTESTATIONS = 256;
|
||||
static constexpr std::uint32_t kMaxAttestations = 256;
|
||||
AttCollection attestations_;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -202,13 +202,13 @@ public:
|
||||
std::is_signed_v<value_type> && std::is_integral_v<value_type>,
|
||||
"Expected XRPAmount to be a signed integral type");
|
||||
|
||||
constexpr auto kMIN = std::numeric_limits<json::Int>::min();
|
||||
constexpr auto kMAX = std::numeric_limits<json::Int>::max();
|
||||
constexpr auto kMin = std::numeric_limits<json::Int>::min();
|
||||
constexpr auto kMax = std::numeric_limits<json::Int>::max();
|
||||
|
||||
if (drops_ < kMIN)
|
||||
return kMIN;
|
||||
if (drops_ > kMAX)
|
||||
return kMAX;
|
||||
if (drops_ < kMin)
|
||||
return kMin;
|
||||
if (drops_ > kMax)
|
||||
return kMax;
|
||||
return static_cast<json::Int>(drops_);
|
||||
}
|
||||
|
||||
@@ -237,12 +237,12 @@ public:
|
||||
};
|
||||
|
||||
/** Number of drops per 1 XRP */
|
||||
constexpr XRPAmount kDROPS_PER_XRP{1'000'000};
|
||||
constexpr XRPAmount kDropsPerXrp{1'000'000};
|
||||
|
||||
constexpr double
|
||||
XRPAmount::decimalXRP() const
|
||||
{
|
||||
return static_cast<double>(drops_) / kDROPS_PER_XRP.drops();
|
||||
return static_cast<double>(drops_) / kDropsPerXrp.drops();
|
||||
}
|
||||
|
||||
// Output XRPAmount as just the drops value.
|
||||
|
||||
@@ -35,9 +35,9 @@ class STVar
|
||||
{
|
||||
private:
|
||||
// The largest "small object" we can accommodate
|
||||
static std::size_t constexpr kMAX_SIZE = 72;
|
||||
static constexpr std::size_t kMaxSize = 72;
|
||||
|
||||
std::aligned_storage<kMAX_SIZE>::type d_ = {};
|
||||
std::aligned_storage<kMaxSize>::type d_ = {};
|
||||
STBase* p_ = nullptr;
|
||||
|
||||
public:
|
||||
@@ -51,12 +51,12 @@ public:
|
||||
|
||||
STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
{
|
||||
p_ = t.move(kMAX_SIZE, &d_);
|
||||
p_ = t.move(kMaxSize, &d_);
|
||||
}
|
||||
|
||||
STVar(STBase const& t)
|
||||
{
|
||||
p_ = t.copy(kMAX_SIZE, &d_);
|
||||
p_ = t.copy(kMaxSize, &d_);
|
||||
}
|
||||
|
||||
STVar(DefaultObjectT, SField const& name);
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
void
|
||||
construct(Args&&... args)
|
||||
{
|
||||
if constexpr (sizeof(T) > kMAX_SIZE)
|
||||
if constexpr (sizeof(T) > kMaxSize)
|
||||
{
|
||||
p_ = new T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -155,16 +155,16 @@ inplaceBigintDivRem(std::span<uint64_t> numerator, std::uint64_t divisor)
|
||||
[[nodiscard]] inline std::array<std::uint8_t, 10>
|
||||
b5810ToB58Be(std::uint64_t input)
|
||||
{
|
||||
[[maybe_unused]] static constexpr std::uint64_t kB_58_10 = 430804206899405824; // 58^10;
|
||||
XRPL_ASSERT(input < kB_58_10, "xrpl::b58_fast::detail::b5810ToB58Be : valid input");
|
||||
constexpr std::size_t kRESULT_SIZE = 10;
|
||||
std::array<std::uint8_t, kRESULT_SIZE> result{};
|
||||
[[maybe_unused]] static constexpr std::uint64_t kB5810 = 430804206899405824; // 58^10;
|
||||
XRPL_ASSERT(input < kB5810, "xrpl::b58_fast::detail::b5810ToB58Be : valid input");
|
||||
static constexpr std::size_t kResultSize = 10;
|
||||
std::array<std::uint8_t, kResultSize> result{};
|
||||
int i = 0;
|
||||
while (input > 0)
|
||||
{
|
||||
std::uint64_t rem = 0;
|
||||
std::tie(input, rem) = divRem(input, 58);
|
||||
result[kRESULT_SIZE - 1 - i] = rem;
|
||||
result[kResultSize - 1 - i] = rem;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
// Keep it sorted in reverse chronological order.
|
||||
|
||||
XRPL_FEATURE(ConfidentialTransfer, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_2_0, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV2, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Security3_1_3, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PermissionedDomainInvariant, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (BatchInnerSigs, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_2_0, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV2, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_1_3, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (BatchInnerSigs, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(LendingProtocol, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionDelegationV1_1, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (DirectoryLimit, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
@@ -35,7 +34,7 @@ XRPL_FIX (EnforceNFTokenTrustlineV2, Supported::Yes, VoteBehavior::DefaultN
|
||||
XRPL_FIX (AMMv1_3, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionedDEX, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Batch, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(SingleAssetVault, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(SingleAssetVault, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PayChanCancelAfter, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
// Check flags in Credential transactions
|
||||
XRPL_FIX (InvalidTxFlags, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
@@ -47,9 +46,6 @@ XRPL_FEATURE(Credentials, Supported::Yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(AMMClawback, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_2, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV1, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
// InvariantsV1_1 will be changes to Supported::yes when all the
|
||||
// invariants expected to be included under it are complete.
|
||||
XRPL_FEATURE(InvariantsV1_1, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (NFTokenPageLinks, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (InnerObjTemplate2, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EnforceNFTokenTrustline, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
|
||||
@@ -84,7 +84,7 @@ LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, nunl, ({
|
||||
|
||||
/** A ledger object which contains a list of NFTs
|
||||
|
||||
\sa keylet::nftpage_min, keylet::nftpage_max, keylet::nftpage
|
||||
\sa keylet::nftpageMin, keylet::nftpageMax, keylet::nftpage
|
||||
*/
|
||||
LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({
|
||||
{sfPreviousPageMin, SoeOptional},
|
||||
@@ -112,7 +112,7 @@ LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({
|
||||
|
||||
/** A ledger object which describes a ticket.
|
||||
|
||||
\sa keylet::ticket
|
||||
\sa keylet::kTicket
|
||||
*/
|
||||
LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({
|
||||
{sfAccount, SoeRequired},
|
||||
@@ -405,10 +405,11 @@ LEDGER_ENTRY(
|
||||
{sfPreviousTxnLgrSeq, SoeRequired},
|
||||
{sfDomainID, SoeOptional},
|
||||
{sfMutableFlags, SoeDefault},
|
||||
{sfReferenceHolding, SoeOptional},
|
||||
{sfIssuerEncryptionKey, SoeOptional},
|
||||
{sfAuditorEncryptionKey, SoeOptional},
|
||||
{sfConfidentialOutstandingAmount, SoeDefault},
|
||||
}))
|
||||
}))
|
||||
|
||||
/** A ledger object which tracks MPToken
|
||||
\sa keylet::mptoken
|
||||
@@ -605,7 +606,7 @@ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({
|
||||
// LoanBroker.ManagementFeeRate
|
||||
// The unrounded true total fee still owed to the broker.
|
||||
//
|
||||
// Note the the "True" values may differ significantly from the tracked
|
||||
// Note the "True" values may differ significantly from the tracked
|
||||
// rounded values.
|
||||
{sfPaymentRemaining, SoeDefault},
|
||||
{sfPeriodicPayment, SoeRequired},
|
||||
|
||||
@@ -27,7 +27,7 @@ TYPED_SFIELD(sfWasLockingChainSend, UINT8, 19)
|
||||
TYPED_SFIELD(sfWithdrawalPolicy, UINT8, 20)
|
||||
|
||||
// 16-bit integers (common)
|
||||
TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::SMdNever)
|
||||
TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::kSmdNever)
|
||||
TYPED_SFIELD(sfTransactionType, UINT16, 2)
|
||||
TYPED_SFIELD(sfSignerWeight, UINT16, 3)
|
||||
TYPED_SFIELD(sfTransferFee, UINT16, 4)
|
||||
@@ -48,7 +48,7 @@ TYPED_SFIELD(sfNetworkID, UINT32, 1)
|
||||
TYPED_SFIELD(sfFlags, UINT32, 2)
|
||||
TYPED_SFIELD(sfSourceTag, UINT32, 3)
|
||||
TYPED_SFIELD(sfSequence, UINT32, 4)
|
||||
TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::SMdDeleteFinal)
|
||||
TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::kSmdDeleteFinal)
|
||||
TYPED_SFIELD(sfLedgerSequence, UINT32, 6)
|
||||
TYPED_SFIELD(sfCloseTime, UINT32, 7)
|
||||
TYPED_SFIELD(sfParentCloseTime, UINT32, 8)
|
||||
@@ -139,15 +139,15 @@ TYPED_SFIELD(sfXChainClaimID, UINT64, 20)
|
||||
TYPED_SFIELD(sfXChainAccountCreateCount, UINT64, 21)
|
||||
TYPED_SFIELD(sfXChainAccountClaimCount, UINT64, 22)
|
||||
TYPED_SFIELD(sfAssetPrice, UINT64, 23)
|
||||
TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::SMdBaseTen|SField::SMdDefault)
|
||||
TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::SMdBaseTen|SField::SMdDefault)
|
||||
TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::SMdBaseTen|SField::SMdDefault)
|
||||
TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfIssuerNode, UINT64, 27)
|
||||
TYPED_SFIELD(sfSubjectNode, UINT64, 28)
|
||||
TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::SMdBaseTen|SField::SMdDefault)
|
||||
TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfVaultNode, UINT64, 30)
|
||||
TYPED_SFIELD(sfLoanBrokerNode, UINT64, 31)
|
||||
TYPED_SFIELD(sfConfidentialOutstandingAmount, UINT64, 32, SField::SMdBaseTen|SField::SMdDefault)
|
||||
TYPED_SFIELD(sfConfidentialOutstandingAmount, UINT64, 32, SField::kSmdBaseTen|SField::kSmdDefault)
|
||||
|
||||
// 128-bit
|
||||
TYPED_SFIELD(sfEmailHash, UINT128, 1)
|
||||
@@ -169,17 +169,17 @@ TYPED_SFIELD(sfLedgerHash, UINT256, 1)
|
||||
TYPED_SFIELD(sfParentHash, UINT256, 2)
|
||||
TYPED_SFIELD(sfTransactionHash, UINT256, 3)
|
||||
TYPED_SFIELD(sfAccountHash, UINT256, 4)
|
||||
TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::SMdDeleteFinal)
|
||||
TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::kSmdDeleteFinal)
|
||||
TYPED_SFIELD(sfLedgerIndex, UINT256, 6)
|
||||
TYPED_SFIELD(sfWalletLocator, UINT256, 7)
|
||||
TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::SMdAlways)
|
||||
TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::kSmdAlways)
|
||||
TYPED_SFIELD(sfAccountTxnID, UINT256, 9)
|
||||
TYPED_SFIELD(sfNFTokenID, UINT256, 10)
|
||||
TYPED_SFIELD(sfEmitParentTxnID, UINT256, 11)
|
||||
TYPED_SFIELD(sfEmitNonce, UINT256, 12)
|
||||
TYPED_SFIELD(sfEmitHookHash, UINT256, 13)
|
||||
TYPED_SFIELD(sfAMMID, UINT256, 14,
|
||||
SField::SMdPseudoAccount | SField::SMdDefault)
|
||||
SField::kSmdPseudoAccount | SField::kSmdDefault)
|
||||
|
||||
// 256-bit (uncommon)
|
||||
TYPED_SFIELD(sfBookDirectory, UINT256, 16)
|
||||
@@ -202,31 +202,32 @@ TYPED_SFIELD(sfHookNamespace, UINT256, 32)
|
||||
TYPED_SFIELD(sfHookSetTxnID, UINT256, 33)
|
||||
TYPED_SFIELD(sfDomainID, UINT256, 34)
|
||||
TYPED_SFIELD(sfVaultID, UINT256, 35,
|
||||
SField::SMdPseudoAccount | SField::SMdDefault)
|
||||
SField::kSmdPseudoAccount | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfParentBatchID, UINT256, 36)
|
||||
TYPED_SFIELD(sfLoanBrokerID, UINT256, 37,
|
||||
SField::SMdPseudoAccount | SField::SMdDefault)
|
||||
SField::kSmdPseudoAccount | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfLoanID, UINT256, 38)
|
||||
TYPED_SFIELD(sfBlindingFactor, UINT256, 39)
|
||||
TYPED_SFIELD(sfReferenceHolding, UINT256, 39)
|
||||
TYPED_SFIELD(sfBlindingFactor, UINT256, 40)
|
||||
|
||||
// number (common)
|
||||
TYPED_SFIELD(sfNumber, NUMBER, 1)
|
||||
TYPED_SFIELD(sfAssetsAvailable, NUMBER, 2, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfAssetsMaximum, NUMBER, 3, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfAssetsTotal, NUMBER, 4, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfLossUnrealized, NUMBER, 5, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfDebtTotal, NUMBER, 6, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfDebtMaximum, NUMBER, 7, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfCoverAvailable, NUMBER, 8, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfAssetsAvailable, NUMBER, 2, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfAssetsMaximum, NUMBER, 3, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfAssetsTotal, NUMBER, 4, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfLossUnrealized, NUMBER, 5, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfDebtTotal, NUMBER, 6, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfDebtMaximum, NUMBER, 7, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfCoverAvailable, NUMBER, 8, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfLoanOriginationFee, NUMBER, 9)
|
||||
TYPED_SFIELD(sfLoanServiceFee, NUMBER, 10)
|
||||
TYPED_SFIELD(sfLatePaymentFee, NUMBER, 11)
|
||||
TYPED_SFIELD(sfClosePaymentFee, NUMBER, 12)
|
||||
TYPED_SFIELD(sfPrincipalOutstanding, NUMBER, 13, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfPrincipalOutstanding, NUMBER, 13, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfPrincipalRequested, NUMBER, 14)
|
||||
TYPED_SFIELD(sfTotalValueOutstanding, NUMBER, 15, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfTotalValueOutstanding, NUMBER, 15, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
TYPED_SFIELD(sfPeriodicPayment, NUMBER, 16)
|
||||
TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::SMdNeedsAsset | SField::SMdDefault)
|
||||
TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::kSmdNeedsAsset | SField::kSmdDefault)
|
||||
|
||||
// int32
|
||||
TYPED_SFIELD(sfLoanScale, INT32, 1)
|
||||
@@ -272,9 +273,9 @@ TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31)
|
||||
TYPED_SFIELD(sfPublicKey, VL, 1)
|
||||
TYPED_SFIELD(sfMessageKey, VL, 2)
|
||||
TYPED_SFIELD(sfSigningPubKey, VL, 3)
|
||||
TYPED_SFIELD(sfTxnSignature, VL, 4, SField::SMdDefault, SField::kNOT_SIGNING)
|
||||
TYPED_SFIELD(sfTxnSignature, VL, 4, SField::kSmdDefault, SField::kNotSigning)
|
||||
TYPED_SFIELD(sfURI, VL, 5)
|
||||
TYPED_SFIELD(sfSignature, VL, 6, SField::SMdDefault, SField::kNOT_SIGNING)
|
||||
TYPED_SFIELD(sfSignature, VL, 6, SField::kSmdDefault, SField::kNotSigning)
|
||||
TYPED_SFIELD(sfDomain, VL, 7)
|
||||
TYPED_SFIELD(sfFundCode, VL, 8)
|
||||
TYPED_SFIELD(sfRemoveCode, VL, 9)
|
||||
@@ -287,7 +288,7 @@ TYPED_SFIELD(sfMemoFormat, VL, 14)
|
||||
// variable length (uncommon)
|
||||
TYPED_SFIELD(sfFulfillment, VL, 16)
|
||||
TYPED_SFIELD(sfCondition, VL, 17)
|
||||
TYPED_SFIELD(sfMasterSignature, VL, 18, SField::SMdDefault, SField::kNOT_SIGNING)
|
||||
TYPED_SFIELD(sfMasterSignature, VL, 18, SField::kSmdDefault, SField::kNotSigning)
|
||||
TYPED_SFIELD(sfUNLModifyValidator, VL, 19)
|
||||
TYPED_SFIELD(sfValidatorToDisable, VL, 20)
|
||||
TYPED_SFIELD(sfValidatorToReEnable, VL, 21)
|
||||
@@ -344,7 +345,7 @@ TYPED_SFIELD(sfBorrower, ACCOUNT, 25)
|
||||
TYPED_SFIELD(sfCounterparty, ACCOUNT, 26)
|
||||
|
||||
// vector of 256-bit
|
||||
TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::SMdNever)
|
||||
TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::kSmdNever)
|
||||
TYPED_SFIELD(sfHashes, VECTOR256, 2)
|
||||
TYPED_SFIELD(sfAmendments, VECTOR256, 3)
|
||||
TYPED_SFIELD(sfNFTokenOffers, VECTOR256, 4)
|
||||
@@ -405,13 +406,13 @@ UNTYPED_SFIELD(sfCredential, OBJECT, 33)
|
||||
UNTYPED_SFIELD(sfRawTransaction, OBJECT, 34)
|
||||
UNTYPED_SFIELD(sfBatchSigner, OBJECT, 35)
|
||||
UNTYPED_SFIELD(sfBook, OBJECT, 36)
|
||||
UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::SMdDefault, SField::kNOT_SIGNING)
|
||||
UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::kSmdDefault, SField::kNotSigning)
|
||||
|
||||
// array of objects (common)
|
||||
// ARRAY/1 is reserved for end of array
|
||||
// sfSigningAccounts has never been used.
|
||||
//UNTYPED_SFIELD(sfSigningAccounts, ARRAY, 2)
|
||||
UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::SMdDefault, SField::kNOT_SIGNING)
|
||||
UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::kSmdDefault, SField::kNotSigning)
|
||||
UNTYPED_SFIELD(sfSignerEntries, ARRAY, 4)
|
||||
UNTYPED_SFIELD(sfTemplate, ARRAY, 5)
|
||||
UNTYPED_SFIELD(sfNecessary, ARRAY, 6)
|
||||
@@ -439,4 +440,4 @@ UNTYPED_SFIELD(sfUnauthorizeCredentials, ARRAY, 27)
|
||||
UNTYPED_SFIELD(sfAcceptedCredentials, ARRAY, 28)
|
||||
UNTYPED_SFIELD(sfPermissions, ARRAY, 29)
|
||||
UNTYPED_SFIELD(sfRawTransactions, ARRAY, 30)
|
||||
UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::SMdDefault, SField::kNOT_SIGNING)
|
||||
UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::kSmdDefault, SField::kNotSigning)
|
||||
|
||||
@@ -688,6 +688,7 @@ TRANSACTION(ttLEDGER_STATE_FIX, 53, LedgerStateFix,
|
||||
({
|
||||
{sfLedgerFixType, SoeRequired},
|
||||
{sfOwner, SoeOptional},
|
||||
{sfBookDirectory, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction type creates a MPTokensIssuance instance */
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace xrpl {
|
||||
struct OpensslRipemd160Hasher
|
||||
{
|
||||
public:
|
||||
static constexpr auto const kENDIAN = boost::endian::order::native;
|
||||
static constexpr auto kEndian = boost::endian::order::native;
|
||||
|
||||
using result_type = std::array<std::uint8_t, 20>;
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
struct OpensslSha512Hasher
|
||||
{
|
||||
public:
|
||||
static constexpr auto const kENDIAN = boost::endian::order::native;
|
||||
static constexpr auto kEndian = boost::endian::order::native;
|
||||
|
||||
using result_type = std::array<std::uint8_t, 64>;
|
||||
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
struct OpensslSha256Hasher
|
||||
{
|
||||
public:
|
||||
static constexpr auto const kENDIAN = boost::endian::order::native;
|
||||
static constexpr auto kEndian = boost::endian::order::native;
|
||||
|
||||
using result_type = std::array<std::uint8_t, 32>;
|
||||
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
sha256_hasher h_;
|
||||
|
||||
public:
|
||||
static constexpr auto const kENDIAN = boost::endian::order::native;
|
||||
static constexpr auto kEndian = boost::endian::order::native;
|
||||
|
||||
using result_type = std::array<std::uint8_t, 20>;
|
||||
|
||||
@@ -154,7 +154,7 @@ private:
|
||||
sha512_hasher h_;
|
||||
|
||||
public:
|
||||
static constexpr auto const kENDIAN = boost::endian::order::big;
|
||||
static constexpr auto kEndian = boost::endian::order::big;
|
||||
|
||||
using result_type = uint256;
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ toUInt32(Taxon t)
|
||||
return static_cast<std::uint32_t>(t);
|
||||
}
|
||||
|
||||
constexpr std::uint16_t const kFLAG_BURNABLE = 0x0001;
|
||||
constexpr std::uint16_t const kFLAG_ONLY_XRP = 0x0002;
|
||||
constexpr std::uint16_t const kFLAG_CREATE_TRUST_LINES = 0x0004;
|
||||
constexpr std::uint16_t const kFLAG_TRANSFERABLE = 0x0008;
|
||||
constexpr std::uint16_t const kFLAG_MUTABLE = 0x0010;
|
||||
constexpr std::uint16_t const kFlagBurnable = 0x0001;
|
||||
constexpr std::uint16_t const kFlagOnlyXrp = 0x0002;
|
||||
constexpr std::uint16_t const kFlagCreateTrustLines = 0x0004;
|
||||
constexpr std::uint16_t const kFlagTransferable = 0x0008;
|
||||
constexpr std::uint16_t const kFlagMutable = 0x0010;
|
||||
|
||||
inline std::uint16_t
|
||||
getFlags(uint256 const& id)
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace xrpl::nft {
|
||||
|
||||
// NFT directory pages order their contents based only on the low 96 bits of
|
||||
// the NFToken value. This mask provides easy access to the necessary mask.
|
||||
uint256 constexpr kPAGE_MASK(
|
||||
constexpr uint256 kPageMask(
|
||||
std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff"));
|
||||
|
||||
} // namespace xrpl::nft
|
||||
|
||||
Reference in New Issue
Block a user