Merge branch 'ximinez/lending-XLS-66' into ximinez/lending-enabled

This commit is contained in:
Ed Hennis
2025-11-24 21:43:03 -05:00
committed by GitHub
54 changed files with 919 additions and 838 deletions

View File

@@ -352,7 +352,7 @@ accountHolds(
//
// <-- saAmount: amount of currency held by account. May be negative.
[[nodiscard]] STAmount
accountCanSend(
accountSpendable(
ReadView const& view,
AccountID const& account,
Currency const& currency,
@@ -361,7 +361,7 @@ accountCanSend(
beast::Journal j);
[[nodiscard]] STAmount
accountCanSend(
accountSpendable(
ReadView const& view,
AccountID const& account,
Issue const& issue,
@@ -369,7 +369,7 @@ accountCanSend(
beast::Journal j);
[[nodiscard]] STAmount
accountCanSend(
accountSpendable(
ReadView const& view,
AccountID const& account,
MPTIssue const& mptIssue,
@@ -378,7 +378,7 @@ accountCanSend(
beast::Journal j);
[[nodiscard]] STAmount
accountCanSend(
accountSpendable(
ReadView const& view,
AccountID const& account,
Asset const& asset,
@@ -753,6 +753,17 @@ canWithdraw(
[[nodiscard]] TER
canWithdraw(ReadView const& view, STTx const& tx);
[[nodiscard]] TER
doWithdraw(
ApplyView& view,
STTx const& tx,
AccountID const& senderAcct,
AccountID const& dstAcct,
AccountID const& sourceAcct,
XRPAmount priorBalance,
STAmount const& amount,
beast::Journal j);
/// Any transactors that call addEmptyHolding() in doApply must call
/// canAddHolding() in preflight with the same View and Asset
[[nodiscard]] TER

View File

@@ -81,13 +81,27 @@ public:
bool
native() const
{
return holds<Issue>() && get<Issue>().native();
return std::visit(
[&]<ValidIssueType TIss>(TIss const& issue) {
if constexpr (std::is_same_v<TIss, Issue>)
return issue.native();
if constexpr (std::is_same_v<TIss, MPTIssue>)
return false;
},
issue_);
}
bool
integral() const
{
return !holds<Issue>() || get<Issue>().native();
return std::visit(
[&]<ValidIssueType TIss>(TIss const& issue) {
if constexpr (std::is_same_v<TIss, Issue>)
return issue.native();
if constexpr (std::is_same_v<TIss, MPTIssue>)
return true;
},
issue_);
}
friend constexpr bool

View File

@@ -110,6 +110,7 @@ tenthBipsOfValue(T value, TenthBips<TBips> bips)
return value * bips.value() / tenthBipsPerUnity.value();
}
namespace Lending {
/** The maximum management fee rate allowed by a loan broker in 1/10 bips.
Valid values are between 0 and 10% inclusive.
@@ -197,6 +198,7 @@ static constexpr int loanPaymentsPerFeeIncrement = 5;
* without an amendment
*/
static constexpr int loanMaximumPaymentsPerTransaction = 100;
} // namespace Lending
/** The maximum length of a URI inside an NFT */
std::size_t constexpr maxTokenURILength = 256;

View File

@@ -231,11 +231,7 @@ verifyDigest(
SHA512-Half, and the resulting digest is signed.
*/
[[nodiscard]] bool
verify(
PublicKey const& publicKey,
Slice const& m,
Slice const& sig,
bool mustBeFullyCanonical = true) noexcept;
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept;
/** Calculate the 160-bit node ID from a node public key. */
NodeID

View File

@@ -564,7 +564,7 @@ STAmount::clear()
{
// The -100 is used to allow 0 to sort less than a small positive values
// which have a negative exponent.
mOffset = native() ? 0 : -100;
mOffset = integral() ? 0 : -100;
mValue = 0;
mIsNegative = false;
}
@@ -701,7 +701,7 @@ getRate(STAmount const& offerOut, STAmount const& offerIn);
*/
STAmount
roundToScale(
STAmount value,
STAmount const& value,
std::int32_t scale,
Number::rounding_mode rounding = Number::getround());
@@ -729,7 +729,7 @@ roundToAsset(
STAmount const ret{asset, value};
if (ret.integral())
return ret;
// Not that the ctor will round integral types (XRP, MPT) via canonicalize,
// Note that the ctor will round integral types (XRP, MPT) via canonicalize,
// so no extra work is needed for those.
return roundToScale(ret, scale);
}

View File

@@ -103,22 +103,15 @@ public:
std::optional<std::reference_wrapper<SField const>> signatureTarget =
{});
enum class RequireFullyCanonicalSig : bool { no, yes };
/** Check the signature.
@param requireCanonicalSig If `true`, check that the signature is fully
canonical. If `false`, only check that the signature is valid.
@param rules The current ledger rules.
@return `true` if valid signature. If invalid, the error message string.
*/
Expected<void, std::string>
checkSign(RequireFullyCanonicalSig requireCanonicalSig, Rules const& rules)
const;
checkSign(Rules const& rules) const;
Expected<void, std::string>
checkBatchSign(
RequireFullyCanonicalSig requireCanonicalSig,
Rules const& rules) const;
checkBatchSign(Rules const& rules) const;
// SQL Functions with metadata.
static std::string const&
@@ -140,40 +133,25 @@ public:
private:
/** Check the signature.
@param requireCanonicalSig If `true`, check that the signature is fully
canonical. If `false`, only check that the signature is valid.
@param rules The current ledger rules.
@param sigObject Reference to object that contains the signature fields.
Will be *this more often than not.
@return `true` if valid signature. If invalid, the error message string.
*/
Expected<void, std::string>
checkSign(
RequireFullyCanonicalSig requireCanonicalSig,
Rules const& rules,
STObject const& sigObject) const;
checkSign(Rules const& rules, STObject const& sigObject) const;
Expected<void, std::string>
checkSingleSign(
RequireFullyCanonicalSig requireCanonicalSig,
STObject const& sigObject) const;
checkSingleSign(STObject const& sigObject) const;
Expected<void, std::string>
checkMultiSign(
RequireFullyCanonicalSig requireCanonicalSig,
Rules const& rules,
STObject const& sigObject) const;
checkMultiSign(Rules const& rules, STObject const& sigObject) const;
Expected<void, std::string>
checkBatchSingleSign(
STObject const& batchSigner,
RequireFullyCanonicalSig requireCanonicalSig) const;
checkBatchSingleSign(STObject const& batchSigner) const;
Expected<void, std::string>
checkBatchMultiSign(
STObject const& batchSigner,
RequireFullyCanonicalSig requireCanonicalSig,
Rules const& rules) const;
checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const;
STBase*
copy(std::size_t n, void* buf) const override;

View File

@@ -272,8 +272,14 @@ constexpr std::uint32_t const tfBatchMask =
// as an overpayment. False, no overpayments will be taken.
constexpr std::uint32_t const tfLoanOverpayment = 0x00010000;
// LoanPay exclusive flags:
// tfLoanFullPayment: True, indicates that the payment is
// tfLoanFullPayment: True, indicates that the payment is an early
// full payment. It must pay the entire loan including close
// interest and fees, or it will fail. False: Not a full payment.
constexpr std::uint32_t const tfLoanFullPayment = 0x00020000;
// tfLoanLatePayment: True, indicates that the payment is late,
// and includes late iterest and fees. If the loan is not late,
// it will fail. False: not a late payment. If the current payment
// is overdue, the transaction will fail.
constexpr std::uint32_t const tfLoanLatePayment = 0x00040000;
constexpr std::uint32_t const tfLoanSetMask = ~(tfUniversal |
tfLoanOverpayment);

View File

@@ -68,8 +68,6 @@ XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
// The following amendments are obsolete, but must remain supported
@@ -82,9 +80,9 @@ XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYe
// enabled (added to the ledger).
//
// If a feature remains obsolete for long enough that no clients are able
// to vote for it, the feature can be removed (entirely?) from the code.
XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete)
// to vote for it, the feature can be removed entirely from the code. Until
// then the feature needs to be marked explicitly as obsolete, e.g.
// XRPL_FEATURE(Example, Supported::yes, VoteBehavior::Obsolete)
// The following amendments have been active for at least two years. Their
// pre-amendment code has been removed and the identifiers are deprecated.
// All known amendments and amendments that may appear in a validated ledger
@@ -120,6 +118,8 @@ XRPL_RETIRE_FIX(TrustLinesToSelf)
XRPL_RETIRE_FEATURE(Checks)
XRPL_RETIRE_FEATURE(CheckCashMakesTrustLine)
XRPL_RETIRE_FEATURE(CryptoConditions)
XRPL_RETIRE_FEATURE(CryptoConditionsSuite)
XRPL_RETIRE_FEATURE(DeletableAccounts)
XRPL_RETIRE_FEATURE(DepositAuth)
XRPL_RETIRE_FEATURE(DepositPreauth)
XRPL_RETIRE_FEATURE(DisallowIncoming)
@@ -135,6 +135,7 @@ XRPL_RETIRE_FEATURE(MultiSignReserve)
XRPL_RETIRE_FEATURE(NegativeUNL)
XRPL_RETIRE_FEATURE(NonFungibleTokensV1_1)
XRPL_RETIRE_FEATURE(PayChan)
XRPL_RETIRE_FEATURE(RequireFullyCanonicalSig)
XRPL_RETIRE_FEATURE(SortedDirectories)
XRPL_RETIRE_FEATURE(TicketBatch)
XRPL_RETIRE_FEATURE(TickSize)

View File

@@ -572,7 +572,7 @@ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({
//
// - InterestOwedToVault = InterestOutstanding - ManagementFeeOutstanding
// The amount of the total interest that is owed to the vault, and
// will be sent to as part of a payment.
// will be sent to it as part of a payment.
//
// - TrueTotalLoanValue = PaymentRemaining * PeriodicPayment
// The unrounded true total value of the loan.

View File

@@ -297,7 +297,7 @@ TRANSACTION(ttTRUST_SET, 20, TrustSet,
#endif
TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete,
Delegation::notDelegatable,
featureDeletableAccounts,
uint256{},
mustDeleteAcct,
({
{sfDestination, soeREQUIRED},