2024-10-03 14:29:05 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
|
|
|
|
* Copyright (C) 2024 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/>.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef TRANSACTIONSFETCHER_H
|
|
|
|
|
#define TRANSACTIONSFETCHER_H
|
|
|
|
|
|
|
|
|
|
#include <ElectronXClient.h>
|
|
|
|
|
#include <uint256.h>
|
|
|
|
|
#include <streaming/ConstBuffer.h>
|
|
|
|
|
|
|
|
|
|
class TransactionsFetcher : public ElectronXClient
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit TransactionsFetcher(QObject *parent = nullptr);
|
|
|
|
|
|
2024-10-03 17:55:26 +02:00
|
|
|
struct Output {
|
|
|
|
|
QString txid;
|
|
|
|
|
int outIndex = -1;
|
|
|
|
|
QString filename;
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-03 14:29:05 +02:00
|
|
|
void start(const Streaming::ConstBuffer &scripthash);
|
|
|
|
|
|
2024-10-06 14:07:33 +02:00
|
|
|
int numTokensFound() const {
|
|
|
|
|
return m_tokensFound;
|
|
|
|
|
}
|
|
|
|
|
int numOutputsFound() const {
|
|
|
|
|
return m_coinsFound;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-03 14:29:05 +02:00
|
|
|
signals:
|
2024-10-06 14:07:33 +02:00
|
|
|
void searchComplete(); // the numCoins/numTokens have been determined
|
2024-10-03 17:55:26 +02:00
|
|
|
void finished(const QList<TransactionsFetcher::Output> &result);
|
2024-10-14 19:55:53 +02:00
|
|
|
void fetched(int utxoCount);
|
2024-10-03 14:29:05 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void handshakeCompleted() override;
|
|
|
|
|
void handleResponse(int id, const QJsonObject &data) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void checkAllAvailable();
|
|
|
|
|
Streaming::ConstBuffer m_scriptHash;
|
|
|
|
|
|
|
|
|
|
int m_coinsFound = 0;
|
|
|
|
|
int m_tokensFound = 0;
|
2024-10-14 19:55:53 +02:00
|
|
|
int m_utxosDownloaded = 0;
|
2024-10-03 14:29:05 +02:00
|
|
|
int64_t m_balance = 0;
|
|
|
|
|
|
|
|
|
|
QList<Output> m_outputs;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|