use bitcoin::NetworkKind;
use bitcoin::bip32::{ChainCode, ChildNumber, DerivationPath, Fingerprint, Xpub};
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
pub(crate) fn synthetic_xpub(path: &DerivationPath) -> Xpub {
let secp = Secp256k1::new();
let sk = SecretKey::from_slice(&[1u8; 32]).unwrap();
let pk = PublicKey::from_secret_key(&secp, &sk);
let components: Vec<ChildNumber> = path.into_iter().copied().collect();
let depth = components.len() as u8;
let child_number = components
.last()
.copied()
.unwrap_or(ChildNumber::Normal { index: 0 });
Xpub {
network: NetworkKind::Main,
depth,
parent_fingerprint: Fingerprint::from([0xAA, 0xBB, 0xCC, 0xDD]),
child_number,
public_key: pk,
chain_code: ChainCode::from([0x55u8; 32]),
}
}