Skip to content
Permalink
Browse files

1.1.8.9 - Mandatory Upgrade (for Entire Network)

- Prevent crash in POG Leaderboard when chain not synced (MIP)
- Prevent POG illegal tithes, Fix POG pool bug, make POG more exact
- Enhance exec pogaudit, and exec istithelegal
- Allow users to pay prayer_threshhold_amount to send a public prayer
  • Loading branch information...
biblepay committed Feb 19, 2019
1 parent 6c781f2 commit 17375d5292aa010c3ac13f383b75bf9eefdccc7f
Showing with 197 additions and 53 deletions.
  1. +1 −1 configure.ac
  2. +1 −1 src/clientversion.cpp
  3. +80 −21 src/main.cpp
  4. +1 −0 src/main.h
  5. +6 −0 src/primitives/block.h
  6. +4 −3 src/qt/businessobjectlist.cpp
  7. +6 −1 src/qt/sendcoinsentry.cpp
  8. +27 −15 src/rpcblockchain.cpp
  9. +67 −10 src/rpcpog.cpp
  10. +4 −1 src/rpcpog.h
@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_REVISION, 8)
define(_CLIENT_VERSION_BUILD, 8)
define(_CLIENT_VERSION_BUILD, 9)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
AC_INIT([biblepay Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/biblepaypay/biblepay/issues],[biblepaycore])
@@ -19,7 +19,7 @@ const std::string CLIENT_NAME("Biblepay Core");
const int BIBLEPAY_VERSION_MAJOR = 1;
const int BIBLEPAY_VERSION_MINOR = 1;
const int BIBLEPAY_VERSION_REVISION = 8;
const int BIBLEPAY_VERSION_BUILD = 8;
const int BIBLEPAY_VERSION_BUILD = 9;


const int BIBLE_VERSION = 1000000 * BIBLEPAY_VERSION_MAJOR
@@ -1705,23 +1705,49 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
int nTitheCount = pool.getTitheCount();
double dPogDiff = GetPOGDifficulty(chainActive.Tip());
std::string sRecipient = PubKeyToAddress(tx.vout[0].scriptPubKey);
bool bIsTithe = (sRecipient == chainparams.GetConsensus().FoundationAddress);
if (bIsTithe && dPogDiff < LOW_POG_DIFF && nTitheCount > TITHE_OVERFLOW)
CAmount nTitheAmount = GetTitheTotal(tx);
if (nTitheAmount > 0)
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type I; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (bIsTithe && nTitheCount > (TITHE_OVERFLOW * 2))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type II; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (bIsTithe && dPogDiff < LOW_POG_DIFF && chainActive.Height() < POG_V2_CUTOVER_HEIGHT_PROD && nTitheCount > (TITHE_OVERFLOW / 15))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type III; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
if (dPogDiff < LOW_POG_DIFF && nTitheCount > TITHE_OVERFLOW)
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type I; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (nTitheCount > (TITHE_OVERFLOW))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type II; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (dPogDiff < LOW_POG_DIFF && chainActive.Height() < POG_V2_CUTOVER_HEIGHT_PROD && nTitheCount > (TITHE_OVERFLOW / 15))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type III; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (chainActive.Height() < POG_V3_CUTOVER_HEIGHT_PROD && fProd && nTitheAmount > (10 * COIN) && chainActive.Height() > POG_V2_CUTOVER_HEIGHT_PROD)
{
LogPrintf("AcceptToMemPool::Tithe Too Large; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}

/*
TitheDifficultyParams tdp = GetTitheParams(chainActive.Tip());
else if (nTitheAmount > (10 * COIN))
{
LogPrintf("AcceptToMemPool::Tithe Too Large; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
CTitheObject oTithe = TxToTithe(tx, chainActive.Tip());
int iLegal = IsTitheLegal3(oTithe, tdp);
if (iLegal != 1)
{
std::string sErr = TitheErrorToString(iLegal);
LogPrintf("AcceptToMemPool::Illegal Tithe; Tithe Rejected; Status %s, TitheCount %f, Pog Diff %f", sErr.c_str(), nTitheCount, dPogDiff);
return false;
}
LogPrintf("Tithe Count %f, Diff %f ",(double)nTitheCount, dPogDiff);
*/
}
LogPrintf("Tithe Count %f, Diff %f ",(double)nTitheCount, dPogDiff);
}

