Skip to content

Commit 55509f1

Browse files
Document assumptions that are being made to avoid division by zero
1 parent 3f726c9 commit 55509f1

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

src/policy/fees.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ void TxConfirmStats::removeTx(unsigned int entryHeight, unsigned int nBestSeenHe
503503
}
504504
}
505505
if (!inBlock && (unsigned int)blocksAgo >= scale) { // Only counts as a failure if not confirmed for entire period
506+
assert(scale != 0);
506507
unsigned int periodsAgo = blocksAgo / scale;
507508
for (size_t i = 0; i < periodsAgo && i < failAvg.size(); i++) {
508509
failAvg[i][bucketindex]++;

src/qt/coincontroldialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
581581
QString toolTipDust = tr("This label turns red if any recipient receives an amount smaller than the current dust threshold.");
582582

583583
// how many satoshis the estimated fee can vary per byte we guess wrong
584+
assert(nBytes != 0);
584585
double dFeeVary = (double)nPayFee / nBytes;
585586

586587
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,6 +2741,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27412741

27422742
if (recipient.fSubtractFeeFromAmount)
27432743
{
2744+
assert(nSubtractFeeFromAmount != 0);
27442745
txout.nValue -= nFeeRet / nSubtractFeeFromAmount; // Subtract fee equally from each selected recipient
27452746

27462747
if (fFirst) // first receiver pays the remainder not divisible by output count

0 commit comments

Comments
 (0)