Skip to content

Commit d8f803a

Browse files
committed
[BUG][RPC] Add missing lock in sendrawtransaction
1 parent 98c6183 commit d8f803a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,17 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
863863
}
864864
CValidationState state;
865865
bool fMissingInputs;
866-
if (!AcceptToMemoryPool(mempool, state, MakeTransactionRef(std::move(tx)), false, &fMissingInputs, false, !fOverrideFees)) {
867-
if (state.IsInvalid()) {
868-
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
869-
} else {
870-
if (fMissingInputs) {
871-
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Missing inputs");
866+
{
867+
LOCK(cs_main);
868+
if (!AcceptToMemoryPool(mempool, state, MakeTransactionRef(std::move(tx)), false, &fMissingInputs, false, !fOverrideFees)) {
869+
if (state.IsInvalid()) {
870+
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
871+
} else {
872+
if (fMissingInputs) {
873+
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Missing inputs");
874+
}
875+
throw JSONRPCError(RPC_TRANSACTION_ERROR, state.GetRejectReason());
872876
}
873-
throw JSONRPCError(RPC_TRANSACTION_ERROR, state.GetRejectReason());
874877
}
875878
}
876879
} else if (fHaveChain) {

0 commit comments

Comments
 (0)