Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] New Deterministic Masternodes Graphical User Interface #2751

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d40aac0
mnmodel: implement MN wrapper first step
furszy Jan 25, 2022
9ec79d3
Move FundSpecialTx function from rpcevo.cpp to specialtx_utils.cpp
furszy Jan 18, 2022
316d924
Move CalcTxInputsHash from specialtx_validation.h to transaction.h
furszy Jan 19, 2022
2e797f1
Move SignSpecialTxPayload* functions to specialtx_utils
furszy Jan 21, 2022
c6b415b
RPC: Remove extra special tx validation.
furszy Jan 21, 2022
4e603db
RPC: Commit special transaction inside the wallet before relay it to …
furszy Jan 21, 2022
9590eb8
Encapsulate SignTransaction inside the wallet class.
furszy Jan 21, 2022
13c438b
RPC: Move SignAndSendSpecialTx to specialtx_utils.h/cpp
furszy Jan 21, 2022
34eddd9
RPC: cleanup unneeded variable from parseProReg
furszy Jan 23, 2022
42be387
chainparams: set v6.0 regtest activation height.
furszy Jan 24, 2022
7e7c018
Move ParsePubKeyIDFromAddress to specialtx_utils.h/cpp
furszy Jan 24, 2022
1784fff
GUI: implement basic create DMN process
furszy Jan 23, 2022
b62a622
Create tiertwo interface, initializing and connecting the local DMNs …
furszy Jan 27, 2022
f36ca3d
GUI: Connect known DMN to the MN screen
furszy Jan 28, 2022
b43129c
GUI: Add DMN PoSe banned start.
furszy Jan 31, 2022
26d8715
GUI: Generalize and simplify TooltipMenu
furszy Jan 31, 2022
acc12da
Store DMN operator sk within the dmn registration tx (if the key was …
furszy Jan 31, 2022
5806d8d
GUI: Implement and connect owner "kill DMN" functionality.
furszy Jan 31, 2022
f056cbf
GUI: Implement and connect create DMN summary page
furszy Feb 1, 2022
5f2fe77
GUI: Masternode creation wizard; generalize pages setup, next and bac…
furszy Feb 2, 2022
e9100d4
interfaces:tiertwo, implement isBlsPubKeyValid function.
furszy Feb 4, 2022
c89102a
GUI: Masternode creation wizard dialog, create and connect owner and …
furszy Feb 4, 2022
3beb523
GUI: add copy to clipboard action to DMN creation summary page
furszy Feb 7, 2022
6109b88
GUI: add subtitle to masternode creation wizard summary page
furszy Feb 8, 2022
48cae01
GUI: do not invalidate addresses filter when the new filter type is e…
furszy Feb 8, 2022
01c45e8
GUI: masternode creation wizard, connect dropdown list to owner addre…
furszy Feb 8, 2022
a17173c
interfaces::tiertwo, implement function to get single DMN data.
furszy Feb 8, 2022
c6a893a
GUI: Implement and connect MN information dialog for Deterministic Ma…
furszy Feb 8, 2022
5d7c07b
GUI: add export DMN functionality
furszy Feb 9, 2022
ab5fb95
GUI: Masternode creation wizard; add voter customization page.
furszy Feb 17, 2022
811e0e6
GUI: Masternode creation wizard; connect custom voting key to the bac…
furszy Feb 18, 2022
7410e45
GUI: connect custom voting address to summary screen
furszy Feb 18, 2022
377b09d
GUI: DMN creation, convert rejection error into an understandable str…
furszy Feb 19, 2022
fce1940
test: failing txs are now properly considered RPC_VERIFY_REJECTED and…
furszy Feb 21, 2022
c019cc8
Add and connect function to validate the operator service
furszy Feb 21, 2022
2a11af8
GUI: enable custom operator payout
furszy Feb 21, 2022
527ac1b
GUI, Voting dialog: filter out legacy MNs and DMNs that don't have th…
furszy Feb 21, 2022
32e289a
GUI: MN wizard dialog text cut off correction.
furszy Feb 28, 2022
b127b1e
GUI: MN creation wizard, get default port number from the client model.
furszy Mar 1, 2022
4a4bfef
GUI: hide MN start button if it's a deterministic MN
furszy Mar 4, 2022
9e4b653
trigger NotifyMasternodeListChanged asynchronously.
furszy Mar 9, 2022
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ set(SERVER_SOURCES
./src/tiertwo/init.cpp
./src/interfaces/handler.cpp
./src/interfaces/wallet.cpp
./src/interfaces/tiertwo.cpp
./src/dbwrapper.cpp
./src/legacy/validation_zerocoin_legacy.cpp
./src/mapport.cpp
Expand Down Expand Up @@ -417,6 +418,7 @@ set(COMMON_SOURCES
./src/evo/evodb.cpp
./src/evo/providertx.cpp
./src/evo/specialtx_validation.cpp
./src/evo/specialtx_utils.cpp
./src/llmq/quorums_blockprocessor.cpp
./src/llmq/quorums_commitment.cpp
./src/llmq/quorums_connections.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ BITCOIN_CORE_H = \
evo/evonotificationinterface.h \
evo/providertx.h \
evo/specialtx_validation.h \
evo/specialtx_utils.h \
flatdb.h \
llmq/quorums_blockprocessor.h \
llmq/quorums_commitment.h \
Expand All @@ -213,6 +214,7 @@ BITCOIN_CORE_H = \
init.h \
tiertwo/init.h \
interfaces/handler.h \
interfaces/tiertwo.h \
interfaces/wallet.h \
invalid.h \
invalid_outpoints.json.h \
Expand Down Expand Up @@ -366,6 +368,7 @@ libbitcoin_server_a_SOURCES = \
evo/mnauth.cpp \
evo/providertx.cpp \
evo/specialtx_validation.cpp \
evo/specialtx_utils.cpp \
llmq/quorums_blockprocessor.cpp \
llmq/quorums_commitment.cpp \
llmq/quorums_connections.cpp \
Expand Down Expand Up @@ -592,6 +595,7 @@ libbitcoin_util_a_SOURCES = \
compat/strnlen.cpp \
fs.cpp \
interfaces/handler.cpp \
interfaces/tiertwo.cpp \
logging.cpp \
random.cpp \
randomenv.cpp \
Expand Down
6 changes: 5 additions & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ QT_MOC_CPP = \
qt/pivx/moc_furabstractlistitemdelegate.cpp \
qt/pivx/moc_receivedialog.cpp \
qt/pivx/moc_pfborderimage.cpp \
qt/pivx/moc_clickablelabel.cpp \
qt/pivx/moc_topbar.cpp \
qt/pivx/moc_txrow.cpp \
qt/pivx/moc_dashboardwidget.cpp \
Expand Down Expand Up @@ -275,7 +276,8 @@ BITCOIN_QT_H = \
qt/pivx/settings/settingswalletrepairwidget.h \
qt/pivx/settings/settingswidget.h \
qt/pivx/welcomecontentwidget.h \
qt/pivx/splash.h
qt/pivx/splash.h \
qt/pivx/clickablelabel.h

RES_ICONS = \
qt/res/icons/bitcoin.ico \
Expand Down Expand Up @@ -511,6 +513,8 @@ RES_ICONS = \
qt/pivx/res/img/ic-nav-governance-hover.svg \
qt/pivx/res/img/ic-time.svg \
qt/pivx/res/img/ic-link-hover.svg \
qt/pivx/res/img/ic-dmn.svg \
qt/pivx/res/img/ic-lmn.svg \
qt/pivx/res/img/img-empty-governance.svg \
qt/pivx/res/img/img-empty-dark-governance.svg

Expand Down
3 changes: 1 addition & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,7 @@ class CRegTestParams : public CChainParams
consensus.vUpgrades[Consensus::UPGRADE_V5_0].nActivationHeight = 300;
consensus.vUpgrades[Consensus::UPGRADE_V5_2].nActivationHeight = 300;
consensus.vUpgrades[Consensus::UPGRADE_V5_3].nActivationHeight = 251;
consensus.vUpgrades[Consensus::UPGRADE_V6_0].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V6_0].nActivationHeight = 301;

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand Down
2 changes: 1 addition & 1 deletion src/destination_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Destination& Destination::operator=(const Destination& from)
}

// Returns the key ID if Destination is a transparent "regular" destination
const CKeyID* Destination::getKeyID()
const CKeyID* Destination::getKeyID() const
{
const CTxDestination* regDest = Standard::GetTransparentDestination(dest);
return (regDest) ? boost::get<CKeyID>(regDest) : nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/destination_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Destination {

Destination& operator=(const Destination& from);
// Returns the key ID if Destination is a transparent "regular" destination
const CKeyID* getKeyID();
const CKeyID* getKeyID() const;
// Returns the encoded string address
std::string ToString() const;
};
Expand Down
3 changes: 2 additions & 1 deletion src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "bls/key_io.h"
#include "chain.h"
#include "coins.h"
#include "chainparams.h"
#include "consensus/upgrades.h"
#include "consensus/validation.h"
Expand Down Expand Up @@ -505,6 +504,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
}

diff.nHeight = pindex->nHeight;
diff.blockHash = pindex->GetBlockHash();
mnListDiffsCache.emplace(pindex->GetBlockHash(), diff);
} catch (const std::exception& e) {
LogPrintf("CDeterministicMNManager::%s -- internal error: %s\n", __func__, e.what());
Expand Down Expand Up @@ -888,6 +888,7 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlock(const CBlockIndex*
}

diff.nHeight = pindex->nHeight;
diff.blockHash = pindex->GetBlockHash();
mnListDiffsCache.emplace(pindex->GetBlockHash(), std::move(diff));
listDiffIndexes.emplace_front(pindex);
pindex = pindex->pprev;
Expand Down
3 changes: 2 additions & 1 deletion src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ class CDeterministicMNList
class CDeterministicMNListDiff
{
public:
int nHeight{-1}; //memory only
int nHeight{-1}; // memory only
uint256 blockHash; // memory only

std::vector<CDeterministicMNCPtr> addedMNs;
// keys are all relating to the internalId of MNs
Expand Down
82 changes: 82 additions & 0 deletions src/evo/specialtx_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2022 The PIVX Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or htts://www.opensource.org/licenses/mit-license.php.

#include "evo/specialtx_utils.h"

#include "net.h"
#include "script/script.h"
#include "wallet/wallet.h"

#ifdef ENABLE_WALLET

OperationResult FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx)
{
static CTxOut dummyTxOut(0, CScript() << OP_RETURN);
std::vector<CRecipient> vecSend;
bool dummyTxOutAdded = false;

if (tx.vout.empty()) {
// add dummy txout as CreateTransaction requires at least one recipient
tx.vout.emplace_back(dummyTxOut);
dummyTxOutAdded = true;
}

CAmount nFee;
CFeeRate feeRate = CFeeRate(0);
int nChangePos = -1;
std::string strFailReason;
std::set<int> setSubtractFeeFromOutputs;
if (!pwallet->FundTransaction(tx, nFee, false, feeRate, nChangePos, strFailReason, false, false, {})) {
return {false, strFailReason};
}

if (dummyTxOutAdded && tx.vout.size() > 1) {
// FundTransaction added a change output, so we don't need the dummy txout anymore
// Removing it results in slight overpayment of fees, but we ignore this for now (as it's a very low amount)
auto it = std::find(tx.vout.begin(), tx.vout.end(), dummyTxOut);
assert(it != tx.vout.end());
tx.vout.erase(it);
}

return {true};
}

OperationResult SignAndSendSpecialTx(CWallet* pwallet, CMutableTransaction& tx, std::map<std::string, std::string>* extras)
{
if (!pwallet->SignTransaction(tx)) {
return {false, "signature failed"};
}

CWallet::CommitResult res = pwallet->CommitTransaction(MakeTransactionRef(tx), nullptr, g_connman.get(), extras);
CValidationState& state = res.state;
if (state.IsInvalid()) {
std::string debugMsg = state.GetDebugMessage();
return {false, debugMsg.empty() ? state.GetRejectReason() :
strprintf("%s: %s", state.GetRejectReason(), debugMsg)};
}

return {true};
}

#endif

Optional<CKeyID> ParsePubKeyIDFromAddress(const std::string& strAddress, std::string& strError)
{
bool isStaking{false}, isShield{false};
const CWDestination& cwdest = Standard::DecodeDestination(strAddress, isStaking, isShield);
if (isStaking) {
strError = "cold staking addresses not supported";
return nullopt;
}
if (isShield) {
strError = "shield addresses not supported";
return nullopt;
}
const CKeyID* keyID = boost::get<CKeyID>(Standard::GetTransparentDestination(cwdest));
if (!keyID) {
strError = strprintf("invalid PIVX address %s", strAddress);
return nullopt;
}
return *keyID;
}
73 changes: 73 additions & 0 deletions src/evo/specialtx_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) 2022 The PIVX Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or htts://www.opensource.org/licenses/mit-license.php.

