File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -261,14 +261,15 @@ pub enum DescriptorType {
261261}
262262
263263impl DescriptorType {
264- /// Whether this is a segwit descriptor.
264+ /// Returns the segwit version implied by the descriptor type .
265265 ///
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 > {
268268 use self :: DescriptorType :: * ;
269269 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 ,
272273 }
273274 }
274275}
Original file line number Diff line number Diff line change @@ -730,14 +730,14 @@ impl PsbtExt for Psbt {
730730 let expected_spk = {
731731 match ( & input. witness_utxo , & input. non_witness_utxo ) {
732732 ( Some ( witness_utxo) , None ) => {
733- if desc_type. is_segwit ( ) {
733+ if desc_type. segwit_version ( ) . is_some ( ) {
734734 witness_utxo. script_pubkey . clone ( )
735735 } else {
736736 return Err ( UtxoUpdateError :: UtxoCheck ) ;
737737 }
738738 }
739739 ( None , Some ( non_witness_utxo) ) => {
740- if desc_type. is_segwit ( ) {
740+ if desc_type. segwit_version ( ) . is_some ( ) {
741741 return Err ( UtxoUpdateError :: UtxoCheck ) ;
742742 }
743743
You can’t perform that action at this time.
0 commit comments