use ln::features::InitFeatures;
-use std::convert::From;
use std::convert::TryFrom;
/// A script pubkey for shutting down a channel as defined by [BOLT #2].
}
impl ShutdownScript {
+ /// Generates a P2WPKH script pubkey from the given [`PublicKey`].
+ pub fn new_p2wpkh_from_pubkey(pubkey: PublicKey) -> Self {
+ Self(ShutdownScriptImpl::Legacy(pubkey))
+ }
+
/// Generates a P2PKH script pubkey from the given [`PubkeyHash`].
pub fn new_p2pkh(pubkey_hash: &PubkeyHash) -> Self {
Self(ShutdownScriptImpl::Bolt2(Script::new_p2pkh(pubkey_hash)))
}
}
-impl From<PublicKey> for ShutdownScript {
- fn from(pubkey: PublicKey) -> Self {
- Self(ShutdownScriptImpl::Legacy(pubkey))
- }
-}
-
impl TryFrom<Script> for ShutdownScript {
type Error = InvalidShutdownScript;
let pubkey_hash = pubkey.wpubkey_hash().unwrap();
let p2wpkh_script = Script::new_v0_wpkh(&pubkey_hash);
- let shutdown_script = ShutdownScript::from(pubkey.key);
+ let shutdown_script = ShutdownScript::new_p2wpkh_from_pubkey(pubkey.key);
assert_eq!(shutdown_script.into_inner(), p2wpkh_script);
}