#include "appcontext.h"
#include "config.h"
+#include "libwalletqt/Coins.h"
+#include "libwalletqt/CoinsInfo.h"
#include "libwalletqt/TransactionHistory.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/WalletManager.h"
ui->btn_rebroadcastTx->hide();
}
- QTextCursor cursor = ui->destinations->textCursor();
- for (const auto& transfer : txInfo->transfers()) {
- auto address = transfer->address();
- auto amount = WalletManager::displayAmount(transfer->amount());
- auto index = m_ctx->wallet->subaddressIndex(address);
- cursor.insertText(address, Utils::addressTextFormat(index, transfer->amount()));
- cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
- cursor.insertBlock();
+ if (txInfo->direction() == TransactionInfo::Direction_Out) {
+ // TODO: this will not properly represent coinjoin-like transactions.
+ QVector<CoinsInfo*> coins = m_ctx->wallet->coins()->coins_from_txid(m_txid);
+ QTextCursor c_i = ui->inputs->textCursor();
+ QString inputs_str;
+ for (const auto &coin : coins) {
+ inputs_str += QString("%1 %2\n").arg(coin->pubKey(), coin->displayAmount());
+ }
+ ui->inputs->setText(inputs_str);
+ ui->label_inputs->setText(QString("Inputs (%1)").arg(QString::number(coins.size())));
+ this->adjustHeight(ui->inputs, coins.size());
+ } else {
+ ui->frameInputs->hide();
}
- if (txInfo->transfers().size() == 0) {
- ui->frameDestinations->hide();
+ QTextCursor cursor = ui->outputs->textCursor();
+
+ auto transfers = txInfo->transfers();
+ if (!transfers.isEmpty()) {
+ for (const auto& transfer : transfers) {
+ auto address = transfer->address();
+ auto amount = WalletManager::displayAmount(transfer->amount());
+ auto index = m_ctx->wallet->subaddressIndex(address);
+ cursor.insertText(address, Utils::addressTextFormat(index, transfer->amount()));
+ cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
+ cursor.insertBlock();
+ }
+ ui->label_outputs->setText(QString("Destinations (%2)").arg(QString::number(transfers.size())));
+ this->adjustHeight(ui->outputs, transfers.size());
+ } else {
+ ui->frameOutputs->hide();
}
+ this->adjustSize();
+}
+
+void TxInfoDialog::adjustHeight(QTextEdit *textEdit, qreal docHeight) {
QCoreApplication::processEvents();
- qreal lineHeight = QFontMetrics(ui->destinations->document()->defaultFont()).height();
- qreal docHeight = txInfo->transfers().size();
+ qreal lineHeight = QFontMetrics(ui->outputs->document()->defaultFont()).height();
+
int h = int(docHeight * (lineHeight + 2) + 11);
h = qMin(qMax(h, 100), 600);
- ui->destinations->setMinimumHeight(h);
- ui->destinations->setMaximumHeight(h);
- ui->destinations->verticalScrollBar()->hide();
-
- this->adjustSize();
+ textEdit->setMinimumHeight(h);
+ textEdit->setMaximumHeight(h);
+ textEdit->verticalScrollBar()->hide();
}
void TxInfoDialog::setData(TransactionInfo *tx) {
</spacer>
</item>
<item>
- <widget class="QFrame" name="frameDestinations">
+ <widget class="QFrame" name="frameInputs">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_inputs">
+ <property name="text">
+ <string>Inputs:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="inputs">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFrame" name="frameOutputs">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<number>0</number>
</property>
<item>
- <widget class="QLabel" name="label_destinations">
+ <widget class="QLabel" name="label_outputs">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
</widget>
</item>
<item>
- <widget class="QTextEdit" name="destinations">
+ <widget class="QTextEdit" name="outputs">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>