Skip to main content

kaspa_bip32/
address_type.rs

1//!
2//!  Address type (`Receive` or `Change`) used in HD wallet address derivation.
3//!
4
5use std::fmt;
6
7/// Address type used in HD wallet address derivation.
8pub enum AddressType {
9    Receive = 0,
10    Change,
11}
12
13impl fmt::Display for AddressType {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        match self {
16            Self::Receive => write!(f, "Receive"),
17            Self::Change => write!(f, "Change"),
18        }
19    }
20}
21
22impl AddressType {
23    pub fn index(&self) -> u32 {
24        match self {
25            Self::Receive => 0,
26            Self::Change => 1,
27        }
28    }
29}