lib/peatio/bitgo/wallet.rb in peatio-bitgo-2.6.6 vs lib/peatio/bitgo/wallet.rb in peatio-bitgo-2.6.7

- old
+ new

@@ -84,22 +84,35 @@ }.compact) end def create_eth_transaction(transaction, options = {}) amount = convert_to_base_unit(transaction.amount) - hop = true unless options.slice(:erc20_contract_address).present? + hop = options.slice(:erc20_contract_address).present? ? false : true + fee_estimate = fee_estimate(amount.to_s, hop) + + if transaction.options.present? + options[:gas_price] = transaction.options[:gas_price] + else + options[:gas_price] = fee_estimate['minGasPrice'].to_i + end + txid = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", { address: transaction.to_address.to_s, amount: amount.to_s, walletPassphrase: bitgo_wallet_passphrase, gas: options.fetch(:gas_limit).to_i, gasPrice: options.fetch(:gas_price).to_i, hop: hop }.compact).fetch('txid') transaction.hash = normalize_txid(txid) + transaction.options = options transaction + end + + def fee_estimate(amount, hop) + client.rest_api(:get, "#{erc20_currency_id}/tx/fee", {amount: amount, hop: hop}) end def load_balance! if @currency.fetch(:options).slice(:erc20_contract_address).present? load_erc20_balance!