Skip to content

Commit

Permalink
Maybe add proper key byte decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
pokkst committed Dec 21, 2023
1 parent c047d69 commit fbba3c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion swap/src/bin/asb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ async fn init_bitcoin_wallet(
config.bitcoin.electrum_rpc_url.clone(),
proxy_string.as_str(),
data_dir,
seed.derive_extended_private_key(env_config.bitcoin_network)?,
seed.derive_bip32_key()?,
env_config,
config.bitcoin.target_block,
)
Expand Down
8 changes: 8 additions & 0 deletions swap/src/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ impl Seed {
Ok(private_key)
}

pub fn derive_bip32_key(
&self
) -> Result<ExtendedPrivKey> {
let key_bytes = self.bytes();
let xprv = ExtendedPrivKey::decode(&key_bytes).expect("Failed to decode key_bytes");
Ok(xprv)
}

pub fn derive_libp2p_identity(&self) -> identity::Keypair {
let bytes = self.derive(b"NETWORK").derive(b"LIBP2P_IDENTITY").bytes();
let key = identity::ed25519::SecretKey::from_bytes(bytes).expect("we always pass 32 bytes");
Expand Down

0 comments on commit fbba3c4

Please sign in to comment.