@@ -886,26 +886,18 @@ static UniValue verifychainlock(const JSONRPCRequest& request)
886886 } else {
887887 nBlockHeight = ParseInt32V (request.params [2 ], " blockHeight" );
888888 LOCK (cs_main);
889- if (nBlockHeight < 0 ) {
889+ if (nBlockHeight < 0 || nBlockHeight > :: ChainActive (). Height () ) {
890890 throw JSONRPCError (RPC_INVALID_PARAMETER, " Block height out of range" );
891891 }
892- if (nBlockHeight <= ::ChainActive ().Height ()) {
893- pIndex = ::ChainActive ()[nBlockHeight];
894- }
892+ pIndex = ::ChainActive ()[nBlockHeight];
895893 }
896894
895+ CHECK_NONFATAL (pIndex != nullptr );
896+
897897 CBLSSignature sig;
898- if (pIndex) {
899- bool use_legacy_signature = !llmq::utils::IsV19Active (pIndex);
900- if (!sig.SetHexStr (request.params [1 ].get_str (), use_legacy_signature)) {
901- throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid signature format" );
902- }
903- } else {
904- if (!sig.SetHexStr (request.params [1 ].get_str (), false ) &&
905- !sig.SetHexStr (request.params [1 ].get_str (), true )
906- ) {
907- throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid signature format" );
908- }
898+ bool use_legacy_signature = !llmq::utils::IsV19Active (pIndex);
899+ if (!sig.SetHexStr (request.params [1 ].get_str (), use_legacy_signature)) {
900+ throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid signature format" );
909901 }
910902
911903 LLMQContext& llmq_ctx = EnsureLLMQContext (request.context );
@@ -961,7 +953,7 @@ static UniValue verifyislock(const JSONRPCRequest& request)
961953 signHeight = pindexMined->nHeight ;
962954 }
963955
964- CBlockIndex* pBlockIndex;
956+ CBlockIndex* pBlockIndex{ nullptr } ;
965957 {
966958 LOCK (cs_main);
967959 if (signHeight == -1 ) {
@@ -971,17 +963,12 @@ static UniValue verifyislock(const JSONRPCRequest& request)
971963 }
972964 }
973965
966+ CHECK_NONFATAL (pBlockIndex != nullptr );
967+
974968 CBLSSignature sig;
975- if (pindexMined != nullptr ) {
976- const bool use_bls_legacy = !llmq::utils::IsV19Active (pindexMined);
977- if (!sig.SetHexStr (request.params [2 ].get_str (), use_bls_legacy)) {
978- throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid signature format" );
979- }
980- } else {
981- if (!sig.SetHexStr (request.params [2 ].get_str (), false ) &&
982- !sig.SetHexStr (request.params [2 ].get_str (), true )) {
983- throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid signature format" );
984- }
969+ const bool use_bls_legacy = !llmq::utils::IsV19Active (pBlockIndex);
970+ if (!sig.SetHexStr (request.params [2 ].get_str (), use_bls_legacy)) {
971+ throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid signature format" );
985972 }
986973
987974 LLMQContext& llmq_ctx = EnsureLLMQContext (request.context );
0 commit comments