[descriptor] Fix pk_h() in the descriptor!() macro
				
					
				
			Instead of accepting just a `DescriptorPublicKey` it now accepts anything that implements `IntoDescriptorKey` like `pk_k()` does.
This commit is contained in:
		
							parent
							
								
									b500cfe4e5
								
							
						
					
					
						commit
						e3dd755396
					
				| @ -571,8 +571,9 @@ macro_rules! fragment { | ||||
|     ( pk ( $key:expr ) ) => ({ | ||||
|         $crate::fragment!(c:pk_k ( $key )) | ||||
|     }); | ||||
|     ( pk_h ( $key_hash:expr ) ) => ({ | ||||
|         $crate::impl_leaf_opcode_value!(PkH, $key_hash) | ||||
|     ( pk_h ( $key:expr ) ) => ({ | ||||
|         let secp = $crate::bitcoin::secp256k1::Secp256k1::new(); | ||||
|         $crate::keys::make_pkh($key, &secp) | ||||
|     }); | ||||
|     ( after ( $value:expr ) ) => ({ | ||||
|         $crate::impl_leaf_opcode_value!(After, $value) | ||||
|  | ||||
| @ -753,6 +753,20 @@ pub fn make_pk<Pk: IntoDescriptorKey<Ctx>, Ctx: ScriptContext>( | ||||
|     Ok((minisc, key_map, valid_networks)) | ||||
| } | ||||
| 
 | ||||
| // Used internally by `bdk::fragment!` to build `pk_h()` fragments
 | ||||
| #[doc(hidden)] | ||||
| pub fn make_pkh<Pk: IntoDescriptorKey<Ctx>, Ctx: ScriptContext>( | ||||
|     descriptor_key: Pk, | ||||
|     secp: &SecpCtx, | ||||
| ) -> Result<(Miniscript<DescriptorPublicKey, Ctx>, KeyMap, ValidNetworks), DescriptorError> { | ||||
|     let (key, key_map, valid_networks) = descriptor_key.into_descriptor_key()?.extract(secp)?; | ||||
|     let minisc = Miniscript::from_ast(Terminal::PkH(key))?; | ||||
| 
 | ||||
|     minisc.check_minsicript()?; | ||||
| 
 | ||||
|     Ok((minisc, key_map, valid_networks)) | ||||
| } | ||||
| 
 | ||||
| // Used internally by `bdk::fragment!` to build `multi()` fragments
 | ||||
| #[doc(hidden)] | ||||
| pub fn make_multi<Pk: IntoDescriptorKey<Ctx>, Ctx: ScriptContext>( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user