| 95 | } |
| 96 | |
| 97 | QString 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 | } |
nothing calls this directly
no test coverage detected