Skip to content

Commit 7310fc4

Browse files
committed
Enable multisig proposal after v6
1 parent a161b1d commit 7310fc4

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

src/budget/budgetmanager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,18 @@ bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal)
324324
{
325325
AssertLockNotHeld(cs_proposals); // need to lock cs_main here (CheckCollateral)
326326
const uint256& nHash = budgetProposal.GetHash();
327-
327+
int nCurrentHeight = GetBestHeight();
328328
if (WITH_LOCK(cs_proposals, return mapProposals.count(nHash))) {
329329
LogPrint(BCLog::MNBUDGET,"%s: proposal %s already added\n", __func__, nHash.ToString());
330330
return false;
331331
}
332332

333-
if (!budgetProposal.IsWellFormed(GetTotalBudget(budgetProposal.GetBlockStart()))) {
333+
if (!budgetProposal.IsWellFormed(GetTotalBudget(budgetProposal.GetBlockStart()), nCurrentHeight)) {
334334
LogPrint(BCLog::MNBUDGET,"%s: Invalid budget proposal %s %s\n", __func__, nHash.ToString(), budgetProposal.IsInvalidLogStr());
335335
return false;
336336
}
337337

338338
std::string strError;
339-
int nCurrentHeight = GetBestHeight();
340339
const uint256& feeTxId = budgetProposal.GetFeeTXHash();
341340
if (!CheckCollateral(feeTxId, nHash, strError, budgetProposal.nTime, nCurrentHeight, false)) {
342341
LogPrint(BCLog::MNBUDGET,"%s: invalid budget proposal (%s) collateral id=%s - %s\n",

src/budget/budgetproposal.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ bool CBudgetProposal::CheckAmount(const CAmount& nTotalBudget)
123123
return true;
124124
}
125125

126-
bool CBudgetProposal::CheckAddress()
126+
bool CBudgetProposal::CheckAddress(const int nCurrentHeight)
127127
{
128-
// !TODO: There might be an issue with multisig in the coinbase on mainnet
129-
// we will add support for it in a future release.
130-
if (address.IsPayToScriptHash()) {
128+
// Multisig is supported only after v6
129+
bool isV6Enforced = Params().GetConsensus().NetworkUpgradeActive(nCurrentHeight, Consensus::UPGRADE_V6_0);
130+
if (!isV6Enforced && address.IsPayToScriptHash()) {
131131
strInvalid = "Multisig is not currently supported.";
132132
return false;
133133
}
@@ -160,9 +160,9 @@ bool CBudgetProposal::CheckStrings()
160160
}
161161
}
162162

163-
bool CBudgetProposal::IsWellFormed(const CAmount& nTotalBudget)
163+
bool CBudgetProposal::IsWellFormed(const CAmount& nTotalBudget, const int nCurrentHeight)
164164
{
165-
return CheckStartEnd() && CheckAmount(nTotalBudget) && CheckAddress();
165+
return CheckStartEnd() && CheckAmount(nTotalBudget) && CheckAddress(nCurrentHeight);
166166
}
167167

168168
bool CBudgetProposal::updateExpired(int nCurrentHeight)

src/budget/budgetproposal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CBudgetProposal
4141
bool updateExpired(int nCurrentHeight);
4242
bool CheckStartEnd();
4343
bool CheckAmount(const CAmount& nTotalBudget);
44-
bool CheckAddress();
44+
bool CheckAddress(const int nCurrentHeight);
4545
bool CheckStrings();
4646

4747
protected:
@@ -71,7 +71,7 @@ class CBudgetProposal
7171
// sets fValid and strInvalid, returns fValid
7272
bool UpdateValid(int nHeight, int mnCount);
7373
// Static checks that should be done only once - sets strInvalid
74-
bool IsWellFormed(const CAmount& nTotalBudget);
74+
bool IsWellFormed(const CAmount& nTotalBudget, const int nCurrentHeight);
7575
bool IsValid() const { return fValid; }
7676
void SetStrInvalid(const std::string& _strInvalid) { strInvalid = _strInvalid; }
7777
std::string IsInvalidReason() const { return strInvalid; }

src/qt/pivx/governancemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ OperationResult GovernanceModel::createProposal(const std::string& strProposalNa
245245

246246
// Validate proposal
247247
CBudgetProposal proposal(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, UINT256_ZERO);
248-
if (!proposal.IsWellFormed(g_budgetman.GetTotalBudget(proposal.GetBlockStart()))) {
248+
if (!proposal.IsWellFormed(g_budgetman.GetTotalBudget(proposal.GetBlockStart()), clientModel->getNumBlocks())) {
249249
return {false, strprintf(_("Proposal is not valid %s"), proposal.IsInvalidReason())};
250250
}
251251

src/rpc/budget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ UniValue preparebudget(const JSONRPCRequest& request)
147147
// create transaction 15 minutes into the future, to allow for confirmation time
148148
CBudgetProposal proposal(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, UINT256_ZERO);
149149
const uint256& nHash = proposal.GetHash();
150-
if (!proposal.IsWellFormed(g_budgetman.GetTotalBudget(proposal.GetBlockStart())))
150+
if (!proposal.IsWellFormed(g_budgetman.GetTotalBudget(proposal.GetBlockStart()), GetChainTip()->nHeight))
151151
throw std::runtime_error("Proposal is not valid " + proposal.IsInvalidReason());
152152

153153
CTransactionRef wtx;

0 commit comments

Comments
 (0)