Skip to content

Commit b90711c

Browse files
committed
[Qt] Fix Transaction details shows wrong To:
1 parent bdc7f1a commit b90711c

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

src/qt/transactiondesc.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
4242
}
4343
}
4444

45-
QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int unit)
45+
QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit)
4646
{
4747
QString strHTML;
4848

@@ -86,26 +86,19 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int u
8686
if (nNet > 0)
8787
{
8888
// Credit
89-
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
89+
if (CBitcoinAddress(rec->address).IsValid())
9090
{
91-
if (wallet->IsMine(txout))
91+
CTxDestination address = CBitcoinAddress(rec->address).Get();
92+
if (wallet->mapAddressBook.count(address))
9293
{
93-
CTxDestination address;
94-
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
95-
{
96-
if (wallet->mapAddressBook.count(address))
97-
{
98-
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
99-
strHTML += "<b>" + tr("To") + ":</b> ";
100-
strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());
101-
if (!wallet->mapAddressBook[address].name.empty())
102-
strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";
103-
else
104-
strHTML += " (" + tr("own address") + ")";
105-
strHTML += "<br>";
106-
}
107-
}
108-
break;
94+
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
95+
strHTML += "<b>" + tr("To") + ":</b> ";
96+
strHTML += GUIUtil::HtmlEscape(rec->address);
97+
if (!wallet->mapAddressBook[address].name.empty())
98+
strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";
99+
else
100+
strHTML += " (" + tr("own address") + ")";
101+
strHTML += "<br>";
109102
}
110103
}
111104
}
@@ -224,7 +217,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int u
224217
if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty())
225218
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
226219

227-
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + TransactionRecord::formatSubTxId(wtx.GetHash(), vout) + "<br>";
220+
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + TransactionRecord::formatSubTxId(wtx.GetHash(), rec->idx) + "<br>";
228221

229222
// Message from normal bitcoin:URI (bitcoin:123...?message=example)
230223
foreach (const PAIRTYPE(string, string)& r, wtx.vOrderForm)

src/qt/transactiondesc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <QObject>
99
#include <QString>
1010

11+
class TransactionRecord;
1112
class CWallet;
1213
class CWalletTx;
1314

@@ -18,7 +19,7 @@ class TransactionDesc: public QObject
1819
Q_OBJECT
1920

2021
public:
21-
static QString toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int unit);
22+
static QString toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit);
2223

2324
private:
2425
TransactionDesc() {}

src/qt/transactiontablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class TransactionTablePriv
222222
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
223223
if(mi != wallet->mapWallet.end())
224224
{
225-
return TransactionDesc::toHTML(wallet, mi->second, rec->idx, unit);
225+
return TransactionDesc::toHTML(wallet, mi->second, rec, unit);
226226
}
227227
}
228228
return QString("");

0 commit comments

Comments
 (0)