X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Fcoincontroldialog.cpp;h=25b2d6e39a76b768a3cce49f7d4ba1112da78451;hb=HEAD;hp=ae73042b5207a1e4984cf59f5b69d2b556791015;hpb=aab109cb39615ef4bc7a108cb7071c7c2f1dae65;p=novacoin.git diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index ae73042..25b2d6e 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -4,11 +4,13 @@ #include "init.h" #include "base58.h" #include "bitcoinunits.h" +#include "script.h" #include "walletmodel.h" #include "addresstablemodel.h" #include "optionsmodel.h" #include "coincontrol.h" #include "dialogwindowflags.h" +#include "wallet.h" #include #include @@ -457,7 +459,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QWidget* dialog) coinControl->ListSelected(vCoinControl); model->getOutputs(vCoinControl, vOutputs); - BOOST_FOREACH(const COutput& out, vOutputs) + for (const COutput& out : vOutputs) { // Quantity nQuantity++; @@ -469,17 +471,21 @@ void CoinControlDialog::updateLabels(WalletModel *model, QWidget* dialog) dPriorityInputs += (double)out.tx->vout[out.i].nValue * (out.nDepth+1); // Bytes - CTxDestination address; - if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) + CBitcoinAddress address; + if(ExtractAddress(*pwalletMain, out.tx->vout[out.i].scriptPubKey, address)) { - CPubKey pubkey; - CKeyID *keyid = boost::get< CKeyID >(&address); - if (keyid && model->getPubKey(*keyid, pubkey)) - nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); - else - nBytesInputs += 148; // in all error cases, simply assume 148 here + if (address.IsPair()) + nBytesInputs += 213; + else if (address.IsPubKey()) + { + CPubKey pubkey; + CKeyID keyid; + if (address.GetKeyID(keyid) && model->getPubKey(keyid, pubkey)) + nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); + else + nBytesInputs += 148; // in all error cases, simply assume 148 here + } } - else nBytesInputs += 148; } // calculation @@ -583,7 +589,7 @@ void CoinControlDialog::updateView() map > mapCoins; model->listCoins(mapCoins); - BOOST_FOREACH(PAIRTYPE(QString, vector) coins, mapCoins) + for (auto coins : mapCoins) { QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem(); QString sWalletAddress = coins.first; @@ -616,7 +622,7 @@ void CoinControlDialog::updateView() int nChildren = 0; int nInputSum = 0; uint64_t nTxWeight = 0, nTxWeightSum = 0; - BOOST_FOREACH(const COutput& out, coins.second) + for (const COutput& out : coins.second) { int nInputSize = 148; // 180 if uncompressed public key nSum += out.tx->vout[out.i].nValue; @@ -631,9 +637,10 @@ void CoinControlDialog::updateView() itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); // address - CTxDestination outputAddress; + CBitcoinAddress outputAddress; QString sAddress = ""; - if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress)) + + if(ExtractAddress(*pwalletMain, out.tx->vout[out.i].scriptPubKey, outputAddress)) { sAddress = CBitcoinAddress(outputAddress).ToString().c_str(); @@ -641,10 +648,13 @@ void CoinControlDialog::updateView() if (!treeMode || (!(sAddress == sWalletAddress))) itemOutput->setText(COLUMN_ADDRESS, sAddress); - CPubKey pubkey; - CKeyID *keyid = boost::get< CKeyID >(&outputAddress); - if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed()) - nInputSize = 180; + if (outputAddress.IsPubKey()) + { + CPubKey pubkey; + CKeyID keyid; + if (outputAddress.GetKeyID(keyid) && model->getPubKey(keyid, pubkey) && !pubkey.IsCompressed()) + nInputSize = 180; + } } // label