#ifndef PIVX_SPECIALTX_UTILS_H
#define PIVX_SPECIALTX_UTILS_H

#include "bls/bls_wrapper.h"
#include "messagesigner.h"
#include "operationresult.h"
#include "primitives/transaction.h"

template<typename SpecialTxPayload>
OperationResult SignSpecialTxPayloadByHash(const CMutableTransaction& tx, SpecialTxPayload& payload, const CKey& key)
{
payload.vchSig.clear();
uint256 hash = ::SerializeHash(payload);
return CHashSigner::SignHash(hash, key, payload.vchSig) ? OperationResult{true} :
OperationResult{false, "failed to sign special tx payload"};
}

template<typename SpecialTxPayload>
OperationResult SignSpecialTxPayloadByHash(const CMutableTransaction& tx, SpecialTxPayload& payload, const CBLSSecretKey& key)
{
payload.sig = key.Sign(::SerializeHash(payload));
return payload.sig.IsValid() ? OperationResult{true} : OperationResult{false, "failed to sign special tx payload"};
}

template<typename SpecialTxPayload>
OperationResult SignSpecialTxPayloadByString(SpecialTxPayload& payload, const CKey& key)
{
payload.vchSig.clear();
std::string m = payload.MakeSignString();
return CMessageSigner::SignMessage(m, payload.vchSig, key) ? OperationResult{true} :
OperationResult{false, "failed to sign special tx payload"};
}

