rusnap_api/
bip44.rs

1use rusnap_utils::bytes;
2use serde::{Deserialize, Serialize};
3
4use crate::Result;
5
6use super::request;
7
8/// Entropy for Bip32
9#[derive(Debug, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct Bip44Entropy {
12    #[serde(with = "bytes")]
13    pub chain_code: Vec<u8>,
14
15    #[serde(rename = "coin_type")]
16    pub coin_type: u64,
17
18    pub depth: u32,
19
20    pub index: u64,
21
22    pub master_fingerprint: u64,
23
24    pub parent_fingerprint: u64,
25
26    pub path: String,
27
28    #[serde(with = "bytes")]
29    pub private_key: Vec<u8>,
30
31    #[serde(with = "bytes")]
32    pub public_key: Vec<u8>,
33}
34
35#[derive(Debug, Serialize, Deserialize)]
36struct Bip44Params {
37    #[serde(rename = "coinType")]
38    pub coin_type: u64,
39}
40
41/// Get entropy in EIP44.
42pub async fn get_bip44_entropy(coin_type: u64) -> Result<Bip44Entropy> {
43    let params = Bip44Params { coin_type };
44
45    Ok(request("snap_getBip44Entropy", params).await?)
46}