Add context if we fail to compute extended private key

This commit is contained in:
Thomas Eizinger 2021-03-04 17:40:51 +11:00
parent 1aa6d177bf
commit c826a28911
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -1,7 +1,7 @@
use crate::fs::ensure_directory_exists;
use ::bitcoin::secp256k1::constants::SECRET_KEY_SIZE;
use ::bitcoin::secp256k1::{self, SecretKey};
use anyhow::Result;
use anyhow::{Context, Result};
use bdk::bitcoin::util::bip32::ExtendedPrivKey;
use bitcoin::hashes::{sha256, Hash, HashEngine};
use libp2p::identity;
@ -34,7 +34,8 @@ impl Seed {
network: bitcoin::Network,
) -> Result<ExtendedPrivKey> {
let seed = self.derive(b"BITCOIN_EXTENDED_PRIVATE_KEY").bytes();
let private_key = ExtendedPrivKey::new_master(network, &seed)?;
let private_key = ExtendedPrivKey::new_master(network, &seed)
.context("Failed to create new master extended private key")?;
Ok(private_key)
}