mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-10-12 13:30:58 -04:00
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:
parent
8c9b087e39
commit
3ad9516188
2 changed files with 12 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
bitcoin::{timelocks::BlockHeight, Address, Amount, Transaction, TxLock},
|
||||
bitcoin::{timelocks::BlockHeight, Address, Amount, Transaction},
|
||||
execution_params::ExecutionParams,
|
||||
};
|
||||
use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid};
|
||||
|
@ -165,16 +165,15 @@ impl Wallet {
|
|||
Ok(txid)
|
||||
}
|
||||
|
||||
pub async fn sign_tx_lock(&self, tx_lock: TxLock) -> Result<Transaction> {
|
||||
let txid = tx_lock.txid();
|
||||
tracing::debug!("signing tx lock: {}", txid);
|
||||
let psbt = PartiallySignedTransaction::from(tx_lock);
|
||||
pub async fn sign_and_finalize(&self, psbt: PartiallySignedTransaction) -> Result<Transaction> {
|
||||
let (signed_psbt, finalized) = self.inner.lock().await.sign(psbt, None)?;
|
||||
|
||||
if !finalized {
|
||||
bail!("Could not finalize TxLock psbt")
|
||||
bail!("PSBT is not finalized")
|
||||
}
|
||||
|
||||
let tx = signed_psbt.extract_tx();
|
||||
tracing::debug!("signed tx lock: {}", txid);
|
||||
|
||||
Ok(tx)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue