@@ -76,18 +76,6 @@ pub type KeyMap = HashMap<DescriptorPublicKey, DescriptorSecretKey>;
7676// because of traits cannot know underlying generic of Self.
7777// Thus, we must implement additional trait for translate function
7878pub trait DescriptorTrait < Pk : MiniscriptKey > {
79- /// Computes the scriptSig that will be in place for an unsigned
80- /// input spending an output with this descriptor. For pre-segwit
81- /// descriptors, which use the scriptSig for signatures, this
82- /// returns the empty script.
83- ///
84- /// This is used in Segwit transactions to produce an unsigned
85- /// transaction whose txid will not change during signing (since
86- /// only the witness data will change).
87- fn unsigned_script_sig ( & self ) -> Script
88- where
89- Pk : ToPublicKey ;
90-
9179 /// Computes the "witness script" of the descriptor, i.e. the underlying
9280 /// script before any hashing is done. For `Bare`, `Pkh` and `Wpkh` this
9381 /// is the scriptPubkey; for `ShWpkh` and `Sh` this is the redeemScript;
@@ -423,6 +411,24 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
423411 Descriptor :: Tr ( ref tr) => tr. script_pubkey ( ) ,
424412 }
425413 }
414+
415+ /// Computes the scriptSig that will be in place for an unsigned input
416+ /// spending an output with this descriptor. For pre-segwit descriptors,
417+ /// which use the scriptSig for signatures, this returns the empty script.
418+ ///
419+ /// This is used in Segwit transactions to produce an unsigned transaction
420+ /// whose txid will not change during signing (since only the witness data
421+ /// will change).
422+ pub fn unsigned_script_sig ( & self ) -> Script {
423+ match * self {
424+ Descriptor :: Bare ( _) => Script :: new ( ) ,
425+ Descriptor :: Pkh ( _) => Script :: new ( ) ,
426+ Descriptor :: Wpkh ( _) => Script :: new ( ) ,
427+ Descriptor :: Wsh ( _) => Script :: new ( ) ,
428+ Descriptor :: Sh ( ref sh) => sh. unsigned_script_sig ( ) ,
429+ Descriptor :: Tr ( _) => Script :: new ( ) ,
430+ }
431+ }
426432}
427433
428434impl < P , Q > TranslatePk < P , Q > for Descriptor < P >
@@ -456,28 +462,6 @@ where
456462}
457463
458464impl < Pk : MiniscriptKey > DescriptorTrait < Pk > for Descriptor < Pk > {
459- /// Computes the scriptSig that will be in place for an unsigned
460- /// input spending an output with this descriptor. For pre-segwit
461- /// descriptors, which use the scriptSig for signatures, this
462- /// returns the empty script.
463- ///
464- /// This is used in Segwit transactions to produce an unsigned
465- /// transaction whose txid will not change during signing (since
466- /// only the witness data will change).
467- fn unsigned_script_sig ( & self ) -> Script
468- where
469- Pk : ToPublicKey ,
470- {
471- match * self {
472- Descriptor :: Bare ( ref bare) => bare. unsigned_script_sig ( ) ,
473- Descriptor :: Pkh ( ref pkh) => pkh. unsigned_script_sig ( ) ,
474- Descriptor :: Wpkh ( ref wpkh) => wpkh. unsigned_script_sig ( ) ,
475- Descriptor :: Wsh ( ref wsh) => wsh. unsigned_script_sig ( ) ,
476- Descriptor :: Sh ( ref sh) => sh. unsigned_script_sig ( ) ,
477- Descriptor :: Tr ( ref tr) => tr. unsigned_script_sig ( ) ,
478- }
479- }
480-
481465 /// Computes the "witness script" of the descriptor, i.e. the underlying
482466 /// script before any hashing is done. For `Bare`, `Pkh` and `Wpkh` this
483467 /// is the scriptPubkey; for `ShWpkh` and `Sh` this is the redeemScript;
0 commit comments