mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-19 01:03:30 +00:00
working on wrong input amount calculation
This commit is contained in:
@ -15,8 +15,28 @@ pub async fn process_order(
|
|||||||
let wallet = &coordinator.coordinator_wallet;
|
let wallet = &coordinator.coordinator_wallet;
|
||||||
let database = &coordinator.coordinator_db;
|
let database = &coordinator.coordinator_db;
|
||||||
|
|
||||||
let locking_amount_sat = offer.amount_satoshi * u64::from(offer.bond_ratio) / 100;
|
// the client also uses this amount to select inputs for the escrow psbt, this could be separated
|
||||||
|
// to make the required bond amount lower without causing the client to return too small inputs
|
||||||
|
// 5000 is the abs tx fee used in the escrow psbt per trader
|
||||||
|
panic!("This is borked");
|
||||||
|
let coordinator_feerate = (coordinator.coordinator_wallet.coordinator_feerate
|
||||||
|
* offer.amount_satoshi as f64) as u64
|
||||||
|
/ 100;
|
||||||
|
let locking_amount_sat = match offer.is_buy_order {
|
||||||
|
true => {
|
||||||
|
5000 + coordinator_feerate + offer.amount_satoshi * u64::from(offer.bond_ratio) / 100
|
||||||
|
}
|
||||||
|
false => {
|
||||||
|
(offer.amount_satoshi * u64::from(offer.bond_ratio) / 100)
|
||||||
|
+ offer.amount_satoshi
|
||||||
|
+ 5000 + coordinator_feerate
|
||||||
|
}
|
||||||
|
};
|
||||||
|
trace!(
|
||||||
|
"Offer amount: {}, Locking amount: {}",
|
||||||
|
offer.amount_satoshi,
|
||||||
|
locking_amount_sat
|
||||||
|
);
|
||||||
let bond_requirements = BondRequirementResponse {
|
let bond_requirements = BondRequirementResponse {
|
||||||
bond_address: wallet.get_new_address().await?,
|
bond_address: wallet.get_new_address().await?,
|
||||||
locking_amount_sat,
|
locking_amount_sat,
|
||||||
|
@ -159,6 +159,12 @@ impl<D: bdk::database::BatchDatabase> CoordinatorWallet<D> {
|
|||||||
// upfront and substract the fee from the change outputs (10k == ~30/sat vbyte)
|
// upfront and substract the fee from the change outputs (10k == ~30/sat vbyte)
|
||||||
let tx_fee_abs = 10000;
|
let tx_fee_abs = 10000;
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Escrow amounts: maker: {}, fee: {}, input sum: {}",
|
||||||
|
escrow_amount_maker_sat,
|
||||||
|
escrow_fee_sat_per_participant,
|
||||||
|
maker_psbt_input_data.input_sum()?
|
||||||
|
);
|
||||||
let change_amount_maker = maker_psbt_input_data.input_sum()?
|
let change_amount_maker = maker_psbt_input_data.input_sum()?
|
||||||
- (escrow_amount_maker_sat + escrow_fee_sat_per_participant + tx_fee_abs / 2);
|
- (escrow_amount_maker_sat + escrow_fee_sat_per_participant + tx_fee_abs / 2);
|
||||||
let change_amount_taker = taker_psbt_input_data.input_sum()?
|
let change_amount_taker = taker_psbt_input_data.input_sum()?
|
||||||
|
@ -55,7 +55,7 @@ impl ActiveOffer {
|
|||||||
// returns the PSBT of the escrow trade transaction we have to validate, sign and return
|
// returns the PSBT of the escrow trade transaction we have to validate, sign and return
|
||||||
pub fn wait_until_taken(&self, trader_config: &TraderSettings) -> Result<OfferTakenResponse> {
|
pub fn wait_until_taken(&self, trader_config: &TraderSettings) -> Result<OfferTakenResponse> {
|
||||||
loop {
|
loop {
|
||||||
thread::sleep(Duration::from_secs(10));
|
thread::sleep(Duration::from_secs(2));
|
||||||
if let Some(offer_taken_response) = OfferTakenResponse::check(self, trader_config)? {
|
if let Some(offer_taken_response) = OfferTakenResponse::check(self, trader_config)? {
|
||||||
return Ok(offer_taken_response);
|
return Ok(offer_taken_response);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user