24
24
#include < QDialogButtonBox>
25
25
#include < QFlags>
26
26
#include < QIcon>
27
+ #include < QSettings>
27
28
#include < QString>
28
29
#include < QTreeWidget>
29
30
#include < QTreeWidgetItem>
@@ -130,10 +131,22 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
130
131
131
132
// default view is sorted by amount desc
132
133
sortView (COLUMN_AMOUNT_INT64, Qt::DescendingOrder);
134
+
135
+ // restore list mode and sortorder as a convenience feature
136
+ QSettings settings;
137
+ if (settings.contains (" nCoinControlMode" ) && !settings.value (" nCoinControlMode" ).toBool ())
138
+ ui->radioTreeMode ->click ();
139
+ if (settings.contains (" nCoinControlSortColumn" ) && settings.contains (" nCoinControlSortOrder" ))
140
+ sortView (settings.value (" nCoinControlSortColumn" ).toInt (), ((Qt::SortOrder)settings.value (" nCoinControlSortOrder" ).toInt ()));
133
141
}
134
142
135
143
CoinControlDialog::~CoinControlDialog ()
136
144
{
145
+ QSettings settings;
146
+ settings.setValue (" nCoinControlMode" , ui->radioListMode ->isChecked ());
147
+ settings.setValue (" nCoinControlSortColumn" , sortColumn);
148
+ settings.setValue (" nCoinControlSortOrder" , (int )sortOrder);
149
+
137
150
delete ui;
138
151
}
139
152
@@ -290,19 +303,19 @@ void CoinControlDialog::clipboardAmount()
290
303
// copy label "Fee" to clipboard
291
304
void CoinControlDialog::clipboardFee ()
292
305
{
293
- GUIUtil::setClipboard (ui->labelCoinControlFee ->text ().left (ui->labelCoinControlFee ->text ().indexOf (" " )));
306
+ GUIUtil::setClipboard (ui->labelCoinControlFee ->text ().left (ui->labelCoinControlFee ->text ().indexOf (" " )). replace ( " ~ " , " " ) );
294
307
}
295
308
296
309
// copy label "After fee" to clipboard
297
310
void CoinControlDialog::clipboardAfterFee ()
298
311
{
299
- GUIUtil::setClipboard (ui->labelCoinControlAfterFee ->text ().left (ui->labelCoinControlAfterFee ->text ().indexOf (" " )));
312
+ GUIUtil::setClipboard (ui->labelCoinControlAfterFee ->text ().left (ui->labelCoinControlAfterFee ->text ().indexOf (" " )). replace ( " ~ " , " " ) );
300
313
}
301
314
302
315
// copy label "Bytes" to clipboard
303
316
void CoinControlDialog::clipboardBytes ()
304
317
{
305
- GUIUtil::setClipboard (ui->labelCoinControlBytes ->text ());
318
+ GUIUtil::setClipboard (ui->labelCoinControlBytes ->text (). replace ( " ~ " , " " ) );
306
319
}
307
320
308
321
// copy label "Priority" to clipboard
@@ -320,7 +333,7 @@ void CoinControlDialog::clipboardLowOutput()
320
333
// copy label "Change" to clipboard
321
334
void CoinControlDialog::clipboardChange ()
322
335
{
323
- GUIUtil::setClipboard (ui->labelCoinControlChange ->text ().left (ui->labelCoinControlChange ->text ().indexOf (" " )));
336
+ GUIUtil::setClipboard (ui->labelCoinControlChange ->text ().left (ui->labelCoinControlChange ->text ().indexOf (" " )). replace ( " ~ " , " " ) );
324
337
}
325
338
326
339
// treeview: sort
@@ -402,26 +415,22 @@ void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
402
415
}
403
416
404
417
// return human readable label for priority number
405
- QString CoinControlDialog::getPriorityLabel (const CTxMemPool& pool , double dPriority )
418
+ QString CoinControlDialog::getPriorityLabel (double dPriority , double mempoolEstimatePriority )
406
419
{
407
- // confirmations -> textual description
408
- typedef std::map<unsigned int , QString> PriorityDescription;
409
- const static PriorityDescription priorityDescriptions = boost::assign::map_list_of
410
- (1 , tr (" highest" ))(2 , tr (" higher" ))(3 , tr (" high" ))
411
- (5 , tr (" medium-high" ))(6 , tr (" medium" ))
412
- (10 , tr (" low-medium" ))(15 , tr (" low" ))
413
- (20 , tr (" lower" ));
414
-
415
- BOOST_FOREACH (const PriorityDescription::value_type& i, priorityDescriptions)
416
- {
417
- double p = mempool.estimatePriority (i.first );
418
- if (p > 0 && dPriority >= p) return i.second ;
419
- }
420
- // Note: if mempool hasn't accumulated enough history (estimatePriority
421
- // returns -1) we're conservative and classify as "lowest"
422
- if (mempool.estimatePriority (nTxConfirmTarget) <= 0 && AllowFree (dPriority))
423
- return " >=" + tr (" medium" );
424
- return tr (" lowest" );
420
+ double dPriorityMedium = mempoolEstimatePriority;
421
+
422
+ if (dPriorityMedium <= 0 )
423
+ dPriorityMedium = AllowFreeThreshold (); // not enough data, back to hard-coded
424
+
425
+ if (dPriority / 1000000 > dPriorityMedium) return tr (" highest" );
426
+ else if (dPriority / 100000 > dPriorityMedium) return tr (" higher" );
427
+ else if (dPriority / 10000 > dPriorityMedium) return tr (" high" );
428
+ else if (dPriority / 1000 > dPriorityMedium) return tr (" medium-high" );
429
+ else if (dPriority > dPriorityMedium) return tr (" medium" );
430
+ else if (dPriority * 10 > dPriorityMedium) return tr (" low-medium" );
431
+ else if (dPriority * 100 > dPriorityMedium) return tr (" low" );
432
+ else if (dPriority * 1000 > dPriorityMedium) return tr (" lower" );
433
+ else return tr (" lowest" );
425
434
}
426
435
427
436
// shows count of locked unspent outputs
@@ -470,6 +479,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
470
479
double dPriorityInputs = 0 ;
471
480
unsigned int nQuantity = 0 ;
472
481
int nQuantityUncompressed = 0 ;
482
+ bool fAllowFree = false ;
473
483
474
484
vector<COutPoint> vCoinControl;
475
485
vector<COutput> vOutputs;
@@ -522,24 +532,22 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
522
532
nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size () > 0 ? CoinControlDialog::payAmounts.size () + 1 : 2 ) * 34 ) + 10 ; // always assume +1 output for change here
523
533
524
534
// Priority
535
+ double mempoolEstimatePriority = mempool.estimatePriority (nTxConfirmTarget);
525
536
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)
526
- sPriorityLabel = CoinControlDialog::getPriorityLabel (mempool, dPriority );
537
+ sPriorityLabel = CoinControlDialog::getPriorityLabel (dPriority, mempoolEstimatePriority );
527
538
528
- // Voluntary Fee
529
- nPayFee = payTxFee. GetFee ( max (( unsigned int ) 1000 , nBytes) );
539
+ // Fee
540
+ nPayFee = CWallet::GetMinimumFee (nBytes, nTxConfirmTarget, mempool );
530
541
531
- // Min Fee
532
- if (nPayFee == 0 )
533
- {
534
- nPayFee = CWallet::GetMinimumFee (nBytes, nTxConfirmTarget, mempool);
535
-
536
- double dPriorityNeeded = mempool.estimatePriority (nTxConfirmTarget);
537
- if (dPriorityNeeded <= 0 && !AllowFree (dPriority)) // not enough mempool history: never send free
538
- dPriorityNeeded = std::numeric_limits<double >::max ();
542
+ // Allow free?
543
+ double dPriorityNeeded = mempoolEstimatePriority;
544
+ if (dPriorityNeeded <= 0 )
545
+ dPriorityNeeded = AllowFreeThreshold (); // not enough data, back to hard-coded
546
+ fAllowFree = (dPriority >= dPriorityNeeded);
539
547
540
- if (nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE && dPriority >= dPriorityNeeded)
548
+ if (fSendFreeTransactions )
549
+ if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
541
550
nPayFee = 0 ;
542
- }
543
551
544
552
if (nPayAmount > 0 )
545
553
{
@@ -595,7 +603,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
595
603
l6->setText (sPriorityLabel ); // Priority
596
604
l7->setText (fDust ? tr (" yes" ) : tr (" no" )); // Dust
597
605
l8->setText (BitcoinUnits::formatWithUnit (nDisplayUnit, nChange)); // Change
598
- if (nPayFee > 0 )
606
+ if (nPayFee > 0 && !(payTxFee. GetFeePerK () > 0 && fPayAtLeastCustomFee && nBytes < 1000 ) )
599
607
{
600
608
l3->setText (" ~" + l3->text ());
601
609
l4->setText (" ~" + l4->text ());
@@ -605,7 +613,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
605
613
606
614
// turn labels "red"
607
615
l5->setStyleSheet ((nBytes >= MAX_FREE_TRANSACTION_CREATE_SIZE) ? " color:red;" : " " );// Bytes >= 1000
608
- l6->setStyleSheet ((dPriority > 0 && !AllowFree (dPriority)) ? " color:red;" : " " ); // Priority < "medium"
616
+ l6->setStyleSheet ((dPriority > 0 && !fAllowFree ) ? " color:red;" : " " ); // Priority < "medium"
609
617
l7->setStyleSheet ((fDust ) ? " color:red;" : " " ); // Dust = "yes"
610
618
611
619
// tool tips
@@ -620,7 +628,11 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
620
628
QString toolTip3 = tr (" This label turns red, if any recipient receives an amount smaller than %1." ).arg (BitcoinUnits::formatWithUnit (nDisplayUnit, ::minRelayTxFee.GetFee (546 )));
621
629
622
630
// how many satoshis the estimated fee can vary per byte we guess wrong
623
- double dFeeVary = (double )std::max (CWallet::minTxFee.GetFeePerK (), std::max (payTxFee.GetFeePerK (), mempool.estimateFee (nTxConfirmTarget).GetFeePerK ())) / 1000 ;
631
+ double dFeeVary;
632
+ if (payTxFee.GetFeePerK () > 0 )
633
+ dFeeVary = (double )std::max (CWallet::minTxFee.GetFeePerK (), payTxFee.GetFeePerK ()) / 1000 ;
634
+ else
635
+ dFeeVary = (double )std::max (CWallet::minTxFee.GetFeePerK (), mempool.estimateFee (nTxConfirmTarget).GetFeePerK ()) / 1000 ;
624
636
QString toolTip4 = tr (" Can vary +/- %1 satoshi(s) per input." ).arg (dFeeVary);
625
637
626
638
l3->setToolTip (toolTip4);
@@ -656,6 +668,7 @@ void CoinControlDialog::updateView()
656
668
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
657
669
658
670
int nDisplayUnit = model->getOptionsModel ()->getDisplayUnit ();
671
+ double mempoolEstimatePriority = mempool.estimatePriority (nTxConfirmTarget);
659
672
660
673
map<QString, vector<COutput> > mapCoins;
661
674
model->listCoins (mapCoins);
@@ -745,7 +758,7 @@ void CoinControlDialog::updateView()
745
758
746
759
// priority
747
760
double dPriority = ((double )out.tx ->vout [out.i ].nValue / (nInputSize + 78 )) * (out.nDepth +1 ); // 78 = 2 * 34 + 10
748
- itemOutput->setText (COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel (mempool, dPriority ));
761
+ itemOutput->setText (COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel (dPriority, mempoolEstimatePriority ));
749
762
itemOutput->setText (COLUMN_PRIORITY_INT64, strPad (QString::number ((int64_t )dPriority), 20 , " " ));
750
763
dPrioritySum += (double )out.tx ->vout [out.i ].nValue * (out.nDepth +1 );
751
764
nInputSum += nInputSize;
@@ -778,7 +791,7 @@ void CoinControlDialog::updateView()
778
791
itemWalletAddress->setText (COLUMN_CHECKBOX, " (" + QString::number (nChildren) + " )" );
779
792
itemWalletAddress->setText (COLUMN_AMOUNT, BitcoinUnits::format (nDisplayUnit, nSum));
780
793
itemWalletAddress->setText (COLUMN_AMOUNT_INT64, strPad (QString::number (nSum), 15 , " " ));
781
- itemWalletAddress->setText (COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel (mempool, dPrioritySum ));
794
+ itemWalletAddress->setText (COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel (dPrioritySum, mempoolEstimatePriority ));
782
795
itemWalletAddress->setText (COLUMN_PRIORITY_INT64, strPad (QString::number ((int64_t )dPrioritySum), 20 , " " ));
783
796
}
784
797
}
0 commit comments