Skip to main content

rust_hdwallet/hdwallet/cryptocurrencies/
neo.rs

1use crate::hdwallet::slip44::coin_types;
2
3use super::icryptocurrency::{
4    AddressTypes, CryptocurrencyDescriptor, Info, InfoItem, InfoValue, NetworkDescriptor, Params,
5    XPrivateKeyVersions, XPublicKeyVersions,
6};
7use super::NetworkName;
8
9pub struct Mainnet;
10
11impl Mainnet {
12    pub const NAME: &'static str = "mainnet";
13    pub const XPRIVATE_KEY_VERSIONS: XPrivateKeyVersions = &[("P2PKH", 0x0488ade4)];
14    pub const XPUBLIC_KEY_VERSIONS: XPublicKeyVersions = &[("P2PKH", 0x0488b21e)];
15}
16
17pub static MAINNET: NetworkDescriptor = NetworkDescriptor {
18    name: Mainnet::NAME,
19    public_key_address_prefix: None,
20    script_address_prefix: None,
21    hrp: None,
22    witness_versions: None,
23    xprivate_key_versions: Some(Mainnet::XPRIVATE_KEY_VERSIONS),
24    xpublic_key_versions: Some(Mainnet::XPUBLIC_KEY_VERSIONS),
25    message_prefix: None,
26    wif_prefix: None,
27    legacy_public_key_address_prefix: None,
28    std_public_key_address_prefix: None,
29    legacy_script_address_prefix: None,
30    std_script_address_prefix: None,
31    standard: None,
32    integrated: None,
33    sub_address: None,
34    network_type: None,
35    payment_address_hrp: None,
36    reward_address_hrp: None,
37};
38
39pub static NETWORKS: &[(&'static str, &'static NetworkDescriptor)] = &[("MAINNET", &MAINNET)];
40
41pub static ADDRESS_TYPE_LABELS: AddressTypes = &[("NEO", "Neo")];
42
43pub static NEO_PARAMS: Params = Params {
44    checksum_length: None,
45    payment_id_length: None,
46    suffix: Some(0xAC),
47    address_prefix: None,
48    chain_prefixes_by_address_type: None,
49    alphabet: Some("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),
50    field_size_hex: None,
51    tap_tweak_sha256: None,
52    cardano_wallet_types: None,
53    cardano_payment_prefix: None,
54    cardano_reward_prefix: None,
55    cardano_public_key_address: None,
56    cardano_redemption_address: None,
57    address_type_codes: None,
58    address_prefix_byte: Some(0x21),
59    address_version_byte: Some(0x17),
60    key_type: None,
61    address_type_prefix_bytes: None,
62};
63
64pub struct Neo {
65    pub network: NetworkName,
66}
67
68impl Neo {
69    pub const NAME: &'static str = "Neo";
70    pub const SYMBOL: &'static str = "NEO";
71    pub const COIN_TYPE: u32 = coin_types::NEO;
72    pub const ECC: &'static str = "SLIP10Nist256p1ECC";
73    pub const SUPPORT_BIP38: bool = false;
74    pub const DEFAULT_HD: &'static str = "BIP44";
75    pub const DEFAULT_PATH: &'static str = "m/44'/888'/0'/0/0";
76    pub const DEFAULT_ADDRESS: &'static str = "NEO";
77    pub const ENTROPIES: &'static [&'static str] = &["BIP39"];
78    pub const MNEMONICS: &'static [&'static str] = &["BIP39"];
79    pub const SEEDS: &'static [&'static str] = &["BIP39"];
80    pub const HDS: &'static [&'static str] = &["BIP32", "BIP44"];
81    pub const ADDRESSES: &'static [&'static str] = &["NEO"];
82    pub const SEMANTICS: &'static [&'static str] = &["p2pkh"];
83    pub const DEFAULT_SEMANTIC: Option<&'static str> = Some("p2pkh");
84
85    pub const INFO: Info<'static> = Info(&[
86        InfoItem {
87            key: "SOURCE_CODE",
88            value: InfoValue::Str("https://github.com/neo-project/neo"),
89        },
90        InfoItem {
91            key: "WHITEPAPER",
92            value: InfoValue::Str("https://docs.neo.org/docs/en-us/index.html"),
93        },
94        InfoItem {
95            key: "WEBSITES",
96            value: InfoValue::List(&["https://neo.org"]),
97        },
98    ]);
99
100    #[must_use]
101    pub fn network_descriptor(&self) -> &'static NetworkDescriptor {
102        match self.network {
103            NetworkName::Mainnet => &MAINNET,
104            NetworkName::Testnet | NetworkName::Regtest => &MAINNET,
105        }
106    }
107}
108
109pub static DESCRIPTOR: CryptocurrencyDescriptor = CryptocurrencyDescriptor {
110    name: Neo::NAME,
111    symbol: Neo::SYMBOL,
112    info: Neo::INFO,
113    ecc: Neo::ECC,
114    coin_type: Neo::COIN_TYPE,
115    support_bip38: Neo::SUPPORT_BIP38,
116    networks: NETWORKS,
117    default_network: &MAINNET,
118    entropies: Neo::ENTROPIES,
119    mnemonics: Neo::MNEMONICS,
120    seeds: Neo::SEEDS,
121    hds: Neo::HDS,
122    default_hd: Neo::DEFAULT_HD,
123    default_path: Neo::DEFAULT_PATH,
124    addresses: Neo::ADDRESSES,
125    default_address: Neo::DEFAULT_ADDRESS,
126    address_types: Some(ADDRESS_TYPE_LABELS),
127    default_address_type: None,
128    address_prefixes: None,
129    default_address_prefix: None,
130    semantics: Neo::SEMANTICS,
131    default_semantic: Neo::DEFAULT_SEMANTIC,
132    params: Some(NEO_PARAMS),
133};