Fixes to miniscript descriptor
This commit is contained in:
@@ -20,7 +20,6 @@ pub(crate) async fn run() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
// format a new commitment transaction like in Lightning
|
// format a new commitment transaction like in Lightning
|
||||||
let mut commitment_builder = dave.wallet.build_tx();
|
let mut commitment_builder = dave.wallet.build_tx();
|
||||||
commitment_builder.add_recipient(recipient, value);
|
|
||||||
commitment_builder.enable_rbf();
|
commitment_builder.enable_rbf();
|
||||||
let (psbt, _) = commitment_builder
|
let (psbt, _) = commitment_builder
|
||||||
.finish()
|
.finish()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub(crate) async fn run() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
tracing::info!("starting transfer policy flow");
|
tracing::info!("starting transfer policy flow");
|
||||||
|
|
||||||
let policy_str = format!("pk2wsh({:?})", dave.public_key);
|
let policy_str = format!("addr(bc1qgw6xanldsz959z45y4dszehx4xkuzf7nfhya8x)");
|
||||||
|
|
||||||
let policy = policy::Concrete::<bdk::bitcoin::PublicKey>::from_str(&policy_str)
|
let policy = policy::Concrete::<bdk::bitcoin::PublicKey>::from_str(&policy_str)
|
||||||
.expect("policy compilation failed")
|
.expect("policy compilation failed")
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ impl Htlc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn to_miniscript_descriptor(&self) -> Wsh<bdk::bitcoin::PublicKey> {
|
pub(crate) fn to_miniscript_descriptor(&self) -> Wsh<String> {
|
||||||
let htlc_descriptor = Wsh::new(
|
let htlc_descriptor = Wsh::new(
|
||||||
self.to_miniscript_policy()
|
self.to_miniscript_policy()
|
||||||
.compile()
|
.compile()
|
||||||
@@ -46,8 +46,8 @@ impl Htlc {
|
|||||||
htlc_descriptor
|
htlc_descriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_miniscript_policy(&self) -> Concrete<bdk::bitcoin::PublicKey> {
|
fn to_miniscript_policy(&self) -> Concrete<String> {
|
||||||
Concrete::<bdk::bitcoin::PublicKey>::from_str(&format!(
|
Concrete::<String>::from_str(&format!(
|
||||||
"or(10@and(sha256({secret_hash}),pk({redeem_identity})),1@and(older({expiry}),pk({refund_identity})))",
|
"or(10@and(sha256({secret_hash}),pk({redeem_identity})),1@and(older({expiry}),pk({refund_identity})))",
|
||||||
secret_hash = self.hashlock,
|
secret_hash = self.hashlock,
|
||||||
redeem_identity = self.redeem_identity,
|
redeem_identity = self.redeem_identity,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub(crate) enum Commands {
|
|||||||
BtcTransfer {},
|
BtcTransfer {},
|
||||||
|
|
||||||
/// transfers bitcoin but this time uses a Miniscript policy
|
/// transfers bitcoin but this time uses a Miniscript policy
|
||||||
BtcTransferPolicy {},
|
BtcPolicyTransfer {},
|
||||||
|
|
||||||
/// sets up a Bitcoin HTLC
|
/// sets up a Bitcoin HTLC
|
||||||
BtcHtlc {},
|
BtcHtlc {},
|
||||||
|
|||||||
Reference in New Issue
Block a user