-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from isocolsky/feat/estimatefee
Feat/estimatefee
- Loading branch information
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var Utils = require('../models/Utils'), | ||
common = require('./common'); | ||
|
||
exports.estimateFee = function(req, res) { | ||
|
||
var nbBlocks = +req.query.nbBlocks || 2; | ||
var utilsObject = new Utils(); | ||
|
||
var returnJsonp = function(err) { | ||
if (err || !utilsObject) | ||
return common.handleErrors(err, res); | ||
else { | ||
res.jsonp(utilsObject); | ||
} | ||
}; | ||
|
||
utilsObject.estimateFee(nbBlocks, returnJsonp); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
//var imports = require('soop').imports(); | ||
|
||
var bitcore = require('bitcore'); | ||
var RpcClient = bitcore.RpcClient; | ||
var config = require('../../config/config'); | ||
var rpc = new RpcClient(config.bitcoind); | ||
|
||
function Utils() {} | ||
|
||
Utils.prototype.estimateFee = function(n, next) { | ||
var that = this; | ||
|
||
rpc.estimateFee(n, function(err, info) { | ||
if (err) return next(err); | ||
|
||
that.feePerKB = info.result; | ||
return next(); | ||
}); | ||
}; | ||
|
||
module.exports = require('soop')(Utils); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters