pub fn new(seed: &[u8; 32], starting_time_secs: u64, starting_time_nanos: u32, factory: F) -> Self {
        let secp_ctx = Secp256k1::new();
        // Note that when we aren't serializing the key, network doesn't matter
        match ExtendedPrivKey::new_master(Network::Testnet, seed) {
            Ok(master_key) => {
                let node_secret = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(0).unwrap()).expect("Your RNG is busted").private_key.key;
                let destination_script = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(1).unwrap()) {
                    Ok(destination_key) => {
                        let wpubkey_hash = WPubkeyHash::hash(&ExtendedPubKey::from_private(&secp_ctx, &destination_key).public_key.to_bytes());
                        Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
                            .push_slice(&wpubkey_hash.into_inner())
                            .into_script()
                    },
                    Err(_) => panic!("Your RNG is busted"),
                };
                let shutdown_pubkey = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(2).unwrap()) {
                    Ok(shutdown_key) => ExtendedPubKey::from_private(&secp_ctx, &shutdown_key).public_key.key,
                    Err(_) => panic!("Your RNG is busted"),
                };
                let channel_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(3).unwrap()).expect("Your RNG is busted");
                let rand_bytes_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(4).unwrap()).expect("Your RNG is busted");

                let mut rand_bytes_unique_start = Sha256::engine();
                rand_bytes_unique_start.input(&byte_utils::be64_to_array(starting_time_secs));
                rand_bytes_unique_start.input(&byte_utils::be32_to_array(starting_time_nanos));
                rand_bytes_unique_start.input(seed);

                let mut res = KeysManager {
                    secp_ctx,
                    node_secret,

                    destination_script,
                    shutdown_pubkey,

                    channel_master_key,
                    channel_child_index: AtomicUsize::new(0),

                    rand_bytes_master_key,
                    rand_bytes_child_index: AtomicUsize::new(0),
                    rand_bytes_unique_start,

                    seed: *seed,
                    starting_time_secs,
                    starting_time_nanos,
                    factory,
                };
                let secp_seed = res.get_secure_random_bytes();
                res.secp_ctx.seeded_randomize(&secp_seed);
                res
            },
            Err(_) => panic!("Your rng is busted"),
        }
    }
/// Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased (eg your
/// CSRNG is busted) this may panic (but more importantly, you will possibly lose funds).
/// starting_time isn't strictly required to actually be a time, but it must absolutely,
/// without a doubt, be unique to this instance. ie if you start multiple times with the same
/// seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to
/// simply use the current time (with very high precision).
///
/// The seed MUST be backed up safely prior to use so that the keys can be re-created, however,
/// obviously, starting_time should be unique every time you reload the library - it is only
/// used to generate new ephemeral key data (which will be stored by the individual channel if
/// necessary).
///
/// Note that the seed is required to recover certain on-chain funds independent of
/// ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any
/// channel, and some on-chain during-closing funds.
///
/// Note that until the 0.1 release there is no guarantee of backward compatibility between
/// versions. Once the library is more fully supported, the docs will be updated to include a
/// detailed description of the guarantee.
Constructs a KeysManager from a 32-byte seed. If the seed is in some way biased  this may panic (but more importantly, you will possibly lose funds).
starting_time isn't strictly required to actually be a time, but it must absolutely,
without a doubt, be unique to this instance. ie if you start multiple times with the same
seed, starting_time must be unique to each run. Thus, the easiest way to achieve this is to
simply use the current time (with very high precision).

The seed MUST be backed up safely prior to use so that the keys can be re-created, however,
obviously, starting_time should be unique every time you reload the library - it is only
used to generate new ephemeral key data (which will be stored by the individual channel if
necessary).

Note that the seed is required to recover certain on-chain funds independent of
ChannelMonitor data, though a current copy of ChannelMonitor data is also required for any
channel, and some on-chain during-closing funds.

