Merge branch 'ximinez/lending-refactoring-4' into ximinez/lending-XLS-66

This commit is contained in:
Ed Hennis
2025-09-03 21:01:09 -04:00
committed by GitHub
7 changed files with 52 additions and 3 deletions

View File

@@ -673,7 +673,8 @@ isTerRetry(TER x) noexcept
inline bool
isTesSuccess(TER x) noexcept
{
return (x == tesSUCCESS);
// Makes use of TERSubset::operator bool()
return !(x);
}
inline bool

View File

@@ -241,7 +241,6 @@ Batch::preflight(PreflightContext const& ctx)
}
// Validation Inner Batch Txns
std::unordered_set<AccountID> requiredSigners;
std::unordered_set<uint256> uniqueHashes;
std::unordered_map<AccountID, std::unordered_set<std::uint32_t>>
accountSeqTicket;
@@ -396,6 +395,23 @@ Batch::preflight(PreflightContext const& ctx)
}
}
}
}
return tesSUCCESS;
}
NotTEC
Batch::preflightSigValidated(PreflightContext const& ctx)
{
auto const parentBatchId = ctx.tx.getTransactionID();
auto const outerAccount = ctx.tx.getAccountID(sfAccount);
auto const& rawTxns = ctx.tx.getFieldArray(sfRawTransactions);
// Build the signers list
std::unordered_set<AccountID> requiredSigners;
for (STObject const& rb : rawTxns)
{
auto const innerAccount = rb.getAccountID(sfAccount);
// If the inner account is the same as the outer account, do not add the
// inner account to the required signers set.

View File

@@ -49,6 +49,9 @@ public:
static NotTEC
preflight(PreflightContext const& ctx);
static NotTEC
preflightSigValidated(PreflightContext const& ctx);
static NotTEC
checkSign(PreclaimContext const& ctx);

View File

@@ -650,6 +650,15 @@ EscrowFinish::preflight(PreflightContext const& ctx)
if (static_cast<bool>(cb) != static_cast<bool>(fb))
return temMALFORMED;
return tesSUCCESS;
}
NotTEC
EscrowFinish::preflightSigValidated(PreflightContext const& ctx)
{
auto const cb = ctx.tx[~sfCondition];
auto const fb = ctx.tx[~sfFulfillment];
if (cb && fb)
{
auto& router = ctx.app.getHashRouter();

View File

@@ -69,6 +69,9 @@ public:
static NotTEC
preflight(PreflightContext const& ctx);
static NotTEC
preflightSigValidated(PreflightContext const& ctx);
static XRPAmount
calculateBaseFee(ReadView const& view, STTx const& tx);

View File

@@ -272,6 +272,12 @@ Transactor::getFlagsMask(PreflightContext const& ctx)
return tfUniversalMask;
}
NotTEC
Transactor::preflightSigValidated(PreflightContext const& ctx)
{
return tesSUCCESS;
}
TER
Transactor::checkPermission(ReadView const& view, STTx const& tx)
{

View File

@@ -215,6 +215,10 @@ public:
static NotTEC
preflight(PreflightContext const& ctx);
// Optional, rarely needed, if the transaction does any expensive
// checks after the signature is verified.
static NotTEC preflightSigValidated(PreflightContext const& ctx);
* Do not try to call preflight1 or preflight2 directly.
* Do not check whether relevant amendments are enabled in preflight.
Instead, define isEnabled.
@@ -290,6 +294,10 @@ protected:
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);
// Base class always returns tesSUCCESS
static NotTEC
preflightSigValidated(PreflightContext const& ctx);
static bool
validDataLength(std::optional<Slice> const& slice, std::size_t maxLength);
@@ -396,7 +404,10 @@ Transactor::invokePreflight(PreflightContext const& ctx)
if (auto const ret = T::preflight(ctx))
return ret;
return preflight2(ctx);
if (auto const ret = preflight2(ctx))
return ret;
return T::preflightSigValidated(ctx);
}
template <class T>