Store all constructed transactions in cache

This commit is contained in:
tobtoht 2021-08-19 20:22:53 +02:00
parent f2b2bb9b7c
commit 7a467b875a
2 changed files with 27 additions and 30 deletions

View file

@ -592,10 +592,8 @@ void MainWindow::onConnectionStatusChanged(int status)
}
void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVector<QString> &address) {
auto tx_status = tx->status();
QString err{"Can't create transaction: "};
if (tx_status != PendingTransaction::Status_Ok){
if (tx->status() != PendingTransaction::Status_Ok) {
QString tx_err = tx->errorString();
qCritical() << tx_err;
@ -615,25 +613,27 @@ void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVecto
qDebug() << Q_FUNC_INFO << err;
this->displayWalletErrorMsg(err);
m_ctx->wallet->disposeTransaction(tx);
return;
}
else if (tx->txCount() == 0) {
err = QString("%1 %2").arg(err).arg("No unmixable outputs to sweep.");
qDebug() << Q_FUNC_INFO << err;
this->displayWalletErrorMsg(err);
m_ctx->wallet->disposeTransaction(tx);
return;
}
else {
const auto &description = m_ctx->tmpTxDescription;
m_ctx->addCacheTransaction(tx->txid()[0], tx->signedTxToHex(0));
// Show advanced dialog on multi-destination transactions
if (address.size() > 1) {
TxConfAdvDialog dialog_adv{m_ctx, description, this};
TxConfAdvDialog dialog_adv{m_ctx, m_ctx->tmpTxDescription, this};
dialog_adv.setTransaction(tx);
dialog_adv.exec();
return;
}
TxConfDialog dialog{m_ctx, tx, address[0], description, this};
TxConfDialog dialog{m_ctx, tx, address[0], m_ctx->tmpTxDescription, this};
switch (dialog.exec()) {
case QDialog::Rejected:
{
@ -647,12 +647,11 @@ void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVecto
}
if (dialog.showAdvanced) {
TxConfAdvDialog dialog_adv{m_ctx, description, this};
TxConfAdvDialog dialog_adv{m_ctx, m_ctx->tmpTxDescription, this};
dialog_adv.setTransaction(tx);
dialog_adv.exec();
}
}
}
void MainWindow::onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid) {
if (status) { // success

View file

@ -72,12 +72,10 @@ TxConfDialog::TxConfDialog(QSharedPointer<AppContext> ctx, PendingTransaction *t
ui->label_address->setToolTip("Wallet change/primary address");
}
ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Send");
connect(ui->btn_Advanced, &QPushButton::clicked, this, &TxConfDialog::setShowAdvanced);
m_ctx->addCacheTransaction(tx->txid()[0], tx->signedTxToHex(0)); // Todo: Iterate over all txs
this->adjustSize();
}