From abf02b86bd67d21a6496eab4f1020646a8c22166 Mon Sep 17 00:00:00 2001 From: terryhash Date: Fri, 9 Jul 2021 16:06:21 +0800 Subject: [PATCH] QT wallet, MWC "Atomic Swap" transaction with Ether is not getting completion state (Waited for 1 hr) #872 --- bridge/wnd/swap_b.cpp | 4 ++-- bridge/wnd/swap_b.h | 4 ++-- resource/mwc713_mappers.txt | 4 ++++ wallet/mwc713.cpp | 4 ++-- wallet/mwc713.h | 2 +- wallet/tasks/TaskSwap.cpp | 18 +++++++++++------- wallet/wallet.h | 2 +- windows_desktop/s_swaplist_w.cpp | 10 ++++------ windows_desktop/s_swaplist_w.h | 2 +- 9 files changed, 28 insertions(+), 22 deletions(-) diff --git a/bridge/wnd/swap_b.cpp b/bridge/wnd/swap_b.cpp index 3848775..476acf9 100644 --- a/bridge/wnd/swap_b.cpp +++ b/bridge/wnd/swap_b.cpp @@ -299,9 +299,9 @@ void Swap::onRequestEthInfo(QString ethAddr, QString currency, QString balance) emit sgnRequestEthInfo(ethAddr, currency, balance); } -void Swap::onRequestEthSend(QString dest, QString currency, QString amount) { +void Swap::onRequestEthSend(bool result, QString errMsg) { - emit sgnRequestEthSend(dest, currency, amount); + emit sgnRequestEthSend(result, errMsg); } // Check if this Trade is running in auto mode now diff --git a/bridge/wnd/swap_b.h b/bridge/wnd/swap_b.h index 1528bd2..62943c4 100644 --- a/bridge/wnd/swap_b.h +++ b/bridge/wnd/swap_b.h @@ -220,7 +220,7 @@ Q_OBJECT // Response from requestEthSend call // status, result status - void sgnRequestEthSend(QString dest, QString currency, QString amount); + void sgnRequestEthSend(bool result, QString errMsg); // Response from sgnAdjustSwapTrade. OK - empty error message void sgnAdjustSwapTrade(QString swapId, QString call_tag, QString errMsg); @@ -265,7 +265,7 @@ private slots: QString errMsg, QString cookie ); void onRequestEthInfo(QString ethAddr, QString currency, QString balance); - void onRequestEthSend(QString dest, QString currency, QString amount); + void onRequestEthSend(bool result, QString errMsg); void onAdjustSwapData(QString swapId, QString adjustCmd, QString errMsg); void onSwapTradeStatusUpdated(QString swapId, QString stateCmd, QString currentAction, QString currentState, diff --git a/resource/mwc713_mappers.txt b/resource/mwc713_mappers.txt index 997983e..d6eccfb 100644 --- a/resource/mwc713_mappers.txt +++ b/resource/mwc713_mappers.txt @@ -172,6 +172,10 @@ $2 Swap Error , Swap generic error, Unable to parse secondary currency redeem address (.*), Swap generic error, (.*) $2 +# Swap Error , Eth Wallet Balance is not enough +Swap Error , Eth Wallet Balance is not enough +Your Internal Ethereum Wallet hasn't enough funds for swap. Please deposit Ether/Erc-20 Tokens to your internal wallet. + # Your send request has failed: Adapter Callback Error, Checking version: Error: null, Message: null Your send request has failed: Adapter Callback Error, Checking version: Error: null, Message: null Your peer wallet is offline or not reachable. Please check your network connection or contact the owner of that waalet. diff --git a/wallet/mwc713.cpp b/wallet/mwc713.cpp index b102048..73f8e71 100755 --- a/wallet/mwc713.cpp +++ b/wallet/mwc713.cpp @@ -1870,9 +1870,9 @@ void MWC713::setRequestEthInfo(QString ethAddr, QString currency, QString balanc emit onRequestEthInfo(ethAddr, currency, balance); } -void MWC713::setRequestEthSend(QString dest, QString currency, QString amount) { +void MWC713::setRequestEthSend(bool result, QString errMsg) { logger::logEmit("MWC713", "onRequestEthSend", ""); - emit onRequestEthSend(dest, currency, amount); + emit onRequestEthSend(result, errMsg); } void MWC713::setAdjustSwapData(QString swapId, QString adjustCmd, QString errMsg) { diff --git a/wallet/mwc713.h b/wallet/mwc713.h index bb3367d..67748b0 100755 --- a/wallet/mwc713.h +++ b/wallet/mwc713.h @@ -534,7 +534,7 @@ class MWC713 : public Wallet QString error, QString cookie ); void setRequestEthInfo(QString ethAddr, QString currency, QString balance); - void setRequestEthSend(QString dest, QString currency, QString amount); + void setRequestEthSend(bool result, QString errMsg); void setAdjustSwapData(QString swapId, QString adjustCmd, QString errMsg); void setPerformAutoSwapStep(QString swapId, QString stateCmd, QString currentAction, QString currentState, diff --git a/wallet/tasks/TaskSwap.cpp b/wallet/tasks/TaskSwap.cpp index eaea3e2..92748ea 100644 --- a/wallet/tasks/TaskSwap.cpp +++ b/wallet/tasks/TaskSwap.cpp @@ -540,21 +540,25 @@ bool TaskEthSend::processTask(const QVector &events) { QVector lns = filterEvents(events, WALLET_EVENTS::S_LINE); // "Transfer Ether 0.01 to 0xC8C52374289E743CAA8fc6ACdf40c6E0b810261E done!!!" - QString dest = ""; - QString currency = ""; - QString amount = ""; + QString errMsg = ""; + bool result = false; for (const auto& l : lns) { const QString& msg = l.message; if (msg.contains("done")) { QStringList msgList = msg.split(" "); - dest = msgList.at(4); - currency = msgList.at(2); - amount = msgList.at(1); + errMsg = QString("dest: %1, currency: %2, amount: %3").arg(msgList.at(4), msgList.at(1), msgList.at(2)); + + result = true; + } + + if (msg.contains("Not Enough") || msg.contains("Unknown")) { + errMsg = msg; + result = false; } } - wallet713->setRequestEthSend(dest, currency, amount); + wallet713->setRequestEthSend(result, errMsg); return true; } diff --git a/wallet/wallet.h b/wallet/wallet.h index c0a8241..6e03bc8 100755 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -1020,7 +1020,7 @@ class Wallet : public QObject void onRequestEthInfo(QString ethAddr, QString currency, QString balance); // Response from requestEthSend - void onRequestEthSend(QString dest, QString currency, QString amount); + void onRequestEthSend(bool result, QString errMsg); // Response from adjustSwapData void onAdjustSwapData(QString swapId, QString call_tag, QString errMsg); diff --git a/windows_desktop/s_swaplist_w.cpp b/windows_desktop/s_swaplist_w.cpp index 3dc1eea..e8e3c64 100644 --- a/windows_desktop/s_swaplist_w.cpp +++ b/windows_desktop/s_swaplist_w.cpp @@ -639,13 +639,11 @@ void SwapList::sgnRequestEthInfo(QString ethAddr, QString currency, QString bala } -void SwapList::sgnRequestEthSend(QString dest, QString currency, QString amount) { - if (dest.isEmpty()) { - control::MessageBox::messageText(this, "Send Error", - "Send coins failed\n"); +void SwapList::sgnRequestEthSend(bool result, QString errMsg) { + if (!result) { + control::MessageBox::messageText(this, "Send Error", errMsg); } else { - control::MessageBox::messageText(this, "Send Done", - "Send " + currency + ": " + amount + " to " + dest + " done!"); + control::MessageBox::messageText(this, "Send Done", errMsg); } ui->addrSendtoLineEdit->clear(); diff --git a/windows_desktop/s_swaplist_w.h b/windows_desktop/s_swaplist_w.h index 48ae3d2..7e8862f 100644 --- a/windows_desktop/s_swaplist_w.h +++ b/windows_desktop/s_swaplist_w.h @@ -128,7 +128,7 @@ private slots: void sgnBackupSwapTradeData(QString swapId, QString exportedFileName, QString errorMessage); void sgnRestoreSwapTradeData(QString swapId, QString importedFilename, QString errorMessage); void sgnRequestEthInfo(QString ethAddr, QString currency, QString balance); - void sgnRequestEthSend(QString dest, QString currency, QString amount); + void sgnRequestEthSend(bool result, QString errMsg); void onItemActivated(QString id);