Update superblock valid checking to allow block creation by p2pool (#1190)

* Update superblock valid checking to allow block creation by p2pool

* Comment correction for superblock payment not found.

* Comment correction
This commit is contained in:
TheLazieR Yip 2016-12-07 00:26:44 +07:00 committed by UdjinM6
parent 6a3550b94f
commit 3914f4a1c4

View File

@ -670,8 +670,7 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
nOutputs, nPayments, GetGovernanceObject()->GetDataAsHex()); nOutputs, nPayments, GetGovernanceObject()->GetDataAsHex());
// We require an exact match (including order) between the expected // We require an exact match (including order) between the expected
// superblock payments and the payments actually in the block, after // superblock payments and the payments actually in the block.
// skipping any initial miner payments.
if(nMinerPayments < 0) { if(nMinerPayments < 0) {
// This means the block cannot have all the superblock payments // This means the block cannot have all the superblock payments
@ -696,6 +695,7 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
return false; return false;
} }
int nVoutIndex = 0;
for(int i = 0; i < nPayments; i++) { for(int i = 0; i < nPayments; i++) {
CGovernancePayment payment; CGovernancePayment payment;
if(!GetPayment(i, payment)) { if(!GetPayment(i, payment)) {
@ -704,18 +704,26 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
continue; continue;
} }
int nVoutIndex = nMinerPayments + i; bool fPaymentMatch = false;
bool fPaymentMatch = ((payment.script == txNew.vout[nVoutIndex].scriptPubKey) && for (int j = nVoutIndex; j < nOutputs; j++) {
(payment.nAmount == txNew.vout[nVoutIndex].nValue)); // Find superblock payment
fPaymentMatch = ((payment.script == txNew.vout[j].scriptPubKey) &&
(payment.nAmount == txNew.vout[j].nValue));
if (fPaymentMatch) {
nVoutIndex = j;
break;
}
}
if(!fPaymentMatch) { if(!fPaymentMatch) {
// MISMATCHED SUPERBLOCK OUTPUT! // Superblock payment not found!
CTxDestination address1; CTxDestination address1;
ExtractDestination(payment.script, address1); ExtractDestination(payment.script, address1);
CBitcoinAddress address2(address1); CBitcoinAddress address2(address1);
LogPrintf("CSuperblock::IsValid -- ERROR: Block invalid: output n %d payment %d to %s\n", nVoutIndex, payment.nAmount, address2.ToString()); LogPrintf("CSuperblock::IsValid -- ERROR: Block invalid: %d payment %d to %s not found\n", i, payment.nAmount, address2.ToString());
return false; return false;
} }