mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-22 18:54:33 +00:00
Atomic Swap UI to show progress of swap started
Bump to swap tool v 0.13.1 ** Fix to kill swap process & monero-wallet-rpc process on shutdown
This commit is contained in:
parent
a84ff2ef03
commit
cba9eabb4b
9 changed files with 178 additions and 16 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
28
src/plugins/atomic/AtomicSwap.cpp
Normal file
28
src/plugins/atomic/AtomicSwap.cpp
Normal file
|
@ -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();
|
||||
}
|
32
src/plugins/atomic/AtomicSwap.h
Normal file
32
src/plugins/atomic/AtomicSwap.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Created by dev on 6/11/24.
|
||||
//
|
||||
|
||||
#ifndef FEATHER_ATOMICSWAP_H
|
||||
#define FEATHER_ATOMICSWAP_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTime>
|
||||
|
||||
|
||||
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
|
55
src/plugins/atomic/AtomicSwap.ui
Normal file
55
src/plugins/atomic/AtomicSwap.ui
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AtomicSwap</class>
|
||||
<widget class="QDialog" name="AtomicSwap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>AtomicSwap</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>361</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_status">
|
||||
<property name="text">
|
||||
<string>Connected to peer, swap starting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Debug Log</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="debug_log"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -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<QSharedPointer<OfferEntry>>())
|
||||
, swapDialog(new AtomicSwap(this))
|
||||
, procList(new QList<QSharedPointer<QProcess>>())
|
||||
{
|
||||
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<QProcess>(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<QSharedPointer<OfferEntry>> 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<QProcess>(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;
|
||||
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;
|
||||
};
|
|
@ -11,6 +11,8 @@
|
|||
#include <QMutex>
|
||||
|
||||
#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<QSharedPointer<OfferEntry>> *offerList;
|
||||
AtomicSwap *swapDialog;
|
||||
|
||||
void showAtomicSwapDialog();
|
||||
|
||||
QList<QSharedPointer<QProcess>> *procList;
|
||||
Config *m_instance;
|
||||
};
|
||||
|
||||
#endif // FEATHER_ATOMICWIDGET_H
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="change_address"/>
|
||||
<widget class="QLineEdit" name="change_address">
|
||||
<property name="text">
|
||||
<string>bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -43,7 +47,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="xmr_address"/>
|
||||
<widget class="QLineEdit" name="xmr_address">
|
||||
<property name="text">
|
||||
<string>888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
|
@ -142,9 +142,10 @@ static const QHash<Config::ConfigKey, ConfigDirective> 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}},
|
||||
|
|
Loading…
Reference in a new issue