Log miner fee (#237)

* Get miner fee written in some wallet plugins

* Return txid and fee for geth. possible problem with txid (zero hash on pending transaction)

* bitgo fee return

* Wallet apis fees save in cryptoAtoms
This commit is contained in:
Davit Abulashvili 2019-01-04 20:34:50 +04:00 committed by Josh Harvey
parent fa69956963
commit 163473a7ee
9 changed files with 64 additions and 4 deletions

View file

@ -6,6 +6,7 @@ const hdkey = require('ethereumjs-wallet/hdkey')
const Tx = require('ethereumjs-tx')
const util = require('ethereumjs-util')
const pify = require('pify')
const BN = require('../../../bn')
const NAME = 'geth'
exports.SUPPORTED_MODULES = ['wallet']
@ -47,6 +48,16 @@ function isStrictAddress (cryptoCode, toAddress) {
function sendCoins (account, toAddress, cryptoAtoms, cryptoCode) {
return generateTx(toAddress, defaultWallet(account), cryptoAtoms, false)
.then(pify(web3.eth.sendRawTransaction))
.then(r => {
return pify(web3.eth.getTransactionByHash)(r.result)
.then(tx => {
if (!tx) return { txid: r.result }
const fee = BN(tx.gas).multipliedBy(BN(tx.gasPrice)).round()
return { txid: r.result, fee }
})
})
}
function checkCryptoCode (cryptoCode) {