rust_hdwallet/hdwallet/cryptocurrencies/
rubycoin.rs1use crate::hdwallet::slip44::coin_types;
2
3use super::icryptocurrency::{
4 CryptocurrencyDescriptor, Info, InfoItem, InfoValue, NetworkDescriptor, XPrivateKeyVersions,
5 XPublicKeyVersions,
6};
7use super::NetworkName;
8
9pub struct Mainnet;
10
11impl Mainnet {
12 pub const NAME: &'static str = "mainnet";
13 pub const PUBLIC_KEY_ADDRESS_PREFIX: u32 = 0x3c;
14 pub const SCRIPT_ADDRESS_PREFIX: u32 = 0x55;
15 pub const MESSAGE_PREFIX: &'static [u8] = b"\x18Rubycoin Signed Message:\n";
16 pub const WIF_PREFIX: u8 = 0xbc;
17 pub const XPRIVATE_KEY_VERSIONS: XPrivateKeyVersions = &[
18 ("P2PKH", 0x0488ade4),
19 ("P2SH", 0x0488ade4),
20 ];
21 pub const XPUBLIC_KEY_VERSIONS: XPublicKeyVersions = &[
22 ("P2PKH", 0x0488b21e),
23 ("P2SH", 0x0488b21e),
24 ];
25}
26
27pub static MAINNET: NetworkDescriptor = NetworkDescriptor {
28 name: Mainnet::NAME,
29 public_key_address_prefix: Some(Mainnet::PUBLIC_KEY_ADDRESS_PREFIX),
30 script_address_prefix: Some(Mainnet::SCRIPT_ADDRESS_PREFIX),
31 hrp: None,
32 witness_versions: None,
33 xprivate_key_versions: Some(Mainnet::XPRIVATE_KEY_VERSIONS),
34 xpublic_key_versions: Some(Mainnet::XPUBLIC_KEY_VERSIONS),
35 message_prefix: Some(Mainnet::MESSAGE_PREFIX),
36 wif_prefix: Some(Mainnet::WIF_PREFIX),
37 legacy_public_key_address_prefix: None,
38 std_public_key_address_prefix: None,
39 legacy_script_address_prefix: None,
40 std_script_address_prefix: None,
41 standard: None,
42 integrated: None,
43 sub_address: None,
44 network_type: None,
45 payment_address_hrp: None,
46 reward_address_hrp: None,
47};
48
49pub static NETWORKS: &[(&'static str, &'static NetworkDescriptor)] = &[("MAINNET", &MAINNET)];
50
51pub struct Rubycoin {
52 pub network: NetworkName,
53}
54
55impl Rubycoin {
56 pub const NAME: &'static str = "Rubycoin";
57 pub const SYMBOL: &'static str = "RBY";
58 pub const COIN_TYPE: u32 = coin_types::RUBYCOIN;
59 pub const ECC: &'static str = "SLIP10Secp256k1ECC";
60 pub const SUPPORT_BIP38: bool = true;
61 pub const DEFAULT_HD: &'static str = "BIP44";
62 pub const DEFAULT_PATH: &'static str = "m/44'/16'/0'/0/0";
63 pub const DEFAULT_ADDRESS: &'static str = "P2PKH";
64 pub const ENTROPIES: &'static [&'static str] = &["BIP39"];
65 pub const MNEMONICS: &'static [&'static str] = &["BIP39"];
66 pub const SEEDS: &'static [&'static str] = &["BIP39"];
67 pub const HDS: &'static [&'static str] = &["BIP32", "BIP44"];
68 pub const ADDRESSES: &'static [&'static str] = &["P2PKH", "P2SH"];
69 pub const SEMANTICS: &'static [&'static str] = &["p2pkh", "p2sh"];
70 pub const DEFAULT_SEMANTIC: Option<&'static str> = Some("p2pkh");
71
72 pub const INFO: Info<'static> = Info(&[
73 InfoItem {
74 key: "SOURCE_CODE",
75 value: InfoValue::Str("https://github.com/rubycoinorg/rubycoin"),
76 },
77 InfoItem {
78 key: "WEBSITES",
79 value: InfoValue::List(&["http://www.rubycoin.org"]),
80 },
81 ]);
82
83 #[must_use]
84 pub fn network_descriptor(&self) -> &'static NetworkDescriptor {
85 match self.network {
86 NetworkName::Mainnet => &MAINNET,
87 NetworkName::Testnet | NetworkName::Regtest => &MAINNET,
88 }
89 }
90}
91
92pub static DESCRIPTOR: CryptocurrencyDescriptor = CryptocurrencyDescriptor {
93 name: Rubycoin::NAME,
94 symbol: Rubycoin::SYMBOL,
95 info: Rubycoin::INFO,
96 ecc: Rubycoin::ECC,
97 coin_type: Rubycoin::COIN_TYPE,
98 support_bip38: Rubycoin::SUPPORT_BIP38,
99 networks: NETWORKS,
100 default_network: &MAINNET,
101 entropies: Rubycoin::ENTROPIES,
102 mnemonics: Rubycoin::MNEMONICS,
103 seeds: Rubycoin::SEEDS,
104 hds: Rubycoin::HDS,
105 default_hd: Rubycoin::DEFAULT_HD,
106 default_path: Rubycoin::DEFAULT_PATH,
107 addresses: Rubycoin::ADDRESSES,
108 default_address: Rubycoin::DEFAULT_ADDRESS,
109 address_types: None,
110 default_address_type: None,
111 address_prefixes: None,
112 default_address_prefix: None,
113 semantics: Rubycoin::SEMANTICS,
114 default_semantic: Rubycoin::DEFAULT_SEMANTIC,
115 params: None,
116};