Skip to content
Bitcoin Roots

v29.4-roots.4 · Commit 7: [PATCH 07/37] 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. The two line-number columns refer to before and after.

src/policy/policy.h CHANGED
@@ -8,21 +8,20 @@
8
8
 
9
9
  #include <consensus/amount.h>
10
10
  #include <consensus/consensus.h>
11
+ #include <policy/feerate.h>
12
+ #include <policy/settings.h>
11
13
  #include <primitives/transaction.h>
12
14
  #include <script/interpreter.h>
13
15
  #include <script/solver.h>
14
16
 
15
17
  #include <cstdint>
18
+ #include <optional>
16
19
  #include <string>
17
20
  #include <unordered_set>
18
21
  #include <utility>
19
22
 
20
23
  class CCoinsViewCache;
21
- class CFeeRate;
22
24
  class CScript;
23
- namespace kernel {
24
- struct MemPoolOptions;
25
- };
26
25
 
27
26
  /** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
28
27
  static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 300000;
@@ -56,14 +55,6 @@ static constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500};
56
55
  /** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
57
56
  static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
58
57
  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
58
  /** Default for -rejecttokens */
68
59
  static constexpr bool DEFAULT_REJECT_TOKENS{false};
69
60
  /** Default for -subdustfeepenalty */
@@ -85,6 +76,8 @@ static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{false};
85
76
  static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{false};
86
77
  /** Default for -rejectparasites */
87
78
  static constexpr bool DEFAULT_REJECT_PARASITES{true};
79
+ /** Default for -acceptunknownwitness */
80
+ static constexpr bool DEFAULT_ACCEPTUNKNOWNWITNESS{true};
88
81
  /** The maximum number of witness stack items in a standard P2WSH script */
89
82
  static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
90
83
  /** 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
176
  typedef std::unordered_set<std::string> ignore_rejects_type;
184
177
  static const ignore_rejects_type empty_ignore_rejects{};
185
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
+
186
196
  CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
187
197
 
188
198
  bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);
@@ -201,16 +211,16 @@ static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
201
211
  * Check for standard transaction types
202
212
  * @return True if all outputs (scriptPubKeys) use only standard transaction forms
203
213
  */
204
- bool IsStandardTx(const CTransaction& tx, const kernel::MemPoolOptions& opts, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
214
+ bool IsStandardTx(const CTransaction& tx, const StandardnessOptions& opts, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
205
215
  // Compatibility entry point for existing unit tests. Production admission uses
206
- // the MemPoolOptions overload above so every policy setting is explicit.
216
+ // the StandardnessOptions overload above so every policy setting is explicit.
207
217
  bool IsStandardTx(const CTransaction& tx, unsigned int max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_feerate, std::string& out_reason);
208
218
  /**
209
219
  * Check for standard transaction types
210
220
  * @param[in] mapInputs Map of previous transactions that have outputs we're spending
211
221
  * @return True if all inputs (scriptSigs) use only standard transaction forms
212
222
  */
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);
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);
214
224
 
215
225
  bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& map_inputs);
216
226