From 2dca047f794b9818dcb6c643299239caf669f6ef Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Sun, 19 Jul 2020 15:54:38 +0200 Subject: [PATCH] add feerates info to /wallet --- lib/wallet/wallet-info.js | 11 +++++++++++ lib/wallet/wallet-service.js | 3 +++ 2 files changed, 14 insertions(+) diff --git a/lib/wallet/wallet-info.js b/lib/wallet/wallet-info.js index 54693c4..f010461 100644 --- a/lib/wallet/wallet-info.js +++ b/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()), diff --git a/lib/wallet/wallet-service.js b/lib/wallet/wallet-service.js index 64ca4bc..d77adbc 100644 --- a/lib/wallet/wallet-service.js +++ b/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']