diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 71ed3618e4..f73f18f5a3 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -385,7 +385,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
return QString();
}
}
- strAddress = CBitcoinAddress(newKey.GetID()).ToString();
+ strAddress = CBitcoinAddress(newKey.GetID()).AddBlindingKey(wallet->GetBlindingPubKey(GetScriptForDestination(CTxDestination(newKey.GetID())))).ToString();
}
else
{
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index de83c4f03e..ec1b954b58 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -507,10 +507,10 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
nQuantity++;
// Amount
- nAmount += out.tx->vout[out.i].nValue;
+ nAmount += out.tx->GetValueOut(out.i);
// Priority
- dPriorityInputs += (double)out.tx->vout[out.i].nValue * (out.nDepth+1);
+ dPriorityInputs += (double)COIN * (out.nDepth+1);
// Bytes
CTxDestination address;
@@ -736,7 +736,7 @@ void CoinControlDialog::updateView()
int nInputSum = 0;
BOOST_FOREACH(const COutput& out, coins.second) {
int nInputSize = 0;
- nSum += out.tx->vout[out.i].nValue;
+ nSum += out.tx->GetValueOut(out.i);
nChildren++;
QTreeWidgetItem *itemOutput;
@@ -778,8 +778,8 @@ void CoinControlDialog::updateView()
}
// amount
- itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx->vout[out.i].nValue));
- itemOutput->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(out.tx->vout[out.i].nValue), 15, " ")); // padding so that sorting works correctly
+ itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx->GetValueOut(out.i)));
+ itemOutput->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(out.tx->GetValueOut(out.i)), 15, " ")); // padding so that sorting works correctly
// date
itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.tx->GetTxTime()));
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 193b02c15b..3c1c7f3049 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -132,9 +132,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
// Coinbase
//
- CAmount nUnmatured = 0;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- nUnmatured += wallet->GetCredit(txout, ISMINE_ALL);
+ CAmount nUnmatured = wallet->GetCredit(wtx, ISMINE_ALL);
strHTML += "" + tr("Credit") + ": ";
if (wtx.IsInMainChain())
strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
@@ -173,8 +171,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
// Debit
//
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (unsigned int i = 0; i < wtx.vout.size(); i++)
{
+ const CTxOut& txout = wtx.vout[i];
// Ignore change
isminetype toSelf = wallet->IsMine(txout);
if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE))
@@ -198,9 +197,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
}
}
- strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -txout.nValue) + "
";
+ strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wtx.GetValueOut(i)) + "
";
if(toSelf)
- strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) + "
";
+ strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wtx.GetValueOut(i)) + "
";
}
if (fAllToMe)
@@ -224,9 +223,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if (wallet->IsMine(txin))
strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "
";
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- if (wallet->IsMine(txout))
- strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "
";
+ for (unsigned int i = 0; i < wtx.vout.size(); i++)
+ if (wallet->IsMine(wtx.vout[i]) & ISMINE_ALL)
+ strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wtx.GetValueOut(i)) + "
";
}
}
@@ -278,9 +277,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if(wallet->IsMine(txin))
strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "
";
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- if(wallet->IsMine(txout))
- strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "
";
+ for (unsigned int i = 0; i < wtx.vout.size(); i++)
+ if(wallet->IsMine(wtx.vout[i]) & ISMINE_ALL)
+ strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wtx.GetCredit(i)) + "
";
strHTML += "
" + tr("Transaction") + ":
";
strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);
@@ -306,7 +305,6 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + " ";
strHTML += QString::fromStdString(CBitcoinAddress(address).ToString());
}
- strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatHtmlWithUnit(unit, vout.nValue);
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) & ISMINE_SPENDABLE ? tr("true") : tr("false")) + "";
strHTML = strHTML + " IsWatchOnly=" + (wallet->IsMine(vout) & ISMINE_WATCH_ONLY ? tr("true") : tr("false")) + "";
}
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index 3dcc161a98..22072cace9 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -47,15 +47,16 @@ QList TransactionRecord::decomposeTransaction(const CWallet *
//
// Credit
//
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (unsigned int i = 0; i < wtx.vout.size(); i++)
{
+ const CTxOut& txout = wtx.vout[i];
isminetype mine = wallet->IsMine(txout);
if(mine)
{
TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.idx = parts.size(); // sequence number
- sub.credit = txout.nValue;
+ sub.credit = wtx.GetValueOut(i);
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
{
@@ -142,7 +143,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet *
sub.address = mapValue["to"];
}
- CAmount nValue = txout.nValue;
+ CAmount nValue = wtx.GetValueOut(nOut);
/* Add fee to first output */
if (nTxFee > 0)
{
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 3867310cd6..95c7b3a5a3 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -64,7 +64,7 @@ CAmount WalletModel::getBalance(const CCoinControl *coinControl) const
wallet->AvailableCoins(vCoins, true, coinControl);
BOOST_FOREACH(const COutput& out, vCoins)
if(out.fSpendable)
- nBalance += out.tx->vout[out.i].nValue;
+ nBalance += out.tx->GetValueOut(out.i);
return nBalance;
}
@@ -222,7 +222,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
CAmount nAmount = out.amount();
- CRecipient recipient = {scriptPubKey, nAmount, rcp.fSubtractFeeFromAmount};
+ CRecipient recipient = {scriptPubKey, nAmount, CPubKey(), rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
}
if (subtotal <= 0)
@@ -244,8 +244,13 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
setAddress.insert(rcp.address);
++nAddresses;
- CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
- CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
+ CBitcoinAddress addr(rcp.address.toStdString());
+ CScript scriptPubKey = GetScriptForDestination(addr.Get());
+ CPubKey confidentiality_pubkey;
+ if (addr.IsBlinded()) {
+ confidentiality_pubkey = addr.GetBlindingKey();
+ }
+ CRecipient recipient = {scriptPubKey, rcp.amount, confidentiality_pubkey, rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
total += rcp.amount;
@@ -274,10 +279,11 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
CWalletTx *newTx = transaction.getTransaction();
CReserveKey *keyChange = transaction.getPossibleKeyChange();
- bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl);
+ std::vector outAmounts;
+ bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl, true, &outAmounts);
transaction.setTransactionFee(nFeeRequired);
if (fSubtractFeeFromAmount && fCreated)
- transaction.reassignAmounts(nChangePosRet);
+ transaction.reassignAmounts(outAmounts, nChangePosRet);
if(!fCreated)
{
diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp
index ffadf89cc8..b2e0c928a0 100644
--- a/src/qt/walletmodeltransaction.cpp
+++ b/src/qt/walletmodeltransaction.cpp
@@ -47,7 +47,7 @@ void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
fee = newFee;
}
-void WalletModelTransaction::reassignAmounts(int nChangePosRet)
+void WalletModelTransaction::reassignAmounts(const std::vector& outAmounts, int nChangePosRet)
{
int i = 0;
for (QList::iterator it = recipients.begin(); it != recipients.end(); ++it)
@@ -64,7 +64,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
if (out.amount() <= 0) continue;
if (i == nChangePosRet)
i++;
- subtotal += walletTransaction->vout[i].nValue;
+ subtotal += outAmounts[i];
i++;
}
rcp.amount = subtotal;
@@ -73,7 +73,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
{
if (i == nChangePosRet)
i++;
- rcp.amount = walletTransaction->vout[i].nValue;
+ rcp.amount = outAmounts[i];
i++;
}
}
diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h
index 64922efada..705fd9e4a6 100644
--- a/src/qt/walletmodeltransaction.h
+++ b/src/qt/walletmodeltransaction.h
@@ -35,7 +35,7 @@ public:
void newPossibleKeyChange(CWallet *wallet);
CReserveKey *getPossibleKeyChange();
- void reassignAmounts(int nChangePosRet); // needed for the subtract-fee-from-amount feature
+ void reassignAmounts(const std::vector& outAmounts, int nChangePosRet); // needed for the subtract-fee-from-amount feature
private:
QList recipients;