Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
251assert_equal(self.nodes[0].getmempoolentry(txid1)["vsize"], tx1.get_vsize())252assert_equal(self.nodes[0].getmempoolentry(txid1)["weight"], tx1.get_weight())254# Now create tx2, which will spend from txid1.255tx = CTransaction()256tx.vin.append(CTxIn(COutPoint(int(txid1, 16), 0), b''))257tx.vout.append(CTxOut(int(49.99 * COIN), CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE])))258tx2_hex = self.nodes[0].signrawtransactionwithwallet(tx.serialize().hex())['hex']259txid2 = self.nodes[0].sendrawtransaction(tx2_hex)260tx = tx_from_hex(tx2_hex)261assert not tx.wit.is_null()263# Check that wtxid is properly reported in mempool entry (txid2)264assert_equal(self.nodes[0].getmempoolentry(txid2)["wtxid"], tx.wtxid_hex)266# Check that weight and vsize are properly reported in mempool entry (txid2)267assert_equal(self.nodes[0].getmempoolentry(txid2)["vsize"], tx.get_vsize())268assert_equal(self.nodes[0].getmempoolentry(txid2)["weight"], tx.get_weight())270# Now create tx3, which will spend from txid2271tx = CTransaction()272tx.vin.append(CTxIn(COutPoint(int(txid2, 16), 0), b""))273tx.vout.append(CTxOut(int(49.95 * COIN), CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))) # Huge fee274txid3 = self.nodes[0].sendrawtransaction(hexstring=tx.serialize().hex(), maxfeerate=0)275assert tx.wit.is_null()276assert txid3 in self.nodes[0].getrawmempool()278# Check that getblocktemplate includes all transactions.279template = self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)280template_txids = [t['txid'] for t in template['transactions']]281assert txid1 in template_txids282assert txid2 in template_txids283assert txid3 in template_txids285# Check that wtxid is properly reported in mempool entry (txid3)286assert_equal(self.nodes[0].getmempoolentry(txid3)["wtxid"], tx.wtxid_hex)288# Check that weight and vsize are properly reported in mempool entry (txid3)289assert_equal(self.nodes[0].getmempoolentry(txid3)["vsize"], tx.get_vsize())290assert_equal(self.nodes[0].getmempoolentry(txid3)["weight"], tx.get_weight())292# Mine a block to clear the gbt cache again.293self.generate(self.nodes[0], 1)296if __name__ == '__main__':297SegWitTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.