HTLC broadcast working
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::fs;
|
||||
|
||||
use bdk::{
|
||||
bitcoin::{psbt::PartiallySignedTransaction, Network, Transaction},
|
||||
bitcoin::{psbt::PartiallySignedTransaction, secp256k1::PublicKey, Network, Transaction},
|
||||
blockchain::EsploraBlockchain,
|
||||
database::MemoryDatabase,
|
||||
keys::{bip39::Mnemonic, DerivableKey, ExtendedKey},
|
||||
@@ -17,6 +17,7 @@ pub struct BitcoinClient {
|
||||
pub(crate) blockchain: bdk::blockchain::EsploraBlockchain,
|
||||
name: String,
|
||||
pub(crate) wallet: Wallet<MemoryDatabase>,
|
||||
pub(crate) external_public_key: PublicKey,
|
||||
}
|
||||
|
||||
impl BitcoinClient {
|
||||
@@ -91,22 +92,27 @@ impl BitcoinClient {
|
||||
.into_xprv(Network::Signet)
|
||||
.expect("couldn't turn xkey into xprv");
|
||||
|
||||
let external_descriptor = Bip84(xprv, KeychainKind::External);
|
||||
let secp = bdk::bitcoin::secp256k1::Secp256k1::new();
|
||||
|
||||
let external_descriptor1 = Bip84(xprv.clone(), KeychainKind::External);
|
||||
let external_descriptor2 = Bip84(xprv, KeychainKind::External);
|
||||
let internal_descriptor = Some(Bip84(xprv, KeychainKind::Internal));
|
||||
|
||||
let wallet = Wallet::new(
|
||||
external_descriptor,
|
||||
external_descriptor1,
|
||||
internal_descriptor,
|
||||
network,
|
||||
MemoryDatabase::default(),
|
||||
)?;
|
||||
|
||||
let blockchain = EsploraBlockchain::new("https://mutinynet.com/api", 20);
|
||||
let external_public_key = external_descriptor2.0.private_key.public_key(&secp);
|
||||
|
||||
let esplora = BitcoinClient {
|
||||
name: name.to_string(),
|
||||
wallet,
|
||||
blockchain,
|
||||
external_public_key,
|
||||
};
|
||||
|
||||
Ok(esplora)
|
||||
|
||||
Reference in New Issue
Block a user