rustywallet_export/
lib.rs

1//! # rustywallet-export
2//!
3//! Export private keys to various formats.
4//!
5//! ## Supported Formats
6//!
7//! - **WIF** - Wallet Import Format (compressed/uncompressed)
8//! - **Hex** - Raw hex string (with optional 0x prefix)
9//! - **JSON** - Structured JSON with address, WIF, hex, public key
10//! - **CSV** - Comma-separated values for batch export
11//! - **Paper Wallet** - Address + WIF pair for cold storage
12//! - **BIP38** - Password-encrypted private key
13//! - **BIP21** - Bitcoin URI format for QR codes
14//!
15//! ## Quick Start
16//!
17//! ```rust
18//! use rustywallet_export::prelude::*;
19//! use rustywallet_keys::prelude::PrivateKey;
20//!
21//! let key = PrivateKey::random();
22//!
23//! // Export to WIF
24//! let wif = export_wif(&key, Network::Mainnet, true);
25//! println!("WIF: {}", wif);
26//!
27//! // Export to hex
28//! let hex = export_hex(&key, HexOptions::new());
29//! println!("Hex: {}", hex);
30//!
31//! // Export to JSON
32//! let json = export_json(&key, Network::Mainnet).unwrap();
33//! println!("{}", json);
34//!
35//! // Generate paper wallet
36//! let paper = to_paper_wallet(&key, Network::Mainnet, AddressType::P2PKH).unwrap();
37//! println!("Address: {}", paper.address);
38//! println!("WIF: {}", paper.wif);
39//! ```
40
41pub mod error;
42pub mod types;
43
44mod wif;
45mod hex_export;
46mod json;
47mod csv;
48mod paper_wallet;
49mod bip38;
50mod bip21;
51
52pub use error::{ExportError, Result};
53pub use types::{
54    Network, HexOptions, KeyExport, CsvColumn, CsvOptions,
55    PaperWallet, AddressType, Bip21Options,
56};
57
58pub use wif::export_wif;
59pub use hex_export::export_hex;
60pub use json::{export_json, export_json_batch};
61pub use csv::export_csv;
62pub use paper_wallet::to_paper_wallet;
63pub use bip38::export_bip38;
64pub use bip21::to_bip21_uri;
65
66/// Prelude module for convenient imports.
67pub mod prelude {
68    pub use crate::{
69        export_wif, export_hex, export_json, export_json_batch,
70        export_csv, to_paper_wallet, export_bip38, to_bip21_uri,
71        ExportError, Network, HexOptions, KeyExport, CsvColumn, CsvOptions,
72        PaperWallet, AddressType, Bip21Options,
73    };
74}