From 047f990d050158cfe0de4fe5e4f501ff1ac7a8f0 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 7 Jan 2021 14:44:31 +1100 Subject: [PATCH] Improve error reporting on signature verification --- swap/src/protocol/alice/state.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index 292fe03d..b25f0720 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, Context, Result}; use ecdsa_fun::{ adaptor::{Adaptor, EncryptedSignature}, nonce::Deterministic, @@ -254,10 +254,12 @@ impl State2 { pub fn receive(self, msg: bob::Message2) -> Result { let tx_cancel = bitcoin::TxCancel::new(&self.tx_lock, self.cancel_timelock, self.a.public(), self.B); - bitcoin::verify_sig(&self.B, &tx_cancel.digest(), &msg.tx_cancel_sig)?; + bitcoin::verify_sig(&self.B, &tx_cancel.digest(), &msg.tx_cancel_sig) + .context("Failed to verify cancel transaction")?; let tx_punish = bitcoin::TxPunish::new(&tx_cancel, &self.punish_address, self.punish_timelock); - bitcoin::verify_sig(&self.B, &tx_punish.digest(), &msg.tx_punish_sig)?; + bitcoin::verify_sig(&self.B, &tx_punish.digest(), &msg.tx_punish_sig) + .context("Failed to verify Punish Transaction")?; Ok(State3 { a: self.a,