Skip to content
Draft
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
22 changes: 12 additions & 10 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ DYNAMIC_CORE_H = \
flat-database.h \
fluid/banaccount.h \
fluid/fluid.h \
fluid/fluiddb.h \
fluid/fluiddynode.h \
fluid/fluidmining.h \
fluid/fluidmint.h \
fluid/fluidsovereign.h \
fluid/db.h \
fluid/dynode.h \
fluid/mining.h \
fluid/mint.h \
fluid/script.h \
fluid/sovereign.h \
fluid/operations.h \
governance.h \
governance-classes.h \
Expand Down Expand Up @@ -297,11 +298,12 @@ libdynamic_server_a_SOURCES = \
dynodeman.cpp \
fluid/banaccount.cpp \
fluid/fluid.cpp \
fluid/fluiddb.cpp \
fluid/fluiddynode.cpp \
fluid/fluidmining.cpp \
fluid/fluidmint.cpp \
fluid/fluidsovereign.cpp \
fluid/db.cpp \
fluid/dynode.cpp \
fluid/mining.cpp \
fluid/mint.cpp \
fluid/script.cpp \
fluid/sovereign.cpp \
fluid/operations.cpp \
governance.cpp \
governance-classes.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class CDynamicAddress : public CBase58Data
bool IsValidStealthAddress(const CChainParams& params) const;

CDynamicAddress() {}
CDynamicAddress(const CPubKey& pk) { Set(pk.GetID()); } // Dynamic: Add the ability to directly import from pubkey
CDynamicAddress(const CTxDestination& dest) { Set(dest); }
CDynamicAddress(const std::string& strAddress) { SetString(strAddress); }
CDynamicAddress(const char* pszAddress) { SetString(pszAddress); }
Expand Down
31 changes: 31 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ class CMainParams : public CChainParams
vSporkAddresses = {"DDDax6fjzoCqHj9nwTgNdAQsucFBJUJ3Jk"};
nMinSporkKeys = 1;

fluidSignatureKeys = {
"032f31a815c3bbb8c2386d6006542bb1367073013639161d5e406034203ab9178b",
"03d7f7b945571672b6d6cd06d0abde805a1578872e436cbd4d4624c74cc7c86aef",
"02dab261cd65669d09e83db22d16308f17e99c1c3fe25af2b5b6a105332ce60bbb",
"02e267ae5cc5f7ea05769dacc5c7d0fc61d7a4c0b9bb8a213e77663d8ce002da5e"
};

