Skip to content

Commit b300f4a

Browse files
committed
Refactor ecdsa_sighash_script_code
This method contains duplicate code, for which we already have a method. As such, the code can be simplified. This patch does beg the question 'why are we using hardcoded Network::Bitcoin'?
1 parent c88ea19 commit b300f4a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/descriptor/segwitv0.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,13 @@ impl<Pk: MiniscriptKey + ToPublicKey> Wpkh<Pk> {
380380
self.spk()
381381
}
382382

383-
/// Obtain the pre bip-340 signature script code for this descriptor
384-
/// Non failing verion of [`DescriptorTrait::script_code`] for this descriptor
383+
/// Obtains the pre bip-340 signature script code for this descriptor.
385384
pub fn ecdsa_sighash_script_code(&self) -> Script {
386385
// For SegWit outputs, it is defined by bip-0143 (quoted below) and is different from
387386
// the previous txo's scriptPubKey.
388387
// The item 5:
389388
// - For P2WPKH witness program, the scriptCode is `0x1976a914{20-byte-pubkey-hash}88ac`.
390-
let addr = Address::p2pkh(&self.pk.to_public_key(), Network::Bitcoin);
391-
addr.script_pubkey()
389+
self.addr(Network::Bitcoin).script_pubkey()
392390
}
393391
}
394392

0 commit comments

Comments
 (0)