template<typename SpecialTxPayload>
static void UpdateSpecialTxInputsHash(const CMutableTransaction& tx, SpecialTxPayload& payload)
{
payload.inputsHash = CalcTxInputsHash(tx);
}

#ifdef ENABLE_WALLET

class CWallet;
struct CMutableTransaction;

OperationResult FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx);

template<typename SpecialTxPayload>
OperationResult FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx, SpecialTxPayload& payload)
{
SetTxPayload(tx, payload);
auto res = FundSpecialTx(pwallet, tx);
if (res) UpdateSpecialTxInputsHash(tx, payload);
return res;
}

OperationResult SignAndSendSpecialTx(CWallet* pwallet, CMutableTransaction& tx, std::map<std::string, std::string>* extras = nullptr);

template<typename SpecialTxPayload>
OperationResult SignAndSendSpecialTx(CWallet* const pwallet, CMutableTransaction& tx, const SpecialTxPayload& pl, std::map<std::string, std::string>* extras = nullptr)
{
SetTxPayload(tx, pl);
return SignAndSendSpecialTx(pwallet, tx, extras);
}

#endif // ENABLE_WALLET

Optional<CKeyID> ParsePubKeyIDFromAddress(const std::string& strAddress, std::string& strError);

#endif //PIVX_SPECIALTX_UTILS_H
17 changes: 1 addition & 16 deletions src/evo/specialtx_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/* -- Helper static functions -- */

