Make Address:p2sh_from_hash public
We previously made this function Private and added a comment that doing so was somehow better to remove the footgun of hashing the wrong length script. However in hindsight this was a bad idea and users want the functionality. Make the `Address:p2sh_from_hash` public and document it as we do for `Address::p2sh`.
This commit is contained in:
parent
d0c1eb138c
commit
a3d2d1a184
|
@ -384,8 +384,13 @@ impl Address {
|
||||||
Ok(Address::p2sh_from_hash(hash, network))
|
Ok(Address::p2sh_from_hash(hash, network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is intentionally not public so we enforce script length checks.
|
/// Creates a pay to script hash P2SH address from a script hash.
|
||||||
fn p2sh_from_hash(hash: ScriptHash, network: impl Into<NetworkKind>) -> Address {
|
///
|
||||||
|
/// # Warning
|
||||||
|
///
|
||||||
|
/// The `hash` pre-image (redeem script) must not exceed 520 bytes in length
|
||||||
|
/// otherwise outputs created from the returned address will be un-spendable.
|
||||||
|
pub fn p2sh_from_hash(hash: ScriptHash, network: impl Into<NetworkKind>) -> Address {
|
||||||
Self(AddressInner::P2sh { hash, network: network.into() }, PhantomData)
|
Self(AddressInner::P2sh { hash, network: network.into() }, PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue