Fix: Show fee box on Testnet and Liquid.

Use 0.1 sat/vB as minimum liquid fee.
This commit is contained in:
softsimon 2020-09-27 18:12:36 +07:00
parent 3450de774f
commit 3e3dd83243
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
4 changed files with 13 additions and 7 deletions

View File

@ -8,6 +8,7 @@
"DB_DISABLED": false,
"API_ENDPOINT": "/api/v1/",
"ELECTRS_POLL_RATE_MS": 2000,
"LIQUID": true,
"MEMPOOL_REFRESH_RATE_MS": 2000,
"DEFAULT_PROJECTED_BLOCKS_AMOUNT": 8,
"KEEP_BLOCK_AMOUNT": 24,

View File

@ -1,8 +1,11 @@
const config = require('../../mempool-config.json');
import projectedBlocks from './mempool-blocks';
class FeeApi {
constructor() { }
defaultFee = config.LIQUID ? 0.1 : 1;
public getRecommendedFee() {
const pBlocks = projectedBlocks.getMempoolBlocks();
if (!pBlocks.length) {
@ -15,11 +18,11 @@ class FeeApi {
let firstMedianFee = Math.ceil(pBlocks[0].medianFee);
if (pBlocks.length === 1 && pBlocks[0].blockVSize <= 500000) {
firstMedianFee = 1;
firstMedianFee = this.defaultFee;
}
const secondMedianFee = pBlocks[1] ? Math.ceil(pBlocks[1].medianFee) : 1;
const thirdMedianFee = pBlocks[2] ? Math.ceil(pBlocks[2].medianFee) : 1;
const secondMedianFee = pBlocks[1] ? Math.ceil(pBlocks[1].medianFee) : this.defaultFee;
const thirdMedianFee = pBlocks[2] ? Math.ceil(pBlocks[2].medianFee) : this.defaultFee;
return {
'fastestFee': firstMedianFee,

View File

@ -24,6 +24,8 @@ export class FeesBoxComponent implements OnInit {
) { }
ngOnInit(): void {
const defaultFee = this.stateService.network === 'liquid' ? 0.1 : 1;
this.isLoadingWebSocket$ = this.stateService.isLoadingWebSocket$;
this.feeEstimations$ = this.stateService.mempoolBlocks$
.pipe(
@ -32,11 +34,11 @@ export class FeesBoxComponent implements OnInit {
let firstMedianFee = Math.ceil(pBlocks[0].medianFee);
if (pBlocks.length === 1 && pBlocks[0].blockVSize <= 500000) {
firstMedianFee = 1;
firstMedianFee = defaultFee;
}
const secondMedianFee = pBlocks[1] ? Math.ceil(pBlocks[1].medianFee) : 1;
const thirdMedianFee = pBlocks[2] ? Math.ceil(pBlocks[2].medianFee) : 1;
const secondMedianFee = pBlocks[1] ? Math.ceil(pBlocks[1].medianFee) : defaultFee;
const thirdMedianFee = pBlocks[2] ? Math.ceil(pBlocks[2].medianFee) : defaultFee;
return {
'fastestFee': firstMedianFee,

View File

@ -5,7 +5,7 @@
<div class="col mb-4">
<div class="card text-center">
<div class="card-body">
<app-fees-box *ngIf="(network$ | async) === ''" class="d-block"></app-fees-box>
<app-fees-box class="d-block"></app-fees-box>
</div>
</div>
</div>