MCPcopy Create free account
hub / github.com/ElementsProject/elements / toHTML

Method toHTML

src/qt/transactiondesc.cpp:80–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80QString 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 }

Callers

nothing calls this directly

Calls 15

valueForFunction · 0.85
dateTimeStrFunction · 0.85
HtmlEscapeFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
ExtractDestinationFunction · 0.85
EncodeDestinationFunction · 0.85
GetFeeMapFunction · 0.85
getWalletTxDetailsMethod · 0.80
countMethod · 0.80
getCreditMethod · 0.80

Tested by

no test coverage detected