mirror of
https://github.com/logos-blockchain/logos-blockchain-module.git
synced 2026-04-10 04:33:24 +00:00
Expose blend_join_as_core_node.
This commit is contained in:
parent
625866c22e
commit
0b23cbe85f
@ -25,6 +25,12 @@ public:
|
||||
const QString& optionalTipHex
|
||||
) = 0;
|
||||
virtual QStringList wallet_get_known_addresses() = 0;
|
||||
virtual int blend_join_as_core_node(
|
||||
const QString& providerIdHex,
|
||||
const QString& zkIdHex,
|
||||
const QString& lockedNoteIdHex,
|
||||
const QStringList& locators
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#define ILogosBlockchainModule_iid "org.logos.ilogosblockchainmodule"
|
||||
|
||||
@ -261,6 +261,62 @@ QStringList LogosBlockchainModule::wallet_get_known_addresses() {
|
||||
return out;
|
||||
}
|
||||
|
||||
int LogosBlockchainModule::blend_join_as_core_node(
|
||||
const QString& providerIdHex,
|
||||
const QString& zkIdHex,
|
||||
const QString& lockedNoteIdHex,
|
||||
const QStringList& locators
|
||||
) {
|
||||
if (!node) {
|
||||
qWarning() << "Could not execute the operation: The node is not running.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QByteArray providerIdBytes = parseAddressHex(providerIdHex);
|
||||
if (providerIdBytes.isEmpty() || providerIdBytes.size() != kAddressBytes) {
|
||||
qCritical() << "blend_join_as_core_node: Invalid providerId (64 hex characters required).";
|
||||
return 2;
|
||||
}
|
||||
|
||||
QByteArray zkIdBytes = parseAddressHex(zkIdHex);
|
||||
if (zkIdBytes.isEmpty() || zkIdBytes.size() != kAddressBytes) {
|
||||
qCritical() << "blend_join_as_core_node: Invalid zkId (64 hex characters required).";
|
||||
return 3;
|
||||
}
|
||||
|
||||
QByteArray lockedNoteIdBytes = parseAddressHex(lockedNoteIdHex);
|
||||
if (lockedNoteIdBytes.isEmpty() || lockedNoteIdBytes.size() != kAddressBytes) {
|
||||
qCritical() << "blend_join_as_core_node: Invalid lockedNoteId (64 hex characters required).";
|
||||
return 4;
|
||||
}
|
||||
|
||||
std::vector<QByteArray> locatorsData;
|
||||
std::vector<const char*> locatorsPtrs;
|
||||
for (const QString& locator : locators) {
|
||||
locatorsData.push_back(locator.toUtf8());
|
||||
}
|
||||
for (const QByteArray& data : locatorsData) {
|
||||
locatorsPtrs.push_back(data.constData());
|
||||
}
|
||||
|
||||
auto [value, error] = ::blend_join_as_core_node(
|
||||
node,
|
||||
reinterpret_cast<const uint8_t*>(providerIdBytes.constData()),
|
||||
reinterpret_cast<const uint8_t*>(zkIdBytes.constData()),
|
||||
reinterpret_cast<const uint8_t*>(lockedNoteIdBytes.constData()),
|
||||
locatorsPtrs.data(),
|
||||
locatorsPtrs.size()
|
||||
);
|
||||
if (!is_ok(&error)) {
|
||||
qCritical() << "Failed to join as core node. Error:" << error;
|
||||
return 5;
|
||||
}
|
||||
|
||||
QByteArray declarationIdBytes(reinterpret_cast<const char*>(&value), sizeof(value));
|
||||
qInfo() << "Successfully joined as core node. DeclarationId:" << declarationIdBytes.toHex();
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Wrapper that owns data and provides GenerateConfigArgs
|
||||
struct OwnedGenerateConfigArgs {
|
||||
|
||||
@ -46,6 +46,12 @@ public:
|
||||
const QString& optionalTipHex
|
||||
);
|
||||
Q_INVOKABLE QStringList wallet_get_known_addresses() override;
|
||||
Q_INVOKABLE int blend_join_as_core_node(
|
||||
const QString& providerIdHex,
|
||||
const QString& zkIdHex,
|
||||
const QString& lockedNoteIdHex,
|
||||
const QStringList& locators
|
||||
) override;
|
||||
|
||||
signals:
|
||||
void eventResponse(const QString& eventName, const QVariantList& data);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user