Merge rust-bitcoin/rust-bitcoin#1312: Add `Script::builder` convenience function

2bae74688e Add `Script::builder` convenience function (Casey Rodarmor)

Pull request description:

  Add a convenience function to `Script` to create a new builder, so that `Builder` doesn't need to be imported. This is a pretty common pattern in Rust for types which have associated builders.

ACKs for top commit:
  sanket1729:
    reACK 2bae74688e
  apoelstra:
    ACK 2bae74688e

Tree-SHA512: 8ae8e6bbd2f078d2bd1727296633ee8beb0af2ebf5d333f24a1bacf6993f86a1f860cfe7f5ec91236d1b30eeb5df53719df4841f462a19ff86a63a037889f17c
This commit is contained in:
Andrew Poelstra 2022-10-08 13:21:11 +00:00
commit b6e3028ccf
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 5 additions and 0 deletions

View File

@ -354,6 +354,11 @@ impl Script {
/// Creates a new empty script. /// Creates a new empty script.
pub fn new() -> Script { Script(vec![].into_boxed_slice()) } pub fn new() -> Script { Script(vec![].into_boxed_slice()) }
/// Creates a new script builder
pub fn builder() -> Builder {
Builder::new()
}
/// Generates P2PK-type of scriptPubkey. /// Generates P2PK-type of scriptPubkey.
pub fn new_p2pk(pubkey: &PublicKey) -> Script { pub fn new_p2pk(pubkey: &PublicKey) -> Script {
Builder::new() Builder::new()