checkpointData = (CCheckpointData){
boost::assign::map_list_of
(0, uint256S("0x00000e140b0c3028f898431890e9dea79ae6ca537ac9362c65b45325db712de2"))
Expand Down Expand Up @@ -392,6 +399,14 @@ class CTestNetParams : public CChainParams
vSporkAddresses = {"DLWYuC7SNhnqZeY87UMqJzVdMVyLzwebhE"}; // QVdXi1qyxxQwTuZ8h3Dh3YRdpMDBWv6oMs9dTmvJmGzQcnsKtdGm
nMinSporkKeys = 1;

fluidSignatureKeys = {
"0246227f26c5a71881ba3312fd443db06b39bdb5f8b6d66cd82e3268f127ebe642",
"0330876a6d45b4b988bc13863ee99d6b8e96022a75979010b46f22ea1cc5551350",
"0359cedc78b59a750641d51c70a30b760b5a0da37ff84a850e7925138c191ab261",
"020506608829abecdb3a61b9ff64a65ea400f882f39dfb2dbb95a71d3b5e3c3434",
"03714874801166849c6dce7bf23b46dc36e05a3cfd06dd5edf038151ffd6c725c0"
};

checkpointData = (CCheckpointData){
boost::assign::map_list_of
(0, uint256S("0x00ff3a06390940bc3fffb7948cc6d0ede8fde544a5fa9eeeafbc4ac65d21f087"))
Expand Down Expand Up @@ -508,6 +523,14 @@ class CRegTestParams : public CChainParams
vSporkAddresses = {"ygUqnUfyRnRfBUks3EBc937tgmYBwQYE2S"}; //private key: cT21Wm3oozS7HpP9K9g1SDxdgr2vw9TBPSTxjxeArLjYxGastsf9
nMinSporkKeys = 1;

fluidSignatureKeys = {
"0246227f26c5a71881ba3312fd443db06b39bdb5f8b6d66cd82e3268f127ebe642",
"0330876a6d45b4b988bc13863ee99d6b8e96022a75979010b46f22ea1cc5551350",
"0359cedc78b59a750641d51c70a30b760b5a0da37ff84a850e7925138c191ab261",
"020506608829abecdb3a61b9ff64a65ea400f882f39dfb2dbb95a71d3b5e3c3434",
"03714874801166849c6dce7bf23b46dc36e05a3cfd06dd5edf038151ffd6c725c0"
};

checkpointData = (CCheckpointData){
boost::assign::map_list_of(0, uint256S("0x000ab751d858e116043e741d097311f2382e600c219483cfda8f25c7f369cc2c"))};

Expand Down Expand Up @@ -656,6 +679,14 @@ class CPrivateNetParams : public CChainParams
vSporkAddresses = {"D777Y4eMXrf1NgDSY1Q7kjoZuVso1ed7HL"};
nMinSporkKeys = 1;

fluidSignatureKeys = {
"02f5e52b333f5a4b312785d63fabb86540649cdfa8d3e462e43eb1a77a58416129",
"02a20a6ab3830d007b9658be2dbf2117c8967c5cb98774e0f514f5ae21fe26c037",
"02edd019d81bc33c868540624561ced215d2b31681947cc1ea7c8ae0f882659d26",
"028386691a85811d91f314d01d17cea0d8afda1b82c7b5068310c720d87f6b6628",
"0327490dff2869b81f46cf7801b582b5ade6d2546b6d5a8818135f4b4f24eff245"
};

checkpointData = (CCheckpointData){
boost::assign::map_list_of(0, uint256S("0x00ff3a06390940bc3fffb7948cc6d0ede8fde544a5fa9eeeafbc4ac65d21f087"))};

Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class CChainParams
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
int MinSporkKeys() const { return nMinSporkKeys; }
uint64_t DifficultySwitchBlock() const { return nSwitchDifficultyBlock; }
std::set<CPubKey> FluidSignatureKeys() const { std::set<CPubKey> pkVch; for (auto& pk : fluidSignatureKeys) { pkVch.insert(CPubKey(ParseHex(pk))); } return pkVch; }

protected:
CChainParams() {}
Expand Down Expand Up @@ -130,6 +131,7 @@ class CChainParams
int64_t nTargetPosSpacing;
int nFutureTimeDriftPoS;
uint64_t nSwitchDifficultyBlock;
std::vector<std::string> fluidSignatureKeys;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dynode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "consensus/validation.h"
#include "dynode-sync.h"
#include "dynodeman.h"
#include "fluid/fluiddb.h"
#include "fluid/db.h"
#include "governance-classes.h"
#include "init.h"
#include "messagesigner.h"
Expand Down
2 changes: 1 addition & 1 deletion src/dynode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "dynode-payments.h"
#include "dynode-sync.h"
#include "dynodeman.h"
#include "fluid/fluiddb.h"
#include "fluid/db.h"
#include "init.h"
#include "messagesigner.h"
#include "netbase.h"
Expand Down
16 changes: 2 additions & 14 deletions src/fluid/banaccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,15 @@

CBanAccountDB* pBanAccountDB = NULL;

bool CheckBanAccountDB()
{
if (!pBanAccountDB)
return false;

return true;
}

bool AddBanAccountEntry(const CBanAccount& entry)
{
if (!CheckBanAccountDB())
return false;

assert(pBanAccountDB);
return pBanAccountDB->AddBanAccountEntry(entry);
}

bool GetAllBanAccountRecords(std::vector<CBanAccount>& entries)
{
if (!CheckBanAccountDB())
return false;

assert(pBanAccountDB);
return pBanAccountDB->GetAllBanAccountRecords(entries);
}

Expand Down
1 change: 0 additions & 1 deletion src/fluid/banaccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class CBanAccountDB : public CDBWrapper
bool RecordExists(const std::vector<unsigned char>& vchFluidScript);
};

bool CheckBanAccountDB();
bool AddBanAccountEntry(const CBanAccount& entry);
bool GetAllBanAccountRecords(std::vector<CBanAccount>& entries);

Expand Down
143 changes: 45 additions & 98 deletions src/fluid/fluiddb.cpp → src/fluid/db.cpp
Original file line number Diff line number Diff line change
@@ -1,62 +1,43 @@
// Copyright (c) 2019-2021 Duality Blockchain Solutions Developers

#include "fluiddb.h"
#include "fluid/db.h"

#include "base58.h"
#include "fluid.h"
#include "fluiddynode.h"
#include "fluidmining.h"
#include "fluidmint.h"
#include "fluidsovereign.h"
#include "fluid/fluid.h"
#include "fluid/dynode.h"
#include "fluid/mining.h"
#include "fluid/mint.h"
#include "fluid/sovereign.h"

CAmount GetFluidDynodeReward(const int nHeight)
{
if (fluid.FLUID_ACTIVATE_HEIGHT > nHeight)
return GetStandardDynodePayment(nHeight);

if (!CheckFluidDynodeDB())
return GetStandardDynodePayment(nHeight);

if (pFluidDynodeDB->IsEmpty())
return GetStandardDynodePayment(nHeight);

CFluidDynode lastDynodeRecord;
if (!pFluidDynodeDB->GetLastFluidDynodeRecord(lastDynodeRecord, nHeight)) {
return GetStandardDynodePayment(nHeight);
}
if (lastDynodeRecord.DynodeReward > 0) {
return lastDynodeRecord.DynodeReward;
} else {
return GetStandardDynodePayment(nHeight);

assert(pFluidDynodeDB);
if (pFluidDynodeDB->GetLastFluidDynodeRecord(lastDynodeRecord, nHeight) && !pFluidDynodeDB->IsEmpty()) {
return (lastDynodeRecord.GetReward() > 0 && FLUID_ACTIVATE_HEIGHT > nHeight) ?
lastDynodeRecord.GetReward() : GetStandardDynodePayment(nHeight);
}

return GetStandardDynodePayment(nHeight);
}

CAmount GetFluidMiningReward(const int nHeight)
{
if (fluid.FLUID_ACTIVATE_HEIGHT > nHeight)
return GetStandardPoWBlockPayment(nHeight);

if (!CheckFluidMiningDB())
return GetStandardPoWBlockPayment(nHeight);

if (pFluidMiningDB->IsEmpty())
return GetStandardPoWBlockPayment(nHeight);

CFluidMining lastMiningRecord;
if (!pFluidMiningDB->GetLastFluidMiningRecord(lastMiningRecord, nHeight)) {
return GetStandardPoWBlockPayment(nHeight);
}
if (lastMiningRecord.MiningReward > 0) {
return lastMiningRecord.MiningReward;
} else {
return GetStandardPoWBlockPayment(nHeight);

assert(pFluidMiningDB);
if (pFluidMiningDB->GetLastFluidMiningRecord(lastMiningRecord, nHeight) && !pFluidMiningDB->IsEmpty()) {
return (lastMiningRecord.GetReward() > 0 && FLUID_ACTIVATE_HEIGHT > nHeight) ?
lastMiningRecord.GetReward() : GetStandardPoWBlockPayment(nHeight);
}

return GetStandardDynodePayment(nHeight);
}

bool GetMintingInstructions(const int nHeight, CFluidMint& fluidMint)
{
if (!CheckFluidMintDB())
return false;
assert(pFluidDynodeDB);

if (pFluidMintDB->IsEmpty())
return false;
Expand All @@ -66,8 +47,8 @@ bool GetMintingInstructions(const int nHeight, CFluidMint& fluidMint)
return false;
}

if ((int)getFluidMint.nHeight == (nHeight - 1)) {
fluidMint = getFluidMint;
if (getFluidMint.GetHeight() == (nHeight - 1)) {
getFluidMint = fluidMint;
return true;
}
return false;
Expand All @@ -76,91 +57,57 @@ bool GetMintingInstructions(const int nHeight, CFluidMint& fluidMint)
/** Checks if any given address is a current sovereign wallet address (invoked by RPC) */
bool IsSovereignAddress(const CDynamicAddress& inputAddress)
{
if (!inputAddress.IsValid()) {
return false;
}

if (!CheckFluidSovereignDB()) {
return false;
}

CFluidSovereign lastSovereign;
if (!pFluidSovereignDB->GetLastFluidSovereignRecord(lastSovereign)) {

if (!inputAddress.IsValid()) {
return false;
}

for (const std::vector<unsigned char>& vchAddress : lastSovereign.SovereignAddresses) {
CDynamicAddress attemptKey(StringFromCharVector(vchAddress));
if (attemptKey.IsValid() && inputAddress == attemptKey) {
return true;
assert(pFluidSovereignDB);
if (pFluidSovereignDB->GetLastFluidSovereignRecord(lastSovereign)) {
for (const std::vector<unsigned char>& vchAddress : lastSovereign.obj_sigs) {
CDynamicAddress attemptKey(StringFromCharVector(vchAddress));
return attemptKey.IsValid() && inputAddress == attemptKey;
}
}

return false;
}

bool GetAllFluidDynodeRecords(std::vector<CFluidDynode>& dynodeEntries)
{
if (CheckFluidDynodeDB()) {
if (!pFluidDynodeDB->GetAllFluidDynodeRecords(dynodeEntries)) {
return false;
}
} else {
return false;
}
return true;
assert(pFluidDynodeDB);
return pFluidDynodeDB->GetAllFluidDynodeRecords(dynodeEntries);
}

bool GetAllFluidMiningRecords(std::vector<CFluidMining>& miningEntries)
{
if (CheckFluidMiningDB()) {
if (!pFluidMiningDB->GetAllFluidMiningRecords(miningEntries)) {
return false;
}
} else {
return false;
}
return true;
assert(pFluidMiningDB);
return pFluidMiningDB->GetAllFluidMiningRecords(miningEntries);
}

bool GetAllFluidMintRecords(std::vector<CFluidMint>& mintEntries)
{
if (CheckFluidMintDB()) {
if (!pFluidMintDB->GetAllFluidMintRecords(mintEntries)) {
return false;
}
} else {
return false;
}
return true;
assert(pFluidMintDB);
return pFluidMintDB->GetAllFluidMintRecords(mintEntries);
}

bool GetAllFluidSovereignRecords(std::vector<CFluidSovereign>& sovereignEntries)
{
if (CheckFluidSovereignDB()) {
if (pFluidSovereignDB->IsEmpty()) {
return false;
}
if (!pFluidSovereignDB->GetAllFluidSovereignRecords(sovereignEntries)) {
return false;
}
} else {
return false;
}
return true;
assert(pFluidSovereignDB);
return pFluidSovereignDB->GetAllFluidSovereignRecords(sovereignEntries) && !pFluidSovereignDB->IsEmpty();
}

bool GetLastFluidSovereignAddressStrings(std::vector<std::string>& sovereignAddresses)
{
if (!CheckFluidSovereignDB()) {
return false;
}

assert(pFluidSovereignDB);
CFluidSovereign lastSovereign;
if (!pFluidSovereignDB->GetLastFluidSovereignRecord(lastSovereign)) {
return false;
if (pFluidSovereignDB->GetLastFluidSovereignRecord(lastSovereign))
{
sovereignAddresses = lastSovereign.SovereignAddressesStrings();
return true;
}
sovereignAddresses = lastSovereign.SovereignAddressesStrings();
return true;
return false;
}

/** Checks whether 3 of 5 sovereign addresses signed the token in the script to meet the quorum requirements */
Expand Down
File renamed without changes.
Loading