Merge rust-bitcoin/rust-bitcoin#1592: Add `From<Address>` for `ScriptBuf`

5f86b3091c Add From<Address> for ScriptBuf (Tobin C. Harding)

Pull request description:

  Add an implementation of `From<Address> for ScriptBuf` that calls through to `address.script_pubkey` (which calls
  `address.payload.script_pubkey()`).

  Fix: #1457

ACKs for top commit:
  apoelstra:
    ACK 5f86b3091c
  Kixunil:
    ACK 5f86b3091c

Tree-SHA512: 8a45f292578765b345863946b276607d561b9bc75f6b9bb97f48b32d503143e234aedb658997db802c87289576361ec9ee6cb31fe3bbccfc06cc2fdabc7c41bb
This commit is contained in:
Andrew Poelstra 2023-02-12 20:35:50 +00:00
commit c4e78661fd
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 6 additions and 0 deletions

View File

@ -1014,6 +1014,12 @@ impl Address<NetworkUnchecked> {
} }
} }
impl From<Address> for script::ScriptBuf {
fn from(a: Address) -> Self {
a.script_pubkey()
}
}
// Alternate formatting `{:#}` is used to return uppercase version of bech32 addresses which should // Alternate formatting `{:#}` is used to return uppercase version of bech32 addresses which should
// be used in QR codes, see [`Address::to_qr_uri`]. // be used in QR codes, see [`Address::to_qr_uri`].
impl fmt::Display for Address { impl fmt::Display for Address {