mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-23 20:19:31 +00:00
Swap tool auto downloader working.
// TODO Later Add in Browse button Add ui reflection of download progess/occuring
This commit is contained in:
parent
da70287dee
commit
435a75d453
7 changed files with 162 additions and 3 deletions
|
@ -19,7 +19,7 @@ set(COPYRIGHT_HOLDERS "The Monero Project")
|
||||||
option(STATIC "Link libraries statically, requires static Qt" OFF)
|
option(STATIC "Link libraries statically, requires static Qt" OFF)
|
||||||
option(SELF_CONTAINED "Disable when building Feather for packages" OFF)
|
option(SELF_CONTAINED "Disable when building Feather for packages" OFF)
|
||||||
option(TOR_DIR "Directory containing Tor binaries to embed inside Feather" OFF)
|
option(TOR_DIR "Directory containing Tor binaries to embed inside Feather" OFF)
|
||||||
option(CHECK_UPDATES "Enable checking for application updates" OFF)
|
option(CHECK_UPDATES "Enable checking for application updates" ON)
|
||||||
option(PLATFORM_INSTALLER "Built-in updater fetches installer (windows-only)" OFF)
|
option(PLATFORM_INSTALLER "Built-in updater fetches installer (windows-only)" OFF)
|
||||||
option(USE_DEVICE_TREZOR "Trezor support compilation" ON)
|
option(USE_DEVICE_TREZOR "Trezor support compilation" ON)
|
||||||
option(DONATE_BEG "Prompt donation window every once in a while" OFF)
|
option(DONATE_BEG "Prompt donation window every once in a while" OFF)
|
||||||
|
@ -119,6 +119,7 @@ endif()
|
||||||
# libzip
|
# libzip
|
||||||
if(CHECK_UPDATES)
|
if(CHECK_UPDATES)
|
||||||
set(ZLIB_USE_STATIC_LIBS "ON")
|
set(ZLIB_USE_STATIC_LIBS "ON")
|
||||||
|
message("libzip inclueded")
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_path(LIBZIP_INCLUDE_DIRS zip.h)
|
find_path(LIBZIP_INCLUDE_DIRS zip.h)
|
||||||
find_library(LIBZIP_LIBRARIES zip)
|
find_library(LIBZIP_LIBRARIES zip)
|
||||||
|
|
|
@ -23,6 +23,8 @@ find_package(Qt6 REQUIRED COMPONENTS ${QT_COMPONENTS})
|
||||||
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
|
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
|
||||||
add_subdirectory(third-party/singleapplication)
|
add_subdirectory(third-party/singleapplication)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (CHECK_UPDATES)
|
if (CHECK_UPDATES)
|
||||||
add_subdirectory(openpgp)
|
add_subdirectory(openpgp)
|
||||||
endif()
|
endif()
|
||||||
|
@ -299,6 +301,12 @@ if (WITH_SCANNER)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
FIND_PACKAGE(LibArchive REQUIRED)
|
||||||
|
INCLUDE_DIRECTORIES(${LibArchive_INCLUDE_DIR})
|
||||||
|
target_link_libraries(feather PRIVATE ${LibArchive_LIBRARIES})
|
||||||
|
|
||||||
|
|
||||||
if(STATIC AND APPLE)
|
if(STATIC AND APPLE)
|
||||||
target_link_libraries(feather PRIVATE Qt6::QDarwinCameraPermissionPlugin)
|
target_link_libraries(feather PRIVATE Qt6::QDarwinCameraPermissionPlugin)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -4,6 +4,14 @@
|
||||||
#include "AtomicConfigDialog.h"
|
#include "AtomicConfigDialog.h"
|
||||||
#include "ui_AtomicConfigDialog.h"
|
#include "ui_AtomicConfigDialog.h"
|
||||||
|
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QDir>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <archive.h>
|
||||||
|
#include <zip.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <archive_entry.h>
|
||||||
|
|
||||||
#include "utils/AppData.h"
|
#include "utils/AppData.h"
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#include "utils/Networking.h"
|
#include "utils/Networking.h"
|
||||||
|
@ -76,9 +84,127 @@ void AtomicConfigDialog::fillListWidgets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomicConfigDialog::downloadBinary() {
|
void AtomicConfigDialog::downloadBinary() {
|
||||||
|
auto* network = new Networking(this);
|
||||||
|
download = new QTemporaryFile(this);
|
||||||
|
download->open();
|
||||||
|
tempFile = download->fileName();
|
||||||
|
QString url;
|
||||||
|
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/download/0.12.3/swap_0.12.3_Windows_x86_64.zip");
|
||||||
|
} else if (strcmp("LINUX",operatingSystem.c_str())==0){
|
||||||
|
url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.12.3/swap_0.12.3_Linux_x86_64.tar");
|
||||||
|
} else {
|
||||||
|
url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.12.3/swap_0.12.3_Darwin_x86_64.tar");
|
||||||
|
}
|
||||||
|
archive = network->get(this, url);
|
||||||
|
QStringList answer;
|
||||||
|
connect(archive,&QNetworkReply::readyRead, this, [&]{
|
||||||
|
QByteArray data= archive->readAll();
|
||||||
|
qDebug() << "received data of size: " << data.size();
|
||||||
|
download->write(data.constData(), data.size());
|
||||||
|
});
|
||||||
|
connect(archive, &QNetworkReply::finished,
|
||||||
|
this,&AtomicConfigDialog::extract);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void AtomicConfigDialog::extract() {
|
||||||
|
|
||||||
|
|
||||||
|
qDebug() << "extracting";
|
||||||
|
download->close();
|
||||||
|
archive->deleteLater();
|
||||||
|
|
||||||
|
auto swapPath = Config::defaultConfigDir().absolutePath();
|
||||||
|
swapPath.append("/swapTool");
|
||||||
|
QFile binaryFile(swapPath);
|
||||||
|
binaryFile.open(QIODevice::WriteOnly);
|
||||||
|
auto operatingSystem = Config::instance()->get(Config::operatingSystem).toString().toStdString();
|
||||||
|
if(strcmp("WIN",operatingSystem.c_str()) == 0) {
|
||||||
|
// UNZIP
|
||||||
|
zip *z = zip_open(tempFile.toStdString().c_str(), 0, 0);
|
||||||
|
|
||||||
|
//Search for the file of given name
|
||||||
|
const char *name = "swap.exe";
|
||||||
|
struct zip_stat st;
|
||||||
|
zip_stat_init(&st);
|
||||||
|
zip_stat(z, name, 0, &st);
|
||||||
|
int total = st.size;
|
||||||
|
int wrote = 0;
|
||||||
|
//Alloc memory for its uncompressed contents
|
||||||
|
char *contents = new char[BUFSIZ];
|
||||||
|
zip_file *f = zip_fopen(z, name, 0);
|
||||||
|
while (wrote < total) {
|
||||||
|
//Read the compressed file
|
||||||
|
zip_fread(f, contents, BUFSIZ);
|
||||||
|
binaryFile.write(contents);
|
||||||
|
wrote += BUFSIZ;
|
||||||
|
}
|
||||||
|
zip_fclose(f);
|
||||||
|
//And close the archive
|
||||||
|
zip_close(z);
|
||||||
|
Config::instance()->set(Config::swapPath,swapPath);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
struct archive *a;
|
||||||
|
struct archive *ext;
|
||||||
|
struct archive_entry *entry;
|
||||||
|
int r;
|
||||||
|
std::string savePath;
|
||||||
|
a = archive_read_new();
|
||||||
|
ext = archive_write_disk_new();
|
||||||
|
archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_PERM);
|
||||||
|
|
||||||
|
archive_read_support_format_tar(a);
|
||||||
|
r = archive_read_open_filename(a, tempFile.toStdString().c_str(), 10240);
|
||||||
|
for (;;) {
|
||||||
|
r = archive_read_next_header(a, &entry);
|
||||||
|
if (r == ARCHIVE_EOF)
|
||||||
|
break;
|
||||||
|
savePath = Config::defaultConfigDir().absolutePath().toStdString().append("/").append(archive_entry_pathname(entry));
|
||||||
|
qDebug() << savePath;
|
||||||
|
archive_entry_set_pathname(entry, savePath.c_str());
|
||||||
|
r = archive_write_header(ext, entry);
|
||||||
|
copy_data(a, ext);
|
||||||
|
r = archive_write_finish_entry(ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
archive_read_close(a);
|
||||||
|
archive_read_free(a);
|
||||||
|
|
||||||
|
archive_write_close(ext);
|
||||||
|
archive_write_free(ext);
|
||||||
|
Config::instance()->set(Config::swapPath, QString(savePath.c_str()));
|
||||||
|
}
|
||||||
|
qDebug() << "Finished";
|
||||||
|
binaryFile.close();
|
||||||
|
|
||||||
|
};
|
||||||
|
int
|
||||||
|
AtomicConfigDialog::copy_data(struct archive *ar, struct archive *aw)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
const void *buff;
|
||||||
|
size_t size;
|
||||||
|
#if ARCHIVE_VERSION_NUMBER >= 3000000
|
||||||
|
int64_t offset;
|
||||||
|
#else
|
||||||
|
off_t offset;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
r = archive_read_data_block(ar, &buff, &size, &offset);
|
||||||
|
if (r == ARCHIVE_EOF)
|
||||||
|
return (ARCHIVE_OK);
|
||||||
|
if (r != ARCHIVE_OK)
|
||||||
|
return (r);
|
||||||
|
r = archive_write_data_block(aw, buff, size, offset);
|
||||||
|
if (r != ARCHIVE_OK) {
|
||||||
|
return (r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void AtomicConfigDialog::selectBinary() {
|
void AtomicConfigDialog::selectBinary() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
|
#include <archive.h>
|
||||||
#include "components.h"
|
#include "components.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -21,6 +24,8 @@ public:
|
||||||
explicit AtomicConfigDialog(QWidget *parent = nullptr);
|
explicit AtomicConfigDialog(QWidget *parent = nullptr);
|
||||||
~AtomicConfigDialog() override;
|
~AtomicConfigDialog() override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void extract();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setCheckState(QListWidget *widget, Qt::CheckState checkState);
|
void setCheckState(QListWidget *widget, Qt::CheckState checkState);
|
||||||
|
@ -28,8 +33,15 @@ private:
|
||||||
void fillListWidgets();
|
void fillListWidgets();
|
||||||
void downloadBinary();
|
void downloadBinary();
|
||||||
void selectBinary();
|
void selectBinary();
|
||||||
|
int copy_data(struct archive *ar, struct archive *aw);
|
||||||
|
|
||||||
QScopedPointer<Ui::AtomicConfigDialog> ui;
|
QScopedPointer<Ui::AtomicConfigDialog> ui;
|
||||||
|
|
||||||
|
QNetworkReply* archive;
|
||||||
|
QString tempFile;
|
||||||
|
QTemporaryFile* download;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ Built in xmr-btc atomic swap
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
## Hacking
|
||||||
|
sudo apt install
|
||||||
|
Install KArchive
|
||||||
## Usage
|
## Usage
|
||||||
Navigate to the Atomic tab after opening your wallet. Click the configure button.
|
Navigate to the Atomic tab after opening your wallet. Click the configure button.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,13 @@
|
||||||
#include "utils/os/tails.h"
|
#include "utils/os/tails.h"
|
||||||
|
|
||||||
#define QS QStringLiteral
|
#define QS QStringLiteral
|
||||||
|
#if defined(Q_OS_WIN64)
|
||||||
|
#define OS "WINDOWS"
|
||||||
|
#elif defined(Q_OS_DARWIN)
|
||||||
|
#define OS "MAC"
|
||||||
|
#else
|
||||||
|
#define OS "LINUX"
|
||||||
|
#endif
|
||||||
struct ConfigDirective
|
struct ConfigDirective
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -142,6 +148,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||||
"/dnsaddr/swapanarchy.cfd/p2p/12D3KooWMgGjeW7ErQxCQzaeHiXxJn42wegCPFepixEXfBJT1PNS",
|
"/dnsaddr/swapanarchy.cfd/p2p/12D3KooWMgGjeW7ErQxCQzaeHiXxJn42wegCPFepixEXfBJT1PNS",
|
||||||
"/onion3/spqfqxirmlrhq7gbiwn4jn35c77gu2kof26i6psoc6bbyduol3zty6qd:9841/p2p/12D3KooWM9ipr33nEtxyCBF7fdbHsMrRzHaSf1bEVYzV8XSBSMet"}}},
|
"/onion3/spqfqxirmlrhq7gbiwn4jn35c77gu2kof26i6psoc6bbyduol3zty6qd:9841/p2p/12D3KooWM9ipr33nEtxyCBF7fdbHsMrRzHaSf1bEVYzV8XSBSMet"}}},
|
||||||
{Config::swapPath, {QS("swapPath"), ""}},
|
{Config::swapPath, {QS("swapPath"), ""}},
|
||||||
|
{Config::operatingSystem, {QS("operatingSystem"), OS}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
class Config : public QObject
|
class Config : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -152,6 +153,7 @@ public:
|
||||||
// Atomic Settings
|
// Atomic Settings
|
||||||
rendezVous,
|
rendezVous,
|
||||||
swapPath,
|
swapPath,
|
||||||
|
operatingSystem,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PrivacyLevel {
|
enum PrivacyLevel {
|
||||||
|
|
Loading…
Reference in a new issue