[−][src]Crate verification
Bitcoin consensus verification
Full block verification consists of two phases:
- pre-verification
- full-verification
In this library, pre-verification is done by VerifyXXX
structures
Full-verification is done by AcceptXXX
structures
Use cases:
--> A. on_new_block:
A.1 VerifyHeader A.2 VerifyBlock, A.3 VerifyTransaction for each tx
A.4.a if it is block from canon chain A.4.a.1 AcceptHeader A.4.a.2 AcceptBlock A.4.a.3 AcceptTransaction for each tx
A.4.b if it is block from side chain becoming canon decanonize old canon chain blocks canonize new canon chain blocks (without currently processed block) A.4.b.1 AcceptHeader for each header A.4.b.2 AcceptBlock for each block A.4.b.3 AcceptTransaction for each tx in each block A.4.b.4 AcceptHeader A.4.b.5 AcceptBlock A.4.b.6 AcceptTransaction for each tx if any step failed, revert chain back to old canon
A.4.c if it is block from side chain do nothing
--> B. on_memory_pool_transaction
B.1 VerifyMemoryPoolTransaction B.2 AcceptMemoryPoolTransaction
--> C. on_block_header
C.1 VerifyHeader C.2 AcceptHeader (?)
--> D. after successfull chain_reorganization
D.1 AcceptMemoryPoolTransaction on each tx in memory pool
--> E. D might be super inefficient when memory pool is large so instead we might want to call AcceptMemoryPoolTransaction on each tx that is inserted into assembled block
Modules
bigint |
Efficient large, fixed-size big integers and hashes. |
compact |
Compact representation of |
constants |
Consenus constants |
hash |
Fixed-size hashes |
Structs
BackwardsCompatibleChainVerifier | |
BlockAcceptor |
Flexible verification of ordered block |
BlockVerifier | |
CanonBlock |
Blocks whose parents are known to be in the chain |
CanonHeader | |
CanonTransaction | |
ChainAcceptor | |
ChainVerifier | |
Deployments | |
HeaderAcceptor | |
HeaderVerifier | |
MemoryPoolTransactionAcceptor | |
MemoryPoolTransactionVerifier | |
TransactionAcceptor | |
TransactionVerifier |
Enums
Error |
All possible verification errors |
TransactionError |
Possible transactions verification errors |
VerificationLevel |
Blocks verification level. |
Traits
Verify |
Interface for block verification |
Functions
block_reward_satoshi | |
is_valid_proof_of_work |
Returns true if hash is lower or equal than target and target is lower or equal than current network maximum |
is_valid_proof_of_work_hash |
Returns true if hash is lower or equal than target represented by compact bits |
median_timestamp |
Returns median timestamp, of given header ancestors. The header should be later expected to have higher timestamp than this median timestamp |
median_timestamp_inclusive |
Returns median timestamp, of given header + its ancestors. The header should be later expected to have higher timestamp than this median timestamp |
transaction_sigops |
Counts signature operations in given transaction bip16_active flag indicates if we should also count signature operations in previous transactions. If one of the previous transaction outputs is missing, we simply ignore that fact and just carry on counting |
work_required |
Returns work required for given header |