// If we aren't going to actually accept it but just were verifying it, we are fine already
@@ -4607,19 +4633,37 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn

// Rob A., Biblepay, 3/7/2018, Kick Off BotNet Rules
double dBlockVersion = GetBlockVersion(block.vtx[0]);
if (fProd && nHeight > F11000_CUTOVER_HEIGHT_PROD && dBlockVersion < 1101)
if (fProd && nHeight > POG_V3_CUTOVER_HEIGHT_PROD && dBlockVersion < 1189)
{
LogPrintf("ContextualCheckBlock::ERROR Rejecting block version %f at height %f \n",(double)dBlockVersion,(double)nHeight);
return false;
}
return state.DoS(10, error("%s: Rejecting pog block version < 1189", __func__), REJECT_INVALID, "bad-block-version");
}

if (!fProd && nHeight > FPOG_CUTOVER_HEIGHT_TESTNET && dBlockVersion < 1179)
{
if (false) LogPrintf("ContextualCheckBlock::ERROR Rejecting testnet block version %f at height %f \n",(double)dBlockVersion,(double)nHeight);
return state.DoS(10, error("%s: Rejecting testnet block version < 1179", __func__), REJECT_INVALID, "bad-testnet-block-version");
}

// Rob A. - BiblePay - 12/3/2018
// Rob A. - BiblePay - 12/3/2018, 2/18/2019
/* // We are doing this in IsTitheLegal3 in the induction phase for safety
if (nHeight > POG_V3_CUTOVER_HEIGHT_PROD && fProd)
{
int iTitheCount = 0;
BOOST_FOREACH(const CTransaction& tx, block.vtx)
{
CAmount nTitheAmount = GetTitheTotal(tx);
if (nTitheAmount > 0) iTitheCount++;
if (nTitheAmount > (10 * COIN))
return state.DoS(10, error("%s: POG amount too high", __func__), REJECT_INVALID, "pog-tithe-too-high");
}
if (iTitheCount > TITHE_OVERFLOW)
{
return state.DoS(10, error("%s: POG quantity too high", __func__), REJECT_INVALID, "pog-qty-too-high");
}
}
*/

