Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,13 @@ bool AppInitParameterInteraction(const ArgsManager& args)
}
}

// Governance needs the transaction index to look up proposal collateral transactions
if (!args.GetBoolArg("-disablegovernance", !DEFAULT_GOVERNANCE_ENABLE) &&
!args.GetBoolArg("-txindex", DEFAULT_TXINDEX) && chainparams.NetworkIDString() != CBaseChainParams::REGTEST) {
return InitError(_("Transaction index can't be disabled with governance validation enabled. Either start with "
"-disablegovernance command line switch or enable transaction index."));
}

if (args.GetBoolArg("-disablegovernance", !DEFAULT_GOVERNANCE_ENABLE)) {
InitWarning(_("You are starting with governance validation disabled.") +
(fPruneMode ?
Expand Down
35 changes: 35 additions & 0 deletions test/functional/feature_governance_txindex_devnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# Copyright (c) 2026 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test that a node refuses to run governance validation without the transaction index outside regtest.

Regtest exempts nodes from this check, so it is exercised on devnet here.
"""

from test_framework.governance import EXPECTED_STDERR_NO_GOV
from test_framework.test_framework import BitcoinTestFramework


class GovernanceTxindexDevnetTest(BitcoinTestFramework):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd move this scenario to test/functional/p2p_connect_to_devnet.py or test/functional/feature_masternode_params_devnet.py but that's fine for now

def set_test_params(self):
self.setup_clean_chain = True
self.chain = "devnet"
self.num_nodes = 1

def run_test(self):
self.stop_node(0)

self.log.info("Test that -txindex=0 is refused while governance validation is enabled")
self.nodes[0].assert_start_raises_init_error(
extra_args=["-txindex=0"],
expected_msg="Error: Transaction index can't be disabled with governance validation enabled. "
"Either start with -disablegovernance command line switch or enable transaction index.")

self.log.info("Test that -txindex=0 is allowed together with -disablegovernance")
self.start_node(0, extra_args=["-txindex=0", "-disablegovernance"])
self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV)


if __name__ == '__main__':
GovernanceTxindexDevnetTest().main()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
'p2p_compactblocks_blocksonly.py',
'p2p_mutated_blocks.py', # NOTE: needs dash_hash to pass
'p2p_connect_to_devnet.py',
'feature_governance_txindex_devnet.py',
'feature_sporks.py',
'rpc_getblockstats.py',
'feature_bind_port_externalip.py',
Expand Down
Loading