From 625866c22e6ad39771c3021c8411d1b2d64a7ee6 Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Fri, 3 Apr 2026 11:53:21 +0200 Subject: [PATCH 1/4] Update logos blockchain reference. --- flake.lock | 15 ++++++++------- flake.nix | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index fe21341..e47fd70 100644 --- a/flake.lock +++ b/flake.lock @@ -23,16 +23,16 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1772549761, - "narHash": "sha256-NRwUEv7Uf/Tge8y4sDZ/par+iM2/ZqxFEINpiyIqUL8=", + "lastModified": 1775209920, + "narHash": "sha256-6OyLQ2jBX+Ce6PamHnvCmd8MEr9hufD/CflQ2+Ose5c=", "owner": "logos-blockchain", "repo": "logos-blockchain", - "rev": "1e0fcb1c4bc92149dfab09c1c08115662d8b2c23", + "rev": "b362c37d8f1a836fa782498ebd78fa4a19f648f9", "type": "github" }, "original": { "owner": "logos-blockchain", - "ref": "0.2.1", + "ref": "feat/c-bindings/blend", "repo": "logos-blockchain", "type": "github" } @@ -1539,16 +1539,17 @@ ] }, "locked": { - "lastModified": 1771556776, - "narHash": "sha256-zKprqMQDl3xVfhSSYvgru1IGXjFdxryWk+KqK0I20Xk=", + "lastModified": 1772775058, + "narHash": "sha256-i+I9RYN8kYb9/9kibkxd0avkkislD1tyWojSVgIy160=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8b3f46b8a6d17ab46e533a5e3d5b1cc2ff228860", + "rev": "629bbb7f9d02787a54e28398b411da849246253b", "type": "github" }, "original": { "owner": "oxalica", "repo": "rust-overlay", + "rev": "629bbb7f9d02787a54e28398b411da849246253b", "type": "github" } } diff --git a/flake.nix b/flake.nix index 556887d..8415a1c 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,7 @@ logos-liblogos.url = "github:logos-co/logos-liblogos"; logos-core.url = "github:logos-co/logos-cpp-sdk"; - logos-blockchain.url = "github:logos-blockchain/logos-blockchain?ref=0.2.1"; + logos-blockchain.url = "github:logos-blockchain/logos-blockchain?ref=feat/c-bindings/blend"; logos-module-viewer.url = "github:logos-co/logos-module-viewer"; }; From 0b23cbe85ffcb82e1e0ca133bbfaecf58d40e5ad Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Fri, 3 Apr 2026 12:17:55 +0200 Subject: [PATCH 2/4] Expose blend_join_as_core_node. --- src/i_logos_blockchain_module.h | 6 ++++ src/logos_blockchain_module.cpp | 56 +++++++++++++++++++++++++++++++++ src/logos_blockchain_module.h | 6 ++++ 3 files changed, 68 insertions(+) diff --git a/src/i_logos_blockchain_module.h b/src/i_logos_blockchain_module.h index 76f078f..74b85e6 100644 --- a/src/i_logos_blockchain_module.h +++ b/src/i_logos_blockchain_module.h @@ -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" diff --git a/src/logos_blockchain_module.cpp b/src/logos_blockchain_module.cpp index 54a0fa8..3f4391a 100644 --- a/src/logos_blockchain_module.cpp +++ b/src/logos_blockchain_module.cpp @@ -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 locatorsData; + std::vector 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(providerIdBytes.constData()), + reinterpret_cast(zkIdBytes.constData()), + reinterpret_cast(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(&value), sizeof(value)); + qInfo() << "Successfully joined as core node. DeclarationId:" << declarationIdBytes.toHex(); + return 0; +} + namespace { // Wrapper that owns data and provides GenerateConfigArgs struct OwnedGenerateConfigArgs { diff --git a/src/logos_blockchain_module.h b/src/logos_blockchain_module.h index cea694e..f38de90 100644 --- a/src/logos_blockchain_module.h +++ b/src/logos_blockchain_module.h @@ -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); From 189f23bef96db27c49a09b522739dfe0da2a27e7 Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Fri, 3 Apr 2026 12:56:14 +0200 Subject: [PATCH 3/4] Add nix + ide integration documentation. --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index edb9259..c758682 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,25 @@ This will reduce friction when working on the project. * Use `nix build` to build the package * Use `nix run` to launch the module-viewer and check your module loads properly * Use `nix develop` to setup your IDE + +### Troubleshooting + +#### Nix + IDE Integration +If your IDE reports that a file doesn't belong to the project or that files cannot be found, the CMake cache +is likely missing the Nix-provided paths. This happens when the IDE runs CMake on its own, outside the Nix +environment, leaving the required paths empty. + +To fix it: + +1. **Regenerate the cache from within the Nix shell** + + This provides the required Nix paths and writes them into `build/CMakeCache.txt`: + ```bash + nix develop -c just configure + ``` + +2. **Reload the CMake project without resetting the cache** + + If on RustRover: Open the CMake tool window (**View → Tool Windows → CMake**) and click the **Reload** button (↺) in the toolbar. + +> Resetting the cache would wipe the paths you just wrote, so make sure to reload only. From 6a6cdb76d1f77e75670277783d3eab14ff9ab000 Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Fri, 3 Apr 2026 13:18:18 +0200 Subject: [PATCH 4/4] Add explanation for locators ownership. --- src/logos_blockchain_module.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/logos_blockchain_module.cpp b/src/logos_blockchain_module.cpp index 3f4391a..c01f651 100644 --- a/src/logos_blockchain_module.cpp +++ b/src/logos_blockchain_module.cpp @@ -290,13 +290,16 @@ int LogosBlockchainModule::blend_join_as_core_node( return 4; } + // QString is UTF-16, but the FFI requires UTF-8. + // locatorsData owns the converted buffers, while locatorsPtrs holds raw pointers into them for the FFI call. + // Using reserve() prevents reallocation, keeping the constData() pointers stable. std::vector locatorsData; std::vector locatorsPtrs; + locatorsData.reserve(locators.size()); + locatorsPtrs.reserve(locators.size()); for (const QString& locator : locators) { locatorsData.push_back(locator.toUtf8()); - } - for (const QByteArray& data : locatorsData) { - locatorsPtrs.push_back(data.constData()); + locatorsPtrs.push_back(locatorsData.back().constData()); } auto [value, error] = ::blend_join_as_core_node(