Skip to content

Commit c1495ef

Browse files
committed
rustfmt: Run on util/message_signing.rs
1 parent bd28ad0 commit c1495ef

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

lightning/src/util/message_signing.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn sigrec_decode(sig_rec: Vec<u8>) -> Result<RecoverableSignature, Error> {
4747

4848
match RecoveryId::from_i32(rid) {
4949
Ok(x) => RecoverableSignature::from_compact(rsig, x),
50-
Err(e) => Err(e)
50+
Err(e) => Err(e),
5151
}
5252
}
5353

@@ -63,18 +63,18 @@ pub fn sign(msg: &[u8], sk: &SecretKey) -> String {
6363
}
6464

6565
/// Recovers the PublicKey of the signer of the message given the message and the signature.
66-
pub fn recover_pk(msg: &[u8], sig: &str) -> Result<PublicKey, Error> {
66+
pub fn recover_pk(msg: &[u8], sig: &str) -> Result<PublicKey, Error> {
6767
let secp_ctx = Secp256k1::verification_only();
6868
let msg_hash = sha256d::Hash::hash(&[LN_MESSAGE_PREFIX, msg].concat());
6969

7070
match base32::Alphabet::ZBase32.decode(&sig) {
71-
Ok(sig_rec) => {
72-
match sigrec_decode(sig_rec) {
73-
Ok(sig) => secp_ctx.recover_ecdsa(&Message::from_digest(msg_hash.to_byte_array()), &sig),
74-
Err(e) => Err(e)
75-
}
71+
Ok(sig_rec) => match sigrec_decode(sig_rec) {
72+
Ok(sig) => {
73+
secp_ctx.recover_ecdsa(&Message::from_digest(msg_hash.to_byte_array()), &sig)
74+
},
75+
Err(e) => Err(e),
7676
},
77-
Err(_) => Err(Error::InvalidSignature)
77+
Err(_) => Err(Error::InvalidSignature),
7878
}
7979
}
8080

@@ -83,16 +83,16 @@ pub fn recover_pk(msg: &[u8], sig: &str) -> Result<PublicKey, Error> {
8383
pub fn verify(msg: &[u8], sig: &str, pk: &PublicKey) -> bool {
8484
match recover_pk(msg, sig) {
8585
Ok(x) => x == *pk,
86-
Err(_) => false
86+
Err(_) => false,
8787
}
8888
}
8989

9090
#[cfg(test)]
9191
mod test {
92-
use core::str::FromStr;
93-
use crate::util::message_signing::{sign, recover_pk, verify};
92+
use crate::util::message_signing::{recover_pk, sign, verify};
9493
use bitcoin::secp256k1::constants::ONE;
95-
use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1};
94+
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
95+
use core::str::FromStr;
9696

9797
#[test]
9898
fn test_sign() {
@@ -148,4 +148,3 @@ mod test {
148148
}
149149
}
150150
}
151-

0 commit comments

Comments
 (0)