Skip to content

Commit 48a82fa

Browse files
committed
Make claimpegin fail in the case of a double claim
Currently it will commit to the transaction without it being able to enter the mempool. This makes the block creation code include the tx into the block and create an invalid block.
1 parent af22646 commit 48a82fa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,6 +5317,15 @@ UniValue claimpegin(const JSONRPCRequest& request)
53175317
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
53185318
}
53195319

5320+
// To check if it's not double spending an existing pegin UTXO, we check mempool acceptance.
5321+
CValidationState acceptState;
5322+
bool accepted = ::AcceptToMemoryPool(mempool, acceptState, MakeTransactionRef(mtx), nullptr /* pfMissingInputs */,
5323+
nullptr /* plTxnReplaced */, false /* bypass_limits */, maxTxFee, true /* test_accept */);
5324+
if (!accepted) {
5325+
std::string strError = strprintf("Error: The transaction was rejected! Reason given: %s", FormatStateMessage(acceptState));
5326+
throw JSONRPCError(RPC_WALLET_ERROR, strError);
5327+
}
5328+
53205329
// Send it
53215330
CValidationState state;
53225331
mapValue_t mapValue;

0 commit comments

Comments
 (0)