@@ -118,7 +118,7 @@ BOOST_FIXTURE_TEST_CASE(ephemeral_tests, RegTestingSetup)
118
118
CTxMemPool::setEntries empty_ancestors;
119
119
120
120
TxValidationState child_state;
121
- Txid child_txid ;
121
+ Wtxid child_wtxid ;
122
122
123
123
// Arbitrary non-0 feerate for these tests
124
124
CFeeRate dustrelay (DUST_RELAY_TX_FEE);
@@ -133,143 +133,143 @@ BOOST_FIXTURE_TEST_CASE(ephemeral_tests, RegTestingSetup)
133
133
// We first start with nothing "in the mempool", using package checks
134
134
135
135
// Trivial single transaction with no dust
136
- BOOST_CHECK (CheckEphemeralSpends ({dust_spend}, dustrelay, pool, child_state, child_txid ));
136
+ BOOST_CHECK (CheckEphemeralSpends ({dust_spend}, dustrelay, pool, child_state, child_wtxid ));
137
137
BOOST_CHECK (child_state.IsValid ());
138
- BOOST_CHECK_EQUAL (child_txid, Txid ());
138
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
139
139
140
140
// Now with dust, ok because the tx has no dusty parents
141
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1}, dustrelay, pool, child_state, child_txid ));
141
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1}, dustrelay, pool, child_state, child_wtxid ));
142
142
BOOST_CHECK (child_state.IsValid ());
143
- BOOST_CHECK_EQUAL (child_txid, Txid ());
143
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
144
144
145
145
// Dust checks pass
146
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, CFeeRate (0 ), pool, child_state, child_txid ));
146
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, CFeeRate (0 ), pool, child_state, child_wtxid ));
147
147
BOOST_CHECK (child_state.IsValid ());
148
- BOOST_CHECK_EQUAL (child_txid, Txid ());
149
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, dustrelay, pool, child_state, child_txid ));
148
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
149
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, dustrelay, pool, child_state, child_wtxid ));
150
150
BOOST_CHECK (child_state.IsValid ());
151
- BOOST_CHECK_EQUAL (child_txid, Txid ());
151
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
152
152
153
153
auto dust_non_spend = make_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX - 1 }}, /* version=*/ 2 );
154
154
155
155
// Child spending non-dust only from parent should be disallowed even if dust otherwise spent
156
- const auto dust_non_spend_txid {dust_non_spend->GetHash ()};
157
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend, dust_spend}, dustrelay, pool, child_state, child_txid ));
156
+ const auto dust_non_spend_wtxid {dust_non_spend->GetWitnessHash ()};
157
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend, dust_spend}, dustrelay, pool, child_state, child_wtxid ));
158
158
BOOST_CHECK (!child_state.IsValid ());
159
- BOOST_CHECK_EQUAL (child_txid, dust_non_spend_txid );
159
+ BOOST_CHECK_EQUAL (child_wtxid, dust_non_spend_wtxid );
160
160
child_state = TxValidationState ();
161
- child_txid = Txid ();
161
+ child_wtxid = Wtxid ();
162
162
163
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_spend, dust_non_spend}, dustrelay, pool, child_state, child_txid ));
163
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_spend, dust_non_spend}, dustrelay, pool, child_state, child_wtxid ));
164
164
BOOST_CHECK (!child_state.IsValid ());
165
- BOOST_CHECK_EQUAL (child_txid, dust_non_spend_txid );
165
+ BOOST_CHECK_EQUAL (child_wtxid, dust_non_spend_wtxid );
166
166
child_state = TxValidationState ();
167
- child_txid = Txid ();
167
+ child_wtxid = Wtxid ();
168
168
169
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend}, dustrelay, pool, child_state, child_txid ));
169
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend}, dustrelay, pool, child_state, child_wtxid ));
170
170
BOOST_CHECK (!child_state.IsValid ());
171
- BOOST_CHECK_EQUAL (child_txid, dust_non_spend_txid );
171
+ BOOST_CHECK_EQUAL (child_wtxid, dust_non_spend_wtxid );
172
172
child_state = TxValidationState ();
173
- child_txid = Txid ();
173
+ child_wtxid = Wtxid ();
174
174
175
175
auto grandparent_tx_2 = make_ephemeral_tx (random_outpoints (1 ), /* version=*/ 2 );
176
176
const auto dust_txid_2 = grandparent_tx_2->GetHash ();
177
177
178
178
// Spend dust from one but not another is ok, as long as second grandparent has no child
179
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend}, dustrelay, pool, child_state, child_txid ));
179
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend}, dustrelay, pool, child_state, child_wtxid ));
180
180
BOOST_CHECK (child_state.IsValid ());
181
- BOOST_CHECK_EQUAL (child_txid, Txid ());
181
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
182
182
183
183
auto dust_non_spend_both_parents = make_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX}, COutPoint{dust_txid_2, EPHEMERAL_DUST_INDEX - 1 }}, /* version=*/ 2 );
184
184
// But if we spend from the parent, it must spend dust
185
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_non_spend_both_parents}, dustrelay, pool, child_state, child_txid ));
185
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_non_spend_both_parents}, dustrelay, pool, child_state, child_wtxid ));
186
186
BOOST_CHECK (!child_state.IsValid ());
187
- BOOST_CHECK_EQUAL (child_txid , dust_non_spend_both_parents->GetHash ());
187
+ BOOST_CHECK_EQUAL (child_wtxid , dust_non_spend_both_parents->GetWitnessHash ());
188
188
child_state = TxValidationState ();
189
- child_txid = Txid ();
189
+ child_wtxid = Wtxid ();
190
190
191
191
auto dust_spend_both_parents = make_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX}, COutPoint{dust_txid_2, EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
192
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_both_parents}, dustrelay, pool, child_state, child_txid ));
192
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_both_parents}, dustrelay, pool, child_state, child_wtxid ));
193
193
BOOST_CHECK (child_state.IsValid ());
194
- BOOST_CHECK_EQUAL (child_txid, Txid ());
194
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
195
195
196
196
// Spending other outputs is also correct, as long as the dusty one is spent
197
197
const std::vector<COutPoint> all_outpoints{COutPoint (dust_txid, 0 ), COutPoint (dust_txid, 1 ), COutPoint (dust_txid, 2 ),
198
198
COutPoint (dust_txid_2, 0 ), COutPoint (dust_txid_2, 1 ), COutPoint (dust_txid_2, 2 )};
199
199
auto dust_spend_all_outpoints = make_tx (all_outpoints, /* version=*/ 2 );
200
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_all_outpoints}, dustrelay, pool, child_state, child_txid ));
200
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_all_outpoints}, dustrelay, pool, child_state, child_wtxid ));
201
201
BOOST_CHECK (child_state.IsValid ());
202
- BOOST_CHECK_EQUAL (child_txid, Txid ());
202
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
203
203
204
204
// 2 grandparents with dust <- 1 dust-spending parent with dust <- child with no dust
205
205
auto parent_with_dust = make_ephemeral_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX}, COutPoint{dust_txid_2, EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
206
206
// Ok for parent to have dust
207
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust}, dustrelay, pool, child_state, child_txid ));
207
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust}, dustrelay, pool, child_state, child_wtxid ));
208
208
BOOST_CHECK (child_state.IsValid ());
209
- BOOST_CHECK_EQUAL (child_txid, Txid ());
209
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
210
210
auto child_no_dust = make_tx ({COutPoint{parent_with_dust->GetHash (), EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
211
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_no_dust}, dustrelay, pool, child_state, child_txid ));
211
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_no_dust}, dustrelay, pool, child_state, child_wtxid ));
212
212
BOOST_CHECK (child_state.IsValid ());
213
- BOOST_CHECK_EQUAL (child_txid, Txid ());
213
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
214
214
215
215
// 2 grandparents with dust <- 1 dust-spending parent with dust <- child with dust
216
216
auto child_with_dust = make_ephemeral_tx ({COutPoint{parent_with_dust->GetHash (), EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
217
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_with_dust}, dustrelay, pool, child_state, child_txid ));
217
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_with_dust}, dustrelay, pool, child_state, child_wtxid ));
218
218
BOOST_CHECK (child_state.IsValid ());
219
- BOOST_CHECK_EQUAL (child_txid, Txid ());
219
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
220
220
221
221
// Tests with parents in mempool
222
222
223
223
// Nothing in mempool, this should pass for any transaction
224
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1}, dustrelay, pool, child_state, child_txid ));
224
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_1}, dustrelay, pool, child_state, child_wtxid ));
225
225
BOOST_CHECK (child_state.IsValid ());
226
- BOOST_CHECK_EQUAL (child_txid, Txid ());
226
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
227
227
228
228
// Add first grandparent to mempool and fetch entry
229
229
AddToMempool (pool, entry.FromTx (grandparent_tx_1));
230
230
231
231
// Ignores ancestors that aren't direct parents
232
- BOOST_CHECK (CheckEphemeralSpends ({child_no_dust}, dustrelay, pool, child_state, child_txid ));
232
+ BOOST_CHECK (CheckEphemeralSpends ({child_no_dust}, dustrelay, pool, child_state, child_wtxid ));
233
233
BOOST_CHECK (child_state.IsValid ());
234
- BOOST_CHECK_EQUAL (child_txid, Txid ());
234
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
235
235
236
236
// Valid spend of dust with grandparent in mempool
237
- BOOST_CHECK (CheckEphemeralSpends ({parent_with_dust}, dustrelay, pool, child_state, child_txid ));
237
+ BOOST_CHECK (CheckEphemeralSpends ({parent_with_dust}, dustrelay, pool, child_state, child_wtxid ));
238
238
BOOST_CHECK (child_state.IsValid ());
239
- BOOST_CHECK_EQUAL (child_txid, Txid ());
239
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
240
240
241
241
// Second grandparent in same package
242
- BOOST_CHECK (CheckEphemeralSpends ({parent_with_dust, grandparent_tx_2}, dustrelay, pool, child_state, child_txid ));
242
+ BOOST_CHECK (CheckEphemeralSpends ({parent_with_dust, grandparent_tx_2}, dustrelay, pool, child_state, child_wtxid ));
243
243
BOOST_CHECK (child_state.IsValid ());
244
- BOOST_CHECK_EQUAL (child_txid, Txid ());
244
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
245
245
246
246
// Order in package doesn't matter
247
- BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_2, parent_with_dust}, dustrelay, pool, child_state, child_txid ));
247
+ BOOST_CHECK (CheckEphemeralSpends ({grandparent_tx_2, parent_with_dust}, dustrelay, pool, child_state, child_wtxid ));
248
248
BOOST_CHECK (child_state.IsValid ());
249
- BOOST_CHECK_EQUAL (child_txid, Txid ());
249
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
250
250
251
251
// Add second grandparent to mempool
252
252
AddToMempool (pool, entry.FromTx (grandparent_tx_2));
253
253
254
254
// Only spends single dust out of two direct parents
255
- BOOST_CHECK (!CheckEphemeralSpends ({dust_non_spend_both_parents}, dustrelay, pool, child_state, child_txid ));
255
+ BOOST_CHECK (!CheckEphemeralSpends ({dust_non_spend_both_parents}, dustrelay, pool, child_state, child_wtxid ));
256
256
BOOST_CHECK (!child_state.IsValid ());
257
- BOOST_CHECK_EQUAL (child_txid , dust_non_spend_both_parents->GetHash ());
257
+ BOOST_CHECK_EQUAL (child_wtxid , dust_non_spend_both_parents->GetWitnessHash ());
258
258
child_state = TxValidationState ();
259
- child_txid = Txid ();
259
+ child_wtxid = Wtxid ();
260
260
261
261
// Spends both parents' dust
262
- BOOST_CHECK (CheckEphemeralSpends ({parent_with_dust}, dustrelay, pool, child_state, child_txid ));
262
+ BOOST_CHECK (CheckEphemeralSpends ({parent_with_dust}, dustrelay, pool, child_state, child_wtxid ));
263
263
BOOST_CHECK (child_state.IsValid ());
264
- BOOST_CHECK_EQUAL (child_txid, Txid ());
264
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
265
265
266
266
// Now add dusty parent to mempool
267
267
AddToMempool (pool, entry.FromTx (parent_with_dust));
268
268
269
269
// Passes dust checks even with non-parent ancestors
270
- BOOST_CHECK (CheckEphemeralSpends ({child_no_dust}, dustrelay, pool, child_state, child_txid ));
270
+ BOOST_CHECK (CheckEphemeralSpends ({child_no_dust}, dustrelay, pool, child_state, child_wtxid ));
271
271
BOOST_CHECK (child_state.IsValid ());
272
- BOOST_CHECK_EQUAL (child_txid, Txid ());
272
+ BOOST_CHECK_EQUAL (child_wtxid, Wtxid ());
273
273
}
274
274
275
275
BOOST_FIXTURE_TEST_CASE (version3_tests, RegTestingSetup)
0 commit comments