Skip to content

Commit

Permalink
rename total_fee -> qrc20_payment_fee and minor changes in z_coin
Browse files Browse the repository at this point in the history
  • Loading branch information
borngraced committed May 12, 2024
1 parent 817a479 commit d26490f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions mm2src/coins/qrc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,10 +1408,10 @@ impl MmCoin for Qrc20Coin {
.await?
};

let total_fee = erc20_payment_fee.fee + sender_refund_fee.fee;
let qrc20_payment_fee = erc20_payment_fee.fee + sender_refund_fee.fee;
Ok(TradeFee {
coin: self.platform.clone(),
amount: total_fee.into(),
amount: qrc20_payment_fee.into(),
paid_from_trading_vol: false,
tx_size: sender_refund_fee.tx_size,
})
Expand Down
17 changes: 8 additions & 9 deletions mm2src/coins/z_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::utxo::rpc_clients::{ElectrumRpcRequest, UnspentInfo, UtxoRpcClientEnu
use crate::utxo::utxo_builder::UtxoCoinBuildError;
use crate::utxo::utxo_builder::{UtxoCoinBuilder, UtxoCoinBuilderCommonOps, UtxoFieldsWithGlobalHDBuilder,
UtxoFieldsWithHardwareWalletBuilder, UtxoFieldsWithIguanaSecretBuilder};
use crate::utxo::utxo_common::{addresses_from_script, big_decimal_from_sat, big_decimal_from_sat_unsigned,
payment_script, PreImageTradeFeeResult};
use crate::utxo::utxo_common::{big_decimal_from_sat, big_decimal_from_sat_unsigned, payment_script,
PreImageTradeFeeResult};
use crate::utxo::{sat_from_big_decimal, utxo_common, AdditionalTxData, AddrFromStrError, Address, BroadcastTxErr,
FeePolicy, GetUtxoListOps, HistoryUtxoTx, HistoryUtxoTxMap, HtlcSpendFeeResult, MatureUnspentList,
RecentlySpentOutPointsGuard, UtxoActivationParams, UtxoAddressFormat, UtxoArc, UtxoCoinFields,
Expand Down Expand Up @@ -463,16 +463,13 @@ impl ZCoin {
.await?
.tx_result?;

let mut tx_bytes = Vec::with_capacity(1024);
tx.write(&mut tx_bytes).expect("Write should not fail");

let additional_data = AdditionalTxData {
received_by_me,
spent_by_me: sat_from_big_decimal(&total_input_amount, self.decimals())?,
fee_amount: sat_from_big_decimal(&tx_fee, self.decimals())?,
unused_change: 0,
kmd_rewards: None,
tx_size: tx_bytes.len() as u64,
tx_size: tx.tx_hex().len() as u64,
};

Ok((tx, additional_data, sync_guard))
Expand Down Expand Up @@ -535,7 +532,9 @@ impl ZCoin {

if let Some(spent_output) = prev_tx.vout.get(input.prevout.n() as usize) {
transparent_input_amount += spent_output.value;
if let Ok(addresses) = addresses_from_script(self, &spent_output.script_pubkey.0.clone().into()) {
if let Ok(addresses) =
utxo_common::addresses_from_script(self, &spent_output.script_pubkey.0.clone().into())
{
from.extend(addresses.into_iter().map(|a| a.to_string()));
}
}
Expand All @@ -548,7 +547,7 @@ impl ZCoin {

let mut to = HashSet::new();
for out in z_tx.vout.iter() {
if let Ok(addresses) = addresses_from_script(self, &out.script_pubkey.0.clone().into()) {
if let Ok(addresses) = utxo_common::addresses_from_script(self, &out.script_pubkey.0.clone().into()) {
to.extend(addresses.into_iter().map(|a| a.to_string()));
}
}
Expand Down Expand Up @@ -1834,7 +1833,7 @@ impl UtxoCommonOps for ZCoin {
}

fn addresses_from_script(&self, script: &Script) -> Result<Vec<Address>, String> {
addresses_from_script(self, script)
utxo_common::addresses_from_script(self, script)
}

fn denominate_satoshis(&self, satoshi: i64) -> f64 { utxo_common::denominate_satoshis(&self.utxo_arc, satoshi) }
Expand Down

0 comments on commit d26490f

Please sign in to comment.