Add From<Address> for ScriptBuf

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

Fix: #1457
This commit is contained in:
Tobin C. Harding 2023-01-26 10:28:40 +11:00
parent 2a052acadf
commit 5f86b3091c
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
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 {