diff --git a/src/consensus/params.h b/src/consensus/params.h index 4566a47d7a8d8..a4a22077be438 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -34,6 +34,7 @@ enum DeploymentPos : uint16_t { DEPLOYMENT_TESTDUMMY, DEPLOYMENT_CHECKTEMPLATEVERIFY, // Deployment of CTV (BIP 119) DEPLOYMENT_ANYPREVOUT, + DEPLOYMENT_TXHASH, // Deployment of TXHASH/CHECKTXHASHVERIFY // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp MAX_VERSION_BITS_DEPLOYMENTS }; diff --git a/src/deploymentinfo.cpp b/src/deploymentinfo.cpp index 4153264a607fa..9d6906f457382 100644 --- a/src/deploymentinfo.cpp +++ b/src/deploymentinfo.cpp @@ -19,6 +19,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B /*.name =*/ "checktemplateverify", /*.gbt_force =*/ true, }, + { + /*.name =*/ "txhash", + /*.gbt_force =*/ true, + }, { /*.name =*/ "anyprevout", /*.gbt_force =*/ true, diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index 8710500da9eea..2ae9ab0799e7d 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -132,6 +132,7 @@ class CMainParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true}; consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true}; consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .never = true}; + consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true}; consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000044a50fe819c39ad624021859"); consensus.defaultAssumeValid = uint256S("0x000000000000000000035c3f0d31e71a5ee24c5aaf3354689f65bd7b07dee632"); // 784000 @@ -246,6 +247,7 @@ class CTestNetParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true}; consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true}; consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .never = true}; + consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .never = true}; consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000977edb0244170858d07"); consensus.defaultAssumeValid = uint256S("0x0000000000000021bc50a89cde4870d4a81ffe0153b3c8de77b435a2fd3f6761"); // 2429000 @@ -394,6 +396,12 @@ class SigNetParams : public CChainParams { .activate = 0x60007600, .abandon = 0x40007600, }; + consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{ + .start = 1654041600, // 2022-06-01 + .timeout = 1969660800, // 2032-06-01 + .activate = 0x60007700, + .abandon = 0x40007700, + }; RenounceDeployments(options.renounce, consensus.vDeployments); @@ -461,6 +469,7 @@ class CRegTestParams : public CChainParams consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.start = 0, .timeout = Consensus::HereticalDeployment::NO_TIMEOUT, .activate = 0x30000000, .abandon = 0x50000000}; consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .always = true}; consensus.vDeployments[Consensus::DEPLOYMENT_ANYPREVOUT] = SetupDeployment{.activate = 0x60007600, .abandon = 0x40007600, .always = true}; + consensus.vDeployments[Consensus::DEPLOYMENT_TXHASH] = SetupDeployment{.activate = 0x60007700, .abandon = 0x40007700, .always = true}; consensus.nMinimumChainWork = uint256{}; consensus.defaultAssumeValid = uint256{}; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 725e3e1d27b23..8b53cb2b4b3f1 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1339,6 +1339,7 @@ UniValue DeploymentInfo(const CBlockIndex* blockindex, const ChainstateManager& SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TAPROOT); SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY); SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_ANYPREVOUT); + SoftForkDescPushBack(blockindex, softforks, chainman, Consensus::DEPLOYMENT_TXHASH); return softforks; } } // anon namespace diff --git a/src/script/interpreter.h b/src/script/interpreter.h index 462f57e2c1fa5..a1c01e3565e4d 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -159,10 +159,12 @@ enum : uint32_t { // Making ANYPREVOUT public key versions (in BIP 342 scripts) non-standard SCRIPT_VERIFY_DISCOURAGE_ANYPREVOUT = (1U << 25), - // Support OP_TXHASH and OP_CHECKTXHASHVERIFY. - // + // Support OP_TXHASH and OP_CHECKTXHASHVERIFY for standard template SCRIPT_VERIFY_TXHASH = (1U << 26), + // discourage OP_TXHASH and OP_CHECKTXHASHVERIFY + SCRIPT_VERIFY_DISCOURAGE_TXHASH = (1U << 27), + // Constants to point to the highest flag in use. Add new flags above this line. // SCRIPT_VERIFY_END_MARKER diff --git a/src/validation.cpp b/src/validation.cpp index 9cbeb9331b3c5..14201144f20e0 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1008,9 +1008,11 @@ bool MemPoolAccept::PolicyScriptChecks(const ATMPArgs& args, Workspace& ws) TxValidationState& state = ws.m_state; const bool ctv_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), m_active_chainstate.m_chainman, Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY); + const bool txh_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), m_active_chainstate.m_chainman, Consensus::DEPLOYMENT_TXHASH); const bool apo_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), m_active_chainstate.m_chainman, Consensus::DEPLOYMENT_ANYPREVOUT); const unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS | (ctv_active ? SCRIPT_VERIFY_NONE : SCRIPT_VERIFY_DISCOURAGE_CHECK_TEMPLATE_VERIFY_HASH) + | (txh_active ? SCRIPT_VERIFY_NONE : SCRIPT_VERIFY_DISCOURAGE_TXHASH) | (apo_active ? SCRIPT_VERIFY_NONE : SCRIPT_VERIFY_DISCOURAGE_ANYPREVOUT); // Check input scripts and signatures. @@ -2020,6 +2022,11 @@ unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Chainstat flags |= SCRIPT_VERIFY_ANYPREVOUT; } + // Enforce TXHASH + if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_TXHASH)) { + flags |= SCRIPT_VERIFY_TXHASH; + } + return flags; } diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index b5f0669361b5e..a13c9f4b093e2 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -197,7 +197,7 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash): assert_equal(gdi_result, { "hash": blockhash, "height": height, - "script_flags": "ANYPREVOUT,CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFY,DEFAULT_CHECK_TEMPLATE_VERIFY_HASH,DERSIG,NULLDUMMY,P2SH,TAPROOT,WITNESS", + "script_flags": "ANYPREVOUT,CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFY,DEFAULT_CHECK_TEMPLATE_VERIFY_HASH,DERSIG,NULLDUMMY,P2SH,TAPROOT,TXHASH,WITNESS", "deployments": { 'bip34': {'type': 'buried', 'active': True, 'height': 2}, 'bip66': {'type': 'buried', 'active': True, 'height': 3}, @@ -235,6 +235,21 @@ def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash): 'height': 0, 'active': True }, + 'txhash': { + 'type': 'heretical', + 'heretical': { + 'bip': 118, + 'bip_version': 0, + 'start_time': -1, + 'timeout': 9223372036854775807, + 'period': 144, + 'status': 'active', + 'status_next': 'active', + 'since': 0, + }, + 'height': 0, + 'active': True + }, 'anyprevout': { 'type': 'heretical', 'heretical': {