Wallet-Core Integration
Overview Wallet-Core is vendored under external/wallet-core and built as part of the main CMake build. The engine exposes a minimal Fennel module for HD wallets and address derivation.
Wallet UI Integration
- Wallet state is managed in Fennel by
WalletManager, with the active wallet stored underapp.wallet.active. - Wallet metadata and the active wallet pointer live under
appdirs.user-data-dirinspace/wallets/. - JSON writes use
json-utils.write-json!for atomic updates to avoid corrupting files when the app exits mid-write. - Wallet balances are fetched via JSON-RPC using
wallet-rpc(default:https://nova.arbitrum.io/rpc).
Bindings
- Module:
wallet-core - Factory:
wallet-core.HDWallet({:mnemonic <string> :passphrase <string?>}) - Functions:
wallet-core.mnemonic-valid(<string>) -> boolean
HDWalletmethods::mnemonic() -> string:address-for-coin(<coin-type>) -> string:drop():is-closed() -> boolean
- Coin constants:
wallet-core.coin-types.bitcoinwallet-core.coin-types.ethereumwallet-core.coin-types.arbitrumwallet-core.coin-types.arbitrumnovawallet-core.coin-types.solana
Build Notes
- Wallet-Core is compiled via
add_subdirectory(external/wallet-core)and linked intospace_lib. - The Rust FFI static archive
libwallet_core_rs.ais expected underexternal/wallet-core/rust/target/release/. - Registry-driven sources are generated and tracked in-tree:
external/wallet-core/src/Generated/CoinInfoData.cppexternal/wallet-core/include/TrustWalletCore/TWHRP.hexternal/wallet-core/src/TWHRP.cpp
Tests
- Fennel tests live in
assets/lua/tests/test-wallet-core.fnland are registered inassets/lua/tests/fast.fnl. - Run the suite with:
SKIP_KEYRING_TESTS=1 XDG_DATA_HOME=/tmp/space/tests/xdg-data SPACE_DISABLE_AUDIO=1 SPACE_ASSETS_PATH=$(pwd)/assets make test
Status Implemented:
- Vendored wallet-core library builds with the main project.
- Fennel
wallet-coremodule with HD wallet creation, mnemonic validation, and address derivation. - Bitcoin address derivation test coverage.
Missing / TODO:
- Expand coin type coverage (more constants, or a lookup API).
- Expose additional wallet-core features (private keys, public keys, signing, address validation).
- Add Fennel bindings for more data types (e.g.,
TWPrivateKey,TWAnyAddress,TWPublicKey). - Surface wallet-core errors with richer error types or messages in Fennel.
Build Issues Encountered
- Clang recommendation warning: downgraded to a status message in
external/wallet-core/CMakeLists.txt. - Rust archive path mismatch: wallet-core expected
libwallet_core_rs.aunder the top-levelrust/target, but the vendored path isexternal/wallet-core/rust/target. Fixed by usingCMAKE_CURRENT_SOURCE_DIRinexternal/wallet-core/CMakeLists.txt. - Missing coin registry sources:
CoinInfoData.cppand HRP files are generated by Ruby tooling. Ruby was unavailable, so these were generated via a Python helper and committed in:external/wallet-core/src/Generated/CoinInfoData.cppexternal/wallet-core/include/TrustWalletCore/TWHRP.hexternal/wallet-core/src/TWHRP.cpp
- HRP enum mismatch for eCash: the generated enum uses
TWHRPeCash(lowercase e), so the generator was adjusted to match the naming convention in the registry templates. _Nonnullnot defined in C++ builds: some internal headers use_Nonnullwithout Clang. Added definitions inexternal/wallet-core/src/Data.hso C++ builds with GCC succeed.
Roadmap
- Add a stable, versioned Fennel API surface for wallet-core (expand coin types, normalize addresses, and expose signing workflows).
- Expose additional wallet-core types through Fennel (private/public keys, AnyAddress, protobuf transaction builders).
- Provide a small Fennel helper layer for coin metadata (symbol, decimals, chain id).
- Decide whether to keep generated registry artifacts in-repo or add a scripted build step (with a Ruby/Python fallback).
