mirror of
https://github.com/janoside/btc-rpc-explorer.git
synced 2026-08-13 12:33:13 +02:00
Merge remote-tracking branch 'pointbiz/feature-api-nextblockfees'
...with a few tweaks
This commit is contained in:
commit
34d9269c6c
2 changed files with 33 additions and 23 deletions
|
|
@ -1,5 +1,10 @@
|
|||
This changelog specifically tracks changes to the Public API available at `/api` and is maintained separately from the app CHANGELOG such that it can properly adhere to semantic versioning.
|
||||
|
||||
##### v2.1.0
|
||||
###### Unreleased
|
||||
|
||||
* Changed `/api/mempool/fees` to include more details pertaining to `nextBlock` (nextBlock.smart is where the previous "nextBlock" scalar value used to be)
|
||||
|
||||
##### v2.0.0
|
||||
###### 2023-06-14
|
||||
|
||||
|
|
|
|||
|
|
@ -867,32 +867,37 @@ router.get("/mempool/summary", function(req, res, next) {
|
|||
}).catch(next);
|
||||
});
|
||||
|
||||
router.get("/mempool/fees", function(req, res, next) {
|
||||
let feeConfTargets = [1, 3, 6, 144];
|
||||
coreApi.getSmartFeeEstimates("CONSERVATIVE", feeConfTargets).then(function(rawSmartFeeEstimates){
|
||||
let smartFeeEstimates = {};
|
||||
router.get("/mempool/fees", asyncHandler(async (req, res, next) => {
|
||||
let feeConfTargets = [1, 3, 6, 144];
|
||||
let rawSmartFeeEstimates = await coreApi.getSmartFeeEstimates("CONSERVATIVE", feeConfTargets);
|
||||
let smartFeeEstimates = {};
|
||||
|
||||
for (let i = 0; i < feeConfTargets.length; i++) {
|
||||
let rawSmartFeeEstimate = rawSmartFeeEstimates[i];
|
||||
if (rawSmartFeeEstimate.errors) {
|
||||
smartFeeEstimates[feeConfTargets[i]] = "?";
|
||||
} else {
|
||||
smartFeeEstimates[feeConfTargets[i]] = parseInt(new Decimal(rawSmartFeeEstimate.feerate).times(coinConfig.baseCurrencyUnit.multiplier).dividedBy(1000));
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < feeConfTargets.length; i++) {
|
||||
let rawSmartFeeEstimate = rawSmartFeeEstimates[i];
|
||||
if (rawSmartFeeEstimate.errors) {
|
||||
smartFeeEstimates[feeConfTargets[i]] = "?";
|
||||
let results = {
|
||||
"nextBlock":{"smart":smartFeeEstimates[1]},
|
||||
"30min":smartFeeEstimates[3],
|
||||
"60min":smartFeeEstimates[6],
|
||||
"1day":smartFeeEstimates[144]
|
||||
};
|
||||
|
||||
} else {
|
||||
smartFeeEstimates[feeConfTargets[i]] = parseInt(new Decimal(rawSmartFeeEstimate.feerate).times(coinConfig.baseCurrencyUnit.multiplier).dividedBy(1000));
|
||||
}
|
||||
}
|
||||
|
||||
let results = {
|
||||
"nextBlock":smartFeeEstimates[1],
|
||||
"30min":smartFeeEstimates[3],
|
||||
"60min":smartFeeEstimates[6],
|
||||
"1day":smartFeeEstimates[144]
|
||||
};
|
||||
let nextBlockEstimate = await coreApi.getNextBlockEstimate();
|
||||
if (nextBlockEstimate != undefined && nextBlockEstimate.minFeeRate != undefined) {
|
||||
console.log("abc: " + JSON.stringify(nextBlockEstimate));
|
||||
results.nextBlock.min = parseInt(nextBlockEstimate.minFeeRate);
|
||||
results.nextBlock.max = parseInt(nextBlockEstimate.maxFeeRate);
|
||||
results.nextBlock.median = parseInt(nextBlockEstimate.medianFeeRate);
|
||||
}
|
||||
|
||||
res.json(results);
|
||||
|
||||
}).catch(next);
|
||||
});
|
||||
res.json(results);
|
||||
}));
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue