mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-11 05:15:21 +00:00
Minor Refactoring and addition of behind the scene changes to swap settings based on feather configuration.
Atomic will no longer appear if feather is launched in testnet mode. DONE: 1. Connect signals to make status of swap reflected in AtomicSwap dialog 2. Add informational tabs to AtomicSwap dialog 4. Add recovery to atomic widget 5. Refactor AtomicWidget so AtomicSwap handles parsing of swap binary output. TODO: 3. Add cancel and refund functionality to AtomicSwap when things go wrong
This commit is contained in:
parent
c67fedf9bc
commit
41f78b5f89
10 changed files with 165 additions and 56 deletions
|
@ -69,6 +69,7 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
|
||||||
this->restoreGeo();
|
this->restoreGeo();
|
||||||
|
|
||||||
this->initStatusBar();
|
this->initStatusBar();
|
||||||
|
|
||||||
this->initPlugins();
|
this->initPlugins();
|
||||||
this->initWidgets();
|
this->initWidgets();
|
||||||
this->initMenu();
|
this->initMenu();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "Plugin.h"
|
#include "Plugin.h"
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
class PluginRegistry {
|
class PluginRegistry {
|
||||||
public:
|
public:
|
||||||
|
@ -35,7 +36,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isPluginEnabled(const QString &id) {
|
bool isPluginEnabled(const QString &id) {
|
||||||
if (!pluginMap.contains(id)) {
|
if (!pluginMap.contains(id) or (QString::compare(id,"atomic")==0 && constants::networkType==NetworkType::TESTNET)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ void AtomicConfigDialog::extract() {
|
||||||
swapPath.append("/swapTool");
|
swapPath.append("/swapTool");
|
||||||
QFile binaryFile(swapPath);
|
QFile binaryFile(swapPath);
|
||||||
binaryFile.open(QIODevice::WriteOnly);
|
binaryFile.open(QIODevice::WriteOnly);
|
||||||
auto operatingSystem = Config::instance()->get(Config::operatingSystem).toString().toStdString();
|
auto operatingSystem = conf()->get(Config::operatingSystem).toString().toStdString();
|
||||||
if(strcmp("WIN",operatingSystem.c_str()) == 0) {
|
if(strcmp("WIN",operatingSystem.c_str()) == 0) {
|
||||||
// UNZIP
|
// UNZIP
|
||||||
zip *z = zip_open(tempFile.toStdString().c_str(), 0, 0);
|
zip *z = zip_open(tempFile.toStdString().c_str(), 0, 0);
|
||||||
|
@ -114,7 +114,7 @@ void AtomicConfigDialog::extract() {
|
||||||
zip_fclose(f);
|
zip_fclose(f);
|
||||||
//And close the archive
|
//And close the archive
|
||||||
zip_close(z);
|
zip_close(z);
|
||||||
Config::instance()->set(Config::swapPath,swapPath);
|
conf()->set(Config::swapPath,swapPath);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
struct archive *a;
|
struct archive *a;
|
||||||
|
@ -145,7 +145,7 @@ void AtomicConfigDialog::extract() {
|
||||||
|
|
||||||
archive_write_close(ext);
|
archive_write_close(ext);
|
||||||
archive_write_free(ext);
|
archive_write_free(ext);
|
||||||
Config::instance()->set(Config::swapPath, QString(savePath.c_str()));
|
conf()->set(Config::swapPath, QString(savePath.c_str()));
|
||||||
}
|
}
|
||||||
qDebug() << "Finished";
|
qDebug() << "Finished";
|
||||||
binaryFile.close();
|
binaryFile.close();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "AtomicConfigDialog.h"
|
#include "AtomicConfigDialog.h"
|
||||||
|
|
||||||
#include "plugins/PluginRegistry.h"
|
#include "plugins/PluginRegistry.h"
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
AtomicPlugin::AtomicPlugin()
|
AtomicPlugin::AtomicPlugin()
|
||||||
{
|
{
|
||||||
|
@ -64,7 +65,11 @@ void AtomicPlugin::skinChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool AtomicPlugin::registered = [] {
|
const bool AtomicPlugin::registered = [] {
|
||||||
PluginRegistry::registerPlugin(AtomicPlugin::create());
|
if(constants::networkType!=NetworkType::TESTNET) {
|
||||||
PluginRegistry::getInstance().registerPluginCreator(&AtomicPlugin::create);
|
PluginRegistry::registerPlugin(AtomicPlugin::create());
|
||||||
return true;
|
PluginRegistry::getInstance().registerPluginCreator(&AtomicPlugin::create);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -8,20 +8,27 @@
|
||||||
#include "ui_AtomicRecoverDialog.h"
|
#include "ui_AtomicRecoverDialog.h"
|
||||||
#include "History.h"
|
#include "History.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "AtomicSwap.h"
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
AtomicRecoverDialog::AtomicRecoverDialog(QWidget *parent) :
|
AtomicRecoverDialog::AtomicRecoverDialog(QWidget *parent) :
|
||||||
WindowModalDialog(parent), ui(new Ui::AtomicRecoverDialog) {
|
WindowModalDialog(parent), ui(new Ui::AtomicRecoverDialog), swapDialog(new AtomicSwap(this)) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
auto model = new QStandardItemModel();
|
auto model = new QStandardItemModel();
|
||||||
ui->swap_history->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
ui->swap_history->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
ui->swap_history->setModel(model);
|
ui->swap_history->setModel(model);
|
||||||
|
ui->btn_refund_resume->setVisible(false);
|
||||||
|
ui->swap_history->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
ui->swap_history->verticalHeader()->setVisible(false);
|
||||||
|
// Makes it easy to see if button is in refund or resume mode
|
||||||
|
ui->btn_refund_resume->setProperty("Refund",0);
|
||||||
|
this->setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||||
model->setHorizontalHeaderItem(0, new QStandardItem("Swap-Id"));
|
model->setHorizontalHeaderItem(0, new QStandardItem("Swap-Id"));
|
||||||
model->setHorizontalHeaderItem(1, new QStandardItem("Timestamp swap started"));
|
model->setHorizontalHeaderItem(1, new QStandardItem("Timestamp swap started"));
|
||||||
model->setHorizontalHeaderItem(2, new QStandardItem("Status"));
|
model->setHorizontalHeaderItem(2, new QStandardItem("Status"));
|
||||||
|
|
||||||
QList<QStandardItem*> rowData;
|
QList<QStandardItem*> rowData;
|
||||||
auto data = Config::instance()->get(Config::pendingSwap).value<QVariantList>();
|
auto data = conf()->get(Config::pendingSwap).value<QVariantList>();
|
||||||
for(int i=0; i< data.size(); i++){
|
for(int i=0; i< data.size(); i++){
|
||||||
auto entry = data[i].value<HistoryEntry>();
|
auto entry = data[i].value<HistoryEntry>();
|
||||||
qint64 difference = entry.timestamp.secsTo(QDateTime::currentDateTime());
|
qint64 difference = entry.timestamp.secsTo(QDateTime::currentDateTime());
|
||||||
|
@ -39,20 +46,47 @@ AtomicRecoverDialog::AtomicRecoverDialog(QWidget *parent) :
|
||||||
data.remove(i);
|
data.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Config::instance()->set(Config::pendingSwap,data);
|
conf()->set(Config::pendingSwap,data);
|
||||||
|
connect(ui->swap_history, &QAbstractItemView::clicked, this, &AtomicRecoverDialog::updateBtn);
|
||||||
|
connect(ui->btn_refund_resume, &QPushButton::clicked, this, [this]{
|
||||||
|
QStringList arguments;
|
||||||
|
if (ui->btn_refund_resume->property("Refund").toBool()){
|
||||||
|
arguments << "cancel-and-refund";
|
||||||
|
} else {
|
||||||
|
arguments << "resume";
|
||||||
|
}
|
||||||
|
arguments << "--swap-id";
|
||||||
|
arguments << ui->swap_history->selectionModel()->selectedRows().at(0).sibling(0,1).data().toString();
|
||||||
|
arguments << "--tor-socks5-port";
|
||||||
|
arguments << conf()->get(Config::socks5Port).toString();
|
||||||
|
swapDialog->runSwap(arguments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AtomicRecoverDialog::updateBtn(const QModelIndex &index){
|
||||||
|
auto row = index.sibling(index.row(),2).data().toString();
|
||||||
|
if (row.startsWith("Ref")){
|
||||||
|
ui->btn_refund_resume->setText("Cancel And Refund");
|
||||||
|
ui->btn_refund_resume->setProperty("Refund",1);
|
||||||
|
} else {
|
||||||
|
ui->btn_refund_resume->setText("Attempt to Resume");
|
||||||
|
ui->btn_refund_resume->setProperty("Refund",0);
|
||||||
|
}
|
||||||
|
ui->btn_refund_resume->setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomicRecoverDialog::historyEmpty(){
|
bool AtomicRecoverDialog::historyEmpty(){
|
||||||
return Config::instance()->get(Config::pendingSwap).value<QVariantList>().isEmpty();
|
return conf()->get(Config::pendingSwap).value<QVariantList>().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AtomicRecoverDialog::appendHistory(HistoryEntry entry){
|
void AtomicRecoverDialog::appendHistory(HistoryEntry entry){
|
||||||
auto current = Config::instance()->get(Config::pendingSwap).value<QVariantList>();
|
auto current = conf()->get(Config::pendingSwap).value<QVariantList>();
|
||||||
auto var = QVariant();
|
auto var = QVariant();
|
||||||
var.setValue(entry);
|
var.setValue(entry);
|
||||||
current.append(var);
|
current.append(var);
|
||||||
Config::instance()->set(Config::pendingSwap, current);
|
conf()->set(Config::pendingSwap, current);
|
||||||
}
|
}
|
||||||
AtomicRecoverDialog::~AtomicRecoverDialog() {
|
AtomicRecoverDialog::~AtomicRecoverDialog() {
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "components.h"
|
#include "components.h"
|
||||||
#include "History.h"
|
#include "History.h"
|
||||||
|
#include "AtomicSwap.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class AtomicRecoverDialog; }
|
namespace Ui { class AtomicRecoverDialog; }
|
||||||
|
@ -22,8 +23,12 @@ public:
|
||||||
void appendHistory(HistoryEntry entry);
|
void appendHistory(HistoryEntry entry);
|
||||||
~AtomicRecoverDialog() override;
|
~AtomicRecoverDialog() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateBtn(const QModelIndex &index);
|
||||||
private:
|
private:
|
||||||
Ui::AtomicRecoverDialog *ui;
|
Ui::AtomicRecoverDialog *ui;
|
||||||
|
AtomicSwap *swapDialog;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,71 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>903</width>
|
<width>936</width>
|
||||||
<height>248</height>
|
<height>256</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>AtomicRecoverDialog</string>
|
<string>AtomicRecoverDialog</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTableView" name="swap_history">
|
<widget class="QWidget" name="verticalLayoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>20</y>
|
<y>10</y>
|
||||||
<width>881</width>
|
<width>911</width>
|
||||||
<height>179</height>
|
<height>211</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>There are one or more Atomic Swaps still pending, take action to prevent losing funds!</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="swap_history"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_refund_resume">
|
||||||
|
<property name="text">
|
||||||
|
<string>Resume</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -60,13 +60,21 @@ void AtomicSwap::runSwap(QStringList arguments){
|
||||||
this->updateXMRConf(confs.toInt());
|
this->updateXMRConf(confs.toInt());
|
||||||
} else if (QString message = line["fields"]["message"].toString(); !QString::compare(message, "Bitcoin transaction status changed")){
|
} else if (QString message = line["fields"]["message"].toString(); !QString::compare(message, "Bitcoin transaction status changed")){
|
||||||
qDebug() << "Updating btconfs " + line["fields"]["new_status"].toString().split(" ")[2];
|
qDebug() << "Updating btconfs " + line["fields"]["new_status"].toString().split(" ")[2];
|
||||||
this->updateBTCConf(line["fields"]["new_status"].toString().split(" ")[2].toInt());
|
QString status = line["fields"]["new_status"].toString();
|
||||||
|
bool ok;
|
||||||
|
auto confirmations = status.split(" ")[2].toInt(&ok, 10);
|
||||||
|
if(ok) {
|
||||||
|
this->updateBTCConf(confirmations);
|
||||||
|
} else {
|
||||||
|
this->updateStatus("Found txid " + line["fields"]["txid"].toString() + " in mempool");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Insert line conditionals here
|
//Insert line conditionals here
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
swap->start(Config::instance()->get(Config::swapPath).toString(),arguments);
|
swap->start(conf()->get(Config::swapPath).toString(),arguments);
|
||||||
qDebug() << "process started";
|
qDebug() << "process started";
|
||||||
}
|
}
|
||||||
AtomicSwap::~AtomicSwap() {
|
AtomicSwap::~AtomicSwap() {
|
||||||
|
@ -74,7 +82,7 @@ AtomicSwap::~AtomicSwap() {
|
||||||
for (const auto& proc : *procList){
|
for (const auto& proc : *procList){
|
||||||
proc->kill();
|
proc->kill();
|
||||||
}
|
}
|
||||||
if(QString::compare("WINDOWS",Config::instance()->get(Config::operatingSystem).toString()) != 0) {
|
if(QString::compare("WINDOWS",conf()->get(Config::operatingSystem).toString()) != 0) {
|
||||||
qDebug() << "Closing monero-wallet-rpc";
|
qDebug() << "Closing monero-wallet-rpc";
|
||||||
(new QProcess)->start("kill", QStringList{"-f", Config::defaultConfigDir().absolutePath() +
|
(new QProcess)->start("kill", QStringList{"-f", Config::defaultConfigDir().absolutePath() +
|
||||||
"/mainnet/monero/monero-wallet-rpc"});
|
"/mainnet/monero/monero-wallet-rpc"});
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "AtomicConfigDialog.h"
|
#include "AtomicConfigDialog.h"
|
||||||
#include "OfferModel.h"
|
#include "OfferModel.h"
|
||||||
#include "utils/AppData.h"
|
#include "utils/AppData.h"
|
||||||
|
#include "utils/nodes.h"
|
||||||
#include "utils/ColorScheme.h"
|
#include "utils/ColorScheme.h"
|
||||||
#include "utils/WebsocketNotifier.h"
|
#include "utils/WebsocketNotifier.h"
|
||||||
#include "AtomicFundDialog.h"
|
#include "AtomicFundDialog.h"
|
||||||
|
@ -18,7 +19,6 @@
|
||||||
AtomicWidget::AtomicWidget(QWidget *parent)
|
AtomicWidget::AtomicWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::AtomicWidget)
|
, ui(new Ui::AtomicWidget)
|
||||||
, m_instance(Config::instance())
|
|
||||||
, o_model(new OfferModel(this))
|
, o_model(new OfferModel(this))
|
||||||
, offerList(new QList<QSharedPointer<OfferEntry>>())
|
, offerList(new QList<QSharedPointer<OfferEntry>>())
|
||||||
, swapDialog(new AtomicSwap(this))
|
, swapDialog(new AtomicSwap(this))
|
||||||
|
@ -43,7 +43,7 @@ AtomicWidget::AtomicWidget(QWidget *parent)
|
||||||
ui->offerBookTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
|
ui->offerBookTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
|
||||||
ui->btn_configure->setEnabled(true);
|
ui->btn_configure->setEnabled(true);
|
||||||
|
|
||||||
if (!m_instance->get(Config::swapPath).toString().isEmpty())
|
if (!conf()->get(Config::swapPath).toString().isEmpty())
|
||||||
ui->meta_label->setText("Refresh offer book before swapping to prevent errors");
|
ui->meta_label->setText("Refresh offer book before swapping to prevent errors");
|
||||||
|
|
||||||
connect(ui->btn_configure, &QPushButton::clicked, this, &AtomicWidget::showAtomicConfigureDialog);
|
connect(ui->btn_configure, &QPushButton::clicked, this, &AtomicWidget::showAtomicConfigureDialog);
|
||||||
|
@ -53,7 +53,7 @@ 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");
|
ui->meta_label->setText("Updating offer book this may take a bit, if no offers appear after a while try refreshing again");
|
||||||
|
|
||||||
QStringList pointList = m_instance->get(Config::rendezVous).toStringList();
|
QStringList pointList = conf()->get(Config::rendezVous).toStringList();
|
||||||
for(const QString& point :pointList)
|
for(const QString& point :pointList)
|
||||||
AtomicWidget::list(point);
|
AtomicWidget::list(point);
|
||||||
});
|
});
|
||||||
|
@ -83,22 +83,21 @@ AtomicWidget::AtomicWidget(QWidget *parent)
|
||||||
tr("p2p multi address of rendezvous point"), QLineEdit::Normal,
|
tr("p2p multi address of rendezvous point"), QLineEdit::Normal,
|
||||||
"", &ok);
|
"", &ok);
|
||||||
if (ok && !text.isEmpty()) {
|
if (ok && !text.isEmpty()) {
|
||||||
QStringList copy = m_instance->get(Config::rendezVous).toStringList();
|
QStringList copy = conf()->get(Config::rendezVous).toStringList();
|
||||||
copy.append(text);
|
copy.append(text);
|
||||||
m_instance->set(Config::rendezVous,copy);
|
conf()->set(Config::rendezVous,copy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//Remove after testing
|
//Remove after testing
|
||||||
//QVariant var;
|
QVariant var;
|
||||||
//var.setValue(HistoryEntry {QDateTime::currentDateTime(),"test-id"});
|
var.setValue(HistoryEntry {QDateTime::currentDateTime(),"test-id"});
|
||||||
//m_instance->set(Config::pendingSwap, QVariantList{var});
|
conf()->set(Config::pendingSwap, QVariantList{var});
|
||||||
//auto recd = new AtomicRecoverDialog();
|
auto recd = new AtomicRecoverDialog(this);
|
||||||
//if (!recd->historyEmpty()){
|
if (!recd->historyEmpty()){
|
||||||
// recd->show();
|
recd->show();
|
||||||
//}
|
}
|
||||||
this->updateStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,13 +110,6 @@ void AtomicWidget::showAtomicConfigureDialog() {
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomicWidget::showAtomicSwapDialog() {
|
|
||||||
swapDialog->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomicWidget::updateStatus() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomicWidget::runSwap(const QString& seller, const QString& btcChange, const QString& xmrReceive) {
|
void AtomicWidget::runSwap(const QString& seller, const QString& btcChange, const QString& xmrReceive) {
|
||||||
qDebug() << "starting swap";
|
qDebug() << "starting swap";
|
||||||
|
@ -125,7 +117,9 @@ void AtomicWidget::runSwap(const QString& seller, const QString& btcChange, cons
|
||||||
arguments << "--data-base-dir";
|
arguments << "--data-base-dir";
|
||||||
arguments << Config::defaultConfigDir().absolutePath();
|
arguments << Config::defaultConfigDir().absolutePath();
|
||||||
// Remove after testing
|
// Remove after testing
|
||||||
arguments << "--testnet";
|
if (constants::networkType==NetworkType::STAGENET){
|
||||||
|
arguments << "--testnet";
|
||||||
|
}
|
||||||
arguments << "--debug";
|
arguments << "--debug";
|
||||||
arguments << "-j";
|
arguments << "-j";
|
||||||
arguments << "buy-xmr";
|
arguments << "buy-xmr";
|
||||||
|
@ -142,12 +136,24 @@ void AtomicWidget::runSwap(const QString& seller, const QString& btcChange, cons
|
||||||
arguments << "tcp://127.0.0.1:50001";
|
arguments << "tcp://127.0.0.1:50001";
|
||||||
arguments << "--bitcoin-target-block";
|
arguments << "--bitcoin-target-block";
|
||||||
arguments << "1";
|
arguments << "1";
|
||||||
|
auto nodes = conf()->get(Config::nodes).toJsonObject();
|
||||||
|
if (nodes.isEmpty()) {
|
||||||
|
auto jsonData = conf()->get(Config::nodes).toByteArray();
|
||||||
|
if (Utils::validateJSON(jsonData)) {
|
||||||
|
auto doc = QJsonDocument::fromJson(jsonData);
|
||||||
|
nodes = doc.object();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() << nodes.value("0").toObject()["ws"].toArray()[0];
|
||||||
arguments << "--monero-daemon-address";
|
arguments << "--monero-daemon-address";
|
||||||
arguments << "node.monerodevs.org:38089";
|
//arguments << "node.monerodevs.org:38089";
|
||||||
|
arguments << nodes.value("0").toObject()["ws"].toArray()[0].toString();
|
||||||
// Uncomment after testing
|
// Uncomment after testing
|
||||||
//arguments << seller;
|
//arguments << seller;
|
||||||
arguments << "--tor-socks5-port";
|
if(conf()->get(Config::proxy).toInt() != Config::Proxy::None) {
|
||||||
arguments << m_instance->get(Config::socks5Port).toString();
|
arguments << "--tor-socks5-port";
|
||||||
|
arguments << conf()->get(Config::socks5Port).toString();
|
||||||
|
}
|
||||||
swapDialog->runSwap(arguments);
|
swapDialog->runSwap(arguments);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,16 +162,21 @@ void AtomicWidget::list(const QString& rendezvous) {
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << "--data-base-dir";
|
arguments << "--data-base-dir";
|
||||||
arguments << Config::defaultConfigDir().absolutePath();
|
arguments << Config::defaultConfigDir().absolutePath();
|
||||||
|
if (constants::networkType==NetworkType::STAGENET){
|
||||||
|
arguments << "--testnet";
|
||||||
|
}
|
||||||
arguments << "-j";
|
arguments << "-j";
|
||||||
arguments << "list-sellers";
|
arguments << "list-sellers";
|
||||||
arguments << "--tor-socks5-port";
|
if(conf()->get(Config::proxy).toInt() != Config::Proxy::None) {
|
||||||
arguments << m_instance->get(Config::socks5Port).toString();
|
arguments << "--tor-socks5-port";
|
||||||
|
arguments << conf()->get(Config::socks5Port).toString();
|
||||||
|
}
|
||||||
arguments << "--rendezvous-point";
|
arguments << "--rendezvous-point";
|
||||||
arguments << rendezvous;
|
arguments << rendezvous;
|
||||||
auto *swap = new QProcess();
|
auto *swap = new QProcess();
|
||||||
procList->append(QSharedPointer<QProcess>(swap));
|
procList->append(QSharedPointer<QProcess>(swap));
|
||||||
swap->setReadChannel(QProcess::StandardError);
|
swap->setReadChannel(QProcess::StandardError);
|
||||||
//swap->start(m_instance->get(Config::swapPath).toString(), arguments);
|
//swap->start(conf()->get(Config::swapPath).toString(), arguments);
|
||||||
connect(swap, &QProcess::finished, this, [this, swap]{
|
connect(swap, &QProcess::finished, this, [this, swap]{
|
||||||
QJsonDocument parsedLine;
|
QJsonDocument parsedLine;
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
|
@ -203,7 +214,7 @@ void AtomicWidget::list(const QString& rendezvous) {
|
||||||
o_model->updateOffers(*offerList);
|
o_model->updateOffers(*offerList);
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
swap->start(m_instance->get(Config::swapPath).toString(), arguments);
|
swap->start(conf()->get(Config::swapPath).toString(), arguments);
|
||||||
//swap->waitForFinished(120000);
|
//swap->waitForFinished(120000);
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,7 +227,6 @@ AtomicWidget::~AtomicWidget() {
|
||||||
delete o_model;
|
delete o_model;
|
||||||
delete offerList;
|
delete offerList;
|
||||||
clean();
|
clean();
|
||||||
delete m_instance;
|
|
||||||
delete procList;
|
delete procList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +234,7 @@ void AtomicWidget::clean() {
|
||||||
for (const auto& proc : *procList){
|
for (const auto& proc : *procList){
|
||||||
proc->kill();
|
proc->kill();
|
||||||
}
|
}
|
||||||
if(QString::compare("WINDOWS",m_instance->get(Config::operatingSystem).toString()) != 0) {
|
if(QString::compare("WINDOWS",conf()->get(Config::operatingSystem).toString()) != 0) {
|
||||||
qDebug() << "Closing monero-wallet-rpc";
|
qDebug() << "Closing monero-wallet-rpc";
|
||||||
(new QProcess)->start("kill", QStringList{"-f", Config::defaultConfigDir().absolutePath() +
|
(new QProcess)->start("kill", QStringList{"-f", Config::defaultConfigDir().absolutePath() +
|
||||||
"/mainnet/monero/monero-wallet-rpc"});
|
"/mainnet/monero/monero-wallet-rpc"});
|
||||||
|
|
|
@ -38,8 +38,6 @@ private slots:
|
||||||
void runSwap(const QString& seller, const QString& btcChange, const QString& xmrReceive);
|
void runSwap(const QString& seller, const QString& btcChange, const QString& xmrReceive);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateStatus();
|
|
||||||
|
|
||||||
QScopedPointer<Ui::AtomicWidget> ui;
|
QScopedPointer<Ui::AtomicWidget> ui;
|
||||||
bool m_comboBoxInit = false;
|
bool m_comboBoxInit = false;
|
||||||
QTimer m_statusTimer;
|
QTimer m_statusTimer;
|
||||||
|
@ -48,10 +46,8 @@ private:
|
||||||
AtomicSwap *swapDialog;
|
AtomicSwap *swapDialog;
|
||||||
AtomicFundDialog *fundDialog;
|
AtomicFundDialog *fundDialog;
|
||||||
AtomicRecoverDialog *recoverDialog;
|
AtomicRecoverDialog *recoverDialog;
|
||||||
void showAtomicSwapDialog();
|
|
||||||
|
|
||||||
QList<QSharedPointer<QProcess>> *procList;
|
QList<QSharedPointer<QProcess>> *procList;
|
||||||
Config *m_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FEATHER_ATOMICWIDGET_H
|
#endif // FEATHER_ATOMICWIDGET_H
|
||||||
|
|
Loading…
Reference in a new issue