Skip to content

Commit 3374e11

Browse files
committed
fixup! Add segwit_version to DescriptorType
1 parent e85b99c commit 3374e11

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/descriptor/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use std::{
3131
};
3232

3333
use bitcoin::blockdata::witness::Witness;
34+
use bitcoin::util::address::WitnessVersion;
3435
use bitcoin::{self, secp256k1, Script};
3536

3637
use self::checksum::verify_checksum;
@@ -263,12 +264,14 @@ pub enum DescriptorType {
263264
impl DescriptorType {
264265
/// Returns the segwit version implied by the descriptor type.
265266
///
266-
/// This will return `Some(0)` whether it is "native" segwitv0 or "wrapped" p2sh segwit.
267-
pub fn segwit_version(&self) -> Option<u8> {
267+
/// This will return `Some(WitnessVersion::V0)` whether it is "native" segwitv0 or "wrapped" p2sh segwit.
268+
pub fn segwit_version(&self) -> Option<WitnessVersion> {
268269
use self::DescriptorType::*;
269270
match self {
270-
Tr => Some(1),
271-
Wpkh | ShWpkh | Wsh | ShWsh | ShWshSortedMulti | WshSortedMulti => Some(0),
271+
Tr => Some(WitnessVersion::V1),
272+
Wpkh | ShWpkh | Wsh | ShWsh | ShWshSortedMulti | WshSortedMulti => {
273+
Some(WitnessVersion::V0)
274+
}
272275
Bare | Sh | Pkh | ShSortedMulti => None,
273276
}
274277
}

0 commit comments

Comments
 (0)