From 92037d786aa8c4546bc5f5e1ef9800aa2e08d3bb Mon Sep 17 00:00:00 2001 From: lbrynaut Date: Tue, 6 Aug 2019 09:50:52 -0500 Subject: [PATCH] Detect "claim" type transactions. Add code to enable a hardfork into witness support, in addition to possible BIP9 fiddling. Fix a bug in abandonclaim and abandonsupport that burns coins on abandon, rather than sending to the intended destination. --- src/chainparams.cpp | 7 +++++-- src/claimscriptop.h | 24 ++++++++++++------------ src/consensus/params.h | 2 ++ src/core_write.cpp | 1 + src/script/standard.cpp | 7 ++++++- src/script/standard.h | 1 + src/versionbits.cpp | 5 +++++ src/wallet/rpcwallet.cpp | 28 +++------------------------- src/wallet/test/claim_rpc_tests.cpp | 9 ++++----- 9 files changed, 39 insertions(+), 45 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1442e783d..dd9b33ab5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -145,6 +145,7 @@ public: consensus.nNormalizedNameForkHeight = 539940; // targeting 21 March 2019 consensus.nMinTakeoverWorkaroundHeight = 496850; consensus.nMaxTakeoverWorkaroundHeight = 10000000; + consensus.nWitnessForkHeight = 700000; consensus.fPowAllowMinDifficultyBlocks = false; consensus.fPowNoRetargeting = false; consensus.nRuleChangeActivationThreshold = 1916; // 95% of a half week @@ -158,7 +159,7 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1462060800; // May 1st, 2016 consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017 - // Deployment of SegWit (BIP141, BIP143, and BIP147) + // Deployment of SegWit (BIP141, BIP143, and BIP147) -- Unused (see nWitnessForkHeight). consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1; consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1547942400; // Jan 20, 2019 consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1548288000; // Jan 24, 2019 @@ -262,6 +263,7 @@ public: consensus.nNormalizedNameForkHeight = 993380; // targeting, 21 Feb 2019 consensus.nMinTakeoverWorkaroundHeight = 99; consensus.nMaxTakeoverWorkaroundHeight = 10000000; + consensus.nWitnessForkHeight = 1600000; consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowNoRetargeting = false; consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains @@ -275,7 +277,7 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1456790400; // March 1st, 2016 consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017 - // Deployment of SegWit (BIP141, BIP143, and BIP147) + // Deployment of SegWit (BIP141, BIP143, and BIP147) -- Unused (see nWitnessForkHeight). consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1; consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1462060800; // May 1st 2016 consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1493596800; // May 1st 2017 @@ -367,6 +369,7 @@ public: consensus.nNormalizedNameForkHeight = 250; // SDK depends upon this number consensus.nMinTakeoverWorkaroundHeight = -1; consensus.nMaxTakeoverWorkaroundHeight = -1; + consensus.nWitnessForkHeight = 150; consensus.fPowAllowMinDifficultyBlocks = false; consensus.fPowNoRetargeting = false; consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains diff --git a/src/claimscriptop.h b/src/claimscriptop.h index 7fc93048a..afea2930c 100644 --- a/src/claimscriptop.h +++ b/src/claimscriptop.h @@ -59,17 +59,17 @@ public: */ CClaimScriptAddOp(const COutPoint& point, CAmount nValue, int nHeight); /** - * Implamention of OP_CLAIM_NAME handler + * Implementation of OP_CLAIM_NAME handler * @see CClaimScriptOp::claimName */ bool claimName(CClaimTrieCache& trieCache, const std::string& name) override; /** - * Implamention of OP_UPDATE_CLAIM handler + * Implementation of OP_UPDATE_CLAIM handler * @see CClaimScriptOp::updateClaim */ bool updateClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; /** - * Implamention of OP_SUPPORT_CLAIM handler + * Implementation of OP_SUPPORT_CLAIM handler * @see CClaimScriptOp::supportClaim */ bool supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; @@ -100,17 +100,17 @@ public: */ CClaimScriptUndoAddOp(const COutPoint& point, int nHeight); /** - * Implamention of OP_CLAIM_NAME handler + * Implementation of OP_CLAIM_NAME handler * @see CClaimScriptOp::claimName */ bool claimName(CClaimTrieCache& trieCache, const std::string& name) override; /** - * Implamention of OP_UPDATE_CLAIM handler + * Implementation of OP_UPDATE_CLAIM handler * @see CClaimScriptOp::updateClaim */ bool updateClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; /** - * Implamention of OP_SUPPORT_CLAIM handler + * Implementation of OP_SUPPORT_CLAIM handler * @see CClaimScriptOp::supportClaim */ bool supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; @@ -141,17 +141,17 @@ public: */ CClaimScriptSpendOp(const COutPoint& point, int nHeight, int& nValidHeight); /** - * Implamention of OP_CLAIM_NAME handler + * Implementation of OP_CLAIM_NAME handler * @see CClaimScriptOp::claimName */ bool claimName(CClaimTrieCache& trieCache, const std::string& name) override; /** - * Implamention of OP_UPDATE_CLAIM handler + * Implementation of OP_UPDATE_CLAIM handler * @see CClaimScriptOp::updateClaim */ bool updateClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; /** - * Implamention of OP_SUPPORT_CLAIM handler + * Implementation of OP_SUPPORT_CLAIM handler * @see CClaimScriptOp::supportClaim */ bool supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; @@ -184,17 +184,17 @@ public: */ CClaimScriptUndoSpendOp(const COutPoint& point, CAmount nValue, int nHeight, int nValidHeight); /** - * Implamention of OP_CLAIM_NAME handler + * Implementation of OP_CLAIM_NAME handler * @see CClaimScriptOp::claimName */ bool claimName(CClaimTrieCache& trieCache, const std::string& name) override; /** - * Implamention of OP_UPDATE_CLAIM handler + * Implementation of OP_UPDATE_CLAIM handler * @see CClaimScriptOp::updateClaim */ bool updateClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; /** - * Implamention of OP_SUPPORT_CLAIM handler + * Implementation of OP_SUPPORT_CLAIM handler * @see CClaimScriptOp::supportClaim */ bool supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId) override; diff --git a/src/consensus/params.h b/src/consensus/params.h index 0bb2affc6..582159a27 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -81,6 +81,8 @@ struct Params { int nMinTakeoverWorkaroundHeight; int nMaxTakeoverWorkaroundHeight; + int nWitnessForkHeight; + int64_t nPowTargetSpacing; int64_t nPowTargetTimespan; /** how long it took claims to expire before the hard fork */ diff --git a/src/core_write.cpp b/src/core_write.cpp index 34a9d2360..df6897b0e 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include