fix errors

This commit is contained in:
fbock
2024-08-06 18:29:12 +02:00
parent 9b5749d721
commit 6cb138484c
2 changed files with 18 additions and 5 deletions

View File

@ -127,7 +127,10 @@ async fn submit_escrow_psbt(
Err(RequestError::PsbtAlreadySubmitted) => {
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
Err(RequestError::PsbtInvalid) => Ok(StatusCode::NOT_ACCEPTABLE.into_response()),
Err(RequestError::PsbtInvalid(e)) => {
warn!("Invalid PSBT: {e}");
Ok(StatusCode::NOT_ACCEPTABLE.into_response())
}
_ => Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response()),
// Err(RequestError::NotFound) => {
// info!("Offer for escrow psbt not found");
@ -187,6 +190,10 @@ async fn submit_obligation_confirmation(
error!("Database error fetching obligation confirmation: {e}");
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
_ => {
error!("Unknown error handling obligation confirmation");
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
}
}
@ -212,6 +219,10 @@ async fn request_escrow(
error!("Database error fetching obligation confirmation: {e}");
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
_ => {
error!("Unknown error handling request_escrow()");
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
}
}
@ -240,6 +251,10 @@ async fn poll_final_payout(
error!("Database error fetching final payout: {e}");
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
_ => {
error!("Unknown error handling poll_final_payout()");
Ok(StatusCode::INTERNAL_SERVER_ERROR.into_response())
}
}
}

View File

@ -1,11 +1,10 @@
use super::*;
use bdk::{
bitcoin::psbt::Input,
bitcoin::psbt::PartiallySignedTransaction,
descriptor::Descriptor,
miniscript::{descriptor::TapTree, policy::Concrete, Tap},
SignOptions,
};
use bitcoin::psbt::PartiallySignedTransaction;
use musig2::{secp256k1::PublicKey as MuSig2PubKey, KeyAggContext};
#[derive(Debug)]
@ -237,13 +236,12 @@ impl<D: bdk::database::BatchDatabase> CoordinatorWallet<D> {
let mut maker_psbt = PartiallySignedTransaction::from_str(signed_maker_psbt_hex)?;
let taker_psbt = PartiallySignedTransaction::from_str(signed_taker_psbt_hex)?;
maker_psbt.combine(&taker_psbt)?;
maker_psbt.combine(taker_psbt)?;
let wallet = self.wallet.lock().await;
match wallet.finalize_psbt(&mut maker_psbt, SignOptions::default()) {
Ok(true) => {
let tx = maker_psbt.extract_tx();
let tx_hex = tx.to_string();
self.backend.broadcast(&tx)?;
info!("Escrow transaction broadcasted: {}", tx.txid());
Ok(())