Skip to content

Commit

Permalink
Merge #2671: [GUI] Differentiate Budget payment output records from M…
Browse files Browse the repository at this point in the history
…Ns block reward records.

8be73ac GUI: Differentiate Budget payment transaction records from MNs block reward records. (furszy)
d3ca538 Refactor: Move MN block reward to chainparams. (furszy)

Pull request description:

  Fixes #2667. Created a new transaction record type `BudgetPayment` to distinguish MN block rewards from budget payments

  In order to do this without duplicate code, moved the MN reward amount value to chainparams.

ACKs for top commit:
  Fuzzbawls:
    ACK 8be73ac
  random-zebra:
    utACK 8be73ac

Tree-SHA512: c052c8cd0b9787c3adb1fa4b139c4dc8b1006ebada056e8d2fd027457ed6cd028db04ab0b9fd2ebe9b459eca5e2689c2d1074a6b8859a07832117d3ea27a19fb
  • Loading branch information
furszy committed Dec 8, 2021
2 parents 308547d + 8be73ac commit 1dabb39
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class CMainParams : public CChainParams
consensus.nFutureTimeDriftPoS = 180;
consensus.nMaxMoneyOut = 21000000 * COIN;
consensus.nMNCollateralAmt = 10000 * COIN;
consensus.nMNBlockReward = 3 * COIN;
consensus.nProposalEstablishmentTime = 60 * 60 * 24; // must be at least a day old to make it into a budget
consensus.nStakeMinAge = 60 * 60;
consensus.nStakeMinDepth = 600;
Expand Down Expand Up @@ -290,6 +291,7 @@ class CTestNetParams : public CChainParams
consensus.nFutureTimeDriftPoS = 180;
consensus.nMaxMoneyOut = 21000000 * COIN;
consensus.nMNCollateralAmt = 10000 * COIN;
consensus.nMNBlockReward = 3 * COIN;
consensus.nProposalEstablishmentTime = 60 * 5; // at least 5 min old to make it into a budget
consensus.nStakeMinAge = 60 * 60;
consensus.nStakeMinDepth = 100;
Expand Down Expand Up @@ -415,6 +417,7 @@ class CRegTestParams : public CChainParams
consensus.nFutureTimeDriftPoS = 180;
consensus.nMaxMoneyOut = 43199500 * COIN;
consensus.nMNCollateralAmt = 100 * COIN;
consensus.nMNBlockReward = 3 * COIN;
consensus.nProposalEstablishmentTime = 60 * 5; // at least 5 min old to make it into a budget
consensus.nStakeMinAge = 0;
consensus.nStakeMinDepth = 20;
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct Params {
int nFutureTimeDriftPoS;
CAmount nMaxMoneyOut;
CAmount nMNCollateralAmt;
CAmount nMNBlockReward;
int64_t nProposalEstablishmentTime;
int nStakeMinAge;
int nStakeMinDepth;
Expand Down
1 change: 1 addition & 0 deletions src/qt/pivx/qtutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void setSortTxTypeFilter(QComboBox* filter, SortEdit* lineEditType)
filter->addItem(QObject::tr("Hot stakes"), TransactionFilterProxy::TYPE(TransactionRecord::StakeHot));
filter->addItem(QObject::tr("Delegated"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSent) | TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegationSentOwner));
filter->addItem(QObject::tr("Delegations"), TransactionFilterProxy::TYPE(TransactionRecord::P2CSDelegation));
filter->addItem(QObject::tr("DAO payment"), TransactionFilterProxy::TYPE(TransactionRecord::BudgetPayment));
}

void setupSettings(QSettings* settings)
Expand Down
1 change: 1 addition & 0 deletions src/qt/pivx/txrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void TxRow::setType(bool isLightTheme, int type, bool isConfirmed)
case TransactionRecord::StakeZPIV:
case TransactionRecord::MNReward:
case TransactionRecord::StakeMint:
case TransactionRecord::BudgetPayment:
path = "://ic-transaction-staked";
css = "text-list-amount-receive";
break;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionfilterproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ int TransactionFilterProxy::rowCount(const QModelIndex& parent) const
bool TransactionFilterProxy::isOrphan(const int status, const int type)
{
return ( (type == TransactionRecord::Generated || type == TransactionRecord::StakeMint ||
type == TransactionRecord::StakeZPIV || type == TransactionRecord::MNReward)
type == TransactionRecord::StakeZPIV || type == TransactionRecord::MNReward || type == TransactionRecord::BudgetPayment)
&& (status == TransactionStatus::Conflicted || status == TransactionStatus::NotAccepted) );
}
5 changes: 4 additions & 1 deletion src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ bool TransactionRecord::decomposeCoinStake(const CWallet* wallet, const CWalletT
int nIndexMN = (int) wtx.tx->vout.size() - 1;
if (ExtractDestination(wtx.tx->vout[nIndexMN].scriptPubKey, destMN) && (mine = IsMine(*wallet, destMN)) ) {
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
sub.type = TransactionRecord::MNReward;
sub.address = EncodeDestination(destMN);
sub.credit = wtx.tx->vout[nIndexMN].nValue;
// Simple way to differentiate budget payments from MN rewards.
CAmount mn_reward = Params().GetConsensus().nMNBlockReward;
sub.type = sub.credit > mn_reward ? TransactionRecord::BudgetPayment : TransactionRecord::MNReward;
}
}

Expand Down Expand Up @@ -612,6 +614,7 @@ void TransactionRecord::updateStatus(const CWalletTx& wtx, int chainHeight)
type == TransactionRecord::StakeMint ||
type == TransactionRecord::StakeZPIV ||
type == TransactionRecord::MNReward ||
type == TransactionRecord::BudgetPayment ||
type == TransactionRecord::StakeDelegated ||
type == TransactionRecord::StakeHot) {

Expand Down
1 change: 1 addition & 0 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class TransactionRecord
SendToOther,
RecvWithAddress,
MNReward,
BudgetPayment,
RecvFromOther,
SendToSelf,
ZerocoinMint,
Expand Down
4 changes: 4 additions & 0 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ QString TransactionTableModel::formatTxType(const TransactionRecord* wtx) const
return tr("Received with");
case TransactionRecord::MNReward:
return tr("Masternode Reward");
case TransactionRecord::BudgetPayment:
return tr("Budget Payment");
case TransactionRecord::RecvFromOther:
return tr("Received from");
case TransactionRecord::SendToAddress:
Expand Down Expand Up @@ -493,6 +495,7 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord* wtx
case TransactionRecord::StakeMint:
case TransactionRecord::StakeZPIV:
case TransactionRecord::MNReward:
case TransactionRecord::BudgetPayment:
return QIcon(":/icons/tx_mined");
case TransactionRecord::RecvWithAddress:
case TransactionRecord::RecvFromOther:
Expand Down Expand Up @@ -520,6 +523,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord* wtx, b
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::RecvWithAddress:
case TransactionRecord::MNReward:
case TransactionRecord::BudgetPayment:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::StakeMint:
Expand Down
3 changes: 2 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,8 @@ CAmount GetBlockValue(int nHeight)

int64_t GetMasternodePayment()
{
return 3 * COIN;
// Future: refactor function callers to use this line directly.
return Params().GetConsensus().nMNBlockReward;
}

bool IsInitialBlockDownload()
Expand Down

0 comments on commit 1dabb39

Please sign in to comment.