Skip to content

Commit

Permalink
Merge pull request dashpay#19 from PACGlobalOfficial/0.14-dip0003-cha…
Browse files Browse the repository at this point in the history
…nges

Change policies regarding DIP0003 transaction propogation.
  • Loading branch information
barrystyle authored and barrystyle committed Sep 28, 2019
2 parents eafd13a + ae721ad commit b573a72
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ void static BitcoinMiner(const CChainParams& chainparams, CConnman& connman, CWa
BlockAssembler assembler(chainparams);
auto pblocktemplate = assembler.CreateNewBlock(coinbaseScript->reserveScript, fProofOfStake);
if (!pblocktemplate.get()) {
LogPrintf("PACminer -- Failed to find a coinstake\n");
MilliSleep(5000);
continue;
}
Expand Down
16 changes: 7 additions & 9 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,15 +856,13 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
}

// No transactions are allowed below minRelayTxFee except from disconnected blocks (or unless tx.nType != TRANSACTION_NORMAL)
if (fLimitFree && nModifiedFees < MinRelayFee().GetFee(nSize) && (tx.nType == TRANSACTION_NORMAL)) {
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "min relay fee not met");
}

if (nAbsurdFee && nFees > nAbsurdFee)
return state.Invalid(false,
REJECT_HIGHFEE, "absurdly-high-fee",
strprintf("%d > %d", nFees, nAbsurdFee));
// No transactions are allowed below minRelayTxFee except from disconnected blocks
if (tx.nType == TRANSACTION_NORMAL) {
if (fLimitFree && nModifiedFees < MinRelayFee().GetFee(nSize))
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "min relay fee not met");
if (nAbsurdFee && nFees > nAbsurdFee)
return state.Invalid(false, REJECT_HIGHFEE, "absurdly-high-fee", strprintf("%d > %d", nFees, nAbsurdFee));
}

// Calculate in-mempool ancestors, up to a limit.
CTxMemPool::setEntries setAncestors;
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const int INIT_PROTO_VERSION = 209;
static const int GETHEADERS_VERSION = 70077;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION_MAINNET = 70215;
static const int MIN_PEER_PROTO_VERSION_MAINNET = 70216;
static const int MIN_PEER_PROTO_VERSION_TESTNET = 70216;

//! nTime field added to CAddress, starting with this version;
Expand Down
13 changes: 9 additions & 4 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,7 +2911,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov

CReserveKey reservekey(this);
CWalletTx wtx;
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, &coinControl, false, ALL_COINS, false, nExtraPayloadSize, (tx.nType == TRANSACTION_NORMAL)))
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, &coinControl, false, ALL_COINS, false, nExtraPayloadSize))
return false;

if (nChangePosInOut != -1)
Expand Down Expand Up @@ -3319,14 +3319,19 @@ bool CWallet::ConvertList(std::vector<CTxIn> vecTxIn, std::vector<CAmount>& vecA
}

bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet,
int& nChangePosInOut, std::string& strFailReason, const CCoinControl* coinControl, bool sign, AvailableCoinsType nCoinType, bool fUseInstaPAC, int nExtraPayloadSize, bool fStandardTx)
int& nChangePosInOut, std::string& strFailReason, const CCoinControl* coinControl, bool sign, AvailableCoinsType nCoinType, bool fUseInstaPAC, int nExtraPayloadSize)
{
if (!llmq::IsOldInstaPACEnabled()) {
// The new system does not require special handling for InstaPAC as this is all done in CInstaPACManager.
// There is also no need for an extra fee anymore.
fUseInstaPAC = false;
}

if (nExtraPayloadSize > 0 && chainActive.Height() < Params().GetConsensus().DIP0003Height) {
strFailReason = _("The DIP0003 activation height has not been met.");
return false;
}

CAmount nFeePay = fUseInstaPAC ? CTxLockRequest().GetMinFee(true) : 0;

CAmount nValue = 0;
Expand All @@ -3340,7 +3345,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
return false;
}

if (recipient.nAmount < COIN && fStandardTx == true)
if (recipient.nAmount < COIN && nExtraPayloadSize == 0)
{
strFailReason = _("Output amounts must be equal to or greater than 1 PAC");
return false;
Expand Down Expand Up @@ -3925,7 +3930,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, CAm
}

if(!fKernelFound) {
LogPrintf("Failed to find a coinstake");
LogPrintf("Failed to find a coinstake\n");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
* @note passing nChangePosInOut as -1 will result in setting a random position
*/
bool CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosInOut,
std::string& strFailReason, const CCoinControl *coinControl = NULL, bool sign = true, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstaPAC=false, int nExtraPayloadSize = 0, bool fStandardTx = true);
std::string& strFailReason, const CCoinControl *coinControl = NULL, bool sign = true, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstaPAC=false, int nExtraPayloadSize = 0);
bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, CAmount blockReward,
CMutableTransaction& txNew, unsigned int& nTxNewTime,
std::vector<const CWalletTx *> &vwtxPrev);
Expand Down

0 comments on commit b573a72

Please sign in to comment.