From 4e68f901390d512a9dfaf0de34daf822449e9bd2 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Tue, 1 Oct 2024 10:28:28 -0400 Subject: [PATCH] rpc: disallow in-mempool prioritisation of dusty tx --- src/rpc/mining.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c1af397872c..006ec3c78c7 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -491,7 +492,15 @@ static RPCHelpMan prioritisetransaction() throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is no longer supported, dummy argument to prioritisetransaction must be 0."); } - EnsureAnyMemPool(request.context).PrioritiseTransaction(hash, nAmount); + CTxMemPool& mempool = EnsureAnyMemPool(request.context); + + // Non-0 fee dust transactions are not allowed for entry, and modification not allowed afterwards + const auto& tx = mempool.get(hash); + if (tx && HasDust(tx, mempool.m_opts.dust_relay_feerate)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is not supported for transactions with dust outputs."); + } + + mempool.PrioritiseTransaction(hash, nAmount); return true; }, };