| 78 | } |
| 79 | |
| 80 | QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wallet, TransactionRecord *rec, int unit) |
| 81 | { |
| 82 | int numBlocks; |
| 83 | interfaces::WalletTxStatus status; |
| 84 | interfaces::WalletOrderForm orderForm; |
| 85 | bool inMempool; |
| 86 | interfaces::WalletTx wtx = wallet.getWalletTxDetails(rec->hash, status, orderForm, inMempool, numBlocks); |
| 87 | |
| 88 | QString strHTML; |
| 89 | |
| 90 | strHTML.reserve(4000); |
| 91 | strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>"; |
| 92 | |
| 93 | int64_t nTime = wtx.time; |
| 94 | CAmount nCredit = valueFor(wtx.credit, ::policyAsset); |
| 95 | CAmount nDebit = valueFor(wtx.debit, ::policyAsset); |
| 96 | CAmount nNet = nCredit - nDebit; |
| 97 | |
| 98 | strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx, status, inMempool, numBlocks); |
| 99 | strHTML += "<br>"; |
| 100 | |
| 101 | strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>"; |
| 102 | |
| 103 | // |
| 104 | // From |
| 105 | // |
| 106 | if (wtx.is_coinbase) |
| 107 | { |
| 108 | strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>"; |
| 109 | } |
| 110 | else if (wtx.value_map.count("from") && !wtx.value_map["from"].empty()) |
| 111 | { |
| 112 | // Online transaction |
| 113 | strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.value_map["from"]) + "<br>"; |
| 114 | } |
| 115 | else |
| 116 | { |
| 117 | // Offline transaction |
| 118 | if (nNet > 0) |
| 119 | { |
| 120 | // Credit |
| 121 | CTxDestination address = DecodeDestination(rec->address); |
| 122 | if (IsValidDestination(address)) { |
| 123 | std::string name; |
| 124 | isminetype ismine; |
| 125 | if (wallet.getAddress(address, &name, &ismine, /* purpose= */ nullptr)) |
| 126 | { |
| 127 | strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>"; |
| 128 | strHTML += "<b>" + tr("To") + ":</b> "; |
| 129 | strHTML += GUIUtil::HtmlEscape(rec->address); |
| 130 | QString addressOwned = ismine == ISMINE_SPENDABLE ? tr("own address") : tr("watch-only"); |
| 131 | if (!name.empty()) |
| 132 | strHTML += " (" + addressOwned + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(name) + ")"; |
| 133 | else |
| 134 | strHTML += " (" + addressOwned + ")"; |
| 135 | strHTML += "<br>"; |
| 136 | } |
| 137 | } |
nothing calls this directly
no test coverage detected