Bitcoin Core 28.99.0
P2P Digital Currency
|
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <util/hasher.h>
#include <cstdint>
#include <unordered_set>
#include <vector>
Go to the source code of this file.
Classes | |
class | PackageValidationState |
Typedefs | |
using | Package = std::vector< CTransactionRef > |
A package is an ordered list of transactions. More... | |
Enumerations | |
enum class | PackageValidationResult { PCKG_RESULT_UNSET = 0 , PCKG_POLICY , PCKG_TX , PCKG_MEMPOOL_ERROR } |
A "reason" why a package was invalid. More... | |
Functions | |
bool | IsTopoSortedPackage (const Package &txns) |
If any direct dependencies exist between transactions (i.e. More... | |
bool | IsConsistentPackage (const Package &txns) |
Checks that these transactions don't conflict, i.e., spend the same prevout. More... | |
bool | IsWellFormedPackage (const Package &txns, PackageValidationState &state, bool require_sorted) |
Context-free package policy checks: More... | |
bool | IsChildWithParents (const Package &package) |
Context-free check that a package is exactly one child and its parents; not all parents need to be present, but the package must not contain any transactions that are not the child's parents. More... | |
bool | IsChildWithParentsTree (const Package &package) |
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (the package is a "tree"). More... | |
uint256 | GetPackageHash (const std::vector< CTransactionRef > &transactions) |
Get the hash of these transactions' wtxids, concatenated in lexicographical order (treating the wtxids as little endian encoded uint256, smallest to largest). More... | |
Variables | |
static constexpr uint32_t | MAX_PACKAGE_COUNT {25} |
Default maximum number of transactions in a package. More... | |
static constexpr uint32_t | MAX_PACKAGE_WEIGHT = 404'000 |
Default maximum total weight of transactions in a package in weight to allow for context-less checks. More... | |
using Package = std::vector<CTransactionRef> |
A package is an ordered list of transactions.
The transactions cannot conflict with (spend the same inputs as) one another.
Definition at line 50 of file packages.h.
|
strong |
A "reason" why a package was invalid.
It may be that one or more of the included transactions is invalid or the package itself violates our rules. We don't distinguish between consensus and policy violations right now.
Definition at line 41 of file packages.h.
uint256 GetPackageHash | ( | const std::vector< CTransactionRef > & | transactions | ) |
Get the hash of these transactions' wtxids, concatenated in lexicographical order (treating the wtxids as little endian encoded uint256, smallest to largest).
Definition at line 151 of file packages.cpp.
bool IsChildWithParents | ( | const Package & | package | ) |
Context-free check that a package is exactly one child and its parents; not all parents need to be present, but the package must not contain any transactions that are not the child's parents.
It is expected to be sorted, which means the last transaction must be the child.
Definition at line 119 of file packages.cpp.
bool IsChildWithParentsTree | ( | const Package & | package | ) |
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (the package is a "tree").
Definition at line 136 of file packages.cpp.
bool IsConsistentPackage | ( | const Package & | txns | ) |
Checks that these transactions don't conflict, i.e., spend the same prevout.
This includes checking that there are no duplicate transactions. Since these checks require looking at the inputs of a transaction, returns false immediately if any transactions have empty vin.
Does not check consistency of a transaction with oneself; does not check if a transaction spends the same prevout multiple times (see bad-txns-inputs-duplicate in CheckTransaction()).
Definition at line 52 of file packages.cpp.
bool IsTopoSortedPackage | ( | const Package & | txns | ) |
If any direct dependencies exist between transactions (i.e.
a child spending the output of a parent), checks that all parents appear somewhere in the list before their respective children. No other ordering is enforced. This function cannot detect indirect dependencies (e.g. a transaction's grandparent if its parent is not present).
Definition at line 43 of file packages.cpp.
bool IsWellFormedPackage | ( | const Package & | txns, |
PackageValidationState & | state, | ||
bool | require_sorted | ||
) |
Context-free package policy checks:
Definition at line 79 of file packages.cpp.
|
staticconstexpr |
Default maximum number of transactions in a package.
Definition at line 19 of file packages.h.
|
staticconstexpr |
Default maximum total weight of transactions in a package in weight to allow for context-less checks.
This must allow a superset of sigops weighted vsize limited transactions to not disallow transactions we would have otherwise accepted individually.
Definition at line 24 of file packages.h.