Skip to content

Commit ddf58c7

Browse files
MarcoFalkemorcos
authored andcommitted
wallet: Remove sendfree
This removes the option from the wallet to not pay a fee on "small" transactions which spend "old" inputs. This code is no longer worth keeping around, as almost all miners prefer not to include transactions which pay no fee at all.
1 parent 94e5ba9 commit ddf58c7

File tree

5 files changed

+3
-60
lines changed

5 files changed

+3
-60
lines changed

contrib/debian/examples/bitcoin.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@
118118

119119
# Transaction Fee Changes in 0.10.0
120120

121-
# Send transactions as zero-fee transactions if possible (default: 0)
122-
#sendfreetransactions=0
123-
124121
# Create transactions that have enough fees (or priority) so they are likely to begin confirmation within n blocks (default: 1).
125122
# This setting is over-ridden by the -paytxfee option.
126123
#txconfirmtarget=n

contrib/devtools/check-doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"')
2222
REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
2323
# list unsupported, deprecated and duplicate args as they need no documentation
24-
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize'])
24+
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags', '-blockminsize', '-sendfreetransactions'])
2525

2626
def main():
2727
used = check_output(CMD_GREP_ARGS, shell=True)

src/qt/coincontroldialog.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
444444
CAmount nChange = 0;
445445
unsigned int nBytes = 0;
446446
unsigned int nBytesInputs = 0;
447-
double dPriority = 0;
448-
double dPriorityInputs = 0;
449447
unsigned int nQuantity = 0;
450-
int nQuantityUncompressed = 0;
451-
bool fAllowFree = false;
452448
bool fWitness = false;
453449

454450
std::vector<COutPoint> vCoinControl;
@@ -473,9 +469,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
473469
// Amount
474470
nAmount += out.tx->tx->vout[out.i].nValue;
475471

476-
// Priority
477-
dPriorityInputs += (double)out.tx->tx->vout[out.i].nValue * (out.nDepth+1);
478-
479472
// Bytes
480473
CTxDestination address;
481474
int witnessversion = 0;
@@ -492,8 +485,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
492485
if (keyid && model->getPubKey(*keyid, pubkey))
493486
{
494487
nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);
495-
if (!pubkey.IsCompressed())
496-
nQuantityUncompressed++;
497488
}
498489
else
499490
nBytesInputs += 148; // in all error cases, simply assume 148 here
@@ -525,17 +516,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
525516
if (nPayFee > 0 && coinControl->nMinimumTotalFee > nPayFee)
526517
nPayFee = coinControl->nMinimumTotalFee;
527518

528-
529-
// Allow free? (require at least hard-coded threshold and default to that if no estimate)
530-
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
531-
dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
532-
double dPriorityNeeded = std::max(mempoolEstimatePriority, AllowFreeThreshold());
533-
fAllowFree = (dPriority >= dPriorityNeeded);
534-
535-
if (fSendFreeTransactions)
536-
if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
537-
nPayFee = 0;
538-
539519
if (nPayAmount > 0)
540520
{
541521
nChange = nAmount - nPayAmount;

src/wallet/wallet.cpp

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ CWallet* pwalletMain = NULL;
3939
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE);
4040
unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET;
4141
bool bSpendZeroConfChange = DEFAULT_SPEND_ZEROCONF_CHANGE;
42-
bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS;
4342
bool fWalletRbf = DEFAULT_WALLET_RBF;
4443

4544
const char * DEFAULT_WALLET_DAT = "wallet.dat";
@@ -2449,7 +2448,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
24492448
CAmount nValueToSelect = nValue;
24502449
if (nSubtractFeeFromAmount == 0)
24512450
nValueToSelect += nFeeRet;
2452-
double dPriority = 0;
24532451
// vouts to the payees
24542452
for (const auto& recipient : vecSend)
24552453
{
@@ -2490,19 +2488,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
24902488
strFailReason = _("Insufficient funds");
24912489
return false;
24922490
}
2493-
for (const auto& pcoin : setCoins)
2494-
{
2495-
CAmount nCredit = pcoin.first->tx->vout[pcoin.second].nValue;
2496-
//The coin age after the next block (depth+1) is used instead of the current,
2497-
//reflecting an assumption the user would accept a bit more delay for
2498-
//a chance at a free transaction.
2499-
//But mempool inputs might still be in the mempool, so their age stays 0
2500-
int age = pcoin.first->GetDepthInMainChain();
2501-
assert(age >= 0);
2502-
if (age != 0)
2503-
age += 1;
2504-
dPriority += (double)nCredit * age;
2505-
}
25062491

