v31.1-roots.1 · Commit 2: [PATCH 02/17] feat(policy): preserve Roots parsing and local transaction checks
src/policy/policy.cpp
Before: src/policy/policy.cpp · After: src/policy/policy.cpp
File metadata
index 46ec238c3b18fd1c0a5ce35f25d1b619317dafda..d0455dd98cedea3adbc884b10ed5a1e58c570eb1 100644
Download original patch · Release notes
Diff rows 1–400 of 550. 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.cpp
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <consensus/consensus.h>
|
|
13
13
|
#include <consensus/validation.h>
|
|
14
14
|
#include <policy/feerate.h>
|
|
15
|
+
#include <policy/settings.h>
|
|
15
16
|
#include <primitives/transaction.h>
|
|
16
17
|
#include <script/interpreter.h>
|
|
17
18
|
#include <script/script.h>
|
|
@@ -21,6 +22,8 @@
|
|
|
21
22
|
|
|
22
23
|
#include <algorithm>
|
|
23
24
|
#include <cstddef>
|
|
25
|
+
#include <limits>
|
|
26
|
+
#include <utility>
|
|
24
27
|
#include <vector>
|
|
25
28
|
|
|
26
29
|
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
|
|
@@ -42,7 +45,7 @@ CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
|
|
|
42
45
|
if (txout.scriptPubKey.IsUnspendable())
|
|
43
46
|
return 0;
|
|
44
47
|
|
|
45
|
-
uint64_t nSize{GetSerializeSize(txout)};
|
|
48
|
+
size_t nSize = GetSerializeSize(txout);
|
|
46
49
|
int witnessversion = 0;
|
|
47
50
|
std::vector<unsigned char> witnessprogram;
|
|
48
51
|
|
|
@@ -76,6 +79,10 @@ std::vector<uint32_t> GetDust(const CTransaction& tx, CFeeRate dust_relay_rate)
|
|
|
76
79
|
return dust_outputs;
|
|
77
80
|
}
|
|
78
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Note this must assign whichType even if returning false, in case
|
|
84
|
+
* IsStandardTx ignores the "scriptpubkey" rejection.
|
|
85
|
+
*/
|
|
79
86
|
bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)
|
|
80
87
|
{
|
|
81
88
|
std::vector<std::vector<unsigned char> > vSolutions;
|
|
@@ -96,11 +103,111 @@ bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)
|
|
|
96
103
|
return true;
|
|
97
104
|
}
|
|
98
105
|
|
|
99
|
-
bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
|
|
106
|
+
static inline bool MaybeReject_(std::string& out_reason, const std::string& reason, const std::string& reason_prefix, const ignore_rejects_type& ignore_rejects) {
|
|
107
|
+
if (ignore_rejects.count(reason_prefix + reason)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
out_reason = reason_prefix + reason;
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#define MaybeReject(reason) do { \
|
|
116
|
+
if (MaybeReject_(out_reason, reason, reason_prefix, ignore_rejects)) { \
|
|
117
|
+
return false; \
|
|
118
|
+
} \
|
|
119
|
+
} while(0)
|
|
120
|
+
|
|
121
|
+
namespace {
|
|
122
|
+
size_t OlgaBytes(const CScript& script, size_t remaining_outputs)
|
|
123
|
+
{
|
|
124
|
+
if (!script.IsPayToWitnessScriptHash()) return 0;
|
|
125
|
+
|
|
126
|
+
const size_t payload_size{(size_t{script[2]} << 8) | script[3]};
|
|
127
|
+
const size_t outputs{(payload_size + 1) / WITNESS_V0_SCRIPTHASH_SIZE + 1};
|
|
128
|
+
if (remaining_outputs < outputs) return 0;
|
|
129
|
+
if ((script[4] | 0x20) != 's' || (script[5] | 0x20) != 't' ||
|
|
130
|
+
(script[6] | 0x20) != 'a' || (script[7] | 0x20) != 'm' ||
|
|
131
|
+
(script[8] | 0x20) != 'p' || script[9] != ':') {
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
return outputs * (WITNESS_V0_SCRIPTHASH_SIZE + 1 + 8);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
size_t OpNetWitnessBytes(const CScriptWitness& witness)
|
|
138
|
+
{
|
|
139
|
+
const auto& stack{witness.stack};
|
|
140
|
+
if (stack.size() != 5 || stack[4].size() != 65) return 0;
|
|
141
|
+
|
|
142
|
+
const CScript tapscript{stack[3].begin(), stack[3].end()};
|
|
143
|
+
bool found_opnet{false};
|
|
144
|
+
size_t deduct{0};
|
|
145
|
+
CScript::const_iterator pc{tapscript.begin()};
|
|
146
|
+
opcodetype opcode{OP_INVALIDOPCODE};
|
|
147
|
+
opcodetype last_opcode{OP_INVALIDOPCODE};
|
|
148
|
+
std::vector<unsigned char> data;
|
|
149
|
+
while (pc < tapscript.end()) {
|
|
150
|
+
last_opcode = opcode;
|
|
151
|
+
if (!tapscript.GetOp(pc, opcode, data)) break;
|
|
152
|
+
if (data.size() == 2 && data[0] == 0x6f && data[1] == 0x70) found_opnet = true;
|
|
153
|
+
if (opcode == OP_CHECKSIGVERIFY && last_opcode == 0x20) deduct += 34;
|
|
154
|
+
}
|
|
155
|
+
return found_opnet ? stack[0].size() + stack[3].size() - deduct : 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
std::pair<size_t, size_t> ScriptDatacarrierBytes(const CScript& script, size_t remaining_outputs, const CScriptWitness* witness = nullptr)
|
|
100
159
|
{
|
|
160
|
+
if (const size_t olga_bytes{OlgaBytes(script, remaining_outputs)}; olga_bytes) return {0, olga_bytes};
|
|
161
|
+
if (witness) {
|
|
162
|
+
if (const size_t opnet_bytes{OpNetWitnessBytes(*witness)}; opnet_bytes) return {0, opnet_bytes};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
size_t counted{0};
|
|
166
|
+
opcodetype opcode{OP_INVALIDOPCODE};
|
|
167
|
+
opcodetype last_opcode{OP_INVALIDOPCODE};
|
|
168
|
+
std::vector<unsigned char> push_data;
|
|
169
|
+
unsigned int inside_noop{0};
|
|
170
|
+
unsigned int inside_conditional{0};
|
|
171
|
+
CScript::const_iterator opcode_it{script.begin()};
|
|
172
|
+
CScript::const_iterator data_began{script.begin()};
|
|
173
|
+
for (CScript::const_iterator it{script.begin()}; it < script.end(); last_opcode = opcode) {
|
|
174
|
+
opcode_it = it;
|
|
175
|
+
if (!script.GetOp(it, opcode, push_data)) return {0, script.size()};
|
|
176
|
+
|
|
177
|
+
if (opcode == OP_IF || opcode == OP_NOTIF) {
|
|
178
|
+
++inside_conditional;
|
|
179
|
+
} else if (opcode == OP_ENDIF) {
|
|
180
|
+
if (!inside_conditional) return {0, script.size()};
|
|
181
|
+
--inside_conditional;
|
|
182
|
+
} else if (opcode == OP_RETURN && !inside_conditional) {
|
|
183
|
+
return {script.size(), 0};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (inside_noop) {
|
|
187
|
+
if (opcode == OP_IF || opcode == OP_NOTIF) {
|
|
188
|
+
++inside_noop;
|
|
189
|
+
} else if (opcode == OP_ENDIF && --inside_noop == 0) {
|
|
190
|
+
counted += it - data_began + 1;
|
|
191
|
+
}
|
|
192
|
+
} else if (opcode == OP_IF && last_opcode == OP_FALSE) {
|
|
193
|
+
inside_noop = 1;
|
|
194
|
+
data_began = opcode_it;
|
|
195
|
+
} else if (opcode <= OP_PUSHDATA4) {
|
|
196
|
+
data_began = opcode_it;
|
|
197
|
+
} else if (opcode == OP_DROP && last_opcode <= OP_PUSHDATA4) {
|
|
198
|
+
counted += it - data_began;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return {0, counted};
|
|
202
|
+
}
|
|
203
|
+
} // namespace
|
|
204
|
+
|
|
205
|
+
bool IsStandardTx(const CTransaction& tx, const StandardnessOptions& opts, std::string& out_reason, const ignore_rejects_type& ignore_rejects)
|
|
206
|
+
{
|
|
207
|
+
const std::string reason_prefix;
|
|
208
|
+
|
|
101
209
|
if (tx.version > TX_MAX_STANDARD_VERSION || tx.version < TX_MIN_STANDARD_VERSION) {
|
|
102
|
-
reason = "version";
|
|
103
|
-
return false;
|
|
210
|
+
MaybeReject("version");
|
|
104
211
|
}
|
|
105
212
|
|
|
106
213
|
// Extremely large transactions with lots of inputs can cost the network
|
|
@@ -109,8 +216,11 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
|
|
|
109
216
|
// to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks.
|
|
110
217
|
unsigned int sz = GetTransactionWeight(tx);
|
|
111
218
|
if (sz > MAX_STANDARD_TX_WEIGHT) {
|
|
112
|
-
reason = "tx-size";
|
|
113
|
-
return false;
|
|
219
|
+
MaybeReject("tx-size");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (tx.nLockTime == PARASITE_CAT21_LOCKTIME && opts.reject_parasites) {
|
|
223
|
+
MaybeReject("parasite-cat21");
|
|
114
224
|
}
|
|
115
225
|
|
|
116
226
|
for (const CTxIn& txin : tx.vin)
|
|
@@ -123,50 +233,110 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
|
|
|
123
233
|
// some minor future-proofing. That's also enough to spend a
|
|
124
234
|
// 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey
|
|
125
235
|
// is not considered standard.
|
|
126
|
-
if (txin.scriptSig.size() > MAX_STANDARD_SCRIPTSIG_SIZE) {
|
|
127
|
-
reason = "scriptsig-size";
|
|
128
|
-
return false;
|
|
236
|
+
if (txin.scriptSig.size() > std::min(MAX_STANDARD_SCRIPTSIG_SIZE, g_script_size_policy_limit)) {
|
|
237
|
+
MaybeReject("scriptsig-size");
|
|
129
238
|
}
|
|
130
239
|
if (!txin.scriptSig.IsPushOnly()) {
|
|
131
|
-
reason = "scriptsig-not-pushonly";
|
|
132
|
-
return false;
|
|
240
|
+
MaybeReject("scriptsig-not-pushonly");
|
|
133
241
|
}
|
|
134
242
|
}
|
|
135
243
|
|
|
136
|
-
unsigned int datacarrier_bytes_left = max_datacarrier_bytes.value_or(0);
|
|
244
|
+
unsigned int datacarrier_bytes_left = opts.max_datacarrier_bytes.value_or(0);
|
|
245
|
+
unsigned int nDataOut = 0;
|
|
246
|
+
unsigned int n_dust{0};
|
|
247
|
+
unsigned int n_monetary{0};
|
|
137
248
|
TxoutType whichType;
|
|
138
|
-
for (const CTxOut& txout : tx.vout) {
|
|
249
|
+
for (size_t i{tx.vout.size()}; i; ) {
|
|
250
|
+
const CTxOut& txout = tx.vout[--i];
|
|
251
|
+
|
|
252
|
+
if (txout.scriptPubKey.size() > g_script_size_policy_limit) {
|
|
253
|
+
MaybeReject("scriptpubkey-size");
|
|
254
|
+
}
|
|
255
|
+
|
|
139
256
|
if (!::IsStandard(txout.scriptPubKey, whichType)) {
|
|
140
|
-
reason = "scriptpubkey";
|
|
141
|
-
return false;
|
|
257
|
+
MaybeReject("scriptpubkey");
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (whichType == TxoutType::WITNESS_UNKNOWN && !opts.acceptunknownwitness) {
|
|
261
|
+
MaybeReject("scriptpubkey-unknown-witnessversion");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (whichType == TxoutType::ANCHOR && !opts.permitephemeral_anchor) {
|
|
265
|
+
MaybeReject("anchor");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (IsDust(txout, opts.dust_relay_feerate)) {
|
|
269
|
+
if (whichType != TxoutType::ANCHOR && !opts.permitephemeral_send) {
|
|
270
|
+
MaybeReject("dust-nonanchor");
|
|
271
|
+
}
|
|
272
|
+
if (txout.nValue && !opts.permitephemeral_dust) {
|
|
273
|
+
MaybeReject("dust-nonzero");
|
|
274
|
+
}
|
|
275
|
+
++n_dust;
|
|
276
|
+
} else if (whichType != TxoutType::NULL_DATA) {
|
|
277
|
+
++n_monetary;
|
|
142
278
|
}
|
|
143
279
|
|
|
144
280
|
if (whichType == TxoutType::NULL_DATA) {
|
|
145
|
-
unsigned int size = txout.scriptPubKey.size();
|
|
281
|
+
const auto size = txout.scriptPubKey.size();
|
|
146
282
|
if (size > datacarrier_bytes_left) {
|
|
147
|
-
reason = "datacarrier";
|
|
148
|
-
return false;
|
|
283
|
+
MaybeReject("datacarrier");
|
|
284
|
+
datacarrier_bytes_left = 0;
|
|
285
|
+
} else {
|
|
286
|
+
datacarrier_bytes_left -= size;
|
|
149
287
|
}
|
|
150
|
-
datacarrier_bytes_left -= size;
|
|
151
|
-
} else if ((whichType == TxoutType::MULTISIG) && (!permit_bare_multisig)) {
|
|
152
|
-
reason = "bare-multisig";
|
|
153
|
-
return false;
|
|
288
|
+
if (txout.scriptPubKey.size() > 2 && txout.scriptPubKey[1] == OP_13 && opts.reject_tokens) {
|
|
289
|
+
MaybeReject("tokens-runes");
|
|
290
|
+
}
|
|
291
|
+
nDataOut++;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
else if ((whichType == TxoutType::PUBKEY) && (!opts.permit_bare_pubkey)) {
|
|
295
|
+
MaybeReject("bare-pubkey");
|
|
296
|
+
}
|
|
297
|
+
else if ((whichType == TxoutType::MULTISIG) && (!opts.permit_bare_multisig)) {
|
|
298
|
+
MaybeReject("bare-multisig");
|
|
299
|
+
}
|
|
300
|
+
else if (whichType == TxoutType::WITNESS_V0_SCRIPTHASH && opts.reject_tokens && OlgaBytes(txout.scriptPubKey, tx.vout.size() - i)) {
|
|
301
|
+
MaybeReject("tokens-olga");
|
|
154
302
|
}
|
|
155
303
|
}
|
|
156
304
|
|
|
157
305
|
// Only MAX_DUST_OUTPUTS_PER_TX dust is permitted(on otherwise valid ephemeral dust)
|
|
158
|
-
if (GetDust(tx, dust_relay_fee).size() > MAX_DUST_OUTPUTS_PER_TX) {
|
|
159
|
-
reason = "dust";
|
|
160
|
-
return false;
|
|
306
|
+
if (n_dust > MAX_DUST_OUTPUTS_PER_TX) {
|
|
307
|
+
MaybeReject("dust");
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// only one OP_RETURN txout is permitted
|
|
311
|
+
if (nDataOut > 1) {
|
|
312
|
+
MaybeReject("multi-op-return");
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (!n_monetary) {
|
|
316
|
+
if (nDataOut && !opts.permitbaredatacarrier) {
|
|
317
|
+
MaybeReject("bare-datacarrier");
|
|
318
|
+
}
|
|
319
|
+
if ((!nDataOut) && !opts.permitbareanchor) {
|
|
320
|
+
MaybeReject("bare-anchor");
|
|
321
|
+
}
|
|
161
322
|
}
|
|
162
323
|
|
|
163
324
|
return true;
|
|
164
325
|
}
|
|
165
326
|
|
|
327
|
+
bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate& dust_relay_feerate, std::string& out_reason)
|
|
328
|
+
{
|
|
329
|
+
StandardnessOptions opts;
|
|
330
|
+
opts.max_datacarrier_bytes = max_datacarrier_bytes;
|
|
331
|
+
opts.permit_bare_multisig = permit_bare_multisig;
|
|
332
|
+
opts.dust_relay_feerate = dust_relay_feerate;
|
|
333
|
+
return IsStandardTx(tx, opts, out_reason);
|
|
334
|
+
}
|
|
335
|
+
|
|
166
336
|
/**
|
|
167
|
-
* Check the total number of non-witness sigops across the whole transaction, as per BIP54.
|
|
337
|
+
* Check the local transaction limit for potentially executed legacy sigops.
|
|
168
338
|
*/
|
|
169
|
-
static bool CheckSigopsBIP54(const CTransaction& tx, const CCoinsViewCache& inputs)
|
|
339
|
+
static bool CheckLegacyPolicySigops(const CTransaction& tx, const CCoinsViewCache& inputs, const StandardnessOptions& opts)
|
|
170
340
|
{
|
|
171
341
|
Assert(!tx.IsCoinBase());
|
|
172
342
|
|
|
@@ -184,7 +354,7 @@ static bool CheckSigopsBIP54(const CTransaction& tx, const CCoinsViewCache& inpu
|
|
|
184
354
|
sigops += txin.scriptSig.GetSigOpCount(/*fAccurate=*/true);
|
|
185
355
|
sigops += prev_txo.scriptPubKey.GetSigOpCount(txin.scriptSig);
|
|
186
356
|
|
|
187
|
-
if (sigops > MAX_TX_LEGACY_SIGOPS) {
|
|
357
|
+
if (sigops > opts.maxtxlegacysigops) {
|
|
188
358
|
return false;
|
|
189
359
|
}
|
|
190
360
|
}
|
|
@@ -208,39 +378,62 @@ static bool CheckSigopsBIP54(const CTransaction& tx, const CCoinsViewCache& inpu
|
|
|
208
378
|
*
|
|
209
379
|
* Note that only the non-witness portion of the transaction is checked here.
|
|
210
380
|
*
|
|
211
|
-
* We also check the total number of non-witness sigops across the whole transaction, as per BIP54.
|
|
381
|
+
* We also check the local transaction limit for potentially executed legacy sigops.
|
|
212
382
|
*/
|
|
213
|
-
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|
383
|
+
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)
|
|
214
384
|
{
|
|
215
385
|
if (tx.IsCoinBase()) {
|
|
216
386
|
return true; // Coinbases don't use vin normally
|
|
217
387
|
}
|
|
218
388
|
|
|
219
|
-
if (!CheckSigopsBIP54(tx, mapInputs)) {
|
|
220
|
-
return false;
|
|
389
|
+
if (!CheckLegacyPolicySigops(tx, mapInputs, opts)) {
|
|
390
|
+
MaybeReject("sigops-toomany-overall");
|
|
221
391
|
}
|
|
222
392
|
|
|
223
393
|
for (unsigned int i = 0; i < tx.vin.size(); i++) {
|
|
224
394
|
const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
|
|
225
395
|
|
|
396
|
+
if (prev.scriptPubKey.size() > g_script_size_policy_limit) {
|
|
397
|
+
MaybeReject("script-size");
|
|
398
|
+
}
|
|
399
|
+
|
|
226
400
|
std::vector<std::vector<unsigned char> > vSolutions;
|
|
227
401
|
TxoutType whichType = Solver(prev.scriptPubKey, vSolutions);
|
|
228
|
-
if (whichType == TxoutType::NONSTANDARD || whichType == TxoutType::WITNESS_UNKNOWN) {
|
|
402
|
+
if (whichType == TxoutType::NONSTANDARD) {
|
|
403
|
+
MaybeReject("script-unknown");
|
|
404
|
+
} else if (whichType == TxoutType::WITNESS_UNKNOWN) {
|
|
229
405
|
// WITNESS_UNKNOWN failures are typically also caught with a policy
|
|
230
406
|
// flag in the script interpreter, but it can be helpful to catch
|
|
231
407
|
// this type of NONSTANDARD transaction earlier in transaction
|
|
232
408
|
// validation.
|
|
233
|
-
return false;
|
|
409
|
+
MaybeReject("witness-unknown");
|
|
234
410
|
} else if (whichType == TxoutType::SCRIPTHASH) {
|
|
411
|
+
if (!tx.vin[i].scriptSig.IsPushOnly()) {
|
|
412
|
+
// The only way we got this far, is if the user ignored scriptsig-not-pushonly.
|
|
413
|
+
// However, this case is invalid, and will be caught later on.
|
|
414
|
+
// But for now, we don't want to run the [possibly expensive] script here.
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
235
417
|
std::vector<std::vector<unsigned char> > stack;
|
|
236
418
|
// convert the scriptSig into a stack, so we can inspect the redeemScript
|
|
237
419
|
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE))
|
|
420
|
+
{
|
|
421
|
+
// This case is also invalid or a bug
|
|
422
|
+
out_reason = reason_prefix + "scriptsig-failure";
|
|
238
423
|
return false;
|
|
424
|
+
}
|
|
239
425
|
if (stack.empty())
|
|
426
|
+
{
|
|
427
|
+
// Also invalid
|
|
428
|
+
out_reason = reason_prefix + "scriptcheck-missing";
|
|
240
429
|
return false;
|
|
430
|
+
}
|
|
241
431
|
CScript subscript(stack.back().begin(), stack.back().end());
|
|
432
|
+
if (subscript.size() > g_script_size_policy_limit) {
|
|
433
|
+
MaybeReject("scriptcheck-size");
|
|
434
|
+
}
|
|
242
435
|
if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) {
|
|
243
|
-
return false;
|
|
436
|
+
MaybeReject("scriptcheck-sigops");
|
|
244
437
|
}
|
|
245
438
|
}
|
|
246
439
|
}
|
|
@@ -248,7 +441,14 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|
|
248
441
|
return true;
|
|
249
442
|
}
|
|
250
443
|
|
|
251
|
-
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|
444
|
+
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& map_inputs)
|
|
445
|
+
{
|
|
446
|
+
StandardnessOptions opts;
|
|
447
|
+
std::string reason;
|
|
448
|
+
return AreInputsStandard(tx, map_inputs, opts, "", reason);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects)
|
|
252
452
|
{
|
|
253
453
|
if (tx.IsCoinBase())
|
|
254
454
|
return true; // Coinbases are skipped
|
|
@@ -267,7 +467,7 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|
|
267
467
|
|
|
268
468
|
// witness stuffing detected
|
|
269
469
|
if (prevScript.IsPayToAnchor()) {
|
|
270
|
-
return false;
|
|
470
|
+
MaybeReject("anchor-not-empty");
|
|
271
471
|
}
|
|
272
472
|
|
|
273
473
|
bool p2sh = false;
|
|
@@ -277,9 +477,15 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|
|
277
477
|
// into a stack. We do not check IsPushOnly nor compare the hash as these will be done later anyway.
|
|
278
478
|
// If the check fails at this stage, we know that this txid must be a bad one.
|
|
279
479
|
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE))
|
|
480
|
+
{
|
|
481
|
+
out_reason = reason_prefix + "scriptsig-failure";
|
|
280
482
|
return false;
|
|
483
|
+
}
|
|
281
484
|
if (stack.empty())
|
|
485
|
+
{
|