Skip to main content

Crate beekeeper

Crate beekeeper 

Source
Expand description

Rust bindings for the Beekeeper wallet daemon.

This crate exposes the same wallet-management surface as the @hiveio/beekeeper npm package (programs/beekeeper/beekeeper_wasm), but as a native Rust library. The underlying wallet logic and crypto primitives live in the shared C++ core/ library and the FC-backed fc_crypto_bridge, reached through a cxx bridge (ffi::BeekeeperHolder). Storage callbacks are still injected from Rust via RustStorageProtocol.

§Quick start

use beekeeper::prelude::*;

let bk = BeekeeperApi::new(
    BeekeeperOptions::new("./storage_root-rust").unlock_timeout(900),
);
let session = bk.create_session().unwrap();
let mut created = session.create_wallet("my-wallet", "password").unwrap();
let pubkey = created.import_key("5J...wif...").unwrap();
let sig = created.sign_digest(&pubkey, "deadbeef...").unwrap();
// Dropping `session` locks its wallets and closes the session.

§Design notes

The API follows the npm package, but where Rust allows a safer shape than a 1:1 port, the Rust shape wins:

  • Synchronous API. All calls are blocking.
  • Sessions close on Drop. A session::Session is an owned guard that locks its wallets and closes itself when it goes out of scope; there is no explicit close.
  • Lock state lives in the type system. unlock/lock/close consume the wallet handle and return the next state, so stale handles are unrepresentable.
  • Fixed backends. Storage is always the bundled filesystem-backed storage::RustStorageProtocol and crypto is always the FC-backed provider; in-memory mode is selected through BeekeeperOptions::in_memory. The key prefix is hard-coded to wallet::DEFAULT_KEY_PREFIX ("STM").

Re-exports§

pub use api::BeekeeperApi;
pub use options::BeekeeperOptions;

Modules§

api
The top-level BeekeeperApi handle.
ffi
cxx-generated FFI between Rust and the C++ beekeeper_rs::beekeeper_holder.
options
Construction options for BeekeeperApi.
prelude
One-line import for everything the README examples use.
session
Per-session wallet operations.
wallet
Locked / unlocked wallet handles.

Structs§

RustStorageProtocol
Filesystem storage backend handed to C++ as a Box<RustStorageProtocol>.

Enums§

BeekeeperError
Every failure surfaced by the Rust facade.

Functions§

new_rust_storage_protocol
Build a RustStorageProtocol rooted at storage_root.