Reduce logging when signing transactions

1. We can generalize the signing interface by passing a PSBT in
instead of the `TxLock` transaction.
2. Knowing the transaction ID of a transaction that we are about
to sign is not very useful. Instead, it is much more useful to know
what failed. Hence we add a `.context` to the call of `sign_and_finalize`.
3. In case the signing succeeds, we will immediately broadcast it
afterwards. The new broadcasting interface will tell us that we broadcasted
the "lock" transaction.
This commit is contained in:
Thomas Eizinger 2021-03-02 12:53:40 +11:00
parent 8c9b087e39
commit 3ad9516188
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
2 changed files with 12 additions and 10 deletions

View file

@ -13,7 +13,7 @@ use crate::{
CROSS_CURVE_PROOF_SYSTEM,
},
};
use anyhow::{anyhow, bail, Result};
use anyhow::{anyhow, bail, Context, Result};
use ecdsa_fun::{
adaptor::{Adaptor, HashTranscript},
nonce::Deterministic,
@ -269,9 +269,12 @@ impl State2 {
}
pub async fn lock_btc(self, bitcoin_wallet: &bitcoin::Wallet) -> Result<State3> {
let signed_tx_lock = bitcoin_wallet.sign_tx_lock(self.tx_lock.clone()).await?;
let signed_tx = bitcoin_wallet
.sign_and_finalize(self.tx_lock.clone().into())
.await
.context("failed to sign Bitcoin lock transaction")?;
let _ = bitcoin_wallet.broadcast(signed_tx_lock, "lock").await?;
let _ = bitcoin_wallet.broadcast(signed_tx, "lock").await?;
Ok(State3 {
A: self.A,