mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
rpc: Fixed signed integer overflow for large feerates
This commit is contained in:
parent
fade94d11a
commit
fa2a4fdef7
2 changed files with 10 additions and 6 deletions
|
@ -81,9 +81,7 @@ static RPCHelpMan sendrawtransaction()
|
||||||
|
|
||||||
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
||||||
|
|
||||||
const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
|
const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>(1))};
|
||||||
DEFAULT_MAX_RAW_TX_FEE_RATE :
|
|
||||||
CFeeRate(AmountFromValue(request.params[1]));
|
|
||||||
|
|
||||||
int64_t virtual_size = GetVirtualTransactionSize(*tx);
|
int64_t virtual_size = GetVirtualTransactionSize(*tx);
|
||||||
CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
|
CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
|
||||||
|
@ -162,9 +160,7 @@ static RPCHelpMan testmempoolaccept()
|
||||||
"Array must contain between 1 and " + ToString(MAX_PACKAGE_COUNT) + " transactions.");
|
"Array must contain between 1 and " + ToString(MAX_PACKAGE_COUNT) + " transactions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
|
const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>(1))};
|
||||||
DEFAULT_MAX_RAW_TX_FEE_RATE :
|
|
||||||
CFeeRate(AmountFromValue(request.params[1]));
|
|
||||||
|
|
||||||
std::vector<CTransactionRef> txns;
|
std::vector<CTransactionRef> txns;
|
||||||
txns.reserve(raw_transactions.size());
|
txns.reserve(raw_transactions.size());
|
||||||
|
|
|
@ -90,9 +90,17 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
txid_in_block = self.wallet.sendrawtransaction(from_node=node, tx_hex=raw_tx_in_block)
|
txid_in_block = self.wallet.sendrawtransaction(from_node=node, tx_hex=raw_tx_in_block)
|
||||||
self.generate(node, 1)
|
self.generate(node, 1)
|
||||||
self.mempool_size = 0
|
self.mempool_size = 0
|
||||||
|
# Also check feerate. 1BTC/kvB fails
|
||||||
|
assert_raises_rpc_error(-8, "Fee rates larger than or equal to 1BTC/kvB are not accepted", lambda: self.check_mempool_result(
|
||||||
|
result_expected=None,
|
||||||
|
rawtxs=[raw_tx_in_block],
|
||||||
|
maxfeerate=1,
|
||||||
|
))
|
||||||
|
# ... 0.99 passes
|
||||||
self.check_mempool_result(
|
self.check_mempool_result(
|
||||||
result_expected=[{'txid': txid_in_block, 'allowed': False, 'reject-reason': 'txn-already-known'}],
|
result_expected=[{'txid': txid_in_block, 'allowed': False, 'reject-reason': 'txn-already-known'}],
|
||||||
rawtxs=[raw_tx_in_block],
|
rawtxs=[raw_tx_in_block],
|
||||||
|
maxfeerate=0.99,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info('A transaction not in the mempool')
|
self.log.info('A transaction not in the mempool')
|
||||||
|
|
Loading…
Add table
Reference in a new issue