]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #143 from TheBlueMatt/2018-08-announcement_sigs_erroraction
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Mon, 3 Sep 2018 21:44:57 +0000 (17:44 -0400)
committerGitHub <noreply@github.com>
Mon, 3 Sep 2018 21:44:57 +0000 (17:44 -0400)
Ensure handle_announcement_signatures always has a ErrorAction

1  2 
src/ln/channelmanager.rs

index b1d81695b40d8d2cf13dcb39a037f44783a2c7a9,b2f2347b4989086b4b07b5ad621bff024fee2389..dfe246d547f6c1321c7302e1427d04623c38218f
@@@ -475,9 -474,10 +474,9 @@@ impl ChannelManager 
  
        // can only fail if an intermediary hop has an invalid public key or session_priv is invalid
        #[inline]
-       fn construct_onion_keys_callback<T: secp256k1::Signing, FType: FnMut(SharedSecret, [u8; 32], PublicKey, &RouteHop)> (secp_ctx: &Secp256k1<T>, route: &Route, session_priv: &SecretKey, mut callback: FType) -> Result<(), HandleError> {
+       fn construct_onion_keys_callback<T: secp256k1::Signing, FType: FnMut(SharedSecret, [u8; 32], PublicKey, &RouteHop)> (secp_ctx: &Secp256k1<T>, route: &Route, session_priv: &SecretKey, mut callback: FType) -> Result<(), secp256k1::Error> {
                let mut blinded_priv = session_priv.clone();
                let mut blinded_pub = PublicKey::from_secret_key(secp_ctx, &blinded_priv);
 -              let mut first_iteration = true;
  
                for hop in route.hops.iter() {
                        let shared_secret = SharedSecret::new(secp_ctx, &hop.pubkey, &blinded_priv);
                        let mut blinding_factor = [0u8; 32];
                        sha.result(&mut blinding_factor);
  
 -                      if first_iteration {
 -                              blinded_pub = PublicKey::from_secret_key(secp_ctx, &blinded_priv);
 -                              first_iteration = false;
 -                      }
                        let ephemeral_pubkey = blinded_pub;
  
-                       secp_call!(blinded_priv.mul_assign(secp_ctx, &secp_call!(SecretKey::from_slice(secp_ctx, &blinding_factor))));
+                       blinded_priv.mul_assign(secp_ctx, &SecretKey::from_slice(secp_ctx, &blinding_factor)?)?;
                        blinded_pub = PublicKey::from_secret_key(secp_ctx, &blinded_priv);
  
                        callback(shared_secret, blinding_factor, ephemeral_pubkey, hop);