1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! random indexes wallet - 2 Level of randomly chosen hard derivation indexes Wallet

mod hdpayload;

use crate::Key;
use chain_path_derivation::{
    rindex::{self, Rindex},
    DerivationPath,
};
use ed25519_bip32::XPrv;
pub use hdpayload::{decode_derivation_path, HdKey};

impl Key<XPrv, Rindex<rindex::Root>> {
    pub fn key(
        &self,
        derivation_path: &DerivationPath<Rindex<rindex::Address>>,
    ) -> Key<XPrv, Rindex<rindex::Address>> {
        self.derive_path_unchecked(derivation_path)
    }

    /// get an address recovering object, this object can be used to check the
    /// ownership of addresses
    pub fn hd_key(&self) -> HdKey {
        HdKey::new(self.public().public_key())
    }
}