Skip to content

Commit

Permalink
Make claimpegin fail in the case of a double claim
Browse files Browse the repository at this point in the history
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.
stevenroose committed May 8, 2019

Verified

This commit was signed with the committer’s verified signature.
lucasssvaz Lucas Saavedra Vaz
1 parent af22646 commit 48a82fa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
@@ -5317,6 +5317,15 @@ UniValue claimpegin(const JSONRPCRequest& request)
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
}

// To check if it's not double spending an existing pegin UTXO, we check mempool acceptance.
CValidationState acceptState;
bool accepted = ::AcceptToMemoryPool(mempool, acceptState, MakeTransactionRef(mtx), nullptr /* pfMissingInputs */,
nullptr /* plTxnReplaced */, false /* bypass_limits */, maxTxFee, true /* test_accept */);
if (!accepted) {
std::string strError = strprintf("Error: The transaction was rejected! Reason given: %s", FormatStateMessage(acceptState));
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}

// Send it
CValidationState state;
mapValue_t mapValue;

0 comments on commit 48a82fa

Please sign in to comment.