static bool CheckService(const CService& addr, CValidationState& state)
bool CheckService(const CService& addr, CValidationState& state)
{
if (!addr.IsValid()) {
return state.DoS(10, false, REJECT_INVALID, "bad-protx-ipaddr");
Expand Down Expand Up @@ -641,18 +641,3 @@ bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex)
return true;
}

uint256 CalcTxInputsHash(const CTransaction& tx)
{
CHashWriter hw(CLIENT_VERSION, SER_GETHASH);
// transparent inputs
for (const CTxIn& in: tx.vin) {
hw << in.prevout;
}
// shield inputs
if (tx.hasSaplingData()) {
for (const SpendDescription& sd: tx.sapData->vShieldedSpend) {
hw << sd.nullifier;
}
}
return hw.GetHash();
}
5 changes: 3 additions & 2 deletions src/evo/specialtx_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class uint256;
/** The maximum allowed size of the extraPayload (for any TxType) */
static const unsigned int MAX_SPECIALTX_EXTRAPAYLOAD = 10000;

/** Operator service validity checks */
bool CheckService(const CService& addr, CValidationState& state);

/** Payload validity checks (including duplicate unique properties against list at pindexPrev)*/
// Note: for +v2, if the tx is not a special tx, this method returns true.
// Note2: This function only performs extra payload related checks, it does NOT checks regular inputs and outputs.
Expand All @@ -36,6 +39,4 @@ bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex);
// Validate given LLMQ final commitment with the list at pindexQuorum
bool VerifyLLMQCommitment(const llmq::CFinalCommitment& qfc, const CBlockIndex* pindexPrev, CValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);

uint256 CalcTxInputsHash(const CTransaction& tx);

#endif // PIVX_SPECIALTX_H
Loading