Skip to content

Commit ce18ba2

Browse files
committed
refactor: remove *SortedMulti variants from DescriptorType
After 01d25c1, these variants no longer serve a purpose since descriptors containing sortedmulti are not handled as a distinct type, but as an underlying Miniscript.
1 parent ddc42c7 commit ce18ba2

3 files changed

Lines changed: 13 additions & 48 deletions

File tree

bitcoind-tests/tests/test_desc.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,7 @@ fn test_plan_satisfy(
501501
let sighash_type = sighash::EcdsaSighashType::All;
502502
let desc_type = derived_desc.desc_type();
503503
let sighash_msg = match desc_type {
504-
DescriptorType::Wsh
505-
| DescriptorType::WshSortedMulti
506-
| DescriptorType::ShWsh
507-
| DescriptorType::ShWshSortedMulti => {
504+
DescriptorType::Wsh | DescriptorType::ShWsh => {
508505
let script_code = derived_desc.script_code().expect("has script_code");
509506
sighash_cache
510507
.p2wsh_signature_hash(0, &script_code, witness_utxo.value, sighash_type)

src/descriptor/mod.rs

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ pub enum DescriptorType {
125125
ShWsh,
126126
/// Sh wrapped Wpkh
127127
ShWpkh,
128-
/// Sh Sorted Multi
129-
ShSortedMulti,
130-
/// Wsh Sorted Multi
131-
WshSortedMulti,
132-
/// Sh Wsh Sorted Multi
133-
ShWshSortedMulti,
134128
/// Tr Descriptor
135129
Tr,
136130
}
@@ -143,10 +137,8 @@ impl DescriptorType {
143137
use self::DescriptorType::*;
144138
match self {
145139
Tr => Some(WitnessVersion::V1),
146-
Wpkh | ShWpkh | Wsh | ShWsh | ShWshSortedMulti | WshSortedMulti => {
147-
Some(WitnessVersion::V0)
148-
}
149-
Bare | Sh | Pkh | ShSortedMulti => None,
140+
Wpkh | ShWpkh | Wsh | ShWsh => Some(WitnessVersion::V0),
141+
Bare | Sh | Pkh => None,
150142
}
151143
}
152144
}
@@ -300,34 +292,16 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
300292
/// Get the [DescriptorType] of [Descriptor]
301293
pub fn desc_type(&self) -> DescriptorType {
302294
match *self {
303-
Descriptor::Bare(ref _bare) => DescriptorType::Bare,
304-
Descriptor::Pkh(ref _pkh) => DescriptorType::Pkh,
305-
Descriptor::Wpkh(ref _wpkh) => DescriptorType::Wpkh,
295+
Descriptor::Bare(..) => DescriptorType::Bare,
296+
Descriptor::Pkh(..) => DescriptorType::Pkh,
297+
Descriptor::Wpkh(..) => DescriptorType::Wpkh,
306298
Descriptor::Sh(ref sh) => match sh.as_inner() {
307-
ShInner::Wsh(ref wsh) => {
308-
if let Terminal::SortedMulti(..) = wsh.as_inner().node {
309-
DescriptorType::ShWshSortedMulti
310-
} else {
311-
DescriptorType::ShWsh
312-
}
313-
}
299+
ShInner::Wsh(..) => DescriptorType::ShWsh,
314300
ShInner::Wpkh(ref _wpkh) => DescriptorType::ShWpkh,
315-
ShInner::Ms(ref ms) => {
316-
if let Terminal::SortedMulti(..) = ms.node {
317-
DescriptorType::ShSortedMulti
318-
} else {
319-
DescriptorType::Sh
320-
}
321-
}
301+
ShInner::Ms(..) => DescriptorType::Sh,
322302
},
323-
Descriptor::Wsh(ref wsh) => {
324-
if let Terminal::SortedMulti(..) = wsh.as_inner().node {
325-
DescriptorType::WshSortedMulti
326-
} else {
327-
DescriptorType::Wsh
328-
}
329-
}
330-
Descriptor::Tr(ref _tr) => DescriptorType::Tr,
303+
Descriptor::Wsh(..) => DescriptorType::Wsh,
304+
Descriptor::Tr(..) => DescriptorType::Tr,
331305
}
332306
}
333307

src/plan.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl Plan {
245245
// scriptSig len (1) + OP_0 (1) + OP_PUSHBYTES_20 (1) + <pk hash> (20)
246246
(_, DescriptorType::ShWpkh) => 1 + 1 + 1 + 20,
247247
// scriptSig len (1) + OP_0 (1) + OP_PUSHBYTES_32 (1) + <script hash> (32)
248-
(_, DescriptorType::ShWsh) | (_, DescriptorType::ShWshSortedMulti) => 1 + 1 + 1 + 32,
248+
(_, DescriptorType::ShWsh) => 1 + 1 + 1 + 32,
249249
// Native Segwit v0 (scriptSig len (1))
250250
_ => 1,
251251
}
@@ -278,10 +278,7 @@ impl Plan {
278278
.ok_or(Error::CouldNotSatisfy)?;
279279

280280
Ok(match self.descriptor.desc_type() {
281-
DescriptorType::Bare
282-
| DescriptorType::Sh
283-
| DescriptorType::Pkh
284-
| DescriptorType::ShSortedMulti => (
281+
DescriptorType::Bare | DescriptorType::Sh | DescriptorType::Pkh => (
285282
vec![],
286283
stack
287284
.into_iter()
@@ -294,10 +291,7 @@ impl Plan {
294291
),
295292
DescriptorType::Wpkh | DescriptorType::Tr => (stack, ScriptBuf::new()),
296293
DescriptorType::ShWpkh => (stack, self.descriptor.unsigned_script_sig()),
297-
DescriptorType::Wsh
298-
| DescriptorType::WshSortedMulti
299-
| DescriptorType::ShWsh
300-
| DescriptorType::ShWshSortedMulti => {
294+
DescriptorType::Wsh | DescriptorType::ShWsh => {
301295
let mut stack = stack;
302296
let witness_script = self
303297
.descriptor

0 commit comments

Comments
 (0)