diff --git a/README.md b/README.md index 3792b5b..7d335f8 100644 --- a/README.md +++ b/README.md @@ -97,15 +97,23 @@ Every chain subcommand accepts the shared flags `-w/--words`, `-c/--count`, `-p/ ### Library Usage +```toml +# Default is `std` only — enable chains (or `mainstream` / `all-chains`) explicitly. +kobe = { version = "3.2", features = ["std", "mainstream"] } +# Optional: `rand` for Wallet::generate; chain features: evm, btc, svm, … +``` + ```rust use kobe::prelude::*; // Wallet, Derive, DeriveExt, DerivationStyle trait, ... -use kobe::evm::Deriver; // or kobe::btc, kobe::svm, kobe::cosmos, ... +use kobe::evm::Deriver; // requires feature "evm" (or "mainstream") -// Import from mnemonic +// Import from mnemonic (full BIP-39 words) let wallet = Wallet::from_mnemonic( "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", None, // optional passphrase )?; +// Abbreviated 4-letter English prefixes (same as CLI import): +// let wallet = Wallet::from_mnemonic_expanded("aban aban … abou", None)?; // Derive addresses (accessor methods — fields are private for zeroization safety) let eth = kobe::evm::Deriver::new(&wallet).derive(0)?; diff --git a/crates/README.md b/crates/README.md index 63c5425..0ca784a 100644 --- a/crates/README.md +++ b/crates/README.md @@ -50,14 +50,15 @@ The umbrella `kobe` crate provides fine-grained feature control: | Feature | Default | Description | | --- | --- | --- | -| `std` | ✅ | Enable `std` support | -| `alloc` | ✅ | Enable `alloc` (implied by `std`) | +| `std` | ✅ | Enable `std` support (default = `["std"]` only) | +| `alloc` | | Enable `alloc` (implied by `std`) | | `rand` | | Enable random mnemonic generation | | `camouflage` | | Enable mnemonic camouflage encryption | | `raw-seed` | | Expose `Wallet::seed` (escape hatch; prefer derivers) | +| `mainstream` | | Preset: `btc` + `evm` + `svm` | | `btc` | | Bitcoin chain support (enables `bip32`) | | `evm` | | Ethereum chain support (enables `bip32`) | -| `svm` | ✅ | Solana chain support (enables `slip10`) | +| `svm` | | Solana chain support (enables `slip10`) | | `cosmos` | | Cosmos chain support (enables `bip32`) | | `tron` | | Tron chain support (enables `bip32`) | | `spark` | | Spark chain support (enables `bip32`) | diff --git a/crates/kobe-cli/src/commands/simple.rs b/crates/kobe-cli/src/commands/simple.rs index 5e6dd39..2d7ba84 100644 --- a/crates/kobe-cli/src/commands/simple.rs +++ b/crates/kobe-cli/src/commands/simple.rs @@ -53,9 +53,8 @@ impl SimpleArgs { None => Ok(Wallet::generate(self.words, self.passphrase.as_deref())?), Some(phrase) => { let phrase = resolve_mnemonic_input(phrase)?; - let expanded = kobe::mnemonic::expand(&phrase)?; - Ok(Wallet::from_mnemonic( - &expanded, + Ok(Wallet::from_mnemonic_expanded( + &phrase, self.passphrase.as_deref(), )?) } diff --git a/crates/kobe-primitives/src/wallet.rs b/crates/kobe-primitives/src/wallet.rs index e139b40..6a4cebe 100644 --- a/crates/kobe-primitives/src/wallet.rs +++ b/crates/kobe-primitives/src/wallet.rs @@ -201,6 +201,21 @@ impl Wallet { Ok(Self::from_parts(&mnemonic, language, passphrase)) } + /// Expand 4-letter BIP-39 English prefixes then import (same path as CLI `import`). + /// + /// Full words pass through [`mnemonic::expand`](crate::mnemonic::expand) unchanged. + /// + /// # Errors + /// + /// Returns an error if expansion or BIP-39 parse fails. + pub fn from_mnemonic_expanded( + phrase: &str, + passphrase: Option<&str>, + ) -> Result { + let expanded = crate::mnemonic::expand(phrase)?; + Self::from_mnemonic(&expanded, passphrase) + } + /// Create a wallet from an existing mnemonic phrase in the specified language. /// /// # Arguments