feather/src/utils/daemonrpc.h

51 lines
1.3 KiB
C
Raw Normal View History

2020-10-16 03:05:05 +00:00
// SPDX-License-Identifier: BSD-3-Clause
2023-01-02 19:30:11 +00:00
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
2020-10-16 03:05:05 +00:00
#ifndef FEATHER_DAEMON_RPC_H
#define FEATHER_DAEMON_RPC_H
#include <QObject>
#include "utils/Networking.h"
2020-10-16 03:05:05 +00:00
class DaemonRpc : public QObject {
Q_OBJECT
public:
enum Endpoint {
2020-11-10 11:38:37 +00:00
SEND_RAW_TRANSACTION = 0,
GET_TRANSACTIONS
2020-10-16 03:05:05 +00:00
};
struct DaemonResponse {
explicit DaemonResponse(bool ok, Endpoint endpoint, QString status, QJsonObject obj = {})
: ok(ok), endpoint(endpoint), status(std::move(status)), obj(std::move(obj)) {};
bool ok;
DaemonRpc::Endpoint endpoint;
QString status;
QJsonObject obj;
};
2023-02-11 17:11:21 +00:00
explicit DaemonRpc(QObject *parent, QString daemonAddress);
2020-10-16 03:05:05 +00:00
void sendRawTransaction(const QString &tx_as_hex, bool do_not_relay = false, bool do_sanity_checks = true);
2020-11-10 11:38:37 +00:00
void getTransactions(const QStringList &txs_hashes, bool decode_as_json = false, bool prune = false);
2020-10-16 03:05:05 +00:00
void setDaemonAddress(const QString &daemonAddress);
signals:
void ApiResponse(DaemonResponse resp);
private slots:
void onResponse(QNetworkReply *reply, Endpoint endpoint);
QString onSendRawTransactionFailed(const QJsonObject &obj);
private:
Networking *m_network;
2020-10-16 03:05:05 +00:00
QString m_daemonAddress;
};
#endif //FEATHER_DAEMON_RPC_H