Browse Source

add feerates info to /wallet

use-env-var-docker
kenshin-samourai 4 years ago
parent
commit
2dca047f79
  1. 11
      lib/wallet/wallet-info.js
  2. 3
      lib/wallet/wallet-service.js

11
lib/wallet/wallet-info.js

@ -7,6 +7,7 @@
const db = require('../db/mysql-db-wrapper')
const util = require('../util')
const rpcLatestBlock = require('../bitcoind-rpc/latest-block')
const rpcFees = require('../bitcoind-rpc/fees')
const addrService = require('../bitcoin/addresses-service')
const HdAccountInfo = require('./hd-account-info')
const AddressInfo = require('./address-info')
@ -31,6 +32,7 @@ class WalletInfo {
}
this.info = {
fees: {},
latestBlock: {
height: rpcLatestBlock.height,
hash: rpcLatestBlock.hash,
@ -159,6 +161,14 @@ class WalletInfo {
this.nTx = nbTxs
}
/**
* Loads tinfo about the fee rates
* @returns {Promise}
*/
async loadFeesInfo() {
this.info.fees = await rpcFees.getFees()
}
/**
* Loads the list of unspent outputs for this wallet
* @returns {Promise}
@ -295,6 +305,7 @@ class WalletInfo {
final_balance: this.wallet.finalBalance
},
info: {
fees: this.info.fees,
latest_block: this.info.latestBlock
},
addresses: this.addresses.map(a => a.toPojo()),

3
lib/wallet/wallet-service.js

@ -77,6 +77,8 @@ class WalletService {
await walletInfo.loadAddressesInfo()
// Load the most recent transactions
await walletInfo.loadTransactions(0, null, true)
// Load feerates
await walletInfo.loadFeesInfo()
// Postprocessing
await walletInfo.postProcessAddresses()
await walletInfo.postProcessHdAccounts()
@ -181,6 +183,7 @@ class WalletService {
delete ret['n_tx']
delete ret['unspent_outputs']
delete ret['info']['fees']
ret.addresses = ret.addresses.map(x => {
delete x['derivation']

Loading…
Cancel
Save