From 633f7329fc7df3015a00e87cb08a06b2d4973707 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Fri, 30 Jul 2021 18:13:20 -0500 Subject: [PATCH] f - Define method for legacy format rather than using From --- lightning/src/ln/script.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lightning/src/ln/script.rs b/lightning/src/ln/script.rs index 69b09e95..c2987f73 100644 --- a/lightning/src/ln/script.rs +++ b/lightning/src/ln/script.rs @@ -9,7 +9,6 @@ use bitcoin::secp256k1::key::PublicKey; 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]. @@ -31,6 +30,11 @@ enum ShutdownScriptImpl { } 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))) @@ -67,12 +71,6 @@ impl ShutdownScript { } } -impl From for ShutdownScript { - fn from(pubkey: PublicKey) -> Self { - Self(ShutdownScriptImpl::Legacy(pubkey)) - } -} - impl TryFrom