Skip to content

Commit bc534ca

Browse files
committed
rustfmt: Run on lightning/src/ln/script.rs
1 parent 2b5ccaa commit bc534ca

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

lightning/src/ln/script.rs

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//! Abstractions for scripts used in the Lightning Network.
22
3-
use bitcoin::{WitnessProgram, WPubkeyHash, WScriptHash};
3+
use bitcoin::hashes::Hash;
44
use bitcoin::opcodes::all::OP_PUSHBYTES_0 as SEGWIT_V0;
55
use bitcoin::script::{Script, ScriptBuf};
6-
use bitcoin::hashes::Hash;
76
use bitcoin::secp256k1::PublicKey;
7+
use bitcoin::{WPubkeyHash, WScriptHash, WitnessProgram};
88

99
use crate::ln::channelmanager;
10-
use crate::types::features::InitFeatures;
1110
use crate::ln::msgs::DecodeError;
11+
use crate::types::features::InitFeatures;
1212
use crate::util::config::UserConfig;
1313
use crate::util::ser::{Readable, Writeable, Writer};
1414

@@ -29,7 +29,7 @@ pub struct InvalidShutdownScript {
2929
/// The script that did not meet the requirements from [BOLT #2].
3030
///
3131
/// [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md
32-
pub script: ScriptBuf
32+
pub script: ScriptBuf,
3333
}
3434

3535
#[derive(Clone, PartialEq, Eq)]
@@ -83,7 +83,9 @@ impl ShutdownScript {
8383
/// # Errors
8484
///
8585
/// This function may return an error if `program` is invalid for the segwit `version`.
86-
pub fn new_witness_program(witness_program: &WitnessProgram) -> Result<Self, InvalidShutdownScript> {
86+
pub fn new_witness_program(
87+
witness_program: &WitnessProgram,
88+
) -> Result<Self, InvalidShutdownScript> {
8789
Self::try_from(ScriptBuf::new_witness_program(witness_program))
8890
}
8991

@@ -151,14 +153,15 @@ impl TryFrom<(ScriptBuf, &InitFeatures)> for ShutdownScript {
151153
impl Into<ScriptBuf> for ShutdownScript {
152154
fn into(self) -> ScriptBuf {
153155
match self.0 {
154-
ShutdownScriptImpl::Legacy(pubkey) =>
155-
ScriptBuf::new_p2wpkh(&WPubkeyHash::hash(&pubkey.serialize())),
156+
ShutdownScriptImpl::Legacy(pubkey) => {
157+
ScriptBuf::new_p2wpkh(&WPubkeyHash::hash(&pubkey.serialize()))
158+
},
156159
ShutdownScriptImpl::Bolt2(script_pubkey) => script_pubkey,
157160
}
158161
}
159162
}
160163

161-
impl core::fmt::Display for ShutdownScript{
164+
impl core::fmt::Display for ShutdownScript {
162165
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
163166
match &self.0 {
164167
ShutdownScriptImpl::Legacy(_) => self.clone().into_inner().fmt(f),
@@ -171,18 +174,22 @@ impl core::fmt::Display for ShutdownScript{
171174
mod shutdown_script_tests {
172175
use super::ShutdownScript;
173176

174-
use bitcoin::{WitnessProgram, WitnessVersion};
175177
use bitcoin::opcodes;
176178
use bitcoin::script::{Builder, ScriptBuf};
177179
use bitcoin::secp256k1::Secp256k1;
178180
use bitcoin::secp256k1::{PublicKey, SecretKey};
181+
use bitcoin::{WitnessProgram, WitnessVersion};
179182

180-
use crate::types::features::InitFeatures;
181183
use crate::prelude::*;
184+
use crate::types::features::InitFeatures;
182185

183186
fn pubkey() -> bitcoin::key::PublicKey {
184187
let secp_ctx = Secp256k1::signing_only();
185-
let secret_key = SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]).unwrap();
188+
let secret_key = SecretKey::from_slice(&[
189+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
190+
0, 0, 1,
191+
])
192+
.unwrap();
186193
bitcoin::key::PublicKey::new(PublicKey::from_secret_key(&secp_ctx, &secret_key))
187194
}
188195

0 commit comments

Comments
 (0)