14
14
#include < qt/walletmodel.h>
15
15
16
16
#include < wallet/coincontrol.h>
17
- #include < init .h>
17
+ #include < interface/node .h>
18
18
#include < key_io.h>
19
19
#include < policy/fees.h>
20
20
#include < policy/policy.h>
@@ -431,7 +431,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
431
431
{
432
432
CTxOut txout (amount, static_cast <CScript>(std::vector<unsigned char >(24 , 0 )));
433
433
txDummy.vout .push_back (txout);
434
- fDust |= IsDust (txout, ::dustRelayFee );
434
+ fDust |= IsDust (txout, model-> node (). getDustRelayFee () );
435
435
}
436
436
}
437
437
@@ -445,16 +445,16 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
445
445
bool fWitness = false ;
446
446
447
447
std::vector<COutPoint> vCoinControl;
448
- std::vector<COutput> vOutputs;
449
448
coinControl ()->ListSelected (vCoinControl);
450
- model->getOutputs (vCoinControl, vOutputs);
451
449
452
- for (const COutput& out : vOutputs) {
450
+ size_t i = 0 ;
451
+ for (const auto & out : model->wallet ().getCoins (vCoinControl)) {
452
+ if (out.depth_in_main_chain < 0 ) continue ;
453
+
453
454
// unselect already spent, very unlikely scenario, this could happen
454
455
// when selected are spent elsewhere, like rpc or another computer
455
- uint256 txhash = out.tx ->GetHash ();
456
- COutPoint outpt (txhash, out.i );
457
- if (model->isSpent (outpt))
456
+ const COutPoint& outpt = vCoinControl[i++];
457
+ if (out.is_spent )
458
458
{
459
459
coinControl ()->UnSelect (outpt);
460
460
continue ;
@@ -464,18 +464,18 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
464
464
nQuantity++;
465
465
466
466
// Amount
467
- nAmount += out.tx -> tx -> vout [out. i ] .nValue ;
467
+ nAmount += out.txout .nValue ;
468
468
469
469
// Bytes
470
470
CTxDestination address;
471
471
int witnessversion = 0 ;
472
472
std::vector<unsigned char > witnessprogram;
473
- if (out.tx -> tx -> vout [out. i ] .scriptPubKey .IsWitnessProgram (witnessversion, witnessprogram))
473
+ if (out.txout .scriptPubKey .IsWitnessProgram (witnessversion, witnessprogram))
474
474
{
475
475
nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4 );
476
476
fWitness = true ;
477
477
}
478
- else if (ExtractDestination (out.tx -> tx -> vout [out. i ] .scriptPubKey , address))
478
+ else if (ExtractDestination (out.txout .scriptPubKey , address))
479
479
{
480
480
CPubKey pubkey;
481
481
CKeyID *keyid = boost::get<CKeyID>(&address);
@@ -509,7 +509,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
509
509
nBytes -= 34 ;
510
510
511
511
// Fee
512
- nPayFee = GetMinimumFee ( nBytes, *coinControl (), ::mempool, ::feeEstimator , nullptr /* FeeCalculation */ );
512
+ nPayFee = model-> node (). getMinimumFee ( nBytes, *coinControl (), nullptr /* returned_target */ , nullptr /* reason */ );
513
513
514
514
if (nPayAmount > 0 )
515
515
{
@@ -521,7 +521,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
521
521
if (nChange > 0 && nChange < MIN_CHANGE)
522
522
{
523
523
CTxOut txout (nChange, static_cast <CScript>(std::vector<unsigned char >(24 , 0 )));
524
- if (IsDust (txout, ::dustRelayFee ))
524
+ if (IsDust (txout, model-> node (). getDustRelayFee () ))
525
525
{
526
526
nPayFee += nChange;
527
527
nChange = 0 ;
@@ -621,13 +621,10 @@ void CoinControlDialog::updateView()
621
621
622
622
int nDisplayUnit = model->getOptionsModel ()->getDisplayUnit ();
623
623
624
- std::map<QString, std::vector<COutput> > mapCoins;
625
- model->listCoins (mapCoins);
626
-
627
- for (const std::pair<QString, std::vector<COutput>>& coins : mapCoins) {
624
+ for (const auto & coins : model->wallet ().listCoins ()) {
628
625
CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem ();
629
626
itemWalletAddress->setCheckState (COLUMN_CHECKBOX, Qt::Unchecked);
630
- QString sWalletAddress = coins.first ;
627
+ QString sWalletAddress = QString::fromStdString ( EncodeDestination ( coins.first )) ;
631
628
QString sWalletLabel = model->getAddressTableModel ()->labelForAddress (sWalletAddress );
632
629
if (sWalletLabel .isEmpty ())
633
630
sWalletLabel = tr (" (no label)" );
@@ -649,8 +646,10 @@ void CoinControlDialog::updateView()
649
646
650
647
CAmount nSum = 0 ;
651
648
int nChildren = 0 ;
652
- for (const COutput& out : coins.second ) {
653
- nSum += out.tx ->tx ->vout [out.i ].nValue ;
649
+ for (const auto & outpair : coins.second ) {
650
+ const COutPoint& output = std::get<0 >(outpair);
651
+ const interface::WalletTxOut& out = std::get<1 >(outpair);
652
+ nSum += out.txout .nValue ;
654
653
nChildren++;
655
654
656
655
CCoinControlWidgetItem *itemOutput;
@@ -662,7 +661,7 @@ void CoinControlDialog::updateView()
662
661
// address
663
662
CTxDestination outputAddress;
664
663
QString sAddress = " " ;
665
- if (ExtractDestination (out.tx -> tx -> vout [out. i ] .scriptPubKey , outputAddress))
664
+ if (ExtractDestination (out.txout .scriptPubKey , outputAddress))
666
665
{
667
666
sAddress = QString::fromStdString (EncodeDestination (outputAddress));
668
667
@@ -687,35 +686,33 @@ void CoinControlDialog::updateView()
687
686
}
688
687
689
688
// amount
690
- itemOutput->setText (COLUMN_AMOUNT, BitcoinUnits::format (nDisplayUnit, out.tx -> tx -> vout [out. i ] .nValue ));
691
- itemOutput->setData (COLUMN_AMOUNT, Qt::UserRole, QVariant ((qlonglong)out.tx -> tx -> vout [out. i ] .nValue )); // padding so that sorting works correctly
689
+ itemOutput->setText (COLUMN_AMOUNT, BitcoinUnits::format (nDisplayUnit, out.txout .nValue ));
690
+ itemOutput->setData (COLUMN_AMOUNT, Qt::UserRole, QVariant ((qlonglong)out.txout .nValue )); // padding so that sorting works correctly
692
691
693
692
// date
694
- itemOutput->setText (COLUMN_DATE, GUIUtil::dateTimeStr (out.tx -> GetTxTime () ));
695
- itemOutput->setData (COLUMN_DATE, Qt::UserRole, QVariant ((qlonglong)out.tx -> GetTxTime () ));
693
+ itemOutput->setText (COLUMN_DATE, GUIUtil::dateTimeStr (out.time ));
694
+ itemOutput->setData (COLUMN_DATE, Qt::UserRole, QVariant ((qlonglong)out.time ));
696
695
697
696
// confirmations
698
- itemOutput->setText (COLUMN_CONFIRMATIONS, QString::number (out.nDepth ));
699
- itemOutput->setData (COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant ((qlonglong)out.nDepth ));
697
+ itemOutput->setText (COLUMN_CONFIRMATIONS, QString::number (out.depth_in_main_chain ));
698
+ itemOutput->setData (COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant ((qlonglong)out.depth_in_main_chain ));
700
699
701
700
// transaction hash
702
- uint256 txhash = out.tx ->GetHash ();
703
- itemOutput->setText (COLUMN_TXHASH, QString::fromStdString (txhash.GetHex ()));
701
+ itemOutput->setText (COLUMN_TXHASH, QString::fromStdString (output.hash .GetHex ()));
704
702
705
703
// vout index
706
- itemOutput->setText (COLUMN_VOUT_INDEX, QString::number (out. i ));
704
+ itemOutput->setText (COLUMN_VOUT_INDEX, QString::number (output. n ));
707
705
708
706
// disable locked coins
709
- if (model->wallet ().isLockedCoin (COutPoint (txhash, out. i ) ))
707
+ if (model->wallet ().isLockedCoin (output ))
710
708
{
711
- COutPoint outpt (txhash, out.i );
712
- coinControl ()->UnSelect (outpt); // just to be sure
709
+ coinControl ()->UnSelect (output); // just to be sure
713
710
itemOutput->setDisabled (true );
714
711
itemOutput->setIcon (COLUMN_CHECKBOX, platformStyle->SingleColorIcon (" :/icons/lock_closed" ));
715
712
}
716
713
717
714
// set checkbox
718
- if (coinControl ()->IsSelected (COutPoint (txhash, out. i ) ))
715
+ if (coinControl ()->IsSelected (output ))
719
716
itemOutput->setCheckState (COLUMN_CHECKBOX, Qt::Checked);
720
717
}
721
718
0 commit comments