xrpld
Loading...
Searching...
No Matches
libxrpl/ledger/helpers/ProposalHelpers.cpp
1#include <xrpl/ledger/helpers/ProposalHelpers.h>
2
3#include <xrpl/protocol/SField.h>
4#include <xrpl/protocol/STArray.h>
5#include <xrpl/protocol/STObject.h>
6#include <xrpl/protocol/STTx.h>
7#include <xrpl/protocol/TxFlags.h>
8#include <xrpl/protocol/TxFormats.h>
9
10namespace xrpl::proposal {
11
12bool
13isValidProposal(STObject const& proposedTx)
14{
15 if (isProposalTx(proposedTx))
16 return false;
17
18 if (isPseudoTx(proposedTx))
19 return false;
20
21 if (proposedTx.isFieldPresent(sfFlags) &&
22 (proposedTx.getFieldU32(sfFlags) & tfInnerBatchTxn) != 0u)
23 return false;
24
25 if (proposedTx.getFieldU16(sfTransactionType) == ttBATCH &&
26 proposedTx.isFieldPresent(sfRawTransactions))
27 {
28 STArray const& innerTxns = proposedTx.getFieldArray(sfRawTransactions);
29 for (STObject const& inner : innerTxns)
30 {
31 if (isProposalTx(inner) || isPseudoTx(inner))
32 return false;
33 }
34 }
35
36 return true;
37}
38
39} // namespace xrpl::proposal
std::uint32_t getFieldU32(SField const &field) const
Definition STObject.cpp:601
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:688
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:464
std::uint16_t getFieldU16(SField const &field) const
Definition STObject.cpp:595
bool isValidProposal(STObject const &proposedTx)
Whether the proposed transaction is independently submittable through the ordinary multi-sign path: n...
bool isProposalTx(STObject const &proposedTx)
Whether the proposed transaction is itself a proposal transaction, which would nest one proposal insi...
constexpr FlagValue tfInnerBatchTxn
Definition TxFlags.h:44
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
Definition STTx.cpp:889