From 2a78c776b424fd00af4b48fe83800264cb581aa0 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 | 3 +++ 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, 37 insertions(+), 43 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 93e4c3c82..6b2f118bc 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -137,6 +137,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 @@ -247,6 +248,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 @@ -344,6 +346,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 672ae2e35..fdd1ed072 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -88,6 +88,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 3bae95756..b2cefa4e5 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include