if (POGEnabled(nHeight, block.GetBlockTime()) && !fReindex)
{
bool fIsPogSuperblock = CSuperblock::IsPOGSuperblock(nHeight);
@@ -7896,12 +7940,27 @@ TxMessage GetTxMessage(std::string sMessage, int64_t nTime, int iPosition, std::
t.fPrayersMustBeSigned = (GetSporkDouble("prayersmustbesigned", 0) == 1);

if (t.sMessageType == "PRAYER" && (!(Contains(t.sMessageKey, "(") ))) t.sMessageKey += " (" + t.sTimestamp + ")";
if (t.sMessageType == "SPORK" || (t.sMessageType == "PRAYER" && t.fPrayersMustBeSigned))
if (t.sMessageType == "SPORK")
{
t.fSporkSigValid = CheckSporkSig(t);
if (!t.fSporkSigValid) t.sMessageValue = "";
t.fPassedSecurityCheck = t.fSporkSigValid;
}
else if (t.sMessageType == "PRAYER" && t.fPrayersMustBeSigned)
{
double dMinimumUnsignedPrayerDonation = GetSporkDouble("minimumunsignedprayerdonationamount", 3000);
// If donation is to Foundation and meets minimum amount and is not signed
if (dFoundationDonation >= dMinimumUnsignedPrayerDonation)
{
t.fPassedSecurityCheck = true;
}
else
{
t.fSporkSigValid = CheckSporkSig(t);
if (!t.fSporkSigValid) t.sMessageValue = "";
t.fPassedSecurityCheck = t.fSporkSigValid;
}
}
else if (t.sMessageType == "PRAYER" && !t.fPrayersMustBeSigned)
{
// We allow unsigned prayers, as long as abusers don't deface the system (if they do, we set the spork requiring signed prayers and we manually remove the offensive prayers using a signed update)
@@ -90,6 +90,7 @@ static const int FPOG_CUTOVER_HEIGHT_PROD = 100001; // Feb 7th, 2019 (100,001)
static const int PODC_LAST_BLOCK_PROD = 107000; // March 13th, 2019
static const int PODC_LAST_BLOCK_TESTNET = 126150;
static const int POG_V2_CUTOVER_HEIGHT_PROD = 102025;
static const int POG_V3_CUTOVER_HEIGHT_PROD = 103175;
static const int LOW_POG_DIFF = 5000;
static const int TITHE_OVERFLOW = 75;
static const int MINIMUM_EMAIL_LENGTH = 5; // 3 character domain + . + 1 character name
@@ -90,6 +90,8 @@ class CTitheObject
double Age;
std::string TXID;
int Ordinal;
CAmount CoinAmount;
int SpentHeight;

CTitheObject(std::string xAddress, CAmount xAmount, double xWeight) :
Address(xAddress), Amount(xAmount), Weight(xWeight)
@@ -100,13 +102,17 @@ class CTitheObject
LastBlockHash = uint256S("0x0");
Age = 0;
Ordinal = 0;
CoinAmount = 0;
SpentHeight = 0;
}

CTitheObject() : Address(""), Amount(0), Weight(0), PaymentTier(0), Height(0), HeightLast(0)
{
LastBlockHash = uint256S("0x0");
Age = 0;
Ordinal = 0;
CoinAmount = 0;
SpentHeight = 0;
}

uint256 GetHash() const;
@@ -1,6 +1,7 @@
#include "businessobjectlist.h"
#include "bitcoinunits.h"
#include "ui_businessobjectlist.h"
#include "masternode-sync.h"
#include "secdialog.h"
#include "ui_secdialog.h"
#include "writeorphan.h"
@@ -66,12 +67,12 @@ void BusinessObjectList::UpdateObject(std::string objType)
std::string sFields;
QString pString;

if (objType == "pog_leaderboard")
if (objType == "pog_leaderboard" && masternodeSync.IsBlockchainSynced())
{
sFields = "id,nickname,address,height,amount,weight";
pString = GUIUtil::TOQS(GetPOGBusinessObjectList(ObjectType, sFields));
// Update once per minute
QTimer::singleShot(60000, this, SLOT(RefreshPogLeaderboard()));
// Update once per two minutes
QTimer::singleShot(120000, this, SLOT(RefreshPogLeaderboard()));
}
else
{
@@ -101,11 +101,16 @@ void SendCoinsEntry::updateFoundationAddress()
bool bCheckedF = (ui->chkForceTithe->checkState() == Qt::Checked);
bool bCheckedD = (ui->checkboxFoundation->checkState() == Qt::Checked);

if (bCheckedF || bCheckedD)
if (bCheckedD)
{
ui->payTo->setText(GUIUtil::TOQS(chainparams.GetConsensus().FoundationAddress));
ui->payAmount->setFocus();
}
else if (bCheckedF)
{
ui->payTo->setText(GUIUtil::TOQS(chainparams.GetConsensus().FoundationPODSAddress));
ui->payAmount->setFocus();
}
initPOGDifficulty();
}

@@ -1480,7 +1480,7 @@ UniValue exec(const UniValue& params, bool fHelp)
if (sType.empty() || sPrimaryKey.empty() || sValue.empty())
throw runtime_error(sError);
sError = "";
std::string sResult = SendBlockchainMessage(sType, sPrimaryKey, sValue, 1, true, sError);
std::string sResult = SendBlockchainMessage(sType, sPrimaryKey, sValue, .24, true, sError);
results.push_back(Pair("Sent", sValue));
results.push_back(Pair("TXID", sResult));
if (!sError.empty()) results.push_back(Pair("Error", sError));
@@ -3089,11 +3089,11 @@ UniValue exec(const UniValue& params, bool fHelp)
BOOST_FOREACH(const PAIRTYPE(std::string, CTitheObject)& item, pindex->mapTithes)
{
CTitheObject oTithe = item.second;
int iLegal = IsTitheLegal2(oTithe, tdp);
int iLegal = IsTitheLegal3(oTithe, tdp);
std::string sErr = TitheErrorToString(iLegal);

std::string sRow = "Legal: " + RoundToString(iLegal, 0) + " [" + sErr + "], Amount: " + RoundToString((double)(oTithe.Amount/COIN),2)
+ ", Height: " + RoundToString(oTithe.Height, 0)
std::string sRow = "Legal: " + RoundToString(iLegal, 0) + " [" + sErr + "], Amount: " + RoundToString((double)oTithe.Amount/COIN, 2)
+ ", Height: " + RoundToString(oTithe.Height, 0) + ", Spent_Coin_Value: " + RoundToString((double)oTithe.CoinAmount/COIN, 2)
+ ", " + oTithe.TXID + "-" + RoundToString(oTithe.Ordinal, 0)
+ ", Age: " + RoundToString(oTithe.Age, 2) + ", NickName: " + oTithe.NickName;
results.push_back(Pair(oTithe.Address, sRow));
@@ -3140,7 +3140,7 @@ UniValue exec(const UniValue& params, bool fHelp)
else if (sItem == "istithelegal")
{
if (params.size() != 2)
throw runtime_error("You must specify txid.");
throw runtime_error("You must specify a txid.");
std::string sTxId = params[1].get_str();
CTransaction txTithe;
uint256 hashBlockTithe;
@@ -3152,21 +3152,33 @@ UniValue exec(const UniValue& params, bool fHelp)
int hashInputOrdinal = txTithe.vin[0].prevout.n;
int64_t nTxTime = 0;
CAmount caAmount = 0;
GetTxTimeAndAmount(hashInput, hashInputOrdinal, nTxTime, caAmount);
int iHeight = 0;
GetTxTimeAndAmountAndHeight(hashInput, hashInputOrdinal, nTxTime, caAmount, iHeight);
if (mapBlockIndex.count(hashBlockTithe) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pindex = mapBlockIndex[hashBlockTithe];
double nTitheAge = (double)((pindex->GetBlockTime() - nTxTime) / 86400);
CAmount nTotal = GetTitheTotal(txTithe);
bool bTitheLegal = (nTitheAge >= pindex->pprev->nMinCoinAge && caAmount >= pindex->pprev->nMinCoinAmount && nTotal <= pindex->pprev->nMaxTitheAmount);
CTitheObject oTithe = TxToTithe(txTithe, pindex);
TitheDifficultyParams tdp = GetTitheParams(pindex);
int iLegal = IsTitheLegal3(oTithe, tdp);
std::string sErr = TitheErrorToString(iLegal);
if (iLegal == 1) sErr = "VALID";

results.push_back(Pair("Tithe_Legal", iLegal));
results.push_back(Pair("Tithe_Legal_Result", sErr));

results.push_back(Pair("Tx_Time", pindex->GetBlockTime()));
results.push_back(Pair("Tithed_Height", pindex->nHeight));

results.push_back(Pair("Spent_Time", nTxTime));
results.push_back(Pair("Spent_Height", oTithe.SpentHeight));
results.push_back(Pair("Spent_Coin_Amount", (double)oTithe.CoinAmount / COIN));

results.push_back(Pair("Tithe_Age", (double)oTithe.Age));
results.push_back(Pair("Tithe_Amount", (double)oTithe.Amount / COIN));

results.push_back(Pair("Tithe_Legal", bTitheLegal));
results.push_back(Pair("Tithe_Age", nTitheAge));
results.push_back(Pair("Tithe_Spent_Coin_Amount", (double)(caAmount/COIN)));
results.push_back(Pair("Tithe_Amount", (double)(nTotal/COIN)));
results.push_back(Pair("Block_diff_min_coin_age", pindex->nMinCoinAge));
results.push_back(Pair("Block_diff_min_coin_amt", (double)(pindex->nMinCoinAmount/COIN)));
results.push_back(Pair("Block_diff_max_tithe_amt", (double)(pindex->nMaxTitheAmount/COIN)));
results.push_back(Pair("Tithed_Height", pindex->nHeight));
results.push_back(Pair("Block_diff_min_coin_amt", (double)(pindex->nMinCoinAmount / COIN)));
results.push_back(Pair("Block_diff_max_tithe_amt", (double)(pindex->nMaxTitheAmount / COIN)));
}
else
{
Oops, something went wrong.

0 comments on commit 17375d5

Please sign in to comment.
You can’t perform that action at this time.