diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -278,9 +278,13 @@ iscbparam.isNull() ? false : iscbparam.get_bool(); CKey key = DecodeSecret(find_value(stake, "privatekey").get_str()); + if (!key.IsValid()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid private key"); + } + if (!pb.addUTXO(utxo, amount, uint32_t(height), iscoinbase, std::move(key))) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid private key"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Duplicated stake"); } } diff --git a/test/functional/abc_rpc_buildavalancheproof.py b/test/functional/abc_rpc_buildavalancheproof.py --- a/test/functional/abc_rpc_buildavalancheproof.py +++ b/test/functional/abc_rpc_buildavalancheproof.py @@ -82,6 +82,12 @@ [invalid_privkey], ) + duplicate_stake = [good_stake] * 2 + check_buildavalancheproof_error(-8, + "Duplicated stake", + duplicate_stake, + ) + self.log.info("Happy path") assert node.buildavalancheproof(0, 0, proof_master, [good_stake])