Skip to content

Commit dee518a

Browse files
author
Antoine Riard
committed
keysinterface: replace Result match with map_err
1 parent 180a115 commit dee518a

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -641,15 +641,9 @@ impl BaseSign for InMemorySigner {
641641
}
642642

643643
fn sign_justice_revoked_output(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
644-
let revocation_key = match chan_utils::derive_private_revocation_key(&secp_ctx, &per_commitment_key, &self.revocation_base_key) {
645-
Ok(revocation_key) => revocation_key,
646-
Err(_) => return Err(())
647-
};
644+
let revocation_key = chan_utils::derive_private_revocation_key(&secp_ctx, &per_commitment_key, &self.revocation_base_key).map_err(|_| ())?;
648645
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
649-
let revocation_pubkey = match chan_utils::derive_public_revocation_key(&secp_ctx, &per_commitment_point, &self.pubkeys().revocation_basepoint) {
650-
Ok(revocation_pubkey) => revocation_pubkey,
651-
Err(_) => return Err(())
652-
};
646+
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx, &per_commitment_point, &self.pubkeys().revocation_basepoint).map_err(|_| ())?;
653647
let witness_script = {
654648
let counterparty_delayedpubkey = match chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.counterparty_pubkeys().delayed_payment_basepoint) {
655649
Ok(counterparty_delayedpubkey) => counterparty_delayedpubkey,
@@ -663,15 +657,9 @@ impl BaseSign for InMemorySigner {
663657
}
664658

665659
fn sign_justice_revoked_htlc(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
666-
let revocation_key = match chan_utils::derive_private_revocation_key(&secp_ctx, &per_commitment_key, &self.revocation_base_key) {
667-
Ok(revocation_key) => revocation_key,
668-
Err(_) => return Err(())
669-
};
660+
let revocation_key = chan_utils::derive_private_revocation_key(&secp_ctx, &per_commitment_key, &self.revocation_base_key).map_err(|_| ())?;
670661
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
671-
let revocation_pubkey = match chan_utils::derive_public_revocation_key(&secp_ctx, &per_commitment_point, &self.pubkeys().revocation_basepoint) {
672-
Ok(revocation_pubkey) => revocation_pubkey,
673-
Err(_) => return Err(())
674-
};
662+
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx, &per_commitment_point, &self.pubkeys().revocation_basepoint).map_err(|_| ())?;
675663
let witness_script = {
676664
let counterparty_htlcpubkey = match chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.counterparty_pubkeys().htlc_basepoint) {
677665
Ok(counterparty_htlcpubkey) => counterparty_htlcpubkey,

0 commit comments

Comments
 (0)