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 @@ -731,14 +731,14 @@ impl PsbtExt for Psbt {
731731 let expected_spk = {
732732 match ( & input. witness_utxo , & input. non_witness_utxo ) {
733733 ( Some ( witness_utxo) , None ) => {
734- if desc_type. is_segwit ( ) {
734+ if desc_type. segwit_version ( ) . is_some ( ) {
735735 witness_utxo. script_pubkey . clone ( )
736736 } else {
737737 return Err ( UtxoUpdateError :: UtxoCheck ) ;
738738 }
739739 }
740740 ( None , Some ( non_witness_utxo) ) => {
741- if desc_type. is_segwit ( ) {
741+ if desc_type. segwit_version ( ) . is_some ( ) {
742742 return Err ( UtxoUpdateError :: UtxoCheck ) ;
743743 }
744744
You can’t perform that action at this time.
0 commit comments