mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #12356: Fix 'mempool min fee not met' debug output
bb00c95
Consistently use FormatStateMessage in RPC error output (Ben Woosley)8b8a1c4
Add test for 'mempool min fee not met' rpc error (Ben Woosley)c04e0f6
Fix 'mempool min fee not met' debug output (Ben Woosley) Pull request description: Output the value that is tested, rather than the unmodified fee value. Prompted by looking into: #11955 Tree-SHA512: fc0bad47d4af375d208f657a6ccbad6ef7f4e2989ae2ce1171226c22fa92847494a2c55cca687bd5a1548663ed3313569bcc31c00d53c0c193a1b865dd8a7657
This commit is contained in:
parent
7e426dcf0f
commit
831ff51a7f
@ -1723,7 +1723,7 @@ UniValue preciousblock(const JSONRPCRequest& request)
|
||||
PreciousBlock(state, Params(), pblockindex);
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state));
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
@ -1761,7 +1761,7 @@ UniValue invalidateblock(const JSONRPCRequest& request)
|
||||
}
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state));
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
@ -1798,7 +1798,7 @@ UniValue reconsiderblock(const JSONRPCRequest& request)
|
||||
ActivateBestChain(state, Params());
|
||||
|
||||
if (!state.IsValid()) {
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state));
|
||||
}
|
||||
|
||||
return NullUniValue;
|
||||
|
@ -270,11 +270,11 @@ static UniValue BIP22ValidationResult(const CValidationState& state)
|
||||
if (state.IsValid())
|
||||
return NullUniValue;
|
||||
|
||||
std::string strRejectReason = state.GetRejectReason();
|
||||
if (state.IsError())
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, strRejectReason);
|
||||
throw JSONRPCError(RPC_VERIFY_ERROR, FormatStateMessage(state));
|
||||
if (state.IsInvalid())
|
||||
{
|
||||
std::string strRejectReason = state.GetRejectReason();
|
||||
if (strRejectReason.empty())
|
||||
return "rejected";
|
||||
return strRejectReason;
|
||||
|
@ -1015,12 +1015,12 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
if (!AcceptToMemoryPool(mempool, state, std::move(tx), &fMissingInputs,
|
||||
fBypassLimits /* bypass_limits */, nMaxRawTxFee)) {
|
||||
if (state.IsInvalid()) {
|
||||
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
|
||||
throw JSONRPCError(RPC_TRANSACTION_REJECTED, FormatStateMessage(state));
|
||||
} else {
|
||||
if (fMissingInputs) {
|
||||
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Missing inputs");
|
||||
}
|
||||
throw JSONRPCError(RPC_TRANSACTION_ERROR, state.GetRejectReason());
|
||||
throw JSONRPCError(RPC_TRANSACTION_ERROR, FormatStateMessage(state));
|
||||
}
|
||||
} else {
|
||||
// If wallet is enabled, ensure that the wallet has been made aware
|
||||
|
@ -770,7 +770,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
|
||||
|
||||
CAmount mempoolRejectFee = pool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nSize);
|
||||
if (!bypass_limits && mempoolRejectFee > 0 && nModifiedFees < mempoolRejectFee) {
|
||||
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
|
||||
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nModifiedFees, mempoolRejectFee));
|
||||
}
|
||||
|
||||
// No transactions are allowed below minRelayTxFee except from disconnected blocks
|
||||
|
@ -416,7 +416,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
|
||||
}
|
||||
CValidationState state;
|
||||
if (!pwallet->CommitTransaction(wtxNew, reservekey, g_connman.get(), state)) {
|
||||
strError = strprintf("Error: The transaction was rejected! Reason given: %s", state.GetRejectReason());
|
||||
strError = strprintf("Error: The transaction was rejected! Reason given: %s", FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||
}
|
||||
}
|
||||
@ -1198,7 +1198,7 @@ UniValue sendmany(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
|
||||
CValidationState state;
|
||||
if (!pwallet->CommitTransaction(wtx, keyChange, g_connman.get(), state)) {
|
||||
strFailReason = strprintf("Transaction commit failed:: %s", state.GetRejectReason());
|
||||
strFailReason = strprintf("Transaction commit failed:: %s", FormatStateMessage(state));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
|
||||
}
|
||||
|
||||
|
@ -4099,7 +4099,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon
|
||||
{
|
||||
// Broadcast
|
||||
if (!wtx.AcceptToMemoryPool(maxTxFee, state)) {
|
||||
LogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", state.GetRejectReason());
|
||||
LogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", FormatStateMessage(state));
|
||||
// TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
|
||||
} else {
|
||||
wtx.RelayWalletTransaction(connman);
|
||||
|
@ -50,5 +50,15 @@ class MempoolLimitTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[0].getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
|
||||
assert_greater_than(self.nodes[0].getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
|
||||
|
||||
self.log.info('Create a mempool tx that will not pass mempoolminfee')
|
||||
us0 = utxos.pop()
|
||||
inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}]
|
||||
outputs = {self.nodes[0].getnewaddress() : 0.0001}
|
||||
tx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
# specifically fund this tx with a fee < mempoolminfee, >= than minrelaytxfee
|
||||
txF = self.nodes[0].fundrawtransaction(tx, {'feeRate': relayfee})
|
||||
txFS = self.nodes[0].signrawtransaction(txF['hex'])
|
||||
assert_raises_rpc_error(-26, "mempool min fee not met, 166 < 411 (code 66)", self.nodes[0].sendrawtransaction, txFS['hex'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
MempoolLimitTest().main()
|
||||
|
@ -20,7 +20,7 @@ from test_framework.blocktools import create_coinbase, create_block
|
||||
from test_framework.script import CScript
|
||||
from io import BytesIO
|
||||
|
||||
NULLDUMMY_ERROR = "64: non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"
|
||||
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero) (code 64)"
|
||||
|
||||
def trueDummy(tx):
|
||||
scriptSig = CScript(tx.vin[0].scriptSig)
|
||||
|
@ -116,7 +116,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||
tx_id = self.nodes[0].decoderawtransaction(tx_hex)["txid"]
|
||||
|
||||
# This will raise an exception due to min relay fee not being met
|
||||
assert_raises_rpc_error(-26, "66: min relay fee not met", self.nodes[0].sendrawtransaction, tx_hex)
|
||||
assert_raises_rpc_error(-26, "min relay fee not met (code 66)", self.nodes[0].sendrawtransaction, tx_hex)
|
||||
assert(tx_id not in self.nodes[0].getrawmempool())
|
||||
|
||||
# This is a less than 1000-byte transaction, so just set the fee
|
||||
|
Loading…
Reference in New Issue
Block a user