refactor: move getFeePayer to STObject

This commit is contained in:
Denis Angell
2026-06-30 12:59:30 -04:00
parent cc348e7745
commit ae5d27468b
6 changed files with 26 additions and 21 deletions

View File

@@ -217,6 +217,11 @@ public:
[[nodiscard]] AccountID
getAccountID(SField const& field) const;
/** The account responsible for the fee and authorization: the delegate when
sfDelegate is present, otherwise the account. */
[[nodiscard]] AccountID
getFeePayer() const;
[[nodiscard]] Blob
getFieldVL(SField const& field) const;
[[nodiscard]] STAmount const&

View File

@@ -84,9 +84,6 @@ public:
[[nodiscard]] std::uint32_t
getSeqValue() const;
[[nodiscard]] AccountID
getFeePayer() const;
[[nodiscard]] boost::container::flat_set<AccountID>
getMentionedAccounts() const;

View File

@@ -25,9 +25,6 @@ public:
static NotTEC
preflightSigValidated(PreflightContext const& ctx);
static NotTEC
checkBatchSign(PreclaimContext const& ctx);
static NotTEC
checkSign(PreclaimContext const& ctx);
@@ -62,6 +59,12 @@ public:
ttLOAN_MANAGE,
ttLOAN_PAY,
});
private:
// Skips signature verification for inner txns, so keep it private: it must
// only be reached through Batch::checkSign.
static NotTEC
checkBatchSign(PreclaimContext const& ctx);
};
} // namespace xrpl

View File

@@ -635,6 +635,20 @@ STObject::getAccountID(SField const& field) const
return getFieldByValue<STAccount>(field);
}
AccountID
STObject::getFeePayer() const
{
// If sfDelegate is present, the delegate account is the payer
// note: if a delegate is specified, its authorization to act on behalf of the account is
// enforced in `Transactor::invokeCheckPermission`
// cryptographic signature validity is checked separately (e.g., in `Transactor::checkSign`)
if (isFieldPresent(sfDelegate))
return getAccountID(sfDelegate);
// Default payer
return getAccountID(sfAccount);
}
Blob
STObject::getFieldVL(SField const& field) const
{

View File

@@ -214,20 +214,6 @@ STTx::getSeqValue() const
return getSeqProxy().value();
}
AccountID
STTx::getFeePayer() const
{
// If sfDelegate is present, the delegate account is the payer
// note: if a delegate is specified, its authorization to act on behalf of the account is
// enforced in `Transactor::invokeCheckPermission`
// cryptographic signature validity is checked separately (e.g., in `Transactor::checkSign`)
if (isFieldPresent(sfDelegate))
return getAccountID(sfDelegate);
// Default payer
return getAccountID(sfAccount);
}
void
STTx::sign(
PublicKey const& publicKey,

View File

@@ -421,7 +421,7 @@ Batch::preflightSigValidated(PreflightContext const& ctx)
{
// A delegated inner is signed by the delegate, not the account holder,
// so the delegate is the required signer when present.
AccountID const authorizer = rb[~sfDelegate].value_or(rb[sfAccount]);
AccountID const authorizer = rb.getFeePayer();
// The outer account signs the batch itself, so it is never added to the
// required signers.