From cc8880ec274d1cca7d0e5fa3d5e95403673dd8e8 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:03:41 -0400 Subject: [PATCH] llmq/rpc: Adjust verify islock, don't err when transaction isn't known locally (#4106) * llmq/rpc: Adjust verify islock, don't err when transaction isn't known locally * combine two ifs Co-authored-by: UdjinM6 * tests: Verify islocks for unknown txes Co-authored-by: UdjinM6 --- src/rpc/rpcquorums.cpp | 8 +------- test/functional/rpc_verifyislock.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/rpc/rpcquorums.cpp b/src/rpc/rpcquorums.cpp index f661068769..793832ddf6 100644 --- a/src/rpc/rpcquorums.cpp +++ b/src/rpc/rpcquorums.cpp @@ -687,13 +687,7 @@ UniValue verifyislock(const JSONRPCRequest& request) LOCK(cs_main); CTransactionRef tx; uint256 hash_block; - if (!GetTransaction(txid, tx, Params().GetConsensus(), hash_block, true)) { - std::string errmsg = fTxIndex - ? "No such mempool or blockchain transaction" - : "No such mempool transaction. Use -txindex to enable blockchain transaction queries"; - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, errmsg); - } - if (!hash_block.IsNull()) { + if (GetTransaction(txid, tx, Params().GetConsensus(), hash_block, true) && !hash_block.IsNull()) { pindexMined = LookupBlockIndex(hash_block); } } diff --git a/test/functional/rpc_verifyislock.py b/test/functional/rpc_verifyislock.py index b7e34b5d30..04f261dedc 100755 --- a/test/functional/rpc_verifyislock.py +++ b/test/functional/rpc_verifyislock.py @@ -5,7 +5,7 @@ from test_framework.messages import CTransaction, FromHex, hash256, ser_compact_size, ser_string from test_framework.test_framework import DashTestFramework -from test_framework.util import bytes_to_hex_str, satoshi_round, wait_until +from test_framework.util import assert_raises_rpc_error, bytes_to_hex_str, satoshi_round, wait_until ''' rpc_verifyislock.py @@ -83,9 +83,14 @@ class RPCVerifyISLockTest(DashTestFramework): assert selected_hash == oldest_quorum_hash # Create the ISLOCK, then mine a quorum to move the signing quorum out of the active set islock = self.create_islock(rawtx) + # Mine one block to trigger the "signHeight + dkgInterval" verification for the ISLOCK self.mine_quorum() - # Send the tx and verify the ISLOCK. This triggers the "signHeight + dkgInterval" verification - rawtx_txid = node.sendrawtransaction(rawtx) + # Verify the ISLOCK for a transaction that is not yet known by the node + rawtx_txid = node.decoderawtransaction(rawtx)["txid"] + assert_raises_rpc_error(-5, "No such mempool or blockchain transaction", node.getrawtransaction, rawtx_txid) + assert node.verifyislock(request_id, rawtx_txid, bytes_to_hex_str(islock.sig), node.getblockcount()) + # Send the tx and verify the ISLOCK for a now known transaction + assert rawtx_txid == node.sendrawtransaction(rawtx) assert node.verifyislock(request_id, rawtx_txid, bytes_to_hex_str(islock.sig), node.getblockcount())