@@ -69,22 +69,21 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
6969}
7070
7171impl < Pk : MiniscriptKey + ToPublicKey > Bare < Pk > {
72- /// Obtain the corresponding script pubkey for this descriptor
73- /// Non failing verion of [`DescriptorTrait::script_pubkey`] for this descriptor
74- pub fn spk ( & self ) -> Script {
72+ /// Obtains the corresponding script pubkey for this descriptor.
73+ pub fn script_pubkey ( & self ) -> Script {
7574 self . ms . encode ( )
7675 }
7776
7877 /// Obtain the underlying miniscript for this descriptor
7978 /// Non failing verion of [`DescriptorTrait::explicit_script`] for this descriptor
8079 pub fn inner_script ( & self ) -> Script {
81- self . spk ( )
80+ self . script_pubkey ( )
8281 }
8382
8483 /// Obtain the pre bip-340 signature script code for this descriptor
8584 /// Non failing verion of [`DescriptorTrait::script_code`] for this descriptor
8685 pub fn ecdsa_sighash_script_code ( & self ) -> Script {
87- self . spk ( )
86+ self . script_pubkey ( )
8887 }
8988}
9089
@@ -139,13 +138,6 @@ where
139138}
140139
141140impl < Pk : MiniscriptKey > DescriptorTrait < Pk > for Bare < Pk > {
142- fn script_pubkey ( & self ) -> Script
143- where
144- Pk : ToPublicKey ,
145- {
146- self . spk ( )
147- }
148-
149141 fn unsigned_script_sig ( & self ) -> Script
150142 where
151143 Pk : ToPublicKey ,
@@ -249,10 +241,11 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
249241}
250242
251243impl < Pk : MiniscriptKey + ToPublicKey > Pkh < Pk > {
252- /// Obtain the corresponding script pubkey for this descriptor
253- /// Non failing verion of [`DescriptorTrait::script_pubkey`] for this descriptor
254- pub fn spk ( & self ) -> Script {
255- let addr = Address :: p2pkh ( & self . pk . to_public_key ( ) , Network :: Bitcoin ) ;
244+ /// Obtains the corresponding script pubkey for this descriptor.
245+ pub fn script_pubkey ( & self ) -> Script {
246+ // Fine to hard code the `Network` here because we immediately call
247+ // `script_pubkey` which does not use the `network` field of `Address`.
248+ let addr = self . address ( Network :: Bitcoin ) ;
256249 addr. script_pubkey ( )
257250 }
258251
@@ -264,13 +257,13 @@ impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
264257 /// Obtain the underlying miniscript for this descriptor
265258 /// Non failing verion of [`DescriptorTrait::explicit_script`] for this descriptor
266259 pub fn inner_script ( & self ) -> Script {
267- self . spk ( )
260+ self . script_pubkey ( )
268261 }
269262
270263 /// Obtain the pre bip-340 signature script code for this descriptor
271264 /// Non failing verion of [`DescriptorTrait::script_code`] for this descriptor
272265 pub fn ecdsa_sighash_script_code ( & self ) -> Script {
273- self . spk ( )
266+ self . script_pubkey ( )
274267 }
275268}
276269
@@ -333,13 +326,6 @@ where
333326}
334327
335328impl < Pk : MiniscriptKey > DescriptorTrait < Pk > for Pkh < Pk > {
336- fn script_pubkey ( & self ) -> Script
337- where
338- Pk : ToPublicKey ,
339- {
340- self . spk ( )
341- }
342-
343329 fn unsigned_script_sig ( & self ) -> Script
344330 where
345331 Pk : ToPublicKey ,
0 commit comments