mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 00:34:01 +02:00
Merge bitcoin/bitcoin#28950: RPC: Add maxfeerate and maxburnamount args to submitpackage
38f70ba6acRPC: Add maxfeerate and maxburnamount args to submitpackage (Greg Sanders) Pull request description: Resolves https://github.com/bitcoin/bitcoin/issues/28949 I couldn't manage to do it very cleanly outside of (sub)package evaluation itself, since it would change the current interface very heavily. Instead I threaded through the max fee argument and used that directly via ATMPArgs. From that perspective, this is somewhat a reversion from https://github.com/bitcoin/bitcoin/pull/19339. In a post-cluster mempool world, these checks could be consolidated to right after the given (ancestor) package is linearized/chunked, by just checking the feerate of the top chunk and rejecting the submission entirely if the top chunk is too high. The implication here is that subpackages can be submitted to the mempool prior to hitting this new fee-based error condition. ACKs for top commit: ismaelsadeeq: Re-ACK38f70ba6ac👍🏾 glozow: ACK38f70ba6acwith some non-blocking nits murchandamus: LGTM, code review ACK38f70ba6acTree-SHA512: 38212aa9de25730944cee58b0806a3d37097e42719af8dd7de91ce86bb5d9770b6f7c37354bf418bd8ba571c52947da1dcdbb968bf429dd1dbdf8715315af18f
This commit is contained in:
@@ -82,6 +82,7 @@ class RPCPackagesTest(BitcoinTestFramework):
|
||||
self.test_conflicting()
|
||||
self.test_rbf()
|
||||
self.test_submitpackage()
|
||||
self.test_maxfeerate_maxburn_submitpackage()
|
||||
|
||||
def test_independent(self, coin):
|
||||
self.log.info("Test multiple independent transactions in a package")
|
||||
@@ -357,5 +358,34 @@ class RPCPackagesTest(BitcoinTestFramework):
|
||||
assert_equal(res["tx-results"][sec_wtxid]["error"], "version")
|
||||
peer.wait_for_broadcast([first_wtxid])
|
||||
|
||||
def test_maxfeerate_maxburn_submitpackage(self):
|
||||
node = self.nodes[0]
|
||||
# clear mempool
|
||||
deterministic_address = node.get_deterministic_priv_key().address
|
||||
self.generatetoaddress(node, 1, deterministic_address)
|
||||
|
||||
self.log.info("Submitpackage maxfeerate arg testing")
|
||||
chained_txns = self.wallet.create_self_transfer_chain(chain_length=2)
|
||||
minrate_btc_kvb = min([chained_txn["fee"] / chained_txn["tx"].get_vsize() * 1000 for chained_txn in chained_txns])
|
||||
chain_hex = [t["hex"] for t in chained_txns]
|
||||
pkg_result = node.submitpackage(chain_hex, maxfeerate=minrate_btc_kvb - Decimal("0.00000001"))
|
||||
assert_equal(pkg_result["tx-results"][chained_txns[0]["wtxid"]]["error"], "max feerate exceeded")
|
||||
assert_equal(pkg_result["tx-results"][chained_txns[1]["wtxid"]]["error"], "bad-txns-inputs-missingorspent")
|
||||
assert_equal(node.getrawmempool(), [])
|
||||
|
||||
self.log.info("Submitpackage maxburnamount arg testing")
|
||||
tx = tx_from_hex(chain_hex[1])
|
||||
tx.vout[-1].scriptPubKey = b'a' * 10001 # scriptPubKey bigger than 10k IsUnspendable
|
||||
chain_hex = [chain_hex[0], tx.serialize().hex()]
|
||||
# burn test is run before any package evaluation; nothing makes it in and we get broader exception
|
||||
assert_raises_rpc_error(-25, "Unspendable output exceeds maximum configured by user", node.submitpackage, chain_hex, 0, chained_txns[1]["new_utxo"]["value"] - Decimal("0.00000001"))
|
||||
assert_equal(node.getrawmempool(), [])
|
||||
|
||||
# Relax the restrictions for both and send it; parent gets through as own subpackage
|
||||
pkg_result = node.submitpackage(chain_hex, maxfeerate=minrate_btc_kvb, maxburnamount=chained_txns[1]["new_utxo"]["value"])
|
||||
assert "error" not in pkg_result["tx-results"][chained_txns[0]["wtxid"]]
|
||||
assert_equal(pkg_result["tx-results"][tx.getwtxid()]["error"], "scriptpubkey")
|
||||
assert_equal(node.getrawmempool(), [chained_txns[0]["txid"]])
|
||||
|
||||
if __name__ == "__main__":
|
||||
RPCPackagesTest().main()
|
||||
|
||||
Reference in New Issue
Block a user