X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fscript.rs;h=218b482769aeee3859fbd2422fc19a0e29010629;hb=28d33ff9e03b7e3a0cd7ba3bc59f1303b3903f88;hp=00ad48bb1e31c07cf695f52282ea2b746cf05455;hpb=e635db0da31841e8a8ac5c5450c8f595541a6ced;p=rust-lightning diff --git a/lightning/src/ln/script.rs b/lightning/src/ln/script.rs index 00ad48bb..218b4827 100644 --- a/lightning/src/ln/script.rs +++ b/lightning/src/ln/script.rs @@ -4,7 +4,7 @@ use bitcoin::blockdata::opcodes::all::OP_PUSHBYTES_0 as SEGWIT_V0; use bitcoin::blockdata::script::{Builder, Script}; use bitcoin::hashes::Hash; use bitcoin::hash_types::{WPubkeyHash, WScriptHash}; -use bitcoin::secp256k1::key::PublicKey; +use bitcoin::secp256k1::PublicKey; use ln::features::InitFeatures; use ln::msgs::DecodeError; @@ -17,11 +17,11 @@ use io; /// A script pubkey for shutting down a channel as defined by [BOLT #2]. /// /// [BOLT #2]: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct ShutdownScript(ShutdownScriptImpl); /// An error occurring when converting from [`Script`] to [`ShutdownScript`]. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct InvalidShutdownScript { /// The script that did not meet the requirements from [BOLT #2]. /// @@ -29,7 +29,7 @@ pub struct InvalidShutdownScript { pub script: Script } -#[derive(Clone)] +#[derive(Clone, PartialEq)] enum ShutdownScriptImpl { /// [`PublicKey`] used to form a P2WPKH script pubkey. Used to support backward-compatible /// serialization. @@ -68,12 +68,12 @@ impl ShutdownScript { /// Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. pub fn new_p2wpkh(pubkey_hash: &WPubkeyHash) -> Self { - Self(ShutdownScriptImpl::Bolt2(Script::new_v0_wpkh(pubkey_hash))) + Self(ShutdownScriptImpl::Bolt2(Script::new_v0_p2wpkh(pubkey_hash))) } /// Generates a P2WSH script pubkey from the given [`WScriptHash`]. pub fn new_p2wsh(script_hash: &WScriptHash) -> Self { - Self(ShutdownScriptImpl::Bolt2(Script::new_v0_wsh(script_hash))) + Self(ShutdownScriptImpl::Bolt2(Script::new_v0_p2wsh(script_hash))) } /// Generates a witness script pubkey from the given segwit version and program. @@ -156,7 +156,7 @@ impl Into