Module bdk_wallet::descriptor::policy

source ·
Expand description

Descriptor policy

This module implements the logic to extract and represent the spending policies of a descriptor in a more human-readable format.

This is an EXPERIMENTAL feature, API and other major changes are expected.


use bdk_wallet::descriptor::policy::BuildSatisfaction;
let secp = Secp256k1::new();
let desc = "wsh(and_v(v:pk(cV3oCth6zxZ1UVsHLnGothsWNsaoxRhC6aeNi5VbSdFpwUkgkEci),or_d(pk(cVMTy7uebJgvFaSBwcgvwk8qn8xSLc97dKow4MBetjrrahZoimm2),older(12960))))";

let (extended_desc, key_map) = ExtendedDescriptor::parse_descriptor(&secp, desc)?;
println!("{:?}", extended_desc);

let signers = Arc::new(SignersContainer::build(key_map, &extended_desc, &secp));
let policy = extended_desc.extract_policy(&signers, BuildSatisfaction::None, &secp)?;
println!("policy: {}", serde_json::to_string(&policy).unwrap());


  • An extra condition that must be satisfied but that is out of control of the user TODO: use bitcoin::LockTime and bitcoin::Sequence
  • Descriptor spending policy


  • Options to build the satisfaction field in the policy
  • A unique identifier for a key
  • Errors that can happen while extracting and manipulating policies
  • Represent if and how much a policy item is satisfied by the wallet’s descriptor
  • An item that needs to be satisfied

Type Aliases§