Note that until the 0.1 release there is no guarantee of backward compatibility between
versions. Once the library is more fully supported, the docs will be updated to include a
detailed description of the guarantee.
Constructs a KeysManager from a 32 - byte seed . If the seed is in some way biased this may panic ( but more importantly you will possibly lose funds ) . starting_time isn ' t strictly required to actually be a time but it must absolutely without a doubt be unique to this instance . ie if you start multiple times with the same seed starting_time must be unique to each run . Thus the easiest way to achieve this is to simply use the current time ( with very high precision ) . The seed MUST be backed up safely prior to use so that the keys can be re - created however obviously starting_time should be unique every time you reload the library - it is only used to generate new ephemeral key data ( which will be stored by the individual channel if necessary ) . Note that the seed is required to recover certain on - chain funds independent of ChannelMonitor data though a current copy of ChannelMonitor data is also required for any channel and some on - chain during - closing funds . Note that until the 0 . 1 release there is no guarantee of backward compatibility between versions . Once the library is more fully supported the docs will be updated to include a detailed description of the guarantee .
pub fn new(seed: &[u8; 32], starting_time_secs: u64, starting_time_nanos: u32, factory: F) -> Self {
        let secp_ctx = Secp256k1::new();
        // Note that when we aren't serializing the key, network doesn't matter
        match ExtendedPrivKey::new_master(Network::Testnet, seed) {
            Ok(master_key) => {
                let node_secret = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(0).unwrap()).expect("Your RNG is busted").private_key.key;
                let destination_script = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(1).unwrap()) {
                    Ok(destination_key) => {
                        let wpubkey_hash = WPubkeyHash::hash(&ExtendedPubKey::from_private(&secp_ctx, &destination_key).public_key.to_bytes());
                        Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
                            .push_slice(&wpubkey_hash.into_inner())
                            .into_script()
                    },
                    Err(_) => panic!("Your RNG is busted"),
                };
                let shutdown_pubkey = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(2).unwrap()) {
                    Ok(shutdown_key) => ExtendedPubKey::from_private(&secp_ctx, &shutdown_key).public_key.key,
                    Err(_) => panic!("Your RNG is busted"),
                };
                let channel_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(3).unwrap()).expect("Your RNG is busted");
                let rand_bytes_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(4).unwrap()).expect("Your RNG is busted");
                let mut rand_bytes_unique_start = Sha256::engine();
                rand_bytes_unique_start.input(&byte_utils::be64_to_array(starting_time_secs));
                rand_bytes_unique_start.input(&byte_utils::be32_to_array(starting_time_nanos));
                rand_bytes_unique_start.input(seed);
                let mut res = KeysManager {
                    secp_ctx,
                    node_secret,
                    destination_script,
                    shutdown_pubkey,
                    channel_master_key,
                    channel_child_index: AtomicUsize::new(0),
                    rand_bytes_master_key,
                    rand_bytes_child_index: AtomicUsize::new(0),
                    rand_bytes_unique_start,
                    seed: *seed,
                    starting_time_secs,
                    starting_time_nanos,
                    factory,
                };
                let secp_seed = res.get_secure_random_bytes();
                res.secp_ctx.seeded_randomize(&secp_seed);
                res
            },
            Err(_) => panic!("Your rng is busted"),
        }
    }
pub fn new ( seed : & [ u8 ; 32 ] , starting_time_secs : u64 , starting_time_nanos : u32 , factory : F ) -> Self { let secp_ctx = Secp256k1 :: new ( ) ; // Note that when we aren't serializing the key, network doesn't matter match ExtendedPrivKey :: new_master ( Network :: Testnet , seed ) { Ok ( master_key ) => { let node_secret = master_key . ckd_priv ( & secp_ctx , ChildNumber :: from_hardened_idx ( 0 ) . unwrap ( ) ) . expect ( " " ) . private_key . key ; let destination_script = match master_key . ckd_priv ( & secp_ctx , ChildNumber :: from_hardened_idx ( 1 ) . unwrap ( ) ) { Ok ( destination_key ) => { let wpubkey_hash = WPubkeyHash :: hash ( & ExtendedPubKey :: from_private ( & secp_ctx , & destination_key ) . public_key . to_bytes ( ) ) ; Builder :: new ( ) . push_opcode ( opcodes :: all :: OP_PUSHBYTES_0 ) . push_slice ( & wpubkey_hash . into_inner ( ) ) . into_script ( ) } , Err ( _ ) => panic ! ( " " ) , } ; let shutdown_pubkey = match master_key . ckd_priv ( & secp_ctx , ChildNumber :: from_hardened_idx ( 2 ) . unwrap ( ) ) { Ok ( shutdown_key ) => ExtendedPubKey :: from_private ( & secp_ctx , & shutdown_key ) . public_key . key , Err ( _ ) => panic ! ( " " ) , } ; let channel_master_key = master_key . ckd_priv ( & secp_ctx , ChildNumber :: from_hardened_idx ( 3 ) . unwrap ( ) ) . expect ( " " ) ; let rand_bytes_master_key = master_key . ckd_priv ( & secp_ctx , ChildNumber :: from_hardened_idx ( 4 ) . unwrap ( ) ) . expect ( " " ) ; let mut rand_bytes_unique_start = Sha256 :: engine ( ) ; rand_bytes_unique_start . input ( & byte_utils :: be64_to_array ( starting_time_secs ) ) ; rand_bytes_unique_start . input ( & byte_utils :: be32_to_array ( starting_time_nanos ) ) ; rand_bytes_unique_start . input ( seed ) ; let mut res = KeysManager { secp_ctx , node_secret , destination_script , shutdown_pubkey , channel_master_key , channel_child_index : AtomicUsize :: new ( 0 ) , rand_bytes_master_key , rand_bytes_child_index : AtomicUsize :: new ( 0 ) , rand_bytes_unique_start , seed : * seed , starting_time_secs , starting_time_nanos , factory , } ; let secp_seed = res . get_secure_random_bytes ( ) ; res . secp_ctx . seeded_randomize ( & secp_seed ) ; res } , Err ( _ ) => panic ! ( " " ) , } }
Constructs a KeysManager from a 32-byte seed.
Constructs a KeysManager from a 32 - byte seed .
seed
&[u8; 32]
starting_time_secs
u64
starting_time_nanos
u32
factory
F
seed
&[u8; 32]
starting_time_secs
u64
starting_time_nanos
u32
factory
F