25072492
const CAmount nChange = nValueIn - nValueToSelect;
25082493
if (nChange > 0)
@@ -2614,7 +2599,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
26142599
unsigned int nBytes = GetVirtualTransactionSize(txNew);
26152600

26162601
CTransaction txNewConst(txNew);
2617-
dPriority = txNewConst.ComputePriority(dPriority, nBytes);
26182602

26192603
// Remove scriptSigs to eliminate the fee calculation dummy signatures
26202604
for (auto& vin : txNew.vin) {
@@ -2627,16 +2611,6 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
26272611
if (coinControl && coinControl->nConfirmTarget > 0)
26282612
currentConfirmationTarget = coinControl->nConfirmTarget;
26292613

2630-
// Can we complete this as a free transaction?
2631-
if (fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
2632-
{
2633-
// Not enough fee: enough priority?
2634-
double dPriorityNeeded = mempool.estimateSmartPriority(currentConfirmationTarget);
2635-
// Require at least hard-coded AllowFree.
2636-
if (dPriority >= dPriorityNeeded && AllowFree(dPriority))
2637-
break;
2638-
}
2639-
26402614
CAmount nFeeNeeded = GetMinimumFee(nBytes, currentConfirmationTarget, mempool);
26412615
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
26422616
nFeeNeeded = coinControl->nMinimumTotalFee;
@@ -3548,8 +3522,6 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
35483522
CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
35493523
strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
35503524
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup"));
3551-
if (showDebug)
3552-
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), DEFAULT_SEND_FREE_TRANSACTIONS));
35533525
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
35543526
strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
35553527
strUsage += HelpMessageOpt("-usehd", _("Use hierarchical deterministic key generation (HD) after BIP32. Only has effect during wallet creation/first start") + " " + strprintf(_("(default: %u)"), DEFAULT_USE_HD_WALLET));
@@ -3868,11 +3840,10 @@ bool CWallet::ParameterInteraction()
38683840
}
38693841
nTxConfirmTarget = GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
38703842
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
3871-
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", DEFAULT_SEND_FREE_TRANSACTIONS);
38723843
fWalletRbf = GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF);
38733844

3874-
if (fSendFreeTransactions && GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) <= 0)
3875-
return InitError("Creation of free transactions with their relay disabled is not supported.");
3845+
if (GetBoolArg("-sendfreetransactions", false))
3846+
InitWarning("The argument -sendfreetransactions is no longer supported.");
38763847

38773848
return true;
38783849
}

src/wallet/wallet.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ extern CWallet* pwalletMain;
3939
extern CFeeRate payTxFee;
4040
extern unsigned int nTxConfirmTarget;
4141
extern bool bSpendZeroConfChange;
42-
extern bool fSendFreeTransactions;
4342
extern bool fWalletRbf;
4443

4544
static const unsigned int DEFAULT_KEYPOOL_SIZE = 100;
@@ -57,16 +56,12 @@ static const CAmount MIN_CHANGE = CENT;
5756
static const CAmount MIN_FINAL_CHANGE = MIN_CHANGE/2;
5857
//! Default for -spendzeroconfchange
5958
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
60-
//! Default for -sendfreetransactions
61-
static const bool DEFAULT_SEND_FREE_TRANSACTIONS = false;
6259
//! Default for -walletrejectlongchains
6360
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
6461
//! -txconfirmtarget default
6562
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
6663
//! -walletrbf default
6764
static const bool DEFAULT_WALLET_RBF = false;
68-
//! Largest (in bytes) free transaction we're willing to create
69-
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
7065
static const bool DEFAULT_WALLETBROADCAST = true;
7166
static const bool DEFAULT_DISABLE_WALLET = false;
7267
//! if set, all keys will be derived by using BIP32

0 commit comments

Comments
 (0)