27 for (
const auto& tx :
txns) {
28 for (
const auto& input : tx->vin) {
45 std::unordered_set<Txid, SaltedTxidHasher>
later_txids;
47 [](
const auto& tx) { return tx->GetHash(); });
55 std::unordered_set<COutPoint, SaltedOutpointHasher>
inputs_seen;
56 for (
const auto& tx :
txns) {
57 if (tx->vin.empty()) {
64 for (
const auto& input : tx->vin) {
74 [](
const auto& input) { return input.prevout; });
88 [](
int64_t sum,
const auto& tx) { return sum + GetTransactionWeight(*tx); });
94 std::unordered_set<Txid, SaltedTxidHasher>
later_txids;
96 [](
const auto& tx) { return tx->GetHash(); });
121 assert(std::all_of(
package.cbegin(),
package.cend(), [](
const auto& tx){return tx != nullptr;}));
122 if (
package.size() < 2)
return false;
126 std::unordered_set<Txid, SaltedTxidHasher>
input_txids;
127 std::transform(
child->vin.cbegin(),
child->vin.cend(),
129 [](
const auto& input) { return input.prevout.hash; });
133 [&
input_txids](
const auto&
ptx) { return input_txids.contains(ptx->GetHash()); });
139 std::unordered_set<Txid, SaltedTxidHasher>
parent_txids;
141 [](
const auto&
ptx) { return ptx->GetHash(); });
144 for (const auto& input : ptx->vin) {
145 if (parent_txids.contains(input.prevout.hash)) return false;
155 std::transform(transactions.cbegin(), transactions.cend(), std::back_inserter(
wtxids_copy),
156 [](
const auto& tx){ return tx->GetWitnessHash(); });
160 return std::lexicographical_compare(std::make_reverse_iterator(lhs.end()), std::make_reverse_iterator(lhs.begin()),
161 std::make_reverse_iterator(rhs.end()), std::make_reverse_iterator(rhs.begin()));
#define Assume(val)
Assume is the identity function.
A writer stream (for serialization) that computes a 256-bit hash.
uint256 GetSHA256()
Compute the SHA256 hash of all data written to this object.
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
bool IsChildWithParents(const Package &package)
Context-free check that a package is exactly one child and its parents; not all parents need to be pr...
bool IsWellFormedPackage(const Package &txns, PackageValidationState &state)
Context-free package policy checks:
bool IsConsistentPackage(const Package &txns)
Checks that these transactions don't conflict, i.e., spend the same prevout.
bool IsChildWithParentsTree(const Package &package)
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (...
bool IsTopoSortedPackage(const Package &txns, std::unordered_set< Txid, SaltedTxidHasher > &later_txids)
IsTopoSortedPackage where a set of txids has been pre-populated.
uint256 GetPackageHash(const std::vector< CTransactionRef > &transactions)
Get the hash of the concatenated wtxids of transactions, with wtxids treated as a little-endian numbe...
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
static constexpr uint32_t MAX_PACKAGE_WEIGHT
Default maximum total weight of transactions in a package in weight to allow for context-less checks.
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.