flocore-node/lib/services/fee/index.js
2017-07-25 18:29:49 -04:00

51 lines
955 B
JavaScript

'use strict';
var BaseService = require('../../service');
var inherits = require('util').inherits;
var BitcoreRPC = require('bitcoind-rpc');
var FeeService = function(options) {
this._config = options.rpc || {
user: 'bitcoin',
pass: 'local321',
host: 'localhost',
protocol: 'http',
port: 8332
};
BaseService.call(this, options);
};
inherits(FeeService, BaseService);
FeeService.dependencies = [];
FeeService.prototype.start = function() {
return this.node.network.port - 1;
};
FeeService.prototype.start = function(callback) {
callback();
};
FeeService.prototype.stop = function(callback) {
callback();
};
FeeService.prototype.getAPIMethods = function() {
return [
['estimateFee', this, this.estimateFee, 1]
];
};
FeeService.prototype.estimateFee = function(blocks, callback) {
var client = new BitcoreRPC(this._config);
client.estimateFee(blocks || 4, callback);
};
module.exports = FeeService;