Files
pay/src/ImportHandler.h
T

86 lines
2.3 KiB
C++
Raw Permalink Normal View History

2024-04-23 12:58:01 +02:00
/*
* This file is part of the Flowee project
2025-02-03 17:41:47 +01:00
* Copyright (C) 2024-2025 Tom Zander <tom@flowee.org>
2024-04-23 12:58:01 +02:00
*
* 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/>.
*/
2024-04-23 12:55:51 +02:00
#ifndef IMPORTHANDLER_H
#define IMPORTHANDLER_H
#include "ElectronXClient.h"
2024-04-23 12:55:51 +02:00
class ImportHandler : public ElectronXClient
2024-04-23 12:55:51 +02:00
{
Q_OBJECT
public:
explicit ImportHandler(QObject *parent = nullptr);
enum WalletType {
FromSeed,
FromPrivateKey,
FromXPub,
FromXPriv
};
2024-04-23 12:55:51 +02:00
/**
* Find the import details for a verified to be correct type/text.
*
* This method returns instantly and will emit finished() when checking has completed.
*/
void startCheck(WalletType type, const QString &text, const QString &password = QString());
2024-04-23 12:55:51 +02:00
struct ImportData {
std::vector<uint32_t> derivation;
bool electrum = false;
int firstBlockHeight = 0;
};
QList<ImportData> found() const;
2024-04-23 12:55:51 +02:00
signals:
void finished();
2024-04-23 12:55:51 +02:00
protected:
void handshakeCompleted() override;
void handleResponse(int id, const QJsonObject &data) override;
2024-04-23 12:55:51 +02:00
private:
void handleFirstUse(const QJsonObject &rootObject);
void checkNext();
private:
QString m_input;
QString m_password; // seeds may have a password
// what is the Input supposed to re-present?
WalletType m_type;
// for seeds, we need to check multiple options, we iterate through these.
2024-04-23 12:55:51 +02:00
enum NextToCheck {
MainDerivation,
2025-02-03 17:41:47 +01:00
MainDerivationChange,
2024-04-23 12:55:51 +02:00
Derivation145,
2025-02-03 17:41:47 +01:00
Derivation145Change,
2024-04-23 12:55:51 +02:00
MainDerivationElectrumMnemonic,
Derivation145ElectrumMnemonic,
Done
};
NextToCheck m_nextToCheck = MainDerivation;
ImportData m_currentlyChecking;
QList<ImportData> m_found;
};
#endif