mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
rpc: add vsize_adjusted and vsize_bip141 field to mempool-related RPCs
This commit adds a new `vsize_adjusted` and `vsize_bip141` field to mempool acceptance and submission RPCs, including `testmempoolaccept` and `submitpackage`, to report the sigop-adjusted virtual transaction size and virtual transaction size as defined in BIP 141 respectively. While `vsize` is now marked as deprecated. RPC help texts are updated to reflect this addition. Tests in `mempool_accept.py, mempool_accept, p2p_segwit, rpc_packages, mempool_sigoplimit` are extended to verify the presence and correctness of the new fields. Co-authored-by: Gloria Zhao <gloriajzhao@gmail.com>
This commit is contained in:
@@ -136,7 +136,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
raw_tx_0 = tx.serialize().hex()
|
||||
txid_0 = tx.txid_hex
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': fee}}],
|
||||
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize_adjusted': tx.get_vsize(), 'vsize': tx.get_vsize(), 'vsize_bip141': tx.get_vsize(),'fees': {'base': fee}}],
|
||||
rawtxs=[raw_tx_0],
|
||||
)
|
||||
|
||||
@@ -151,7 +151,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
tx = tx_from_hex(raw_tx_final)
|
||||
fee_expected = Decimal('50.0') - output_amount
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': fee_expected}}],
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize_adjusted': tx.get_vsize(), 'vsize': tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), 'fees': {'base': fee_expected}}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
maxfeerate=0,
|
||||
)
|
||||
@@ -172,7 +172,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
raw_tx_0 = tx.serialize().hex()
|
||||
txid_0 = tx.txid_hex
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': (2 * fee)}}],
|
||||
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize_adjusted': tx.get_vsize(), 'vsize': tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), 'fees': {'base': (2 * fee)}}],
|
||||
rawtxs=[raw_tx_0],
|
||||
)
|
||||
node.sendrawtransaction(hexstring=tx.serialize().hex(), maxfeerate=0)
|
||||
@@ -218,7 +218,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
raw_tx_reference = tx.serialize().hex()
|
||||
# Reference tx should be valid on itself
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': { 'base': Decimal('0.1') - Decimal('0.05')}}],
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize_adjusted': tx.get_vsize(), 'vsize': tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), 'fees': { 'base': Decimal('0.1') - Decimal('0.05')}}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
maxfeerate=0,
|
||||
)
|
||||
@@ -354,7 +354,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
tx.vout.append(CTxOut(0, CScript([OP_RETURN, b'\xff' * 50000])))
|
||||
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal('0.05')}}],
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize_adjusted': tx.get_vsize(), 'vsize': tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), 'fees': {'base': Decimal('0.05')}}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
maxfeerate=0
|
||||
)
|
||||
@@ -366,7 +366,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
tx.vout[0].scriptPubKey = CScript([OP_RETURN, b'\xff'])
|
||||
tx.vout = [tx.vout[0]] * op_return_count
|
||||
self.check_mempool_result(
|
||||
result_expected=[{"txid": tx.txid_hex, "allowed": True, "vsize": tx.get_vsize(), "fees": {"base": Decimal("0.05000026")}}],
|
||||
result_expected=[{"txid": tx.txid_hex, "allowed": True, "vsize_adjusted": tx.get_vsize(), "vsize": tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), "fees": {"base": Decimal("0.05000026")}}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
)
|
||||
|
||||
@@ -377,7 +377,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
tx.vout[0].scriptPubKey = CScript([OP_RETURN, b"\xff" * (data_len)])
|
||||
assert_equal(tx.get_vsize(), int(MAX_STANDARD_TX_WEIGHT / 4))
|
||||
self.check_mempool_result(
|
||||
result_expected=[{"txid": tx.txid_hex, "allowed": True, "vsize": tx.get_vsize(), "fees": {"base": Decimal("0.1") - Decimal("0.05")}}],
|
||||
result_expected=[{"txid": tx.txid_hex, "allowed": True, "vsize_adjusted": tx.get_vsize(), "vsize": tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), "fees": {"base": Decimal("0.1") - Decimal("0.05")}}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
)
|
||||
tx.vout[0].scriptPubKey = CScript([OP_RETURN, b"\xff" * (data_len + 1)])
|
||||
@@ -430,7 +430,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
tx.vout[0] = CTxOut(COIN - 1000, DUMMY_MIN_OP_RETURN_SCRIPT)
|
||||
assert_equal(len(tx.serialize_without_witness()), MIN_STANDARD_TX_NONWITNESS_SIZE)
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': { 'base': Decimal('0.00001000')}}],
|
||||
result_expected=[{'txid': tx.txid_hex, 'allowed': True, 'vsize_adjusted': tx.get_vsize(), 'vsize': tx.get_vsize(), 'vsize_bip141': tx.get_vsize(), 'fees': { 'base': Decimal('0.00001000')}}],
|
||||
rawtxs=[tx.serialize().hex()],
|
||||
maxfeerate=0,
|
||||
)
|
||||
@@ -468,7 +468,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
assert_equal(anchor_spend.txid_hex, anchor_spend.wtxid_hex)
|
||||
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': anchor_spend.txid_hex, 'allowed': True, 'vsize': anchor_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
|
||||
result_expected=[{'txid': anchor_spend.txid_hex, 'allowed': True, 'vsize_adjusted': anchor_spend.get_vsize(), 'vsize': anchor_spend.get_vsize(), 'vsize_bip141': anchor_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
|
||||
rawtxs=[anchor_spend.serialize().hex()],
|
||||
maxfeerate=0,
|
||||
)
|
||||
@@ -503,7 +503,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||
sign_input_legacy(tx_spend, 0, tx.vout[0].scriptPubKey, privkey, sighash_type=SIGHASH_ALL)
|
||||
tx_spend.vin[0].scriptSig = bytes(CScript([OP_0])) + tx_spend.vin[0].scriptSig
|
||||
self.check_mempool_result(
|
||||
result_expected=[{'txid': tx_spend.txid_hex, 'allowed': True, 'vsize': tx_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
|
||||
result_expected=[{'txid': tx_spend.txid_hex, 'allowed': True, 'vsize_adjusted': tx_spend.get_vsize(), 'vsize': tx_spend.get_vsize(), 'vsize_bip141': tx_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
|
||||
rawtxs=[tx_spend.serialize().hex()],
|
||||
maxfeerate=0,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user