HTLC broadcast working
This commit is contained in:
@@ -1,15 +1,33 @@
|
||||
use crate::bitcoin::driver;
|
||||
use bdk::wallet::AddressIndex;
|
||||
use crate::bitcoin::{self, driver};
|
||||
use bdk::wallet::AddressIndex::New;
|
||||
use bdk::SignOptions;
|
||||
|
||||
pub(crate) async fn run() -> anyhow::Result<()> {
|
||||
tracing::info!("starting htlc flow");
|
||||
let (dave, sammy) = driver::setup().await?;
|
||||
tracing::info!("syncing dave wallet");
|
||||
let _ = dave.sync();
|
||||
tracing::info!("syncing samy wallet");
|
||||
let _ = sammy.sync();
|
||||
|
||||
// format a new commitment transaction like in Lightning
|
||||
let mut commitment_builder = dave.wallet.build_tx();
|
||||
let amount = 500;
|
||||
let recipient = sammy.wallet.get_address(AddressIndex::New)?.script_pubkey();
|
||||
let recipient = sammy.wallet.get_address(New)?.script_pubkey();
|
||||
|
||||
// Feed it 500 sats, a redeem identity, a hashlock, a refund timelock, and a refund identity
|
||||
//
|
||||
let htlc = bitcoin::htlc::Htlc::new(
|
||||
amount,
|
||||
dave.external_public_key,
|
||||
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff".to_string(),
|
||||
100,
|
||||
sammy.external_public_key,
|
||||
);
|
||||
|
||||
let htlc_descriptor = htlc.to_miniscript_descriptor();
|
||||
tracing::info!("descriptor: {}", htlc_descriptor);
|
||||
|
||||
commitment_builder.add_recipient(recipient, amount);
|
||||
commitment_builder.enable_rbf();
|
||||
let (psbt, _) = commitment_builder
|
||||
|
||||
Reference in New Issue
Block a user