mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-20 17:53:44 +00:00
finish cooperative psbt assembly with pseudo escrow output
This commit is contained in:
@ -209,16 +209,12 @@ pub async fn fetch_escrow_confirmation_status(
|
|||||||
Err(e) => return Err(FetchEscrowConfirmationError::Database(e.to_string())),
|
Err(e) => return Err(FetchEscrowConfirmationError::Database(e.to_string())),
|
||||||
}
|
}
|
||||||
|
|
||||||
if match database
|
match database
|
||||||
.fetch_escrow_tx_confirmation_status(&payload.offer_id_hex)
|
.fetch_escrow_tx_confirmation_status(&payload.offer_id_hex)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(status) => status,
|
Ok(status) => Ok(status),
|
||||||
Err(e) => return Err(FetchEscrowConfirmationError::Database(e.to_string())),
|
Err(e) => return Err(FetchEscrowConfirmationError::Database(e.to_string())),
|
||||||
} {
|
|
||||||
Ok(true)
|
|
||||||
} else {
|
|
||||||
Err(FetchEscrowConfirmationError::NotFound)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +816,8 @@ impl CoordinatorDB {
|
|||||||
let is_buy_order: bool = 1 == row.get::<i64, _>("is_buy_order");
|
let is_buy_order: bool = 1 == row.get::<i64, _>("is_buy_order");
|
||||||
let bond_amount_sat: u64 = row.get("bond_amount_sat");
|
let bond_amount_sat: u64 = row.get("bond_amount_sat");
|
||||||
|
|
||||||
let escrow_fee_per_participant: u64 = (amount_sat as f64 * coordinator_feerate) as u64;
|
let escrow_fee_per_participant: u64 =
|
||||||
|
(amount_sat as f64 * (coordinator_feerate / 100.0)) as u64;
|
||||||
|
|
||||||
let (escrow_amount_maker_sat, escrow_amount_taker_sat) = if is_buy_order {
|
let (escrow_amount_maker_sat, escrow_amount_taker_sat) = if is_buy_order {
|
||||||
(amount_sat + bond_amount_sat, bond_amount_sat)
|
(amount_sat + bond_amount_sat, bond_amount_sat)
|
||||||
|
@ -233,7 +233,7 @@ impl IsOfferReadyRequest {
|
|||||||
.send()?;
|
.send()?;
|
||||||
if res.status() == 200 {
|
if res.status() == 200 {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else if res.status() != 204 {
|
} else if res.status() != 202 {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
"Requesting offer status when waiting on other party failed: {}",
|
"Requesting offer status when waiting on other party failed: {}",
|
||||||
res.status()
|
res.status()
|
||||||
|
@ -180,9 +180,9 @@ impl TradingWallet {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn sign_escrow_psbt(&self, escrow_psbt: &mut PartiallySignedTransaction) -> Result<&Self> {
|
pub fn sign_escrow_psbt(&self, escrow_psbt: &mut PartiallySignedTransaction) -> Result<&Self> {
|
||||||
// do not finalize as the psbt will be finalized by the coordinator
|
// we need to finalize here too to make finalizing on the coordinator side work
|
||||||
let sign_options = SignOptions {
|
let sign_options = SignOptions {
|
||||||
try_finalize: false,
|
try_finalize: true,
|
||||||
..SignOptions::default()
|
..SignOptions::default()
|
||||||
};
|
};
|
||||||
let _ = self.wallet.sign(escrow_psbt, sign_options)?;
|
let _ = self.wallet.sign(escrow_psbt, sign_options)?;
|
||||||
|
Reference in New Issue
Block a user