mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-22 10:44:32 +00:00
Store unconfirmed transactions in wallet cache
This commit is contained in:
parent
deb0087019
commit
24811c92af
6 changed files with 18 additions and 6 deletions
|
@ -83,7 +83,7 @@ void HistoryWidget::showContextMenu(const QPoint &point) {
|
|||
if (!tx) return;
|
||||
|
||||
bool unconfirmed = tx->isFailed() || tx->isPending();
|
||||
if (m_ctx->txCache.contains(tx->hash()) && unconfirmed && tx->direction() != TransactionInfo::Direction_In) {
|
||||
if (unconfirmed && tx->direction() != TransactionInfo::Direction_In) {
|
||||
menu.addAction(icons()->icon("info2.svg"), "Resend transaction", this, &HistoryWidget::onResendTransaction);
|
||||
}
|
||||
|
||||
|
|
|
@ -909,7 +909,8 @@ void MainWindow::onViewOnBlockExplorer(const QString &txid) {
|
|||
}
|
||||
|
||||
void MainWindow::onResendTransaction(const QString &txid) {
|
||||
if (!m_ctx->txCache.contains(txid)) {
|
||||
QString txHex = m_ctx->getCacheTransaction(txid);
|
||||
if (txHex.isEmpty()) {
|
||||
QMessageBox::warning(this, "Unable to resend transaction", "Transaction was not found in transaction cache. Unable to resend.");
|
||||
return;
|
||||
}
|
||||
|
@ -917,7 +918,7 @@ void MainWindow::onResendTransaction(const QString &txid) {
|
|||
// Connect to a different node so chances of successful relay are higher
|
||||
m_ctx->nodes->autoConnect(true);
|
||||
|
||||
TxBroadcastDialog dialog{this, m_ctx, m_ctx->txCache[txid]};
|
||||
TxBroadcastDialog dialog{this, m_ctx, txHex};
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,15 @@ void AppContext::onMultiBroadcast(PendingTransaction *tx) {
|
|||
}
|
||||
}
|
||||
|
||||
void AppContext::addCacheTransaction(const QString &txid, const QString &txHex) const {
|
||||
this->wallet->setCacheAttribute(QString("tx:%1").arg(txid), txHex);
|
||||
}
|
||||
|
||||
QString AppContext::getCacheTransaction(const QString &txid) const {
|
||||
QString txHex = this->wallet->getCacheAttribute(QString("tx:%1").arg(txid));
|
||||
return txHex;
|
||||
}
|
||||
|
||||
// ################## Models ##################
|
||||
|
||||
void AppContext::onPreferredFiatCurrencyChanged(const QString &symbol) {
|
||||
|
|
|
@ -34,7 +34,6 @@ public:
|
|||
|
||||
NetworkType::Type networkType;
|
||||
PendingTransaction::Priority tx_priority = PendingTransaction::Priority::Priority_Low;
|
||||
QMap<QString, QString> txCache;
|
||||
|
||||
// libwalletqt
|
||||
bool refreshed = false;
|
||||
|
@ -48,6 +47,9 @@ public:
|
|||
|
||||
void stopTimers();
|
||||
|
||||
void addCacheTransaction(const QString &txid, const QString &txHex) const;
|
||||
QString getCacheTransaction(const QString &txid) const;
|
||||
|
||||
public slots:
|
||||
void onCreateTransaction(const QString &address, quint64 amount, const QString &description, bool all);
|
||||
void onCreateTransactionMultiDest(const QVector<QString> &addresses, const QVector<quint64> &amounts, const QString &description);
|
||||
|
|
|
@ -77,7 +77,7 @@ TxConfDialog::TxConfDialog(QSharedPointer<AppContext> ctx, PendingTransaction *t
|
|||
|
||||
connect(ui->btn_Advanced, &QPushButton::clicked, this, &TxConfDialog::setShowAdvanced);
|
||||
|
||||
m_ctx->txCache[tx->txid()[0]] = tx->signedTxToHex(0);
|
||||
m_ctx->addCacheTransaction(tx->txid()[0], tx->signedTxToHex(0)); // Todo: Iterate over all txs
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ TxInfoDialog::TxInfoDialog(QSharedPointer<AppContext> ctx, TransactionInfo *txIn
|
|||
|
||||
this->setData(txInfo);
|
||||
|
||||
if (m_ctx->txCache.contains(txInfo->hash()) && (txInfo->isFailed() || txInfo->isPending()) && txInfo->direction() != TransactionInfo::Direction_In) {
|
||||
if ((txInfo->isFailed() || txInfo->isPending()) && txInfo->direction() != TransactionInfo::Direction_In) {
|
||||
connect(ui->btn_rebroadcastTx, &QPushButton::pressed, [this]{
|
||||
emit resendTranscation(m_txid);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue