Files
thehub/wallet-backup-server/main.cpp
T

82 lines
2.8 KiB
C++
Raw Permalink Normal View History

2025-10-02 22:35:41 +02:00
/*
* This file is part of the Flowee project
* Copyright (C) 2019-2025 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BackupWebServer.h"
#include <QStandardPaths>
#include <FloweeServiceApplication.h>
#include <primitives/PrivateKey.h> // for ECC_Start()
namespace {
struct ECC_State
{
ECC_State() {
// Init crypto lib.
ECC_Start();
globalVerifyHandle.reset(new ECCVerifyHandle());
}
~ECC_State() {
globalVerifyHandle.reset();
ECC_Stop();
}
std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
};
}
int main(int argc, char **argv)
{
FloweeServiceApplication app(argc, argv);
app.setOrganizationName("flowee");
app.setOrganizationDomain("flowee.org");
app.setApplicationName("wallet-backup-server");
QCommandLineParser parser;
parser.setApplicationDescription("Wallet Backup Server");
parser.addHelpOption();
QCommandLineOption conf(QStringList() << "conf", "config file", "FILENAME");
parser.addOption(conf);
app.addServerOptions(parser);
parser.process(app.arguments());
app.setup("walletBackup.log", parser.value(conf));
QString confFile;
if (parser.isSet(conf)) {
confFile = parser.value(conf);
} else {
// the next one expects [configs]/flowee/bitcore-proxy/bitcore-proxy.conf
confFile = QStandardPaths::locate(QStandardPaths::AppConfigLocation, "walletBackup.conf");
if (confFile.isEmpty()) // the next one expects [configs]/flowee/bitcore-proxy.conf
confFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, "flowee/walletBackup.conf");
if (confFile.isEmpty()) {
logCritical() << "No config file (walletBackup.conf) found, assuming defaults";
for (auto &dir : QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation)) {
logInfo() << " - not found in" << dir + '/';
}
}
}
BackupWebServer server;
server.loadConfig(confFile);
ECC_State crypo_state; // allows the secp256k1 to function.
QObject::connect (&app, SIGNAL(reparseConfig()), &server, SLOT(reparseConfig()));
return app.exec();
}