diff --git a/src/ReceiveWidget.cpp b/src/ReceiveWidget.cpp index c57e5c9..2bc77db 100644 --- a/src/ReceiveWidget.cpp +++ b/src/ReceiveWidget.cpp @@ -247,7 +247,6 @@ void ReceiveWidget::updateQrCode(){ void ReceiveWidget::showQrCodeDialog() { SubaddressRow* row = this->currentEntry(); - if (!row) return; QString address = this->getAddress(row->getRow()); QrCode qr(address, QrCode::Version::AUTO, QrCode::ErrorCorrectionLevel::HIGH); diff --git a/src/plugins/atomic/AtomicConfigDialog.cpp b/src/plugins/atomic/AtomicConfigDialog.cpp index 9ef469a..c4fc412 100644 --- a/src/plugins/atomic/AtomicConfigDialog.cpp +++ b/src/plugins/atomic/AtomicConfigDialog.cpp @@ -60,11 +60,11 @@ void AtomicConfigDialog::downloadBinary() { auto operatingSystem = Config::instance()->get(Config::operatingSystem).toString().toStdString(); if(strcmp("WIN",operatingSystem.c_str()) == 0) { // HARD CODED DOWNload URL CHANGE IF PROBLEMS - url = QString("https://github.com/comit-network/xmr-btc-swap/releases/tag/0.13.0/swap_0.13.0_Windows_x86_64.zip"); + url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.13.1/swap_0.13.1_Windows_x86_64.zip"); } else if (strcmp("LINUX",operatingSystem.c_str())==0){ - url = QString("https://github.com/comit-network/xmr-btc-swap/releases/tag/0.13.0/swap_0.13.0_Linux_x86_64.tar"); + url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.13.1/swap_0.13.1_Linux_x86_64.tar"); } else { - url = QString("https://github.com/comit-network/xmr-btc-swap/releases/tag/0.13.0/swap_0.13.0_Darwin_x86_64.tar"); + url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.13.1/swap_0.13.1_Linux_x86_64.tar"); } archive = network->get(this, url); diff --git a/src/plugins/atomic/AtomicSwap.cpp b/src/plugins/atomic/AtomicSwap.cpp new file mode 100644 index 0000000..f72fdf8 --- /dev/null +++ b/src/plugins/atomic/AtomicSwap.cpp @@ -0,0 +1,28 @@ +// +// Created by dev on 6/11/24. +// + +// You may need to build the project (run Qt uic code generator) to get "ui_AtomicSwap.h" resolved + +#include "AtomicSwap.h" +#include "ui_AtomicSwap.h" + + + +AtomicSwap::AtomicSwap(QWidget *parent) : + QDialog(parent), ui(new Ui::AtomicSwap) { + ui->setupUi(this); +} + + +AtomicSwap::~AtomicSwap() { + delete ui; +} +void AtomicSwap::logLine(QString line){ + ui->debug_log->setText(ui->debug_log->toPlainText().append(QTime::currentTime().toString() + ":" + line)); + this->update(); +} +void AtomicSwap::updateStatus(QString status){ + ui->label_status->setText(status); + this->update(); +} \ No newline at end of file diff --git a/src/plugins/atomic/AtomicSwap.h b/src/plugins/atomic/AtomicSwap.h new file mode 100644 index 0000000..286c1eb --- /dev/null +++ b/src/plugins/atomic/AtomicSwap.h @@ -0,0 +1,32 @@ +// +// Created by dev on 6/11/24. +// + +#ifndef FEATHER_ATOMICSWAP_H +#define FEATHER_ATOMICSWAP_H + +#include +#include + + +QT_BEGIN_NAMESPACE +namespace Ui { class AtomicSwap; } +QT_END_NAMESPACE + +class AtomicSwap : public QDialog { +Q_OBJECT + +public: + explicit AtomicSwap(QWidget *parent = nullptr); + void updateStatus(QString status); + void logLine(QString line); + ~AtomicSwap() override; + +private: + Ui::AtomicSwap *ui; + + +}; + + +#endif //FEATHER_ATOMICSWAP_H diff --git a/src/plugins/atomic/AtomicSwap.ui b/src/plugins/atomic/AtomicSwap.ui new file mode 100644 index 0000000..4519c2d --- /dev/null +++ b/src/plugins/atomic/AtomicSwap.ui @@ -0,0 +1,55 @@ + + + AtomicSwap + + + + 0 + 0 + 400 + 300 + + + + AtomicSwap + + + + + 0 + 0 + 361 + 271 + + + + + + + Connected to peer, swap starting + + + + + + + + + + + + Debug Log + + + + + + + + + + + + + + diff --git a/src/plugins/atomic/AtomicWidget.cpp b/src/plugins/atomic/AtomicWidget.cpp index 0cf577b..341591b 100644 --- a/src/plugins/atomic/AtomicWidget.cpp +++ b/src/plugins/atomic/AtomicWidget.cpp @@ -12,14 +12,17 @@ #include "OfferModel.h" #include "utils/AppData.h" #include "utils/ColorScheme.h" -#include "utils/config.h" #include "utils/WebsocketNotifier.h" +#include "dialog/QrCodeDialog.h" AtomicWidget::AtomicWidget(QWidget *parent) : QWidget(parent) , ui(new Ui::AtomicWidget) + , m_instance(Config::instance()) , o_model(new OfferModel(this)) , offerList(new QList>()) + , swapDialog(new AtomicSwap(this)) + , procList(new QList>()) { ui->setupUi(this); @@ -49,7 +52,6 @@ AtomicWidget::AtomicWidget(QWidget *parent) ui->meta_label->setText("Updating offer book this may take a bit, if no offers appear after a while try refreshing again"); - auto m_instance = Config::instance(); QStringList pointList = m_instance->get(Config::rendezVous).toStringList(); for(QString point :pointList) AtomicWidget::list(point); @@ -65,6 +67,7 @@ AtomicWidget::AtomicWidget(QWidget *parent) //Add proper error checking on ui input after rest of swap is implemented QString btcChange = ui->change_address->text(); QString xmrReceive = ui->xmr_address->text(); + showAtomicSwapDialog(); runSwap(seller,btcChange, xmrReceive); } }); @@ -99,6 +102,9 @@ void AtomicWidget::showAtomicConfigureDialog() { } } +void AtomicWidget::showAtomicSwapDialog() { + swapDialog->show(); +} void AtomicWidget::updateStatus() { @@ -108,7 +114,6 @@ void AtomicWidget::updateStatus() { void AtomicWidget::runSwap(QString seller, QString btcChange, QString xmrReceive) { qDebug() << "starting swap"; QStringList arguments; - auto m_instance = Config::instance(); arguments << "--data-base-dir"; arguments << Config::defaultConfigDir().absolutePath(); // Remove after testing @@ -125,17 +130,28 @@ void AtomicWidget::runSwap(QString seller, QString btcChange, QString xmrReceive arguments << m_instance->get(Config::socks5Port).toString(); auto *swap = new QProcess(); + procList->append(QSharedPointer(swap)); + swap->setReadChannel(QProcess::StandardError); connect(swap, &QProcess::readyReadStandardError,this, [this, swap] { while(swap->canReadLine()){ QJsonParseError err; - QJsonDocument line = QJsonDocument::fromJson(swap->readLine(), &err); - qDebug() << line; + const QByteArray& rawline = swap->readLine(); + QJsonDocument line = QJsonDocument::fromJson(rawline, &err); + qDebug() << rawline; if (line["fields"]["message"].toString().contains("Connected to Alice")){ qDebug() << "Succesfully connected"; + swapDialog->logLine(line["fields"].toString()); } else if (!line["fields"]["deposit_address"].toString().isEmpty()){ qDebug() << "Deposit to btc to segwit address"; - } else if () + QString address = line["fields"]["deposit_address"].toString(); + QrCode qrc(address, QrCode::Version::AUTO, QrCode::ErrorCorrectionLevel::HIGH); + swapDialog->updateStatus("Add money to this address\n" + address); + QrCodeDialog dialog(this, &qrc, "Deposit BTC to this address"); + dialog.show(); + } else{ + + } //Insert line conditionals here } }); @@ -147,7 +163,6 @@ void AtomicWidget::runSwap(QString seller, QString btcChange, QString xmrReceive void AtomicWidget::list(QString rendezvous) { QStringList arguments; QList> list; - auto m_instance = Config::instance(); arguments << "--data-base-dir"; arguments << Config::defaultConfigDir().absolutePath(); // Remove after testing @@ -159,6 +174,7 @@ void AtomicWidget::list(QString rendezvous) { arguments << "--rendezvous-point"; arguments << rendezvous; auto *swap = new QProcess(); + procList->append(QSharedPointer(swap)); swap->setReadChannel(QProcess::StandardError); //swap->start(m_instance->get(Config::swapPath).toString(), arguments); connect(swap, &QProcess::finished, this, [this, swap]{ @@ -206,4 +222,19 @@ void AtomicWidget::list(QString rendezvous) { } -AtomicWidget::~AtomicWidget() = default; \ No newline at end of file +AtomicWidget::~AtomicWidget() { + qDebug()<< "EXiting widget!!"; + delete o_model; + delete offerList; + for (auto proc : *procList){ + if(!proc->atEnd()) + proc->terminate(); + } + if(QString::compare("WINDOWS",m_instance->get(Config::operatingSystem).toString()) != 0) { + qDebug() << "Closing monero-wallet-rpc"; + (new QProcess)->start("pkill", QStringList{"-f", Config::defaultConfigDir().absolutePath() + + "/mainnet/monero/monero-wallet-rpc"}); + } + delete m_instance; + delete procList; +}; \ No newline at end of file diff --git a/src/plugins/atomic/AtomicWidget.h b/src/plugins/atomic/AtomicWidget.h index 37a21d7..d33cb1f 100644 --- a/src/plugins/atomic/AtomicWidget.h +++ b/src/plugins/atomic/AtomicWidget.h @@ -11,6 +11,8 @@ #include #include "OfferModel.h" +#include "AtomicSwap.h" +#include "config.h" namespace Ui { class AtomicWidget; @@ -40,6 +42,12 @@ private: QTimer m_statusTimer; OfferModel *o_model; QList> *offerList; + AtomicSwap *swapDialog; + + void showAtomicSwapDialog(); + + QList> *procList; + Config *m_instance; }; #endif // FEATHER_ATOMICWIDGET_H diff --git a/src/plugins/atomic/AtomicWidget.ui b/src/plugins/atomic/AtomicWidget.ui index 3bfd080..90ef700 100644 --- a/src/plugins/atomic/AtomicWidget.ui +++ b/src/plugins/atomic/AtomicWidget.ui @@ -29,7 +29,11 @@ - + + + bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq + + @@ -43,7 +47,11 @@ - + + + 888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H + + diff --git a/src/utils/config.cpp b/src/utils/config.cpp index e7878dc..5358269 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -142,9 +142,10 @@ static const QHash configStrings = { {Config::tickersShowFiatBalance, {QS("tickersShowFiatBalance"), true}}, // Atomic - {Config::rendezVous, {QS("rendezVous"), QStringList{"/dns4/discover.unstoppableswap.net/tcp/8888/p2p/12D3KooWA6cnqJpVnreBVnoro8midDL9Lpzmg8oJPoAGi7YYaamE", - "/dns4/eratosthen.es/tcp/7798/p2p/12D3KooWAh7EXXa2ZyegzLGdjvj1W4G3EXrTGrf6trraoT1MEobs", + {Config::rendezVous, {QS("rendezVous"), QStringList{"/dns4/atomicswaps.majesticbank.at/tcp/8888/p2p/12D3KooWKJUwP45K7fLbwGY1VM5V3U7LseU8EwJiAozUFrq5ihoF", "/dnsaddr/rendezvous.coblox.tech/p2p/12D3KooWQUt9DkNZxEn2R5ymJzWj15MpG6mTW84kyd8vDaRZi46o", + "/dns4/discover.unstoppableswap.net/tcp/8888/p2p/12D3KooWA6cnqJpVnreBVnoro8midDL9Lpzmg8oJPoAGi7YYaamE", + "/dns4/eratosthen.es/tcp/7798/p2p/12D3KooWAh7EXXa2ZyegzLGdjvj1W4G3EXrTGrf6trraoT1MEobs", "/dns4/swap.sethforprivacy.com/tcp/8888/p2p/12D3KooWCULyZKuV9YEkb6BX8FuwajdvktSzmMg4U5ZX2uYZjHeu"}}}, {Config::swapPath, {QS("swapPath"), ""}}, {Config::operatingSystem, {QS("operatingSystem"), OS}},