2026-01-30 19:21:23 +01:00
|
|
|
#pragma once
|
2026-02-20 13:56:29 +01:00
|
|
|
|
2026-06-05 11:26:27 -04:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2026-02-20 13:56:29 +01:00
|
|
|
|
2026-06-12 17:04:44 +02:00
|
|
|
#include <logos_module_context.h>
|
2026-06-18 15:31:34 +00:00
|
|
|
#include <logos_result.h>
|
2026-06-12 17:04:44 +02:00
|
|
|
|
2026-02-16 23:14:26 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
#include <logos_blockchain.h>
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2026-01-30 19:21:23 +01:00
|
|
|
|
2026-06-12 17:04:44 +02:00
|
|
|
class LogosBlockchainModule : public LogosModuleContext {
|
2026-01-30 19:21:23 +01:00
|
|
|
public:
|
|
|
|
|
LogosBlockchainModule();
|
2026-06-18 15:31:34 +00:00
|
|
|
~LogosBlockchainModule() override;
|
2026-01-30 19:21:23 +01:00
|
|
|
|
2026-04-17 16:26:47 +02:00
|
|
|
// ---- Node ----
|
|
|
|
|
|
|
|
|
|
// Lifecycle
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult start(const std::string& config_path, const std::string& deployment);
|
|
|
|
|
[[nodiscard]] StdLogosResult stop();
|
2026-04-17 16:26:47 +02:00
|
|
|
|
2026-06-15 13:17:25 +02:00
|
|
|
// Config management
|
2026-06-25 09:04:34 +02:00
|
|
|
// Not static: when the JSON args set "use_persistence_paths": true it routes
|
|
|
|
|
// the node's output/state/storage/logs paths under instancePersistencePath()
|
|
|
|
|
// (config at <base>/<relative output>; state/db/logs at <base>/state, /db,
|
|
|
|
|
// /logs), so it needs the instance context. Basecamp opts in via that flag;
|
|
|
|
|
// logoscore-cli/standalone omit it and keep their own paths. An explicit
|
|
|
|
|
// state/storage/logs path always wins; output is always re-anchored under the
|
|
|
|
|
// base when flagged. On success the result value is the path the config was
|
|
|
|
|
// written to — pass it straight to start().
|
2026-06-26 20:59:13 +00:00
|
|
|
[[nodiscard]] StdLogosResult generate_user_config(const std::string& json_args) const;
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] static StdLogosResult update_user_config(
|
|
|
|
|
const std::string& user_config_path,
|
|
|
|
|
const std::string& keystore_path
|
|
|
|
|
);
|
|
|
|
|
[[nodiscard]] static StdLogosResult migrate_user_config(
|
|
|
|
|
const std::string& output_path,
|
|
|
|
|
const std::string& keystore_path
|
|
|
|
|
);
|
|
|
|
|
[[nodiscard]] static StdLogosResult migrate_user_config_0_1_2(
|
2026-06-15 13:17:25 +02:00
|
|
|
const std::string& new_config_path,
|
|
|
|
|
const std::string& old_config_path,
|
|
|
|
|
const std::string& keystore_path
|
|
|
|
|
);
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] static StdLogosResult participate(
|
2026-06-15 13:17:25 +02:00
|
|
|
const std::string& config_path,
|
|
|
|
|
const std::string& keystore_path,
|
|
|
|
|
const std::string& output_dir,
|
|
|
|
|
const std::string& external_address
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Keystore
|
|
|
|
|
// key_type is "ed25519" or "zk". key_title may be empty (auto-generated).
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] static StdLogosResult generate_key(
|
2026-06-15 13:17:25 +02:00
|
|
|
const std::string& user_config_path,
|
|
|
|
|
const std::string& keystore_path,
|
|
|
|
|
const std::string& key_type,
|
|
|
|
|
const std::string& key_title
|
|
|
|
|
);
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] static StdLogosResult add_key(
|
2026-06-15 13:17:25 +02:00
|
|
|
const std::string& user_config_path,
|
|
|
|
|
const std::string& keystore_path,
|
|
|
|
|
const std::string& key_type,
|
|
|
|
|
const std::string& key_hex,
|
|
|
|
|
const std::string& key_title
|
|
|
|
|
);
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] static StdLogosResult remove_key(
|
2026-06-15 13:17:25 +02:00
|
|
|
const std::string& user_config_path,
|
|
|
|
|
const std::string& keystore_path,
|
|
|
|
|
const std::string& key_title
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Identity
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] static StdLogosResult get_peer_id(const std::string& config_path);
|
2026-06-15 13:17:25 +02:00
|
|
|
|
2026-04-17 16:26:47 +02:00
|
|
|
// Wallet
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult wallet_get_balance(const std::string& address_hex) const;
|
|
|
|
|
[[nodiscard]] StdLogosResult wallet_transfer_funds(
|
2026-06-05 11:26:27 -04:00
|
|
|
const std::string& change_public_key,
|
|
|
|
|
const std::vector<std::string>& sender_addresses,
|
|
|
|
|
const std::string& recipient_address,
|
|
|
|
|
const std::string& amount,
|
|
|
|
|
const std::string& optional_tip_hex
|
2026-06-18 15:31:34 +00:00
|
|
|
) const;
|
|
|
|
|
[[nodiscard]] StdLogosResult wallet_get_known_addresses() const;
|
2026-06-18 15:43:54 +02:00
|
|
|
// Spendable notes (UTXOs) of a wallet address, as a JSON string:
|
|
|
|
|
// { "tip": "<hex>", "notes": [ { "id": "<hex>", "value": "<u64>" }, ... ] }
|
|
|
|
|
// optional_tip_hex may be empty to query at the current tip. Note IDs round-trip
|
|
|
|
|
// into channel_deposit_with_notes.
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult wallet_get_notes(
|
2026-06-18 15:43:54 +02:00
|
|
|
const std::string& wallet_address_hex,
|
|
|
|
|
const std::string& optional_tip_hex
|
2026-06-18 15:31:34 +00:00
|
|
|
) const;
|
|
|
|
|
[[nodiscard]] StdLogosResult leader_claim() const;
|
|
|
|
|
[[nodiscard]] StdLogosResult wallet_get_claimable_vouchers() const;
|
2026-04-17 16:26:47 +02:00
|
|
|
|
2026-06-18 15:43:54 +02:00
|
|
|
// Channel
|
|
|
|
|
// Amount-based deposit: the binding selects funding notes itself (splitting a
|
|
|
|
|
// note via a transfer when no exact-value note exists) so the channel receives
|
|
|
|
|
// exactly `amount`. funding_public_key owns the funding notes, the deposit note
|
|
|
|
|
// and any change. metadata_hex may be empty; optional_tip_hex may be empty to
|
|
|
|
|
// build against the current tip. Returns the transaction hash hex on success.
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult channel_deposit(
|
2026-06-18 15:43:54 +02:00
|
|
|
const std::string& channel_id_hex,
|
|
|
|
|
const std::string& funding_public_key_hex,
|
|
|
|
|
const std::string& amount,
|
|
|
|
|
const std::string& metadata_hex,
|
|
|
|
|
const std::string& optional_tip_hex
|
2026-06-18 15:31:34 +00:00
|
|
|
) const;
|
2026-06-18 15:43:54 +02:00
|
|
|
// Note-based deposit: the caller supplies the exact notes to consume (their
|
|
|
|
|
// whole value enters the channel), so amount = sum of the notes' values. Use
|
|
|
|
|
// wallet_get_notes to obtain note IDs. The gas fee is funded from
|
|
|
|
|
// funding_public_keys (change to change_public_key), capped at max_tx_fee.
|
|
|
|
|
// metadata_hex / optional_tip_hex may be empty. Returns the tx hash hex.
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult channel_deposit_with_notes(
|
2026-06-18 15:43:54 +02:00
|
|
|
const std::string& channel_id_hex,
|
|
|
|
|
const std::vector<std::string>& input_note_id_hexes,
|
|
|
|
|
const std::string& metadata_hex,
|
|
|
|
|
const std::string& change_public_key_hex,
|
|
|
|
|
const std::vector<std::string>& funding_public_key_hexes,
|
|
|
|
|
const std::string& max_tx_fee,
|
|
|
|
|
const std::string& optional_tip_hex
|
2026-06-18 15:31:34 +00:00
|
|
|
) const;
|
2026-06-18 15:43:54 +02:00
|
|
|
|
2026-04-17 16:26:47 +02:00
|
|
|
// Blend
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult blend_join_as_core_node(
|
2026-06-05 11:26:27 -04:00
|
|
|
const std::string& provider_id_hex,
|
|
|
|
|
const std::string& zk_id_hex,
|
|
|
|
|
const std::string& locked_note_id_hex,
|
|
|
|
|
const std::vector<std::string>& locators
|
2026-06-18 15:31:34 +00:00
|
|
|
) const;
|
2026-01-30 19:21:23 +01:00
|
|
|
|
2026-04-17 16:08:25 +02:00
|
|
|
// Explorer
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult get_block(const std::string& header_id_hex) const;
|
|
|
|
|
[[nodiscard]] StdLogosResult get_blocks(uint64_t from_slot, uint64_t to_slot) const;
|
|
|
|
|
[[nodiscard]] StdLogosResult get_transaction(const std::string& tx_hash_hex) const;
|
2026-04-17 16:26:47 +02:00
|
|
|
|
|
|
|
|
// Cryptarchia
|
2026-06-18 15:31:34 +00:00
|
|
|
[[nodiscard]] StdLogosResult get_cryptarchia_info() const;
|
2026-02-02 17:28:11 +01:00
|
|
|
|
2026-06-18 15:31:34 +00:00
|
|
|
// clang-format off
|
|
|
|
|
// Clang-format only handles public/private/protected, so it miss-indents this section.
|
|
|
|
|
// Guard kept until https://github.com/llvm/llvm-project/issues/64763 lands.
|
2026-06-12 17:04:44 +02:00
|
|
|
logos_events:
|
|
|
|
|
// Fired by on_new_block_callback when the Rust node delivers a new block.
|
|
|
|
|
// blockJson is the full block serialized as JSON.
|
2026-06-18 15:31:34 +00:00
|
|
|
// ReSharper disable once CppFunctionIsNotImplemented
|
2026-06-12 17:04:44 +02:00
|
|
|
void newBlock(const std::string& blockJson);
|
2026-06-18 15:31:34 +00:00
|
|
|
// clang-format on
|
2026-06-12 17:04:44 +02:00
|
|
|
|
2026-01-30 19:21:23 +01:00
|
|
|
private:
|
|
|
|
|
LogosBlockchainNode* node = nullptr;
|
2026-02-12 15:25:56 +05:30
|
|
|
|
|
|
|
|
// Static instance for C callback (C API doesn't support user data)
|
|
|
|
|
static LogosBlockchainModule* s_instance;
|
|
|
|
|
|
|
|
|
|
// C-compatible callback function
|
2026-04-17 16:26:47 +02:00
|
|
|
static void on_new_block_callback(const char* block);
|
2026-01-30 19:21:23 +01:00
|
|
|
};
|