Browse Source

OfflineTxSigning: UI improvements

1.0.0
tobtoht 2 months ago
parent
commit
a390bebf08
Signed by: tobtoht GPG Key ID: 1CADD27F41F45C3C
  1. 2
      src/MainWindow.cpp
  2. 26
      src/dialog/TxConfAdvDialog.cpp
  3. 2
      src/dialog/TxConfAdvDialog.h

2
src/MainWindow.cpp

@ -628,7 +628,7 @@ void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVecto
// Show advanced dialog on multi-destination transactions
if (address.size() > 1 || m_ctx->wallet->viewOnly()) {
TxConfAdvDialog dialog_adv{m_ctx, m_ctx->tmpTxDescription, this};
dialog_adv.setTransaction(tx);
dialog_adv.setTransaction(tx, !m_ctx->wallet->viewOnly());
dialog_adv.exec();
return;
}

26
src/dialog/TxConfAdvDialog.cpp

@ -35,11 +35,6 @@ TxConfAdvDialog::TxConfAdvDialog(QSharedPointer<AppContext> ctx, const QString &
m_exportTxKeyMenu->addAction("Copy to clipboard", this, &TxConfAdvDialog::txKeyCopy);
ui->btn_exportTxKey->setMenu(m_exportTxKeyMenu);
if (m_ctx->wallet->viewOnly()) {
ui->btn_exportSigned->hide();
ui->btn_send->hide();
}
ui->label_description->setText(QString("Description: %1").arg(description));
connect(ui->btn_sign, &QPushButton::clicked, this, &TxConfAdvDialog::signTransaction);
@ -52,25 +47,36 @@ TxConfAdvDialog::TxConfAdvDialog(QSharedPointer<AppContext> ctx, const QString &
this->adjustSize();
}
void TxConfAdvDialog::setTransaction(PendingTransaction *tx) {
void TxConfAdvDialog::setTransaction(PendingTransaction *tx, bool isSigned) {
ui->btn_sign->hide();
if (!isSigned) {
ui->btn_exportSigned->hide();
ui->btn_send->hide();
}
m_tx = tx;
m_tx->refresh();
PendingTransactionInfo *ptx = m_tx->transaction(0); //Todo: support split transactions
// TODO: implement hasTxKey()
if (!m_ctx->wallet->isHwBacked() && m_tx->transaction(0)->txKey() == "0100000000000000000000000000000000000000000000000000000000000000") {
ui->btn_exportTxKey->hide();
}
ui->txid->setText(tx->txid().first());
ui->amount->setText(WalletManager::displayAmount(tx->amount()));
ui->fee->setText(WalletManager::displayAmount(ptx->fee()));
ui->total->setText(WalletManager::displayAmount(tx->amount() + ptx->fee()));
auto size_str = [this]{
if (m_ctx->wallet->viewOnly()) {
return QString("Size: %1 bytes (unsigned)").arg(QString::number(m_tx->unsignedTxToBin().size()));
} else {
auto size_str = [this, isSigned]{
if (isSigned) {
auto size = m_tx->signedTxToHex(0).size() / 2;
return QString("Size: %1 bytes (%2 bytes unsigned)").arg(QString::number(size), QString::number(m_tx->unsignedTxToBin().size()));
} else {
return QString("Size: %1 bytes (unsigned)").arg(QString::number(m_tx->unsignedTxToBin().size()));
}
}();
ui->label_size->setText(size_str);

2
src/dialog/TxConfAdvDialog.h

@ -24,7 +24,7 @@ public:
explicit TxConfAdvDialog(QSharedPointer<AppContext> ctx, const QString &description, QWidget *parent = nullptr);
~TxConfAdvDialog() override;
void setTransaction(PendingTransaction *tx);
void setTransaction(PendingTransaction *tx, bool isSigned = true); // #TODO: have libwallet return a UnsignedTransaction, this is just dumb
void setUnsignedTransaction(UnsignedTransaction *utx);
private:

Loading…
Cancel
Save