This commit is contained in:
Felix
2024-06-17 13:53:10 +00:00
parent 228809853f
commit 2758511211
4 changed files with 19 additions and 4 deletions

View File

@ -16,7 +16,7 @@ impl ActiveOffer {
let (bond, mut musig_data, payout_address) =
trading_wallet.trade_onchain_assembly(&offer_conditions, maker_config)?;
let submission_result = BondSubmissionRequest::send(
let submission_result = BondSubmissionRequest::send_maker(
&maker_config.robosats_robohash_hex,
&bond,
&mut musig_data,

View File

@ -45,7 +45,7 @@ pub fn run_taker(taker_config: &TraderSettings) -> Result<()> {
let selected_offer: &PublicOffer = available_offers.ask_user_to_select()?;
let accepted_offer = ActiveOffer::take(&wallet, taker_config, selected_offer)?;
accepted_offer.wait_on_maker();
// accepted_offer.wait_on_maker();
Ok(())
}

View File

@ -1,6 +1,6 @@
use bdk::electrum_client::Request;
use crate::communication::api::{OfferPsbtRequest, RequestOfferPsbt};
use crate::communication::api::OfferPsbtRequest;
use super::utils::*;
use super::*;
@ -10,7 +10,9 @@ impl ActiveOffer {
trading_wallet: &TradingWallet,
taker_config: &TraderSettings,
offer: &PublicOffer,
) -> Result<ActiveOffer> {
) -> Result<()> {
// return Ok(Active offer)
// fetching the bond requirements for the requested Offer (amount, locking address)
let bond_conditions: BondRequirementResponse = offer.request_bond(taker_config)?;
@ -28,6 +30,12 @@ impl ActiveOffer {
)?;
let escrow_contract_psbt =
OfferPsbtRequest::taker_request(offer, bond_submission_request, taker_config)?;
// now we have to verify, sign and submit the escrow psbt again
if !trading_wallet.validate_taker_psbt(&escrow_contract_psbt) {
panic!("taker psbt invalid!");
}
Ok(())
}
pub fn wait_on_maker(&self) -> Result<()> {

View File

@ -71,4 +71,11 @@ impl TradingWallet {
Ok((bond, musig_data, payout_address))
}
// validate that the taker psbt references the correct inputs and amounts
// taker input should be the same as in the previous bond transaction.
// input amount should be the bond amount when buying,
pub fn validate_taker_psbt(&self, psbt: &PartiallySignedTransaction) -> bool {
false
}
}