@@ -226,6 +226,16 @@ def run_test(self):
226
226
assert tx .wit .is_null () # This should not be a segwit input
227
227
assert txid1 in self .nodes [0 ].getrawmempool ()
228
228
229
+ tx1_hex = self .nodes [0 ].gettransaction (txid1 )['hex' ]
230
+ tx1 = FromHex (CTransaction (), tx1_hex )
231
+
232
+ # Check that wtxid is properly reported in mempool entry (txid1)
233
+ assert_equal (int (self .nodes [0 ].getmempoolentry (txid1 )["wtxid" ], 16 ), tx1 .calc_sha256 (True ))
234
+
235
+ # Check that weight and vsize are properly reported in mempool entry (txid1)
236
+ assert_equal (self .nodes [0 ].getmempoolentry (txid1 )["vsize" ], (self .nodes [0 ].getmempoolentry (txid1 )["weight" ] + 3 ) // 4 )
237
+ assert_equal (self .nodes [0 ].getmempoolentry (txid1 )["weight" ], len (tx1 .serialize_without_witness ())* 3 + len (tx1 .serialize_with_witness ()))
238
+
229
239
# Now create tx2, which will spend from txid1.
230
240
tx = CTransaction ()
231
241
tx .vin .append (CTxIn (COutPoint (int (txid1 , 16 ), 0 ), b'' ))
@@ -235,6 +245,13 @@ def run_test(self):
235
245
tx = FromHex (CTransaction (), tx2_hex )
236
246
assert not tx .wit .is_null ()
237
247
248
+ # Check that wtxid is properly reported in mempool entry (txid2)
249
+ assert_equal (int (self .nodes [0 ].getmempoolentry (txid2 )["wtxid" ], 16 ), tx .calc_sha256 (True ))
250
+
251
+ # Check that weight and vsize are properly reported in mempool entry (txid2)
252
+ assert_equal (self .nodes [0 ].getmempoolentry (txid2 )["vsize" ], (self .nodes [0 ].getmempoolentry (txid2 )["weight" ] + 3 ) // 4 )
253
+ assert_equal (self .nodes [0 ].getmempoolentry (txid2 )["weight" ], len (tx .serialize_without_witness ())* 3 + len (tx .serialize_with_witness ()))
254
+
238
255
# Now create tx3, which will spend from txid2
239
256
tx = CTransaction ()
240
257
tx .vin .append (CTxIn (COutPoint (int (txid2 , 16 ), 0 ), b"" ))
@@ -251,9 +268,13 @@ def run_test(self):
251
268
assert txid2 in template_txids
252
269
assert txid3 in template_txids
253
270
254
- # Check that wtxid is properly reported in mempool entry
271
+ # Check that wtxid is properly reported in mempool entry (txid3)
255
272
assert_equal (int (self .nodes [0 ].getmempoolentry (txid3 )["wtxid" ], 16 ), tx .calc_sha256 (True ))
256
273
274
+ # Check that weight and vsize are properly reported in mempool entry (txid3)
275
+ assert_equal (self .nodes [0 ].getmempoolentry (txid3 )["vsize" ], (self .nodes [0 ].getmempoolentry (txid3 )["weight" ] + 3 ) // 4 )
276
+ assert_equal (self .nodes [0 ].getmempoolentry (txid3 )["weight" ], len (tx .serialize_without_witness ())* 3 + len (tx .serialize_with_witness ()))
277
+
257
278
# Mine a block to clear the gbt cache again.
258
279
self .nodes [0 ].generate (1 )
259
280
0 commit comments