MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / toHTML

Method toHTML

src/qt/transactiondesc.cpp:97–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wallet, TransactionRecord* rec, BitcoinUnit unit)
98{
99 int numBlocks;
100 interfaces::WalletTxStatus status;
101 interfaces::WalletOrderForm orderForm;
102 bool inMempool;
103 interfaces::WalletTx wtx = wallet.getWalletTxDetails(rec->hash, status, orderForm, inMempool, numBlocks);
104
105 QString strHTML;
106
107 strHTML.reserve(4000);
108 strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
109
110 int64_t nTime = wtx.time;
111 CAmount nCredit = wtx.credit;
112 CAmount nDebit = wtx.debit;
113 CAmount nNet = nCredit - nDebit;
114
115 strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(status, inMempool);
116 strHTML += "<br>";
117
118 strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
119
120 //
121 // From
122 //
123 if (wtx.is_coinbase)
124 {
125 strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
126 }
127 else if (wtx.value_map.contains("from") && !wtx.value_map["from"].empty())
128 {
129 // Online transaction
130 strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.value_map["from"]) + "<br>";
131 }
132 else
133 {
134 // Offline transaction
135 if (nNet > 0)
136 {
137 // Credit
138 CTxDestination address = DecodeDestination(rec->address);
139 if (IsValidDestination(address)) {
140 std::string name;
141 if (wallet.getAddress(address, &name, /*purpose=*/nullptr))
142 {
143 strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
144 strHTML += "<b>" + tr("To") + ":</b> ";
145 strHTML += GUIUtil::HtmlEscape(rec->address);
146 QString addressOwned = tr("own address");
147 if (!name.empty())
148 strHTML += " (" + addressOwned + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(name) + ")";
149 else
150 strHTML += " (" + addressOwned + ")";
151 strHTML += "<br>";
152 }
153 }
154 }

Callers

nothing calls this directly

Calls 15

dateTimeStrFunction · 0.85
HtmlEscapeFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
ExtractDestinationFunction · 0.85
EncodeDestinationFunction · 0.85
getWalletTxDetailsMethod · 0.80
getCreditMethod · 0.80
GetValueOutMethod · 0.80
getDebitMethod · 0.80
getTxHashMethod · 0.80

Tested by

no test coverage detected