| 173 | } |
| 174 | |
| 175 | std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransaction &psbtx) |
| 176 | { |
| 177 | QString tx_description = ""; |
| 178 | CAmount totalAmount = 0; |
| 179 | int unit = m_client_model->getOptionsModel()->getDisplayUnit(); |
| 180 | for (const PSBTOutput& out : psbtx.outputs) { |
| 181 | CTxDestination address; |
| 182 | ExtractDestination(*out.script, address); |
| 183 | totalAmount += *out.amount; |
| 184 | tx_description.append(tr(" * Sends %1 to %2") |
| 185 | .arg(GUIUtil::formatAssetAmount(CAsset(out.m_asset), *out.amount, unit, BitcoinUnits::SeparatorStyle::ALWAYS)) |
| 186 | .arg(QString::fromStdString(EncodeDestination(address)))); |
| 187 | tx_description.append("<br>"); |
| 188 | } |
| 189 | |
| 190 | PSBTAnalysis analysis = AnalyzePSBT(psbtx); |
| 191 | tx_description.append(" * "); |
| 192 | if (!*analysis.fee) { |
| 193 | // This happens if the transaction is missing input UTXO information. |
| 194 | tx_description.append(tr("Unable to calculate transaction fee or total transaction amount.")); |
| 195 | } else { |
| 196 | // FIXME: should we display non-bitcoin fees? |
| 197 | tx_description.append(tr("Pays transaction fee: ")); |
| 198 | tx_description.append(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, *analysis.fee)); |
| 199 | |
| 200 | // add total amount in all subdivision units |
| 201 | tx_description.append("<hr />"); |
| 202 | QStringList alternativeUnits; |
| 203 | for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) |
| 204 | { |
| 205 | if(u != m_client_model->getOptionsModel()->getDisplayUnit()) { |
| 206 | alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount)); |
| 207 | } |
| 208 | } |
| 209 | tx_description.append(QString("<b>%1</b>: <b>%2</b>").arg(tr("Total Amount")) |
| 210 | .arg(BitcoinUnits::formatHtmlWithUnit(m_client_model->getOptionsModel()->getDisplayUnit(), totalAmount))); |
| 211 | tx_description.append(QString("<br /><span style='font-size:10pt; font-weight:normal;'>(=%1)</span>") |
| 212 | .arg(alternativeUnits.join(" " + tr("or") + " "))); |
| 213 | } |
| 214 | |
| 215 | size_t num_unsigned = CountPSBTUnsignedInputs(psbtx); |
| 216 | if (num_unsigned > 0) { |
| 217 | tx_description.append("<br><br>"); |
| 218 | tx_description.append(tr("Transaction has %1 unsigned inputs.").arg(QString::number(num_unsigned))); |
| 219 | } |
| 220 | |
| 221 | return tx_description.toStdString(); |
| 222 | } |
| 223 | |
| 224 | void PSBTOperationsDialog::showStatus(const QString &msg, StatusLevel level) { |
| 225 | m_ui->statusBar->setText(msg); |
nothing calls this directly
no test coverage detected