BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
policy.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_POLICY_POLICY_H
7 #define BITCOIN_POLICY_POLICY_H
8 
9 #include <consensus/consensus.h>
10 #include <policy/feerate.h>
11 #include <script/interpreter.h>
12 #include <script/standard.h>
13 
14 #include <string>
15 
16 class CCoinsViewCache;
17 class CTxOut;
18 
20 static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = MAX_BLOCK_WEIGHT - 4000;
22 static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000;
24 static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000;
26 static const unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE = 82;
28 static const unsigned int MAX_P2SH_SIGOPS = 15;
30 static const unsigned int MAX_STANDARD_TX_SIGOPS_COST = MAX_BLOCK_SIGOPS_COST/5;
32 static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
34 static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE = 1000;
36 static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20;
38 static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS = 100;
40 static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80;
42 static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600;
48 static const unsigned int DUST_RELAY_TX_FEE = 3000;
54 static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS |
70 
72 static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS;
73 
75 static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE |
76  LOCKTIME_MEDIAN_TIME_PAST;
77 
79 
80 bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
81 
82 bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
87 bool IsStandardTx(const CTransaction& tx, std::string& reason);
93 bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
99 bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
100 
102 extern CFeeRate dustRelayFee;
103 extern unsigned int nBytesPerSigOp;
104 
106 int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost);
107 int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost = 0);
108 int64_t GetVirtualTransactionInputSize(const CTxIn& tx, int64_t nSigOpCost = 0);
109 
110 #endif // BITCOIN_POLICY_POLICY_H
CFeeRate incrementalRelayFee
Definition: policy.cpp:242
CScript scriptPubKey
Definition: transaction.h:135
bool IsStandardTx(const CTransaction &tx, std::string &reason)
Check for standard transaction types.
Definition: policy.cpp:80
CAmount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFee)
Definition: policy.cpp:18
CFeeRate dustRelayFee
Definition: policy.cpp:243
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFee)
Definition: policy.cpp:52
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
An input of a transaction.
Definition: transaction.h:61
int64_t GetVirtualTransactionInputSize(const CTxIn &tx, int64_t nSigOpCost=0)
Definition: policy.cpp:256
An output of a transaction.
Definition: transaction.h:131
txnouttype
Definition: standard.h:56
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
Compute the virtual transaction size (weight reinterpreted as bytes).
Definition: policy.cpp:246
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:384
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:19
unsigned int nBytesPerSigOp
Definition: policy.cpp:244
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:264
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:201
bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType)
Definition: policy.cpp:57
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check for standard transaction types.
Definition: policy.cpp:160
bool IsWitnessStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check if the transaction is over standard P2WSH resources limit: 3600bytes witnessScript size...
Definition: policy.cpp:190