projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
25a6a77
)
f - Define method for legacy format rather than using From
author
Jeffrey Czyz
<jkczyz@gmail.com>
Fri, 30 Jul 2021 23:13:20 +0000
(18:13 -0500)
committer
Jeffrey Czyz
<jkczyz@gmail.com>
Sat, 31 Jul 2021 03:49:30 +0000
(22:49 -0500)
lightning/src/ln/script.rs
patch
|
blob
|
history
diff --git
a/lightning/src/ln/script.rs
b/lightning/src/ln/script.rs
index 69b09e958d9f08507529f4da890710b585a77d97..c2987f7393ff5d90e10de8229de1869af456d325 100644
(file)
--- 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 ln::features::InitFeatures;
-use std::convert::From;
use std::convert::TryFrom;
/// A script pubkey for shutting down a channel as defined by [BOLT #2].
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 {
}
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)))
/// 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<PublicKey> for ShutdownScript {
- fn from(pubkey: PublicKey) -> Self {
- Self(ShutdownScriptImpl::Legacy(pubkey))
- }
-}
-
impl TryFrom<Script> for ShutdownScript {
type Error = InvalidShutdownScript;
impl TryFrom<Script> for ShutdownScript {
type Error = InvalidShutdownScript;
@@
-138,7
+136,7
@@
mod shutdown_script_tests {
let pubkey_hash = pubkey.wpubkey_hash().unwrap();
let p2wpkh_script = Script::new_v0_wpkh(&pubkey_hash);
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);
}
assert_eq!(shutdown_script.into_inner(), p2wpkh_script);
}