From 3d19cc50fb09259dafb74c90916f0e541d57cf39 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Wed, 24 Jul 2024 16:39:19 +0100 Subject: [PATCH] Starting work on HTLC commands --- README.md | 13 +++++++++++-- side-node/src/bitcoin/clients/electrum.rs | 19 ------------------- side-node/src/cli/mod.rs | 2 +- side-node/src/lib.rs | 2 +- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 6d5f012..bb3ad5a 100644 --- a/README.md +++ b/README.md @@ -72,14 +72,18 @@ Later, we will aim to remove the Side Watcher from the architecture, by (a) movi ## Bitcoin integration -There is a Bitcoin client integrated into the node, which can do simple coin transfers using esplora and the Mutinynet server's Signet (30 second blocktime). +There is an Esplora Bitcoin client integrated into the node + +### Simple coin transfers + +The client can do simple coin transfers using esplora and the Mutinynet server's Signet (30 second blocktime). The client's demo driver can be run by doing: ``` cargo run -- init dave cargo run -- init sammy -cargo run -- btc +cargo run -- btc-transfer ``` You'll need to have funded the "dave" address prior to running the `btc` command - otherwise the transfer will fail gracefully. @@ -88,6 +92,11 @@ I was using this primarily as a way to experiment with constructing and broadcas There is a second, unused Bitcoin client in place which uses Blockstream's Electrum server, but this didn't seem to be working properly with respect to Signet Bitcoin network during my testing, so I went with the esplora / Mutiny version instead. +### HTLCs (in progress) + +An experimental driver for Bitcoin Hash Time Locked Contracts (HTLCs). + + ## Possible uses ### DKG diff --git a/side-node/src/bitcoin/clients/electrum.rs b/side-node/src/bitcoin/clients/electrum.rs index 47a8d76..921f80d 100644 --- a/side-node/src/bitcoin/clients/electrum.rs +++ b/side-node/src/bitcoin/clients/electrum.rs @@ -54,25 +54,6 @@ pub async fn run() -> Result<(), anyhow::Error> { Ok(()) } -// /// Create a BDK wallet using BIP 84 descriptor ("m/84h/1h/0h/0" and "m/84h/1h/0h/1") -// pub fn create_wallet(xkey: ExtendedKey) -> anyhow::Result> { -// let xprv = xkey -// .into_xprv(Network::Testnet) -// .expect("couldn't turn xkey into xprv"); - -// let external_descriptor = Bip84(xprv, KeychainKind::External); -// let internal_descriptor = Some(Bip84(xprv, KeychainKind::Internal)); - -// let wallet = Wallet::new( -// external_descriptor, -// internal_descriptor, -// Network::Testnet, -// MemoryDatabase::default(), -// )?; - -// Ok(wallet) -// } - fn display_balance(wallet: &Wallet) { println!( "Wallet balance for {} after syncing: {:?} sats on network {}", diff --git a/side-node/src/cli/mod.rs b/side-node/src/cli/mod.rs index d20431d..acd39b1 100644 --- a/side-node/src/cli/mod.rs +++ b/side-node/src/cli/mod.rs @@ -18,7 +18,7 @@ pub(crate) struct Args { #[derive(Subcommand)] pub(crate) enum Commands { /// Placeholder for future BTC commands - Btc {}, + BtcTransfer {}, /// runs the Side Node Run { name: String }, diff --git a/side-node/src/lib.rs b/side-node/src/lib.rs index 45a3c29..1883e22 100644 --- a/side-node/src/lib.rs +++ b/side-node/src/lib.rs @@ -28,7 +28,7 @@ pub async fn run() { let mut node = setup(name).await; node.start().await; } - Some(Commands::Btc {}) => { + Some(Commands::BtcTransfer {}) => { let _ = bitcoin::driver::run().await; } None => println!("No command provided. Exiting. See --help for more information."),