Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Crown
crown-core
Commits
d187a5cf
Commit
d187a5cf
authored
7 years ago
by
Alastair Clark
2
Browse files
Options
Download
Email Patches
Plain Diff
Budget fail safe payment to devfund address
parent
5ab927c0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/chainparams.cpp
+2
-2
src/chainparams.cpp
src/chainparams.h
+1
-1
src/chainparams.h
src/masternode-budget.cpp
+59
-8
src/masternode-budget.cpp
src/masternode-budget.h
+1
-0
src/masternode-budget.h
with
63 additions
and
11 deletions
+63
-11
src/chainparams.cpp
View file @
d187a5cf
...
...
@@ -186,7 +186,7 @@ public:
nPoolMaxTransactions
=
3
;
strSporkKey
=
"0440409BDACDCE03BFB6D5F16E2D414953038996B49BEE6697CFA400A0001D0837C885C5B57DAD10E5CAAAE36EE975005CC6CBD7001A2A8DE76FF12185904A9BB1"
;
str
LegacySignerDummy
Address
=
"1
8WTcWvwrNnfqeQAn6th9QQ2EpnXMq5Th8
"
;
str
Devfund
Address
=
"1
6tg5tuZrPKoBwfbmj2tmiEPhVPzyn3gtP
"
;
nStartMasternodePayments
=
1403728576
;
//Wed, 25 Jun 2014 20:36:16 GMT
}
...
...
@@ -301,7 +301,7 @@ public:
nPoolMaxTransactions
=
2
;
strSporkKey
=
"0440409BDACDCE03BFB6D5F16E2D414953038996B49BEE6697CFA400A0001D0837C885C5B57DAD10E5CAAAE36EE975005CC6CBD7001A2A8DE76FF12185904A9BB1"
;
str
LegacySignerDummy
Address
=
"y1EZuxhhNMAUofTBEeLqGE1bJrpC2TWRNp"
;
str
Devfund
Address
=
"y1EZuxhhNMAUofTBEeLqGE1bJrpC2TWRNp"
;
nStartMasternodePayments
=
1420837558
;
//Fri, 09 Jan 2015 21:05:58 GMT
}
const
Checkpoints
::
CCheckpointData
&
Checkpoints
()
const
...
...
This diff is collapsed.
Click to expand it.
src/chainparams.h
View file @
d187a5cf
...
...
@@ -79,7 +79,7 @@ public:
virtual
const
Checkpoints
::
CCheckpointData
&
Checkpoints
()
const
=
0
;
int
PoolMaxTransactions
()
const
{
return
nPoolMaxTransactions
;
}
std
::
string
SporkKey
()
const
{
return
strSporkKey
;
}
std
::
string
LegacySignerDummy
Address
()
const
{
return
str
LegacySignerDummy
Address
;
}
std
::
string
Devfund
Address
()
const
{
return
str
Devfund
Address
;
}
int64_t
StartMasternodePayments
()
const
{
return
nStartMasternodePayments
;
}
CBaseChainParams
::
Network
NetworkID
()
const
{
return
networkID
;
}
/* Return the auxpow chain ID. */
...
...
This diff is collapsed.
Click to expand it.
src/masternode-budget.cpp
View file @
d187a5cf
...
...
@@ -481,13 +481,13 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees)
CAmount blockValue = GetBlockValue(pindexPrev->nBits, pindexPrev->nHeight, nFees);
//
m
iners get the full amount on these blocks
//
M
iners get the full amount on these blocks
txNew.vout[0].nValue = blockValue;
if(nHighestCount > 0){
txNew.vout.resize(2);
//
t
hese are super blocks, so their value can be much larger than normal
//
T
hese are super blocks, so their value can be much larger than normal
txNew.vout[1].scriptPubKey = payee;
txNew.vout[1].nValue = nAmount;
...
...
@@ -496,6 +496,16 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees)
CBitcoinAddress address2(address1);
LogPrintf("CBudgetManager::FillBlockPayee - Budget payment to %s for %lld\n", address2.ToString(), nAmount);
} else {
// Pay dev fund
txNew.vout.resize(2);
// These are super blocks, so their value can be much larger than normal
CTxDestination dest = CBitcoinAddress(Params().DevfundAddress()).Get();
txNew.vout[1].scriptPubKey = GetScriptForDestination(dest);
txNew.vout[1].nValue = 4320000000000;
LogPrintf("CBudgetManager::FillBlockPayee - Budget payment to Dev fund for %lld\n", nAmount);
}
}
...
...
@@ -557,9 +567,10 @@ bool CBudgetManager::IsBudgetPaymentBlock(int nBlockHeight)
}
/*
If budget doesn't have 5% of the network votes, then we should pay
a masternode
instead
If budget doesn't have 5% of the network votes, then we should pay
the dev fund
instead
*/
if(nHighestCount > mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/20) return true;
if (nBlockHeight % GetBudgetPaymentCycleBlocks() == 0) return true;
return false;
}
...
...
@@ -604,12 +615,15 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
}
/*
If budget doesn't have 5% of the network votes, then we should
pay a masternode
instead
If budget doesn't have 5% of the network votes, then we should
the dev fund
instead
*/
if(nHighestCount < mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/20) return false;
// check the highest finalized budgets (+/- 10% to assist in consensus)
if(nHighestCount < mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/20) {
return false;
} else if (IsDevTransactionValid(txNew, nBlockHeight)) {
return true;
}
// Check the highest finalized budgets (+/- 10% to assist in consensus)
it = mapFinalizedBudgets.begin();
while(it != mapFinalizedBudgets.end())
{
...
...
@@ -626,10 +640,47 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
++it;
}
//we looked through all of the known budgets
// If budget has more than 5% of the votes but less than 10% pay the dev fund.
// If anything goes wrong above it will default to use IsDevTransactionValid.
if(nHighestCount < mnodeman.CountEnabled(MIN_BUDGET_PEER_PROTO_VERSION)/10)
{
// Check dev fund payment
if (IsDevTransactionValid(txNew, nBlockHeight)) {
return true;
}
}
// We looked through all of the known budgets
return false;
}
bool CBudgetManager::IsDevTransactionValid(const CTransaction& txNew, int nBlockHeight)
{
int nCurrentBudgetPayment = nBlockHeight % GetBudgetPaymentCycleBlocks();
if(nCurrentBudgetPayment > 0) {
LogPrintf("CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n", nBlockHeight, GetBlockStart());
return false;
}
bool found = false;
CTxDestination dest = CBitcoinAddress(Params().DevfundAddress()).Get();
CScript devscript = GetScriptForDestination(dest);
BOOST_FOREACH(CTxOut out, txNew.vout)
{
if(devscript == out.scriptPubKey && 4320000000000 == out.nValue)
found = true;
}
if(!found) {
CTxDestination address1;
ExtractDestination(devscript, address1);
CBitcoinAddress address2(address1);
LogPrintf("CFinalizedBudget::IsTransactionValid - Missing required payment - %s: %d\n", address2.ToString(), vecBudgetPayments[nCurrentBudgetPayment].nAmount);
}
return found;
}
std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals()
{
LOCK(cs);
...
...
This diff is collapsed.
Click to expand it.
src/masternode-budget.h
View file @
d187a5cf
...
...
@@ -138,6 +138,7 @@ public:
bool
UpdateFinalizedBudget
(
CFinalizedBudgetVote
&
vote
,
CNode
*
pfrom
,
std
::
string
&
strError
);
bool
PropExists
(
uint256
nHash
);
bool
IsTransactionValid
(
const
CTransaction
&
txNew
,
int
nBlockHeight
);
bool
IsDevTransactionValid
(
const
CTransaction
&
txNew
,
int
nBlockHeight
);
std
::
string
GetRequiredPaymentsString
(
int
nBlockHeight
);
void
FillBlockPayee
(
CMutableTransaction
&
txNew
,
CAmount
nFees
);
...
...
This diff is collapsed.
Click to expand it.
Volodymyr Shamray
@vshamray
mentioned in commit
baadea2e
·
7 years ago
mentioned in commit
baadea2e
mentioned in commit baadea2e9588b442c6a6048b60dab8b8fbd50b89
Toggle commit list
Volodymyr Shamray
@vshamray
mentioned in merge request
!78 (merged)
·
7 years ago
mentioned in merge request
!78 (merged)
mentioned in merge request !78
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help