Skip to content

Commit ef8c048

Browse files
committed
Add PsbtInputExt::update_with_descriptor
This populates all relevant fields in a PSBT input according to a descriptor. Includes previously not yet implemented logic for populating bip32_derivation and tap_key_origins. Also optionally checks the witness_utxo and non_witness_utxo. I renamed "PsbtExt::update_desc" to "PsbtExt::update_inp_with_descriptor" which calls update_with_descriptor internally but retrieves the vout for the input for the non_witness_utxo check automatically.
1 parent d8cc633 commit ef8c048

File tree

2 files changed

+461
-116
lines changed

2 files changed

+461
-116
lines changed

src/descriptor/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,19 @@ pub enum DescriptorType {
259259
Tr,
260260
}
261261

262+
impl DescriptorType {
263+
/// Whether this is a segwit descriptor.
264+
///
265+
/// Returns true whether it is "native" segwit or "wrapped" p2sh segwit
266+
pub fn is_segwit(&self) -> bool {
267+
use self::DescriptorType::*;
268+
match self {
269+
Wpkh | ShWpkh | Wsh | ShWsh | ShWshSortedMulti | WshSortedMulti | Tr => true,
270+
_ => false,
271+
}
272+
}
273+
}
274+
262275
impl<Pk: MiniscriptKey> Descriptor<Pk> {
263276
// Keys
264277

0 commit comments

Comments
 (0)