dusk_wallet/
lib.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7//! # Dusk Wallet Lib
8//!
9//! The `dusk_wallet` library aims to provide an easy and convenient way of
10//! interfacing with the Dusk Network.
11//!
12//! Clients can use `Wallet` to create their Dusk wallet, send transactions
13//! through the network of their choice, stake and withdraw rewards, etc.
14
15#![deny(missing_docs)]
16
17mod block;
18mod cache;
19mod clients;
20mod crypto;
21
22mod currency;
23mod error;
24mod rusk;
25mod store;
26mod wallet;
27
28/// Methods for parsing/checking the DAT wallet file
29pub mod dat;
30
31pub use rusk::{RuskHttpClient, RuskRequest};
32
33pub use currency::{Dusk, Lux};
34pub use error::Error;
35pub use wallet::gas;
36pub use wallet::{Address, DecodedNote, SecureWalletFile, Wallet, WalletPath};
37
38/// The largest amount of Dusk that is possible to convert
39pub const MAX_CONVERTIBLE: Dusk = Dusk::MAX;
40/// The smallest amount of Dusk that is possible to convert
41pub const MIN_CONVERTIBLE: Dusk = Dusk::new(1);
42/// The length of an epoch in blocks
43pub const EPOCH: u64 = 2160;
44/// Max addresses the wallet can store
45pub const MAX_ADDRESSES: usize = get_max_addresses();
46
47const DEFAULT_MAX_ADDRESSES: usize = 25;
48
49const fn get_max_addresses() -> usize {
50    match option_env!("WALLET_MAX_ADDR") {
51        Some(v) => match konst::primitive::parse_usize(v) {
52            Ok(e) if e > 255 => {
53                panic!("WALLET_MAX_ADDR must be lower or equal to 255")
54            }
55            Ok(e) if e > 0 => e,
56            _ => panic!("Invalid WALLET_MAX_ADDR"),
57        },
58        None => DEFAULT_MAX_ADDRESSES,
59    }
60}