neo3/neo_wallets/
mod.rs

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