rusk_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 cache;
18mod clients;
19mod crypto;
20mod error;
21mod gql;
22mod rues;
23mod store;
24mod wallet;
25
26pub mod currency;
27pub mod dat;
28pub mod gas;
29
30pub use error::Error;
31pub use gql::{BlockTransaction, GraphQL};
32pub use rues::RuesHttpClient;
33pub use wallet::{
34    Address, DecodedNote, Profile, SecureWalletFile, Wallet, WalletPath,
35};
36
37use dusk_core::stake::StakeData;
38use dusk_core::transfer::phoenix::{
39    ArchivedNoteLeaf, Note, NoteOpening, PublicKey as PhoenixPublicKey,
40    SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey,
41};
42use dusk_core::{dusk, from_dusk, BlsScalar};
43
44use currency::Dusk;
45
46/// The maximum allowed size for function names, set to 64 bytes
47pub const MAX_FUNCTION_NAME_SIZE: usize = 64;
48/// Size for the init argument when deploying a contract
49pub const MAX_CONTRACT_INIT_ARG_SIZE: usize = 128;
50/// The largest amount of Dusk that is possible to convert
51pub const MAX_CONVERTIBLE: Dusk = Dusk::MAX;
52/// The smallest amount of Dusk that is possible to convert
53pub const MIN_CONVERTIBLE: Dusk = Dusk::new(1);
54/// The length of an epoch in blocks
55pub const EPOCH: u64 = 2160;
56/// Max addresses the wallet can store
57pub const MAX_PROFILES: usize = get_max_profiles();
58
59const DEFAULT_MAX_PROFILES: usize = 2;
60
61// PANIC: the function is const and will panic during compilation if the value
62// is invalid
63const fn get_max_profiles() -> usize {
64    match option_env!("WALLET_MAX_PROFILES") {
65        Some(v) => match konst::primitive::parse_usize(v) {
66            Ok(e) if e > 255 => {
67                panic!("WALLET_MAX_PROFILES must be lower or equal to 255")
68            }
69            Ok(e) if e > 0 => e,
70            _ => panic!("Invalid WALLET_MAX_PROFILES"),
71        },
72        None => DEFAULT_MAX_PROFILES,
73    }
74}