Compare commits
	
		
			5 Commits
		
	
	
		
			master
			...
			natsoni/fe
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 4fded37cda | ||
|  | e3c06eb93b | ||
|  | 2664f52a23 | ||
|  | 37030356dd | ||
|  | cfe4228a4c | 
| @ -7,6 +7,7 @@ | |||||||
|     "HTTP_PORT": 8999, |     "HTTP_PORT": 8999, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "POLL_RATE_MS": 2000, |     "POLL_RATE_MS": 2000, | ||||||
|     "CACHE_DIR": "./cache", |     "CACHE_DIR": "./cache", | ||||||
|     "CACHE_ENABLED": true, |     "CACHE_ENABLED": true, | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ | |||||||
|     "UNIX_SOCKET_PATH": "/mempool/socket/mempool-bitcoin-mainnet", |     "UNIX_SOCKET_PATH": "/mempool/socket/mempool-bitcoin-mainnet", | ||||||
|     "SPAWN_CLUSTER_PROCS": 2, |     "SPAWN_CLUSTER_PROCS": 2, | ||||||
|     "API_URL_PREFIX": "__MEMPOOL_API_URL_PREFIX__", |     "API_URL_PREFIX": "__MEMPOOL_API_URL_PREFIX__", | ||||||
|  |     "API_V2_URL_PREFIX": "__MEMPOOL_API_V2_URL_PREFIX__", | ||||||
|     "AUTOMATIC_POOLS_UPDATE": false, |     "AUTOMATIC_POOLS_UPDATE": false, | ||||||
|     "POLL_RATE_MS": 3, |     "POLL_RATE_MS": 3, | ||||||
|     "CACHE_DIR": "__MEMPOOL_CACHE_DIR__", |     "CACHE_DIR": "__MEMPOOL_CACHE_DIR__", | ||||||
|  | |||||||
| @ -23,6 +23,7 @@ describe('Mempool Backend Config', () => { | |||||||
|         UNIX_SOCKET_PATH: '', |         UNIX_SOCKET_PATH: '', | ||||||
|         SPAWN_CLUSTER_PROCS: 0, |         SPAWN_CLUSTER_PROCS: 0, | ||||||
|         API_URL_PREFIX: '/api/v1/', |         API_URL_PREFIX: '/api/v1/', | ||||||
|  |         API_V2_URL_PREFIX: '/api/v2/', | ||||||
|         AUTOMATIC_POOLS_UPDATE: false, |         AUTOMATIC_POOLS_UPDATE: false, | ||||||
|         POLL_RATE_MS: 2000, |         POLL_RATE_MS: 2000, | ||||||
|         CACHE_DIR: './cache', |         CACHE_DIR: './cache', | ||||||
|  | |||||||
| @ -47,6 +47,9 @@ class BitcoinRoutes { | |||||||
|       .post(config.MEMPOOL.API_URL_PREFIX + 'psbt/addparents', this.postPsbtCompletion) |       .post(config.MEMPOOL.API_URL_PREFIX + 'psbt/addparents', this.postPsbtCompletion) | ||||||
|       .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-bulk/:from', this.getBlocksByBulk.bind(this)) |       .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-bulk/:from', this.getBlocksByBulk.bind(this)) | ||||||
|       .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-bulk/:from/:to', this.getBlocksByBulk.bind(this)) |       .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-bulk/:from/:to', this.getBlocksByBulk.bind(this)) | ||||||
|  | 
 | ||||||
|  |       // V2 API
 | ||||||
|  |       .get(config.MEMPOOL.API_V2_URL_PREFIX + 'fees/recommended', this.getRecommendedFeesDecimal) | ||||||
|       ; |       ; | ||||||
| 
 | 
 | ||||||
|       if (config.MEMPOOL.BACKEND !== 'esplora') { |       if (config.MEMPOOL.BACKEND !== 'esplora') { | ||||||
| @ -100,6 +103,16 @@ class BitcoinRoutes { | |||||||
|     res.json(result); |     res.json(result); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   private getRecommendedFeesDecimal(req: Request, res: Response) { | ||||||
|  |     if (!mempool.isInSync()) { | ||||||
|  |       res.statusCode = 503; | ||||||
|  |       res.send('Service Unavailable'); | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     const result = feeApi.getRecommendedFee(true); | ||||||
|  |     res.json(result); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   private getMempoolBlocks(req: Request, res: Response) { |   private getMempoolBlocks(req: Request, res: Response) { | ||||||
|     try { |     try { | ||||||
|       const result = mempoolBlocks.getMempoolBlocks(); |       const result = mempoolBlocks.getMempoolBlocks(); | ||||||
|  | |||||||
| @ -19,10 +19,12 @@ class FeeApi { | |||||||
|   defaultFee = isLiquid ? 0.1 : 1; |   defaultFee = isLiquid ? 0.1 : 1; | ||||||
|   minimumIncrement = isLiquid ? 0.1 : 1; |   minimumIncrement = isLiquid ? 0.1 : 1; | ||||||
| 
 | 
 | ||||||
|   public getRecommendedFee(): RecommendedFees { |   public getRecommendedFee(decimal: boolean = false): RecommendedFees { | ||||||
|     const pBlocks = projectedBlocks.getMempoolBlocks(); |     const pBlocks = projectedBlocks.getMempoolBlocks(); | ||||||
|     const mPool = mempool.getMempoolInfo(); |     const mPool = mempool.getMempoolInfo(); | ||||||
|     const minimumFee = this.roundUpToNearest(mPool.mempoolminfee * 100000, this.minimumIncrement); |     const minimumFee = decimal ?  | ||||||
|  |       this.roundUpToNearestDecimal(mPool.mempoolminfee * 100000) : | ||||||
|  |       this.roundUpToNearest(mPool.mempoolminfee * 100000, this.minimumIncrement); | ||||||
|     const defaultMinFee = Math.max(minimumFee, this.defaultFee); |     const defaultMinFee = Math.max(minimumFee, this.defaultFee); | ||||||
| 
 | 
 | ||||||
|     if (!pBlocks.length) { |     if (!pBlocks.length) { | ||||||
| @ -35,9 +37,9 @@ class FeeApi { | |||||||
|       }; |       }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const firstMedianFee = this.optimizeMedianFee(pBlocks[0], pBlocks[1]); |     const firstMedianFee = this.optimizeMedianFee(pBlocks[0], pBlocks[1], undefined, decimal); | ||||||
|     const secondMedianFee = pBlocks[1] ? this.optimizeMedianFee(pBlocks[1], pBlocks[2], firstMedianFee) : this.defaultFee; |     const secondMedianFee = pBlocks[1] ? this.optimizeMedianFee(pBlocks[1], pBlocks[2], firstMedianFee, decimal) : this.defaultFee; | ||||||
|     const thirdMedianFee = pBlocks[2] ? this.optimizeMedianFee(pBlocks[2], pBlocks[3], secondMedianFee) : this.defaultFee; |     const thirdMedianFee = pBlocks[2] ? this.optimizeMedianFee(pBlocks[2], pBlocks[3], secondMedianFee, decimal) : this.defaultFee; | ||||||
| 
 | 
 | ||||||
|     let fastestFee = Math.max(minimumFee, firstMedianFee); |     let fastestFee = Math.max(minimumFee, firstMedianFee); | ||||||
|     let halfHourFee = Math.max(minimumFee, secondMedianFee); |     let halfHourFee = Math.max(minimumFee, secondMedianFee); | ||||||
| @ -62,7 +64,7 @@ class FeeApi { | |||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private optimizeMedianFee(pBlock: MempoolBlock, nextBlock: MempoolBlock | undefined, previousFee?: number): number { |   private optimizeMedianFee(pBlock: MempoolBlock, nextBlock: MempoolBlock | undefined, previousFee?: number, decimal: boolean = false): number { | ||||||
|     const useFee = previousFee ? (pBlock.medianFee + previousFee) / 2 : pBlock.medianFee; |     const useFee = previousFee ? (pBlock.medianFee + previousFee) / 2 : pBlock.medianFee; | ||||||
|     if (pBlock.blockVSize <= 500000) { |     if (pBlock.blockVSize <= 500000) { | ||||||
|       return this.defaultFee; |       return this.defaultFee; | ||||||
| @ -71,12 +73,18 @@ class FeeApi { | |||||||
|       const multiplier = (pBlock.blockVSize - 500000) / 500000; |       const multiplier = (pBlock.blockVSize - 500000) / 500000; | ||||||
|       return Math.max(Math.round(useFee * multiplier), this.defaultFee); |       return Math.max(Math.round(useFee * multiplier), this.defaultFee); | ||||||
|     } |     } | ||||||
|     return this.roundUpToNearest(useFee, this.minimumIncrement); |     return decimal ? | ||||||
|  |       this.roundUpToNearestDecimal(useFee) : | ||||||
|  |       this.roundUpToNearest(useFee, this.minimumIncrement); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private roundUpToNearest(value: number, nearest: number): number { |   private roundUpToNearest(value: number, nearest: number): number { | ||||||
|     return Math.ceil(value / nearest) * nearest; |     return Math.ceil(value / nearest) * nearest; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   private roundUpToNearestDecimal(value: number): number { | ||||||
|  |     return Number(this.roundUpToNearest(value, 0.1).toFixed(1)); // avoid floating point errors
 | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default new FeeApi(); | export default new FeeApi(); | ||||||
|  | |||||||
| @ -95,7 +95,7 @@ class WebsocketHandler { | |||||||
|       'backendInfo': backendInfo.getBackendInfo(), |       'backendInfo': backendInfo.getBackendInfo(), | ||||||
|       'loadingIndicators': loadingIndicators.getLoadingIndicators(), |       'loadingIndicators': loadingIndicators.getLoadingIndicators(), | ||||||
|       'da': da?.previousTime ? da : undefined, |       'da': da?.previousTime ? da : undefined, | ||||||
|       'fees': feeApi.getRecommendedFee(), |       'fees': feeApi.getRecommendedFee(true), | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -567,7 +567,7 @@ class WebsocketHandler { | |||||||
|     } |     } | ||||||
|     memPool.removeFromSpendMap(deletedTransactions); |     memPool.removeFromSpendMap(deletedTransactions); | ||||||
|     memPool.addToSpendMap(newTransactions); |     memPool.addToSpendMap(newTransactions); | ||||||
|     const recommendedFees = feeApi.getRecommendedFee(); |     const recommendedFees = feeApi.getRecommendedFee(true); | ||||||
| 
 | 
 | ||||||
|     const latestTransactions = memPool.getLatestTransactions(); |     const latestTransactions = memPool.getLatestTransactions(); | ||||||
| 
 | 
 | ||||||
| @ -1048,7 +1048,7 @@ class WebsocketHandler { | |||||||
|     const mBlockDeltas = mempoolBlocks.getMempoolBlockDeltas(); |     const mBlockDeltas = mempoolBlocks.getMempoolBlockDeltas(); | ||||||
| 
 | 
 | ||||||
|     const da = difficultyAdjustment.getDifficultyAdjustment(); |     const da = difficultyAdjustment.getDifficultyAdjustment(); | ||||||
|     const fees = feeApi.getRecommendedFee(); |     const fees = feeApi.getRecommendedFee(true); | ||||||
|     const mempoolInfo = memPool.getMempoolInfo(); |     const mempoolInfo = memPool.getMempoolInfo(); | ||||||
| 
 | 
 | ||||||
|     // pre-compute address transactions
 |     // pre-compute address transactions
 | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ interface IConfig { | |||||||
|     UNIX_SOCKET_PATH: string; |     UNIX_SOCKET_PATH: string; | ||||||
|     SPAWN_CLUSTER_PROCS: number; |     SPAWN_CLUSTER_PROCS: number; | ||||||
|     API_URL_PREFIX: string; |     API_URL_PREFIX: string; | ||||||
|  |     API_V2_URL_PREFIX: string; | ||||||
|     POLL_RATE_MS: number; |     POLL_RATE_MS: number; | ||||||
|     CACHE_DIR: string; |     CACHE_DIR: string; | ||||||
|     CACHE_ENABLED: boolean; |     CACHE_ENABLED: boolean; | ||||||
| @ -172,6 +173,7 @@ const defaults: IConfig = { | |||||||
|     'UNIX_SOCKET_PATH': '', |     'UNIX_SOCKET_PATH': '', | ||||||
|     'SPAWN_CLUSTER_PROCS': 0, |     'SPAWN_CLUSTER_PROCS': 0, | ||||||
|     'API_URL_PREFIX': '/api/v1/', |     'API_URL_PREFIX': '/api/v1/', | ||||||
|  |     'API_V2_URL_PREFIX': '/api/v2/', | ||||||
|     'POLL_RATE_MS': 2000, |     'POLL_RATE_MS': 2000, | ||||||
|     'CACHE_DIR': './cache', |     'CACHE_DIR': './cache', | ||||||
|     'CACHE_ENABLED': true, |     'CACHE_ENABLED': true, | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ | |||||||
|     "SPAWN_CLUSTER_PROCS": __MEMPOOL_SPAWN_CLUSTER_PROCS__, |     "SPAWN_CLUSTER_PROCS": __MEMPOOL_SPAWN_CLUSTER_PROCS__, | ||||||
|     "UNIX_SOCKET_PATH": "__MEMPOOL_UNIX_SOCKET_PATH__", |     "UNIX_SOCKET_PATH": "__MEMPOOL_UNIX_SOCKET_PATH__", | ||||||
|     "API_URL_PREFIX": "__MEMPOOL_API_URL_PREFIX__", |     "API_URL_PREFIX": "__MEMPOOL_API_URL_PREFIX__", | ||||||
|  |     "API_V2_URL_PREFIX": "__MEMPOOL_API_V2_URL_PREFIX__", | ||||||
|     "POLL_RATE_MS": __MEMPOOL_POLL_RATE_MS__, |     "POLL_RATE_MS": __MEMPOOL_POLL_RATE_MS__, | ||||||
|     "CACHE_DIR": "__MEMPOOL_CACHE_DIR__", |     "CACHE_DIR": "__MEMPOOL_CACHE_DIR__", | ||||||
|     "CACHE_ENABLED": __MEMPOOL_CACHE_ENABLED__, |     "CACHE_ENABLED": __MEMPOOL_CACHE_ENABLED__, | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ __MEMPOOL_HTTP_PORT__=${BACKEND_HTTP_PORT:=8999} | |||||||
| __MEMPOOL_SPAWN_CLUSTER_PROCS__=${MEMPOOL_SPAWN_CLUSTER_PROCS:=0} | __MEMPOOL_SPAWN_CLUSTER_PROCS__=${MEMPOOL_SPAWN_CLUSTER_PROCS:=0} | ||||||
| __MEMPOOL_UNIX_SOCKET_PATH__=${MEMPOOL_UNIX_SOCKET_PATH:=""} | __MEMPOOL_UNIX_SOCKET_PATH__=${MEMPOOL_UNIX_SOCKET_PATH:=""} | ||||||
| __MEMPOOL_API_URL_PREFIX__=${MEMPOOL_API_URL_PREFIX:=/api/v1/} | __MEMPOOL_API_URL_PREFIX__=${MEMPOOL_API_URL_PREFIX:=/api/v1/} | ||||||
|  | __MEMPOOL_API_V2_URL_PREFIX__=${MEMPOOL_API_V2_URL_PREFIX:=/api/v2/} | ||||||
| __MEMPOOL_POLL_RATE_MS__=${MEMPOOL_POLL_RATE_MS:=2000} | __MEMPOOL_POLL_RATE_MS__=${MEMPOOL_POLL_RATE_MS:=2000} | ||||||
| __MEMPOOL_CACHE_DIR__=${MEMPOOL_CACHE_DIR:=./cache} | __MEMPOOL_CACHE_DIR__=${MEMPOOL_CACHE_DIR:=./cache} | ||||||
| __MEMPOOL_CACHE_ENABLED__=${MEMPOOL_CACHE_ENABLED:=true} | __MEMPOOL_CACHE_ENABLED__=${MEMPOOL_CACHE_ENABLED:=true} | ||||||
| @ -167,6 +168,7 @@ sed -i "s!__MEMPOOL_HTTP_PORT__!${__MEMPOOL_HTTP_PORT__}!g" mempool-config.json | |||||||
| sed -i "s!__MEMPOOL_SPAWN_CLUSTER_PROCS__!${__MEMPOOL_SPAWN_CLUSTER_PROCS__}!g" mempool-config.json | sed -i "s!__MEMPOOL_SPAWN_CLUSTER_PROCS__!${__MEMPOOL_SPAWN_CLUSTER_PROCS__}!g" mempool-config.json | ||||||
| sed -i "s!__MEMPOOL_UNIX_SOCKET_PATH__!${__MEMPOOL_UNIX_SOCKET_PATH__}!g" mempool-config.json | sed -i "s!__MEMPOOL_UNIX_SOCKET_PATH__!${__MEMPOOL_UNIX_SOCKET_PATH__}!g" mempool-config.json | ||||||
| sed -i "s!__MEMPOOL_API_URL_PREFIX__!${__MEMPOOL_API_URL_PREFIX__}!g" mempool-config.json | sed -i "s!__MEMPOOL_API_URL_PREFIX__!${__MEMPOOL_API_URL_PREFIX__}!g" mempool-config.json | ||||||
|  | sed -i "s!__MEMPOOL_API_V2_URL_PREFIX__!${__MEMPOOL_API_V2_URL_PREFIX__}!g" mempool-config.json | ||||||
| sed -i "s!__MEMPOOL_POLL_RATE_MS__!${__MEMPOOL_POLL_RATE_MS__}!g" mempool-config.json | sed -i "s!__MEMPOOL_POLL_RATE_MS__!${__MEMPOOL_POLL_RATE_MS__}!g" mempool-config.json | ||||||
| sed -i "s!__MEMPOOL_CACHE_DIR__!${__MEMPOOL_CACHE_DIR__}!g" mempool-config.json | sed -i "s!__MEMPOOL_CACHE_DIR__!${__MEMPOOL_CACHE_DIR__}!g" mempool-config.json | ||||||
| sed -i "s!__MEMPOOL_CACHE_ENABLED__!${__MEMPOOL_CACHE_ENABLED__}!g" mempool-config.json | sed -i "s!__MEMPOOL_CACHE_ENABLED__!${__MEMPOOL_CACHE_ENABLED__}!g" mempool-config.json | ||||||
|  | |||||||
| @ -33,6 +33,17 @@ if (configContent && configContent.BASE_MODULE === 'liquid') { | |||||||
|           "^/liquid": "" |           "^/liquid": "" | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       context: ['/liquid/api/v2/**'], | ||||||
|  |       target: `http://127.0.0.1:8999`, | ||||||
|  |       secure: false, | ||||||
|  |       ws: true, | ||||||
|  |       changeOrigin: true, | ||||||
|  |       proxyTimeout: 30000, | ||||||
|  |       pathRewrite: { | ||||||
|  |           "^/liquid": "" | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     { |     { | ||||||
|       context: ['/liquid/api/**'], |       context: ['/liquid/api/**'], | ||||||
|       target: `http://127.0.0.1:3000`, |       target: `http://127.0.0.1:3000`, | ||||||
| @ -54,6 +65,17 @@ if (configContent && configContent.BASE_MODULE === 'liquid') { | |||||||
|           "^/liquidtestnet": "" |           "^/liquidtestnet": "" | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       context: ['/liquidtestnet/api/v2/**'], | ||||||
|  |       target: `http://127.0.0.1:8999`, | ||||||
|  |       secure: false, | ||||||
|  |       ws: true, | ||||||
|  |       changeOrigin: true, | ||||||
|  |       proxyTimeout: 30000, | ||||||
|  |       pathRewrite: { | ||||||
|  |           "^/liquidtestnet": "" | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     { |     { | ||||||
|       context: ['/liquidtestnet/api/**'], |       context: ['/liquidtestnet/api/**'], | ||||||
|       target: `http://127.0.0.1:3000`, |       target: `http://127.0.0.1:3000`, | ||||||
| @ -106,6 +128,14 @@ PROXY_CONFIG.push(...[ | |||||||
|     changeOrigin: true, |     changeOrigin: true, | ||||||
|     proxyTimeout: 30000, |     proxyTimeout: 30000, | ||||||
|   }, |   }, | ||||||
|  |   { | ||||||
|  |     context: ['/api/v2/**'], | ||||||
|  |     target: `http://127.0.0.1:8999`, | ||||||
|  |     secure: false, | ||||||
|  |     ws: true, | ||||||
|  |     changeOrigin: true, | ||||||
|  |     proxyTimeout: 30000, | ||||||
|  |   }, | ||||||
|   { |   { | ||||||
|     context: ['/api/**'], |     context: ['/api/**'], | ||||||
|     target: `http://127.0.0.1:3000`, |     target: `http://127.0.0.1:3000`, | ||||||
|  | |||||||
| @ -33,6 +33,17 @@ if (configContent && configContent.BASE_MODULE === 'liquid') { | |||||||
|           "^/liquid": "" |           "^/liquid": "" | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       context: ['/liquid/api/v2/**'], | ||||||
|  |       target: `http://localhost:8999`, | ||||||
|  |       secure: false, | ||||||
|  |       ws: true, | ||||||
|  |       changeOrigin: true, | ||||||
|  |       proxyTimeout: 30000, | ||||||
|  |       pathRewrite: { | ||||||
|  |           "^/liquid": "" | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     { |     { | ||||||
|       context: ['/liquid/api/**'], |       context: ['/liquid/api/**'], | ||||||
|       target: `http://localhost:8999`, |       target: `http://localhost:8999`, | ||||||
| @ -54,6 +65,17 @@ if (configContent && configContent.BASE_MODULE === 'liquid') { | |||||||
|           "^/liquidtestnet": "" |           "^/liquidtestnet": "" | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       context: ['/liquidtestnet/api/v2/**'], | ||||||
|  |       target: `http://localhost:8999`, | ||||||
|  |       secure: false, | ||||||
|  |       ws: true, | ||||||
|  |       changeOrigin: true, | ||||||
|  |       proxyTimeout: 30000, | ||||||
|  |       pathRewrite: { | ||||||
|  |           "^/liquidtestnet": "" | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     { |     { | ||||||
|       context: ['/liquidtestnet/api/**'], |       context: ['/liquidtestnet/api/**'], | ||||||
|       target: `http://localhost:8999`, |       target: `http://localhost:8999`, | ||||||
| @ -94,6 +116,14 @@ PROXY_CONFIG.push(...[ | |||||||
|     changeOrigin: true, |     changeOrigin: true, | ||||||
|     proxyTimeout: 30000, |     proxyTimeout: 30000, | ||||||
|   }, |   }, | ||||||
|  |   { | ||||||
|  |     context: ['/api/v2/**'], | ||||||
|  |     target: `http://localhost:8999`, | ||||||
|  |     secure: false, | ||||||
|  |     ws: true, | ||||||
|  |     changeOrigin: true, | ||||||
|  |     proxyTimeout: 30000, | ||||||
|  |   }, | ||||||
|   { |   { | ||||||
|     context: ['/api/**'], |     context: ['/api/**'], | ||||||
|     target: `http://localhost:8999`, |     target: `http://localhost:8999`, | ||||||
|  | |||||||
| @ -33,6 +33,17 @@ if (configContent && configContent.BASE_MODULE === 'liquid') { | |||||||
|           "^/liquid": "" |           "^/liquid": "" | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       context: ['/liquid/api/v2/**'], | ||||||
|  |       target: `http://localhost:8999`, | ||||||
|  |       secure: false, | ||||||
|  |       ws: true, | ||||||
|  |       changeOrigin: true, | ||||||
|  |       proxyTimeout: 30000, | ||||||
|  |       pathRewrite: { | ||||||
|  |           "^/liquid": "" | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     { |     { | ||||||
|       context: ['/liquid/api/**'], |       context: ['/liquid/api/**'], | ||||||
|       target: `https://liquid.network`, |       target: `https://liquid.network`, | ||||||
| @ -51,6 +62,17 @@ if (configContent && configContent.BASE_MODULE === 'liquid') { | |||||||
|           "^/liquidtestnet": "" |           "^/liquidtestnet": "" | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     { | ||||||
|  |       context: ['/liquidtestnet/api/v2/**'], | ||||||
|  |       target: `http://localhost:8999`, | ||||||
|  |       secure: false, | ||||||
|  |       ws: true, | ||||||
|  |       changeOrigin: true, | ||||||
|  |       proxyTimeout: 30000, | ||||||
|  |       pathRewrite: { | ||||||
|  |           "^/liquidtestnet": "" | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     { |     { | ||||||
|       context: ['/liquidtestnet/api/**'], |       context: ['/liquidtestnet/api/**'], | ||||||
|       target: `https://liquid.network`, |       target: `https://liquid.network`, | ||||||
| @ -78,6 +100,14 @@ PROXY_CONFIG.push(...[ | |||||||
|     changeOrigin: true, |     changeOrigin: true, | ||||||
|     proxyTimeout: 30000, |     proxyTimeout: 30000, | ||||||
|   }, |   }, | ||||||
|  |   { | ||||||
|  |     context: ['/api/v2/**'], | ||||||
|  |     target: `http://localhost:8999`, | ||||||
|  |     secure: false, | ||||||
|  |     ws: true, | ||||||
|  |     changeOrigin: true, | ||||||
|  |     proxyTimeout: 30000, | ||||||
|  |   }, | ||||||
|   { |   { | ||||||
|     context: ['/api/**'], |     context: ['/api/**'], | ||||||
|     target: `https://mempool.space`, |     target: `https://mempool.space`, | ||||||
|  | |||||||
| @ -13,23 +13,23 @@ | |||||||
|   <div class="fee-estimation-container"> |   <div class="fee-estimation-container"> | ||||||
|     <div class="item"> |     <div class="item"> | ||||||
|       <div class="card-text"> |       <div class="card-text"> | ||||||
|         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.economyFee"  rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.economyFee * 140" ></app-fiat></span> |         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.economyFee"  rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.economyFee * 140" ></app-fiat></span> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|     <div class="band-separator"></div> |     <div class="band-separator"></div> | ||||||
|     <div class="item"> |     <div class="item"> | ||||||
|       <div class="card-text"> |       <div class="card-text"> | ||||||
|         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.hourFee"  rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.hourFee * 140" ></app-fiat></span> |         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.hourFee"  rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.hourFee * 140" ></app-fiat></span> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|     <div class="item"> |     <div class="item"> | ||||||
|       <div class="card-text"> |       <div class="card-text"> | ||||||
|         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.halfHourFee"  rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.halfHourFee * 140" ></app-fiat></span> |         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.halfHourFee"  rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.halfHourFee * 140" ></app-fiat></span> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|     <div class="item"> |     <div class="item"> | ||||||
|       <div class="card-text"> |       <div class="card-text"> | ||||||
|         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.fastestFee"  rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.fastestFee * 140" ></app-fiat></span> |         <div class="fee-text"><app-fee-rate [fee]="recommendedFees.fastestFee"  rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.fastestFee * 140" ></app-fiat></span> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ export class FeesBoxComponent implements OnInit, OnDestroy { | |||||||
|     this.recommendedFees$ = this.stateService.recommendedFees$ |     this.recommendedFees$ = this.stateService.recommendedFees$ | ||||||
|       .pipe( |       .pipe( | ||||||
|         tap((fees) => { |         tap((fees) => { | ||||||
|           this.fees = fees; |           this.fees = this.roundFees(fees); | ||||||
|           this.setFeeGradient(); |           this.setFeeGradient(); | ||||||
|         } |         } | ||||||
|       ) |       ) | ||||||
| @ -61,6 +61,19 @@ export class FeesBoxComponent implements OnInit, OnDestroy { | |||||||
|     this.cd.markForCheck(); |     this.cd.markForCheck(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   roundFees(fees: Recommendedfees): Recommendedfees { | ||||||
|  |     fees.fastestFee = this.roundFeeValue(fees.fastestFee); | ||||||
|  |     fees.halfHourFee = this.roundFeeValue(fees.halfHourFee); | ||||||
|  |     fees.hourFee = this.roundFeeValue(fees.hourFee); | ||||||
|  |     fees.economyFee = this.roundFeeValue(fees.economyFee); | ||||||
|  |     fees.minimumFee = this.roundFeeValue(fees.minimumFee); | ||||||
|  |     return fees; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   roundFeeValue(fee: number): number { | ||||||
|  |     return fee >= 10.0 ? Math.ceil(fee) : fee; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   ngOnDestroy(): void { |   ngOnDestroy(): void { | ||||||
|     this.themeSubscription.unsubscribe(); |     this.themeSubscription.unsubscribe(); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -64,6 +64,9 @@ | |||||||
| 	location /api/ { | 	location /api/ { | ||||||
| 		proxy_pass http://127.0.0.1:8999/api/v1/; | 		proxy_pass http://127.0.0.1:8999/api/v1/; | ||||||
| 	} | 	} | ||||||
|  | 	location /api/v2 { | ||||||
|  | 		proxy_pass http://127.0.0.1:8999/api/v2; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	# mainnet API | 	# mainnet API | ||||||
| 	location /ws { | 	location /ws { | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|     "MINED_BLOCKS_CACHE": 144, |     "MINED_BLOCKS_CACHE": 144, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "POLL_RATE_MS": 1000, |     "POLL_RATE_MS": 1000, | ||||||
|     "DISK_CACHE_BLOCK_INTERVAL": 1 |     "DISK_CACHE_BLOCK_INTERVAL": 1 | ||||||
|   }, |   }, | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|     "MINED_BLOCKS_CACHE": 144, |     "MINED_BLOCKS_CACHE": 144, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "POLL_RATE_MS": 1000, |     "POLL_RATE_MS": 1000, | ||||||
|     "DISK_CACHE_BLOCK_INTERVAL": 1 |     "DISK_CACHE_BLOCK_INTERVAL": 1 | ||||||
|   }, |   }, | ||||||
|  | |||||||
| @ -6,7 +6,8 @@ | |||||||
|     "BACKEND": "esplora", |     "BACKEND": "esplora", | ||||||
|     "HTTP_PORT": 8993, |     "HTTP_PORT": 8993, | ||||||
|     "INDEXING_BLOCKS_AMOUNT": 0, |     "INDEXING_BLOCKS_AMOUNT": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/" |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/" | ||||||
|   }, |   }, | ||||||
|   "SYSLOG": { |   "SYSLOG": { | ||||||
|     "MIN_PRIORITY": "debug" |     "MIN_PRIORITY": "debug" | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ | |||||||
|     "MINED_BLOCKS_CACHE": 144, |     "MINED_BLOCKS_CACHE": 144, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "CLEAR_PROTECTION_MINUTES": 5, |     "CLEAR_PROTECTION_MINUTES": 5, | ||||||
|     "POLL_RATE_MS": 1000, |     "POLL_RATE_MS": 1000, | ||||||
|     "INDEXING_BLOCKS_AMOUNT": -1, |     "INDEXING_BLOCKS_AMOUNT": -1, | ||||||
|  | |||||||
| @ -6,7 +6,8 @@ | |||||||
|     "BACKEND": "esplora", |     "BACKEND": "esplora", | ||||||
|     "HTTP_PORT": 8991, |     "HTTP_PORT": 8991, | ||||||
|     "INDEXING_BLOCKS_AMOUNT": 0, |     "INDEXING_BLOCKS_AMOUNT": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/" |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/" | ||||||
|   }, |   }, | ||||||
|   "SYSLOG": { |   "SYSLOG": { | ||||||
|     "MIN_PRIORITY": "debug" |     "MIN_PRIORITY": "debug" | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|     "MINED_BLOCKS_CACHE": 144, |     "MINED_BLOCKS_CACHE": 144, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "INDEXING_BLOCKS_AMOUNT": -1, |     "INDEXING_BLOCKS_AMOUNT": -1, | ||||||
|     "AUTOMATIC_POOLS_UPDATE": true, |     "AUTOMATIC_POOLS_UPDATE": true, | ||||||
|     "AUDIT": true, |     "AUDIT": true, | ||||||
|  | |||||||
| @ -6,7 +6,8 @@ | |||||||
|     "BACKEND": "esplora", |     "BACKEND": "esplora", | ||||||
|     "HTTP_PORT": 8992, |     "HTTP_PORT": 8992, | ||||||
|     "INDEXING_BLOCKS_AMOUNT": 0, |     "INDEXING_BLOCKS_AMOUNT": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/" |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/" | ||||||
|   }, |   }, | ||||||
|   "SYSLOG": { |   "SYSLOG": { | ||||||
|     "MIN_PRIORITY": "debug" |     "MIN_PRIORITY": "debug" | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|     "MINED_BLOCKS_CACHE": 144, |     "MINED_BLOCKS_CACHE": 144, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "INDEXING_BLOCKS_AMOUNT": -1, |     "INDEXING_BLOCKS_AMOUNT": -1, | ||||||
|     "AUTOMATIC_POOLS_UPDATE": true, |     "AUTOMATIC_POOLS_UPDATE": true, | ||||||
|     "AUDIT": true, |     "AUDIT": true, | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|     "MINED_BLOCKS_CACHE": 144, |     "MINED_BLOCKS_CACHE": 144, | ||||||
|     "SPAWN_CLUSTER_PROCS": 0, |     "SPAWN_CLUSTER_PROCS": 0, | ||||||
|     "API_URL_PREFIX": "/api/v1/", |     "API_URL_PREFIX": "/api/v1/", | ||||||
|  |     "API_V2_URL_PREFIX": "/api/v2/", | ||||||
|     "INDEXING_BLOCKS_AMOUNT": -1, |     "INDEXING_BLOCKS_AMOUNT": -1, | ||||||
|     "AUTOMATIC_POOLS_UPDATE": true, |     "AUTOMATIC_POOLS_UPDATE": true, | ||||||
|     "AUDIT": true, |     "AUDIT": true, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user