mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-12-22 13:05:35 +00:00
comments
This commit is contained in:
@ -16,7 +16,7 @@ impl ActiveOffer {
|
|||||||
|
|
||||||
let (bond, mut musig_data, payout_address) =
|
let (bond, mut musig_data, payout_address) =
|
||||||
trading_wallet.trade_onchain_assembly(&offer_conditions, maker_config)?;
|
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,
|
&maker_config.robosats_robohash_hex,
|
||||||
&bond,
|
&bond,
|
||||||
&mut musig_data,
|
&mut musig_data,
|
||||||
|
|||||||
@ -45,7 +45,7 @@ pub fn run_taker(taker_config: &TraderSettings) -> Result<()> {
|
|||||||
let selected_offer: &PublicOffer = available_offers.ask_user_to_select()?;
|
let selected_offer: &PublicOffer = available_offers.ask_user_to_select()?;
|
||||||
let accepted_offer = ActiveOffer::take(&wallet, taker_config, selected_offer)?;
|
let accepted_offer = ActiveOffer::take(&wallet, taker_config, selected_offer)?;
|
||||||
|
|
||||||
accepted_offer.wait_on_maker();
|
// accepted_offer.wait_on_maker();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use bdk::electrum_client::Request;
|
use bdk::electrum_client::Request;
|
||||||
|
|
||||||
use crate::communication::api::{OfferPsbtRequest, RequestOfferPsbt};
|
use crate::communication::api::OfferPsbtRequest;
|
||||||
|
|
||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -10,7 +10,9 @@ impl ActiveOffer {
|
|||||||
trading_wallet: &TradingWallet,
|
trading_wallet: &TradingWallet,
|
||||||
taker_config: &TraderSettings,
|
taker_config: &TraderSettings,
|
||||||
offer: &PublicOffer,
|
offer: &PublicOffer,
|
||||||
) -> Result<ActiveOffer> {
|
) -> Result<()> {
|
||||||
|
// return Ok(Active offer)
|
||||||
|
|
||||||
// fetching the bond requirements for the requested Offer (amount, locking address)
|
// fetching the bond requirements for the requested Offer (amount, locking address)
|
||||||
let bond_conditions: BondRequirementResponse = offer.request_bond(taker_config)?;
|
let bond_conditions: BondRequirementResponse = offer.request_bond(taker_config)?;
|
||||||
|
|
||||||
@ -28,6 +30,12 @@ impl ActiveOffer {
|
|||||||
)?;
|
)?;
|
||||||
let escrow_contract_psbt =
|
let escrow_contract_psbt =
|
||||||
OfferPsbtRequest::taker_request(offer, bond_submission_request, taker_config)?;
|
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<()> {
|
pub fn wait_on_maker(&self) -> Result<()> {
|
||||||
|
|||||||
@ -71,4 +71,11 @@ impl TradingWallet {
|
|||||||
|
|
||||||
Ok((bond, musig_data, payout_address))
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user