Skip to content

Commit

Permalink
QT wallet, MWC "Atomic Swap" transaction with Ether is not getting co…
Browse files Browse the repository at this point in the history
…mpletion state (Waited for 1 hr) #872
  • Loading branch information
terryhash committed Jul 9, 2021
1 parent d10fc39 commit abf02b8
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions bridge/wnd/swap_b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bridge/wnd/swap_b.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions resource/mwc713_mappers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions wallet/mwc713.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion wallet/mwc713.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 11 additions & 7 deletions wallet/tasks/TaskSwap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,21 +540,25 @@ bool TaskEthSend::processTask(const QVector<WEvent> &events) {
QVector<WEvent> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions windows_desktop/s_swaplist_w.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion windows_desktop/s_swaplist_w.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit abf02b8

Please sign in to comment.