Network-specific thresholds for required confirmations (IS) (#1962)

This commit is contained in:
UdjinM6 2018-03-10 15:35:09 +03:00 committed by GitHub
parent 6536003528
commit 7d5223b5e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 5 deletions

View File

@ -126,6 +126,7 @@ public:
consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
consensus.nInstantSendConfirmationsRequired = 6;
consensus.nInstantSendKeepLock = 24; consensus.nInstantSendKeepLock = 24;
consensus.nBudgetPaymentsStartBlock = 328008; // actual historical value consensus.nBudgetPaymentsStartBlock = 328008; // actual historical value
consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725 consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725
@ -278,6 +279,7 @@ public:
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 4030; consensus.nMasternodePaymentsIncreaseBlock = 4030;
consensus.nMasternodePaymentsIncreasePeriod = 10; consensus.nMasternodePaymentsIncreasePeriod = 10;
consensus.nInstantSendConfirmationsRequired = 2;
consensus.nInstantSendKeepLock = 6; consensus.nInstantSendKeepLock = 6;
consensus.nBudgetPaymentsStartBlock = 4100; consensus.nBudgetPaymentsStartBlock = 4100;
consensus.nBudgetPaymentsCycleBlocks = 50; consensus.nBudgetPaymentsCycleBlocks = 50;
@ -408,6 +410,7 @@ public:
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 4030; consensus.nMasternodePaymentsIncreaseBlock = 4030;
consensus.nMasternodePaymentsIncreasePeriod = 10; consensus.nMasternodePaymentsIncreasePeriod = 10;
consensus.nInstantSendConfirmationsRequired = 2;
consensus.nInstantSendKeepLock = 6; consensus.nInstantSendKeepLock = 6;
consensus.nBudgetPaymentsStartBlock = 4100; consensus.nBudgetPaymentsStartBlock = 4100;
consensus.nBudgetPaymentsCycleBlocks = 50; consensus.nBudgetPaymentsCycleBlocks = 50;
@ -534,6 +537,7 @@ public:
consensus.nMasternodePaymentsStartBlock = 240; consensus.nMasternodePaymentsStartBlock = 240;
consensus.nMasternodePaymentsIncreaseBlock = 350; consensus.nMasternodePaymentsIncreaseBlock = 350;
consensus.nMasternodePaymentsIncreasePeriod = 10; consensus.nMasternodePaymentsIncreasePeriod = 10;
consensus.nInstantSendConfirmationsRequired = 2;
consensus.nInstantSendKeepLock = 6; consensus.nInstantSendKeepLock = 6;
consensus.nBudgetPaymentsStartBlock = 1000; consensus.nBudgetPaymentsStartBlock = 1000;
consensus.nBudgetPaymentsCycleBlocks = 50; consensus.nBudgetPaymentsCycleBlocks = 50;

View File

@ -48,6 +48,7 @@ struct Params {
int nMasternodePaymentsStartBlock; int nMasternodePaymentsStartBlock;
int nMasternodePaymentsIncreaseBlock; int nMasternodePaymentsIncreaseBlock;
int nMasternodePaymentsIncreasePeriod; // in blocks int nMasternodePaymentsIncreasePeriod; // in blocks
int nInstantSendConfirmationsRequired; // in blocks
int nInstantSendKeepLock; // in blocks int nInstantSendKeepLock; // in blocks
int nBudgetPaymentsStartBlock; int nBudgetPaymentsStartBlock;
int nBudgetPaymentsCycleBlocks; int nBudgetPaymentsCycleBlocks;

View File

@ -964,6 +964,8 @@ bool CTxLockRequest::IsValid() const
CAmount nValueIn = 0; CAmount nValueIn = 0;
int nInstantSendConfirmationsRequired = Params().GetConsensus().nInstantSendConfirmationsRequired;
for (const auto& txin : tx->vin) { for (const auto& txin : tx->vin) {
Coin coin; Coin coin;
@ -975,7 +977,7 @@ bool CTxLockRequest::IsValid() const
int nTxAge = chainActive.Height() - coin.nHeight + 1; int nTxAge = chainActive.Height() - coin.nHeight + 1;
// 1 less than the "send IX" gui requires, in case of a block propagating the network at the time // 1 less than the "send IX" gui requires, in case of a block propagating the network at the time
int nConfirmationsRequired = INSTANTSEND_CONFIRMATIONS_REQUIRED - 1; int nConfirmationsRequired = nInstantSendConfirmationsRequired - 1;
if(nTxAge < nConfirmationsRequired) { if(nTxAge < nConfirmationsRequired) {
LogPrint("instantsend", "CTxLockRequest::IsValid -- outpoint %s too new: nTxAge=%d, nConfirmationsRequired=%d, txid=%s\n", LogPrint("instantsend", "CTxLockRequest::IsValid -- outpoint %s too new: nTxAge=%d, nConfirmationsRequired=%d, txid=%s\n",

View File

@ -25,7 +25,6 @@ extern CInstantSend instantsend;
### getting 5 of 10 signatures w/ 1000 nodes of 2900 ### getting 5 of 10 signatures w/ 1000 nodes of 2900
(1000/2900.0)**5 = 0.004875397277841433 (1000/2900.0)**5 = 0.004875397277841433
*/ */
static const int INSTANTSEND_CONFIRMATIONS_REQUIRED = 6;
static const int MIN_INSTANTSEND_DEPTH = 0; static const int MIN_INSTANTSEND_DEPTH = 0;
static const int MAX_INSTANTSEND_DEPTH = 60; static const int MAX_INSTANTSEND_DEPTH = 60;

View File

@ -2569,6 +2569,8 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
{ {
LOCK2(cs_main, cs_wallet); LOCK2(cs_main, cs_wallet);
int nInstantSendConfirmationsRequired = Params().GetConsensus().nInstantSendConfirmationsRequired;
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{ {
const uint256& wtxid = it->first; const uint256& wtxid = it->first;
@ -2584,8 +2586,8 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
continue; continue;
int nDepth = pcoin->GetDepthInMainChain(false); int nDepth = pcoin->GetDepthInMainChain(false);
// do not use IX for inputs that have less then INSTANTSEND_CONFIRMATIONS_REQUIRED blockchain confirmations // do not use IX for inputs that have less then nInstantSendConfirmationsRequired blockchain confirmations
if (fUseInstantSend && nDepth < INSTANTSEND_CONFIRMATIONS_REQUIRED) if (fUseInstantSend && nDepth < nInstantSendConfirmationsRequired)
continue; continue;
// We should not consider coins which aren't at least in our mempool // We should not consider coins which aren't at least in our mempool
@ -3464,6 +3466,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
{ {
std::vector<COutput> vAvailableCoins; std::vector<COutput> vAvailableCoins;
AvailableCoins(vAvailableCoins, true, coinControl, false, nCoinType, fUseInstantSend); AvailableCoins(vAvailableCoins, true, coinControl, false, nCoinType, fUseInstantSend);
int nInstantSendConfirmationsRequired = Params().GetConsensus().nInstantSendConfirmationsRequired;
nFeeRet = 0; nFeeRet = 0;
if(nFeePay > 0) nFeeRet = nFeePay; if(nFeePay > 0) nFeeRet = nFeePay;
@ -3526,7 +3529,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
strFailReason = _("Insufficient funds."); strFailReason = _("Insufficient funds.");
if (fUseInstantSend) { if (fUseInstantSend) {
// could be not true but most likely that's the reason // could be not true but most likely that's the reason
strFailReason += " " + strprintf(_("InstantSend requires inputs with at least %d confirmations, you might need to wait a few minutes and try again."), INSTANTSEND_CONFIRMATIONS_REQUIRED); strFailReason += " " + strprintf(_("InstantSend requires inputs with at least %d confirmations, you might need to wait a few minutes and try again."), nInstantSendConfirmationsRequired);
} }
} }