Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 7: [PATCH 07/30] release: establish Roots maintenance and assurance

src/policy/policy.h

Before: src/policy/policy.h · After: src/policy/policy.h

File metadata
index a03289133ac818684799c0091dc0e80b851a6cc8..77a5b898e895edfb36c2723a9f469371c237eb32 100644

Download original patch · Release notes

Diff rows 1–88 of 88. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/policy/policy.h CHANGED
@@ -8,21 +8,20 @@
8
 
9
  #include <consensus/amount.h>
10
  #include <consensus/consensus.h>
 
 
11
  #include <primitives/transaction.h>
12
  #include <script/interpreter.h>
13
  #include <script/solver.h>
14
 
15
  #include <cstdint>
 
16
  #include <string>
17
  #include <unordered_set>
18
  #include <utility>
19
 
20
  class CCoinsViewCache;
21
- class CFeeRate;
22
  class CScript;
23
- namespace kernel {
24
- struct MemPoolOptions;
25
- };
26
 
27
  /** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
28
  static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 300000;
@@ -56,14 +55,6 @@ static constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500};
56
  /** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
57
  static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
58
  static constexpr CAmount CORE_INCREMENTAL_RELAY_FEE{100};
59
- /** Default for -maxscriptsize */
60
- static constexpr unsigned int DEFAULT_SCRIPT_SIZE_POLICY_LIMIT{1650};
61
- /** Default for -bytespersigop */
62
- static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
63
- /** Default for -bytespersigopstrict */
64
- static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP_STRICT{20};
65
- /** Default for -datacarriercost (multiplied by WITNESS_SCALE_FACTOR) */
66
- static constexpr unsigned int DEFAULT_WEIGHT_PER_DATA_BYTE{4};
67
  /** Default for -rejecttokens */
68
  static constexpr bool DEFAULT_REJECT_TOKENS{false};
69
  /** Default for -subdustfeepenalty */
@@ -85,6 +76,8 @@ static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{false};
85
  static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{false};
86
  /** Default for -rejectparasites */
87
  static constexpr bool DEFAULT_REJECT_PARASITES{true};
 
 
88
  /** The maximum number of witness stack items in a standard P2WSH script */
89
  static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
90
  /** The maximum size in bytes of each witness stack item in a standard P2WSH script */
@@ -183,6 +176,23 @@ static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQ
183
  typedef std::unordered_set<std::string> ignore_rejects_type;
184
  static const ignore_rejects_type empty_ignore_rejects{};
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
187
 
188
  bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
@@ -201,16 +211,16 @@ static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
201
  * Check for standard transaction types
202
  * @return True if all outputs (scriptPubKeys) use only standard transaction forms
203
  */
204
- bool IsStandardTx(const CTransaction& tx, const kernel::MemPoolOptions& opts, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
205
  // Compatibility entry point for existing unit tests. Production admission uses
206
- // the MemPoolOptions overload above so every policy setting is explicit.
207
  bool IsStandardTx(const CTransaction& tx, unsigned int max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_feerate, std::string& out_reason);
208
  /**
209
  * Check for standard transaction types
210
  * @param[in] mapInputs Map of previous transactions that have outputs we're spending
211
  * @return True if all inputs (scriptSigs) use only standard transaction forms
212
  */
213
- bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const kernel::MemPoolOptions& opts, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
214
 
215
  bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& map_inputs);
216
 
 
8
 
9
  #include <consensus/amount.h>
10
  #include <consensus/consensus.h>
11
+ #include <policy/feerate.h>
12
+ #include <policy/settings.h>
13
  #include <primitives/transaction.h>
14
  #include <script/interpreter.h>
15
  #include <script/solver.h>
16
 
17
  #include <cstdint>
18
+ #include <optional>
19
  #include <string>
20
  #include <unordered_set>
21
  #include <utility>
22
 
23
  class CCoinsViewCache;
 
24
  class CScript;
 
 
 
25
 
26
  /** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
27
  static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 300000;
 
55
  /** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
56
  static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
57
  static constexpr CAmount CORE_INCREMENTAL_RELAY_FEE{100};
 
 
 
 
 
 
 
 
58
  /** Default for -rejecttokens */
59
  static constexpr bool DEFAULT_REJECT_TOKENS{false};
60
  /** Default for -subdustfeepenalty */
 
76
  static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{false};
77
  /** Default for -rejectparasites */
78
  static constexpr bool DEFAULT_REJECT_PARASITES{true};
79
+ /** Default for -acceptunknownwitness */
80
+ static constexpr bool DEFAULT_ACCEPTUNKNOWNWITNESS{true};
81
  /** The maximum number of witness stack items in a standard P2WSH script */
82
  static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
83
  /** The maximum size in bytes of each witness stack item in a standard P2WSH script */
 
176
  typedef std::unordered_set<std::string> ignore_rejects_type;
177
  static const ignore_rejects_type empty_ignore_rejects{};
178
 
179
+ /** Local transaction-standardness settings shared by admission and policy checks. */
180
+ struct StandardnessOptions {
181
+ CFeeRate dust_relay_feerate{DUST_RELAY_TX_FEE};
182
+ unsigned int maxtxlegacysigops{MAX_TX_LEGACY_SIGOPS};
183
+ std::optional<unsigned> max_datacarrier_bytes{DEFAULT_ACCEPT_DATACARRIER ? std::optional{MAX_OP_RETURN_RELAY} : std::nullopt};
184
+ bool permitbaredatacarrier{DEFAULT_PERMITBAREDATACARRIER};
185
+ bool permitbareanchor{DEFAULT_PERMITBAREANCHOR};
186
+ bool permit_bare_pubkey{DEFAULT_PERMIT_BAREPUBKEY};
187
+ bool permit_bare_multisig{DEFAULT_PERMIT_BAREMULTISIG};
188
+ bool reject_parasites{DEFAULT_REJECT_PARASITES};
189
+ bool reject_tokens{DEFAULT_REJECT_TOKENS};
190
+ bool acceptunknownwitness{DEFAULT_ACCEPTUNKNOWNWITNESS};
191
+ bool permitephemeral_anchor{DEFAULT_PERMITEPHEMERAL_ANCHOR};
192
+ bool permitephemeral_send{DEFAULT_PERMITEPHEMERAL_SEND};
193
+ bool permitephemeral_dust{DEFAULT_PERMITEPHEMERAL_DUST};
194
+ };
195
+
196
  CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
197
 
198
  bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
 
211
  * Check for standard transaction types
212
  * @return True if all outputs (scriptPubKeys) use only standard transaction forms
213
  */
214
+ bool IsStandardTx(const CTransaction& tx, const StandardnessOptions& opts, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
215
  // Compatibility entry point for existing unit tests. Production admission uses
216
+ // the StandardnessOptions overload above so every policy setting is explicit.
217
  bool IsStandardTx(const CTransaction& tx, unsigned int max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_feerate, std::string& out_reason);
218
  /**
219
  * Check for standard transaction types
220
  * @param[in] mapInputs Map of previous transactions that have outputs we're spending
221
  * @return True if all inputs (scriptSigs) use only standard transaction forms
222
  */
223
+ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const StandardnessOptions& opts, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
224
 
225
  bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& map_inputs);
226