File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -261,14 +261,15 @@ pub enum DescriptorType {
261
261
}
262
262
263
263
impl DescriptorType {
264
- /// Whether this is a segwit descriptor.
264
+ /// Returns the segwit version implied by the descriptor type .
265
265
///
266
- /// Returns true whether it is "native" segwit or "wrapped" p2sh segwit
267
- pub fn is_segwit ( & self ) -> bool {
266
+ /// This will return `Some(0)` whether it is "native" segwitv0 or "wrapped" p2sh segwit.
267
+ pub fn segwit_version ( & self ) -> Option < u8 > {
268
268
use self :: DescriptorType :: * ;
269
269
match self {
270
- Wpkh | ShWpkh | Wsh | ShWsh | ShWshSortedMulti | WshSortedMulti | Tr => true ,
271
- Bare | Sh | Pkh | ShSortedMulti => false ,
270
+ Tr => Some ( 1 ) ,
271
+ Wpkh | ShWpkh | Wsh | ShWsh | ShWshSortedMulti | WshSortedMulti => Some ( 0 ) ,
272
+ Bare | Sh | Pkh | ShSortedMulti => None ,
272
273
}
273
274
}
274
275
}
Original file line number Diff line number Diff line change @@ -730,14 +730,14 @@ impl PsbtExt for Psbt {
730
730
let expected_spk = {
731
731
match ( & input. witness_utxo , & input. non_witness_utxo ) {
732
732
( Some ( witness_utxo) , None ) => {
733
- if desc_type. is_segwit ( ) {
733
+ if desc_type. segwit_version ( ) . is_some ( ) {
734
734
witness_utxo. script_pubkey . clone ( )
735
735
} else {
736
736
return Err ( UtxoUpdateError :: UtxoCheck ) ;
737
737
}
738
738
}
739
739
( None , Some ( non_witness_utxo) ) => {
740
- if desc_type. is_segwit ( ) {
740
+ if desc_type. segwit_version ( ) . is_some ( ) {
741
741
return Err ( UtxoUpdateError :: UtxoCheck ) ;
742
742
}
743
743
You can’t perform that action at this time.
0 commit comments