Unify logging of broadcasted transactions

We eliminate unnecessary layers of indirection for broadcasting logic
and force our callers to provide us with the `kind` of transaction
that we are publishing.

Eventually, we can replace this string with some type-system magic
we can derive the name from the actual transaction. For now, we just
require the caller to duplicate this information because it is faster
and good enough TM.
This commit is contained in:
Thomas Eizinger 2021-03-02 12:29:11 +11:00
parent 3a503bf95f
commit 8c9b087e39
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
4 changed files with 44 additions and 66 deletions

View file

@ -271,8 +271,7 @@ 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?;
tracing::debug!("locking BTC in transaction {}", self.tx_lock.txid());
let _ = bitcoin_wallet.broadcast(signed_tx_lock).await?;
let _ = bitcoin_wallet.broadcast(signed_tx_lock, "lock").await?;
Ok(State3 {
A: self.A,
@ -475,7 +474,8 @@ impl State4 {
tx_cancel",
);
let tx_id = bitcoin_wallet.broadcast(tx_cancel).await?;
let tx_id = bitcoin_wallet.broadcast(tx_cancel, "cancel").await?;
Ok(tx_id)
}
@ -544,7 +544,7 @@ impl State4 {
let signed_tx_refund =
tx_refund.add_signatures((self.A, sig_a), (self.b.public(), sig_b))?;
let txid = bitcoin_wallet.broadcast(signed_tx_refund).await?;
let txid = bitcoin_wallet.broadcast(signed_tx_refund, "refund").await?;
bitcoin_wallet
.wait_for_transaction_finality(txid, execution_params)