@@ -56,6 +56,7 @@ struct ParentInfo {
56
56
};
57
57
58
58
std::optional<std::string> PackageTRUCChecks (const CTransactionRef& ptx, int64_t vsize,
59
+ const std::string& reason_prefix, std::string& out_reason,
59
60
const Package& package,
60
61
const CTxMemPool::setEntries& mempool_ancestors)
61
62
{
@@ -69,11 +70,13 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
69
70
if (ptx->version == TRUC_VERSION) {
70
71
// SingleTRUCChecks should have checked this already.
71
72
if (!Assume (vsize <= TRUC_MAX_VSIZE)) {
73
+ out_reason = reason_prefix + " vsize-toobig" ;
72
74
return strprintf (" version=3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
73
75
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, TRUC_MAX_VSIZE);
74
76
}
75
77
76
78
if (mempool_ancestors.size () + in_package_parents.size () + 1 > TRUC_ANCESTOR_LIMIT) {
79
+ out_reason = reason_prefix + " ancestors-toomany" ;
77
80
return strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
78
81
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString ());
79
82
}
@@ -82,6 +85,7 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
82
85
if (has_parent) {
83
86
// A TRUC child cannot be too large.
84
87
if (vsize > TRUC_CHILD_MAX_VSIZE) {
88
+ out_reason = reason_prefix + " child-toobig" ;
85
89
return strprintf (" version=3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
86
90
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
87
91
vsize, TRUC_CHILD_MAX_VSIZE);
@@ -107,6 +111,7 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
107
111
108
112
// If there is a parent, it must have the right version.
109
113
if (parent_info.m_version != TRUC_VERSION) {
114
+ out_reason = reason_prefix + " spends-nontruc" ;
110
115
return strprintf (" version=3 tx %s (wtxid=%s) cannot spend from non-version=3 tx %s (wtxid=%s)" ,
111
116
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
112
117
parent_info.m_txid .ToString (), parent_info.m_wtxid .ToString ());
@@ -121,20 +126,23 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
121
126
// sibling is to-be-replaced (done in SingleTRUCChecks) because these transactions
122
127
// are within the same package.
123
128
if (input.prevout .hash == parent_info.m_txid ) {
129
+ out_reason = reason_prefix + " sibling-known" ;
124
130
return strprintf (" tx %s (wtxid=%s) would exceed descendant count limit" ,
125
131
parent_info.m_txid .ToString (),
126
132
parent_info.m_wtxid .ToString ());
127
133
}
128
134
129
135
// This tx can't have both a parent and an in-package child.
130
136
if (input.prevout .hash == ptx->GetHash ()) {
137
+ out_reason = reason_prefix + " parent-and-child-both" ;
131
138
return strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
132
139
package_tx->GetHash ().ToString (), package_tx->GetWitnessHash ().ToString ());
133
140
}
134
141
}
135
142
}
136
143
137
144
if (parent_info.m_has_mempool_descendant ) {
145
+ out_reason = reason_prefix + " descendant-toomany" ;
138
146
return strprintf (" tx %s (wtxid=%s) would exceed descendant count limit" ,
139
147
parent_info.m_txid .ToString (), parent_info.m_wtxid .ToString ());
140
148
}
@@ -143,13 +151,15 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
143
151
// Non-TRUC transactions cannot have TRUC parents.
144
152
for (auto it : mempool_ancestors) {
145
153
if (it->GetTx ().version == TRUC_VERSION) {
154
+ out_reason = reason_prefix + " spent-by-nontruc" ;
146
155
return strprintf (" non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)" ,
147
156
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
148
157
it->GetSharedTx ()->GetHash ().ToString (), it->GetSharedTx ()->GetWitnessHash ().ToString ());
149
158
}
150
159
}
151
160
for (const auto & index: in_package_parents) {
152
161
if (package.at (index)->version == TRUC_VERSION) {
162
+ out_reason = reason_prefix + " spent-by-nontruc" ;
153
163
return strprintf (" non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)" ,
154
164
ptx->GetHash ().ToString (),
155
165
ptx->GetWitnessHash ().ToString (),
@@ -162,18 +172,21 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
162
172
}
163
173
164
174
std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks (const CTransactionRef& ptx,
175
+ const std::string& reason_prefix, std::string& out_reason,
165
176
const CTxMemPool::setEntries& mempool_ancestors,
166
177
const std::set<Txid>& direct_conflicts,
167
178
int64_t vsize)
168
179
{
169
180
// Check TRUC and non-TRUC inheritance.
170
181
for (const auto & entry : mempool_ancestors) {
171
182
if (ptx->version != TRUC_VERSION && entry->GetTx ().version == TRUC_VERSION) {
183
+ out_reason = reason_prefix + " spent-by-nontruc" ;
172
184
return std::make_pair (strprintf (" non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)" ,
173
185
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
174
186
entry->GetSharedTx ()->GetHash ().ToString (), entry->GetSharedTx ()->GetWitnessHash ().ToString ()),
175
187
nullptr );
176
188
} else if (ptx->version == TRUC_VERSION && entry->GetTx ().version != TRUC_VERSION) {
189
+ out_reason = reason_prefix + " spends-nontruc" ;
177
190
return std::make_pair (strprintf (" version=3 tx %s (wtxid=%s) cannot spend from non-version=3 tx %s (wtxid=%s)" ,
178
191
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (),
179
192
entry->GetSharedTx ()->GetHash ().ToString (), entry->GetSharedTx ()->GetWitnessHash ().ToString ()),
@@ -189,13 +202,15 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
189
202
if (ptx->version != TRUC_VERSION) return std::nullopt;
190
203
191
204
if (vsize > TRUC_MAX_VSIZE) {
205
+ out_reason = reason_prefix + " vsize-toobig" ;
192
206
return std::make_pair (strprintf (" version=3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
193
207
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, TRUC_MAX_VSIZE),
194
208
nullptr );
195
209
}
196
210
197
211
// Check that TRUC_ANCESTOR_LIMIT would not be violated.
198
212
if (mempool_ancestors.size () + 1 > TRUC_ANCESTOR_LIMIT) {
213
+ out_reason = reason_prefix + " ancestors-toomany" ;
199
214
return std::make_pair (strprintf (" tx %s (wtxid=%s) would have too many ancestors" ,
200
215
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString ()),
201
216
nullptr );
@@ -205,6 +220,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
205
220
if (mempool_ancestors.size () > 0 ) {
206
221
// If this transaction spends TRUC parents, it cannot be too large.
207
222
if (vsize > TRUC_CHILD_MAX_VSIZE) {
223
+ out_reason = reason_prefix + " child-toobig" ;
208
224
return std::make_pair (strprintf (" version=3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes" ,
209
225
ptx->GetHash ().ToString (), ptx->GetWitnessHash ().ToString (), vsize, TRUC_CHILD_MAX_VSIZE),
210
226
nullptr );
@@ -233,6 +249,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
233
249
234
250
// Return the sibling if its eviction can be considered. Provide the "descendant count
235
251
// limit" string either way, as the caller may decide not to do sibling eviction.
252
+ out_reason = reason_prefix + " descendants-toomany" ;
236
253
return std::make_pair (strprintf (" tx %u (wtxid=%s) would exceed descendant count limit" ,
237
254
parent_entry->GetSharedTx ()->GetHash ().ToString (),
238
255
parent_entry->GetSharedTx ()->GetWitnessHash ().ToString ()),
0 commit comments