diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 3e6666ffa2..f81339d04a 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -245,6 +245,7 @@ class CMainParams : public CChainParams { consensus.smartContracts.clear(); consensus.smartContracts[SMART_CONTRACT_DFIP_2201] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}))); + consensus.smartContracts[SMART_CONTRACT_DFIP_2203] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}))); // owner base58, operator base58 vMasternodes.push_back({"8PuErAcazqccCVzRcc8vJ3wFaZGm4vFbLe", "8J846CKFF83Jcj5m4EReJmxiaJ6Jy1Y6Ea"}); @@ -462,6 +463,7 @@ class CTestNetParams : public CChainParams { consensus.smartContracts.clear(); consensus.smartContracts[SMART_CONTRACT_DFIP_2201] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}))); + consensus.smartContracts[SMART_CONTRACT_DFIP_2203] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}))); // owner base58, operator base58 vMasternodes.push_back({"7LMorkhKTDjbES6DfRxX2RiNMbeemUkxmp", "7KEu9JMKCx6aJ9wyg138W3p42rjg19DR5D"}); @@ -644,6 +646,7 @@ class CDevNetParams : public CChainParams { consensus.smartContracts.clear(); consensus.smartContracts[SMART_CONTRACT_DFIP_2201] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}))); + consensus.smartContracts[SMART_CONTRACT_DFIP_2203] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}))); // owner base58, operator base58 vMasternodes.push_back({"7M3g9CSERjLdXisE5pv2qryDbURUj9Vpi1", "7Grgx69MZJ4wDKRx1bBxLqTnU9T3quKW7n"}); @@ -832,6 +835,7 @@ class CRegTestParams : public CChainParams { consensus.smartContracts.clear(); consensus.smartContracts[SMART_CONTRACT_DFIP_2201] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}))); + consensus.smartContracts[SMART_CONTRACT_DFIP_2203] = GetScriptForDestination(CTxDestination(WitnessV0KeyHash(std::vector{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}))); // owner base58, operator base58 vMasternodes.push_back({"mwsZw8nF7pKxWH8eoKL9tPxTpaFkz7QeLU", "mswsMVsyGMj1FzDMbbxw2QW3KvQAv2FKiy"}); diff --git a/src/chainparams.h b/src/chainparams.h index 2ec2c0d662..1e0c243cce 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -120,6 +120,7 @@ class CChainParams }; const auto SMART_CONTRACT_DFIP_2201 = "DFIP2201"; +const auto SMART_CONTRACT_DFIP_2203 = "DFIP2203"; /** * Creates and returns a std::unique_ptr of the chosen chain. diff --git a/src/logging.cpp b/src/logging.cpp index 367f898151..529af630a3 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -155,6 +155,7 @@ const CLogCategoryDesc LogCategories[] = {BCLog::ORACLE, "oracle"}, {BCLog::LOAN, "loan"}, {BCLog::ACCOUNTCHANGE, "accountchange"}, + {BCLog::FUTURESWAP, "futureswap"}, {BCLog::ALL, "1"}, {BCLog::ALL, "all"}, }; diff --git a/src/logging.h b/src/logging.h index c1034a1f20..7125f829a1 100644 --- a/src/logging.h +++ b/src/logging.h @@ -61,6 +61,7 @@ namespace BCLog { ORACLE = (1 << 24), LOAN = (1 << 25), ACCOUNTCHANGE = (1 << 26), + FUTURESWAP = (1 << 27), ALL = ~(uint32_t)0, }; diff --git a/src/masternodes/accounts.cpp b/src/masternodes/accounts.cpp index 1644b9d441..2b79fb5368 100644 --- a/src/masternodes/accounts.cpp +++ b/src/masternodes/accounts.cpp @@ -98,3 +98,60 @@ uint32_t CAccountsView::GetBalancesHeight(CScript const & owner) bool ok = ReadBy(owner, height); return ok ? height : 0; } + +Res CAccountsView::StoreFuturesUserValues(const CFuturesUserKey& key, const CFuturesUserValue& futures) +{ + if (!WriteBy(key, futures)) { + return Res::Err("Failed to store futures"); + } + + return Res::Ok(); +} + +void CAccountsView::ForEachFuturesUserValues(std::function callback, const CFuturesUserKey& start) +{ + ForEach(callback, start); +} + +Res CAccountsView::EraseFuturesUserValues(const CFuturesUserKey& key) +{ + if (!EraseBy(key)) { + return Res::Err("Failed to erase futures"); + } + + return Res::Ok(); +} + +boost::optional CAccountsView::GetMostRecentFuturesHeight() +{ + const CFuturesUserKey key{std::numeric_limits::max(), {}, std::numeric_limits::max()}; + auto it = LowerBound(key); + if (it.Valid()) { + return it.Key().height; + } + + return {}; +} + +Res CAccountsView::StoreFuturesDestValues(const CFuturesUserKey& key, const CFuturesUserValue& destination) +{ + if (!WriteBy(key, destination)) { + return Res::Err("Failed to store futures destination"); + } + + return Res::Ok(); +} + +ResVal CAccountsView::GetFuturesUserValues(const CFuturesUserKey& key) { + CFuturesUserValue source; + if (!ReadBy(key, source)) { + return Res::Err("Failed to read futures source"); + } + + return {source, Res::Ok()}; +} + +void CAccountsView::ForEachFuturesDestValues(std::function callback, const CFuturesUserKey& start) +{ + ForEach(callback, start); +} diff --git a/src/masternodes/accounts.h b/src/masternodes/accounts.h index c9d3a9555e..fe259f17c5 100644 --- a/src/masternodes/accounts.h +++ b/src/masternodes/accounts.h @@ -11,6 +11,48 @@ #include #include