neo3/neo_wallets/
mod.rs

1#![deny(unsafe_code)]
2
3//! # Neo Wallets
4//!
5//! Wallet management for the Neo N3 blockchain.
6//!
7//! ## Overview
8//!
9//! The neo_wallets module provides comprehensive wallet management functionality for the Neo N3 blockchain.
10//! It includes:
11//!
12//! - Wallet creation and loading
13//! - NEP-6 wallet standard support
14//! - BIP-39 mnemonic phrase support
15//! - Transaction signing
16//! - Key management and derivation
17//! - Hardware wallet integration (Ledger)
18//! - Secure key storage
19//! - Wallet backup and recovery
20//!
21//! This module enables secure management of private keys and accounts, allowing users to interact
22//! with the Neo N3 blockchain in a secure manner.
23//!
24//! ## Examples
25//!
26//! ### Creating and using a wallet
27//!
28//! ```rust
29//! use neo3::neo_wallets::Wallet;
30//! use std::path::PathBuf;
31//!
32//! #[tokio::main]
33//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
34//!     // Create a new wallet
35//!     let mut wallet = Wallet::new();
36//!     
37//!     // Create a new account in the wallet
38//!     let account = wallet.create_new_account()?;
39//!     println!("New account address: {}", account.get_address());
40//!     
41//!     // Save the wallet to a file
42//!     wallet.save_to_file(PathBuf::from("my_wallet.json"))?;
43//!     
44//!     Ok(())
45//! }
46//! ```
47//!
48//! ### Working with BIP-39 accounts
49//!
50//! ```no_run
51//! use neo3::neo_wallets::Bip39Account;
52//!
53//! #[tokio::main]
54//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
55//!     // Create a new BIP-39 account
56//!     let account = Bip39Account::create("password123")?;
57//!     println!("Generated mnemonic: {}", account.mnemonic());
58//!     
59//!     // Recover an account from a mnemonic
60//!     let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art";
61//!     let recovered = Bip39Account::from_bip39_mnemonic("password123", mnemonic)?;
62//!     
63//!     Ok(())
64//! }
65//! ```
66
67#[cfg(feature = "ledger")]
68pub use ledger::{HDPath, LedgerWallet};
69#[cfg(feature = "yubi")]
70use p256::NistP256;
71#[cfg(all(feature = "yubihsm", not(target_arch = "wasm32")))]
72pub use yubihsm;
73
74use crate::neo_protocol::Account;
75pub use bip39_account::*;
76pub use error::*;
77pub use wallet::*;
78pub use wallet_signer::WalletSigner;
79pub use wallet_trait::WalletTrait;
80
81#[cfg(feature = "ledger")]
82mod ledger;
83mod wallet;
84mod wallet_trait;
85
86/// A wallet instantiated with a locally stored private key
87pub type LocalWallet = WalletSigner<Account>;
88// pub type LocalWallet = Wallet<ethers_core::k256::ecdsa::SigningKey>;
89
90/// A wallet instantiated with a YubiHSM
91#[cfg(feature = "yubi")]
92pub type YubiWallet = WalletSigner<yubihsm::ecdsa::Signer<NistP256>>;
93
94// #[cfg(all(feature = "yubihsm", not(target_arch = "wasm32")))]
95mod yubi;
96
97mod bip39_account;
98mod error;
99mod wallet_signer;