From #19093 and resolves #19057.
Difference from #19093: return vsize
and fees
object (similar to getmempoolentry
) when the test accept is successful. Updates release-notes.md.
101@@ -102,6 +102,9 @@ will trigger BIP 125 (replace-by-fee) opt-in. (#11413)
102 option `-deprecatedrpc=banscore` is used. The `banscore` field will be fully
103 removed in the next major release. (#19469)
104
105+- The `testmempoolaccept` RPC returns `vsize` and a `fee` object with the `base` fee
106+ if the transaction passes validation. (#19093)
91@@ -91,7 +92,7 @@ def run_test(self):
92 tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0)))
93 txid_0 = tx.rehash()
94 self.check_mempool_result(
95- result_expected=[{'txid': txid_0, 'allowed': True}],
96+ result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': 110, 'fees': {'base': Decimal(str(fee))}}],
104@@ -104,7 +105,7 @@ def run_test(self):
105 ))['hex']
106 tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
107 self.check_mempool_result(
108- result_expected=[{'txid': tx.rehash(), 'allowed': True}],
109+ result_expected=[{'txid': tx.rehash(), 'allowed': True, 'vsize': 188, 'fees': { 'base': Decimal(str(int(coin['amount']) - 0.025))}}],
877@@ -878,6 +878,11 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
878 {
879 {RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
880 {RPCResult::Type::BOOL, "allowed", "If the mempool allows this tx to be inserted"},
881+ {RPCResult::Type::NUM, "vsize", "virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted."},
utACK 4943a1392c33cd5ac985e753d9cc728b794c5752
I agree that tests could be better but I would also be fine with merging as is.
Return fee and vsize if tx would pass ATMP.
ACK https://github.com/bitcoin/bitcoin/pull/19940/commits/418958892d22b552c44f7801fd2f233c92b8f5a8
thanks it’s a solid improvement for the next contributor wanting to touch it :)
105- outputs=[{node.getnewaddress(): 0.025}],
106+ outputs=[{node.getnewaddress(): output_amount}],
107 locktime=node.getblockcount() + 2000, # Can be anything
108 ))['hex']
109 tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
110+ fee_expected = int(coin['amount']) - output_amount
91@@ -91,20 +92,22 @@ def run_test(self):
92 tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0)))
93 txid_0 = tx.rehash()
94 self.check_mempool_result(
95- result_expected=[{'txid': txid_0, 'allowed': True}],
96+ result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal(str(fee))}}],
fee
was made a Decimal
as opposed to float
when defined?
108 ))['hex']
109 tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
110+ fee_expected = int(coin['amount']) - output_amount
111 self.check_mempool_result(
112- result_expected=[{'txid': tx.rehash(), 'allowed': True}],
113+ result_expected=[{'txid': tx.rehash(), 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal(str(fee_expected))}}],
Same
(This is my fault for using float in the first place, but now that Decimal is imported, might as well use it everywhere)