Compare commits

...

1530 Commits

Author SHA1 Message Date
wiz
60c22cbb5d Merge pull request #1844 from mempool/wiz/fix-docker-backend-start-script
Fix one more broken sed substitution in docker/backend/start.sh
2022-06-08 23:38:13 +09:00
wiz
c7dd93275e Merge pull request #1847 from mempool/simon/transifex-pull-806
Transifex pull
2022-06-08 23:37:11 +09:00
softsimon
3f0201df3a Transifex pull 2022-06-08 16:14:36 +02:00
wiz
bce8a58cf8 Fix one more broken sed substitution in docker/backend/start.sh 2022-06-08 22:13:56 +09:00
wiz
936964d273 Merge pull request #1839 from mempool/wiz/fix-docker-backend-start-script
Add missing sed substitutions in docker/backend/start.sh
2022-06-08 08:05:41 +09:00
wiz
4d274a3cec Add missing sed substitutions in docker/backend/start.sh
Fixes #1838
2022-06-08 07:50:21 +09:00
wiz
acd342259f Merge pull request #1835 from mempool/simon/transifex-pull-0608
Pulled from Transifex
2022-06-08 05:46:16 +09:00
softsimon
67456c151f Pulled from Transifex 2022-06-08 00:44:04 +04:00
wiz
13ccf55cc8 Merge pull request #1830 from hunicus/faq-projected-mempool
Change "projected block" to "mempool block" in feerate faq
2022-06-08 05:38:48 +09:00
wiz
73bffb5552 Merge pull request #1834 from mempool/nymkappa/bugfix/pools-import
Fix pool import crash
2022-06-08 05:38:38 +09:00
nymkappa
be8ee52af0 Fix pool import crash 2022-06-07 22:18:51 +02:00
hunicus
fbb16d6f22 Change projected to mempool in feerate faq 2022-06-07 14:54:33 -04:00
softsimon
96f8bf4a34 Merge pull request #1829 from mempool/simon/transifex-extract-0607
Extracting i18n
2022-06-07 22:12:44 +04:00
softsimon
2f9a86524a Extracting i18n 2022-06-07 22:11:48 +04:00
softsimon
e617e09ae3 Merge pull request #1827 from hunicus/change-terms
Change 'projected blocks' to 'mempool blocks' in feerate tooltips
2022-06-07 22:09:05 +04:00
wiz
6934aef60b Merge pull request #1828 from mempool/wiz/fix-upgrade-script-exit-code
[ops] Fix upgrade script exit code
2022-06-08 03:08:42 +09:00
hunicus
8f4de39e7b Change 'projected' to 'mempool' in feerate tooltips 2022-06-07 14:06:56 -04:00
wiz
fcb0c51e51 [ops] Fix mempool-build-all script exit code 2022-06-08 03:06:54 +09:00
wiz
ec80eac6b9 Merge pull request #1820 from hunicus/update-feerate-tooltips
Add feerate tooltips
2022-06-08 02:41:02 +09:00
wiz
84e600ac9f Merge branch 'master' into update-feerate-tooltips 2022-06-08 02:26:29 +09:00
wiz
c64d95b0ec Merge pull request #1822 from mempool/nymkappa/bugfix/db-disabled
Add 'db-less' mining pool tagging support
2022-06-08 02:26:02 +09:00
hunicus
3e2ced2e8b Make feerate tooltips appear on top 2022-06-07 13:18:20 -04:00
hunicus
6cc04feda8 Move feerate tooltips to feerate labels 2022-06-07 13:14:30 -04:00
wiz
0b50c17ed0 Merge branch 'master' into nymkappa/bugfix/db-disabled 2022-06-08 01:56:52 +09:00
wiz
81b9153d2b Merge branch 'master' into update-feerate-tooltips 2022-06-08 01:12:38 +09:00
wiz
e7c5307ca4 Merge pull request #1819 from hunicus/update-fee-faq-2
Update fee faq
2022-06-08 01:12:30 +09:00
wiz
8fb377b4eb Merge branch 'master' into update-fee-faq-2 2022-06-08 00:48:43 +09:00
wiz
5642358937 Merge pull request #1824 from hunicus/add-tx-note-1
Add transifex note to issue template
2022-06-08 00:47:39 +09:00
wiz
00cd1386b5 Merge pull request #1825 from hunicus/add-tx-note-2
Add pull request template to discourage tx prs
2022-06-08 00:47:15 +09:00
wiz
da6c72e9b7 Merge pull request #1691 from ayanamitech/cache-static
Handle Error with basic retry while syncing external assets ( Price Data )
2022-06-08 00:46:10 +09:00
hunicus
c318993a79 Add transifex note to issue template 2022-06-07 09:09:38 -04:00
hunicus
87c6e957f0 Remove unnecessary detail in fee faq 2022-06-07 08:56:41 -04:00
hunicus
e133467ea1 Add pull request template to discourage tx prs 2022-06-07 08:41:07 -04:00
hunicus
a0429b243f Make feerate tooltip i18n identifiers unique 2022-06-07 08:32:58 -04:00
nymkappa
21ae1fce2a Fix js crash when sending invalid state to /block page 2022-06-07 12:19:36 +02:00
nymkappa
53bc80e899 Add 'db-less' mining pool tagging support 2022-06-07 11:28:39 +02:00
Ayanami
56dc337672 Temporary disable retries
Until we find out how to sync async
2022-06-07 04:16:37 +09:00
Ayanami
a04bafdb4c Correct the log if the onion address is enabled or not 2022-06-07 04:16:37 +09:00
Ayanami
6ff473ab5d Add an ability to change circuits 2022-06-07 04:16:37 +09:00
Ayanami
40bfc6bff3 Include SocksProxyAgent inside while loop
To address error Socks5 proxy rejected connection - Failure
2022-06-07 04:16:37 +09:00
Ayanami
c610cacee4 Added missing config value
addressing comments from @knorrium
2022-06-07 04:16:36 +09:00
Ayanami
e41a08789a Added configurable user-agent for axios
Will use `mempool/v${backendInfo.getBackendInfo().version}` for default
2022-06-07 04:16:36 +09:00
Ayanami
9d5bbf1f44 Handle Error with basic retry while syncing external assets ( Price Data )
+ Removed unused External Assets value

+ Make static URL dynamic

+ Added config options for syncing pool data

+ Added retry interval & max retry
2022-06-07 04:16:36 +09:00
hunicus
22268b8a33 Add tooltips describing feerate levels 2022-06-06 14:32:16 -04:00
hunicus
0f58ce2322 Show fiat fee tooltip on fiat fee only 2022-06-06 14:17:25 -04:00
hunicus
1aad89ac97 Update fee faq 2022-06-06 13:05:53 -04:00
wiz
e99a684354 Merge pull request #1811 from mempool/simon/reload-mempool-visualizer-on-reconnect
Reload mempool visualization on reconnect
2022-06-06 21:35:05 +09:00
wiz
5360f6dd77 Merge branch 'master' into simon/reload-mempool-visualizer-on-reconnect 2022-06-06 21:23:48 +09:00
wiz
c8d5708155 Merge pull request #1812 from mempool/wiz/fix-foundry-logo-about-page
Use Foundry's dark theme logo on About page
2022-06-06 21:02:06 +09:00
softsimon
ebda00dc74 Send empty list of transactions if data isn't available yet 2022-06-06 14:31:17 +04:00
wiz
789092c76a Update Foundry logo on About page 2022-06-06 06:35:09 +09:00
softsimon
967a2a4461 Reload mempool visualization on reconnect
fixes #1799
2022-06-05 23:40:36 +04:00
wiz
9288628ad7 Merge pull request #1810 from mempool/simon/transifex-pull-0605
Transifex pull
2022-06-06 04:20:12 +09:00
wiz
0384ebb2ff Merge pull request #1745 from antonilol/multisig-label
stricter multisig check + detect bare multisig when spent
2022-06-06 04:19:57 +09:00
wiz
869c40e835 Merge branch 'master' into multisig-label 2022-06-06 04:06:43 +09:00
wiz
579af85544 Merge pull request #1806 from knorrium/cypress10_upgrade
Cypress v10 upgrade
2022-06-06 04:06:24 +09:00
wiz
97f72c1faf Merge branch 'master' into cypress10_upgrade 2022-06-06 03:53:09 +09:00
wiz
262c3af33e Merge pull request #1808 from mempool/nymkappa/bugfix/fix-blocks-list-loading
Make sure blocks list rxjs observable triggers at least once
2022-06-06 03:43:59 +09:00
softsimon
dd7d9b66e5 Transifex pull 2022-06-05 22:39:36 +04:00
wiz
f688da957c Merge branch 'master' into nymkappa/bugfix/fix-blocks-list-loading 2022-06-06 03:37:39 +09:00
wiz
866ac3d5b8 Merge pull request #1809 from mempool/simon/mempool-logo-svg-bugfix
Fix for mempool logo SVG issue
2022-06-06 03:36:41 +09:00
softsimon
63fce2a3ca Fix for mempool logo SVG issue 2022-06-05 22:29:05 +04:00
nymkappa
33e0859847 Make sure blocks list rxjs observable triggers at least once 2022-06-05 17:33:23 +02:00
Felipe Knorr Kuhn
b71922fabf Update Cypress Github Action to v4 2022-06-03 20:59:31 -07:00
Felipe Knorr Kuhn
ce0564a89c Update Cypress Github Action to v4 2022-06-03 20:59:03 -07:00
Felipe Knorr Kuhn
2a287b8d66 Update Cypress triggers back to push and pull request 2022-06-03 20:52:59 -07:00
Felipe Knorr Kuhn
69713ae156 Update to Cypress v10 2022-06-03 20:46:33 -07:00
Antoni Spaanderman
b930b9bf4f stricter multisig check + detect bare multisig when spent 2022-06-03 18:47:44 +02:00
wiz
412f118d22 Merge pull request #1801 from mempool/nymkappa/feature/cache-log
Improve disk cache logging
2022-06-04 01:21:55 +09:00
nymkappa
b60c2a9341 Improve disk cache logging 2022-06-03 18:00:14 +02:00
wiz
1efac916b7 Merge pull request #1800 from mempool/nymkappa/bugfix/missing-cache-version
Re-added missing cache version
2022-06-04 00:25:38 +09:00
wiz
3202629c44 Merge pull request #1772 from mempool/nymkappa/feature/websocket-block-count
Refactor pool ranking rxjs observable
2022-06-04 00:08:24 +09:00
nymkappa
3bc55d80ce Re-added missing cache version 2022-06-03 17:04:52 +02:00
wiz
89699f9b7e Merge branch 'master' into nymkappa/feature/websocket-block-count 2022-06-03 23:56:52 +09:00
wiz
95dd436be5 Merge pull request #1795 from hunicus/blocks-extras-v2
Update /api/blocks docs
2022-06-03 23:56:38 +09:00
wiz
efede07b5c Merge branch 'master' into blocks-extras-v2 2022-06-03 23:47:43 +09:00
wiz
a8123cddf7 Merge pull request #1792 from mempool/wiz/update-v2.4.0-screenshot
Update dashboard screenshot for v2.4.0 release
2022-06-03 23:47:21 +09:00
wiz
7764cceb86 Merge pull request #1797 from mempool/nymkappa/feature/automatic-disk-cache-reset
Skip blocks disk cache loading after db migration
2022-06-03 23:46:59 +09:00
nymkappa
256dbc8c8e Add disk cache versioning 2022-06-03 13:31:45 +02:00
hunicus
9ff006e61e Update /api/blocks in docs (bisq) 2022-06-02 18:08:09 -04:00
hunicus
9de6c716b7 Update /api/blocks in docs (liquid) 2022-06-02 17:51:23 -04:00
hunicus
538a1b1666 Replace blocks-extras with blocks in docs (bitcoin) 2022-06-02 17:29:13 -04:00
nymkappa
56e996c893 Refactor pool block list observable 2022-06-02 22:01:53 +02:00
nymkappa
429b4f2bc6 Refactor pool ranking rxjs observable 2022-06-02 22:01:53 +02:00
softsimon
3196c188f1 Merge pull request #1794 from mempool/simon/transifex-extract-6-2
Extracting i18n strings
2022-06-02 22:42:50 +04:00
softsimon
672833930d Extracting i18n strings 2022-06-02 22:42:27 +04:00
wiz
74ee35e273 Merge pull request #1793 from mempool/wiz/update-about-page-logos-for-v2.4
Update the Enterprise Sponsor logos on About page
2022-06-03 03:35:19 +09:00
wiz
8095a8a5f5 Fix size of Exodus logo on About page 2022-06-03 03:27:00 +09:00
wiz
ed3a614fb7 Change Gemini logo on About page to dark theme 2022-06-03 03:26:42 +09:00
wiz
cabfdcf49c Re-arrange Enterprise Sponsor logos on About page 2022-06-03 03:17:58 +09:00
wiz
69e1474c53 Update Exodus logo on About page 2022-06-03 03:01:12 +09:00
wiz
11f5056871 Merge pull request #1784 from hunicus/node-version-requirement
Make node 16.15 required not recommended
2022-06-03 02:53:55 +09:00
wiz
10ccad16e9 Update dashboard screenshot for v2.4.0 release
Fixes #1778
2022-06-03 02:48:38 +09:00
wiz
18c1be0bd0 Merge pull request #1790 from mempool/nymkappa/feature/fee-redesign-2
Updated new fee widget design
2022-06-03 01:23:58 +09:00
nymkappa
fe32ef75a2 Updated new fee widget design 2022-06-02 17:44:44 +02:00
wiz
a6517ebdc5 Merge pull request #1779 from mempool/simon/projected-block-transactions-fixes
Minor refactor for projected block transactions
2022-06-02 21:30:57 +09:00
hunicus
83660e9cf3 Make node 16.15 required not recommended 2022-06-01 22:54:46 -04:00
softsimon
f0a2ddf57b Minor refactor for projected block transactions 2022-06-02 01:29:03 +04:00
wiz
ddab579111 Merge pull request #1774 from mononaut/projected-block-overview
Feature: Projected block visualization
2022-06-02 05:35:07 +09:00
wiz
82471073c3 Merge branch 'master' into projected-block-overview 2022-06-02 00:35:07 +09:00
wiz
c9b98ed841 Merge pull request #1766 from mempool/nymkappa/feature/fee-redesign
Rewamp the fee widget
2022-06-02 00:34:57 +09:00
Mononaut
57cecee3af Add contributors agreement for mononaut 2022-06-01 13:48:58 +00:00
Mononaut
6cd8c448b4 Projected block loading spinner & WebGL detection 2022-06-01 13:48:58 +00:00
Mononaut
3ffc4956f4 Stream projected block deltas instead of full data 2022-06-01 13:48:58 +00:00
Mononaut
c2802253b7 Smarter update algorithm for projected block viz 2022-06-01 13:48:35 +00:00
Mononaut
1aac96a6f6 Projected block overview mouse events & tx preview 2022-06-01 13:48:34 +00:00
Mononaut
d4c9f6decb Implement WebGL projected block visualization 2022-06-01 13:48:34 +00:00
Mononaut
79dae84363 Data pipeline for projected mempool block overview 2022-06-01 13:48:34 +00:00
nymkappa
34576c0609 Update gradient as soon as we receive the fees 2022-06-01 12:53:36 +02:00
nymkappa
ec24549602 Hide minimum and economy on mobile 2022-06-01 12:28:42 +02:00
wiz
7f8834a2eb Merge branch 'master' into nymkappa/feature/fee-redesign 2022-06-01 17:22:01 +09:00
wiz
ee5cd1cd96 Merge pull request #1769 from mempool/nymkappa/bugfix/divergence-fix
Re-add hash field in the mysql block query
2022-06-01 17:20:38 +09:00
wiz
9ab3b3293a Merge pull request #1765 from mempool/simon/init-data-fees
Send fee info with init data
2022-06-01 17:08:09 +09:00
nymkappa
d860344be4 Re-add hash field in the mysql block query 2022-06-01 10:06:18 +02:00
nymkappa
cefc927b06 Tweaks fee widget 2022-06-01 09:47:00 +02:00
wiz
72cc2e4df0 Merge branch 'master' into nymkappa/feature/fee-redesign 2022-06-01 15:14:56 +09:00
nymkappa
b4fd98f565 Rewamp the fee widget 2022-05-31 22:31:01 +02:00
softsimon
2ee1f197d1 Send fee info with init data 2022-06-01 00:03:25 +04:00
wiz
e629173304 Merge pull request #1642 from mempool/nymkappa/bugfix/bisq-dump-file
If bisq data folder is not ready, retry every 3 minutes instead of exit
2022-06-01 03:58:24 +09:00
wiz
6210936ef4 Merge pull request #1752 from mempool/wiz/use-svg-logo-for-mempool.space
Use inline SVG for mempool.space logo
2022-06-01 03:52:40 +09:00
wiz
de8a51fe9a Merge branch 'master' into nymkappa/bugfix/bisq-dump-file 2022-06-01 03:47:12 +09:00
wiz
260f883d02 Merge pull request #1764 from mempool/nymkappa/bugfix/fx-rate-db-disable
Only attempt to save fx rate if database is enabled
2022-06-01 03:47:05 +09:00
softsimon
e81dfbcc7f Adding missing ngIf check 2022-05-31 22:39:15 +04:00
nymkappa
c7e9b47aa0 Only attempt to save fx rate if database is enabled 2022-05-31 20:29:43 +02:00
wiz
7f6ea58c74 Merge branch 'master' into wiz/use-svg-logo-for-mempool.space 2022-06-01 03:22:52 +09:00
softsimon
5dcde1c702 Store SVG images in a separate component 2022-05-31 22:21:59 +04:00
wiz
4c90d8e811 Merge branch 'master' into nymkappa/bugfix/bisq-dump-file 2022-06-01 03:10:50 +09:00
wiz
dbce727695 Merge pull request #1741 from mempool/nymkappa/feature/remove-fee-calculation-frontend
Remove fee calculation from the frontend
2022-06-01 03:03:09 +09:00
wiz
39f33dded2 Merge branch 'master' into nymkappa/feature/remove-fee-calculation-frontend 2022-06-01 02:44:48 +09:00
wiz
4b445b1191 Merge pull request #1763 from mempool/wiz/fix-backend-starting-syslog-msg
Change backend start syslog message from DEBUG to NOTICE
2022-06-01 02:43:25 +09:00
wiz
a9515f8fc1 Merge pull request #1751 from mempool/simon/handle-nonstandard-inputs
Handle nonstandard inputs
2022-06-01 02:42:57 +09:00
wiz
4ccd786fe9 Change backend start syslog message from DEBUG to NOTICE 2022-06-01 01:09:08 +09:00
wiz
72c3eea863 Merge branch 'master' into nymkappa/bugfix/bisq-dump-file 2022-06-01 00:14:43 +09:00
wiz
6a3df95d4c Merge pull request #1723 from mempool/nymkappa/feature/historical-rates
Save bisq aggregate exchange rates in the database for each new block
2022-06-01 00:14:05 +09:00
wiz
ce49dca7c8 Merge branch 'master' into nymkappa/feature/historical-rates 2022-05-31 23:58:51 +09:00
wiz
f84fee1ba0 Merge pull request #1624 from mempool/dependabot/npm_and_yarn/frontend/clipboard-2.0.11
Bump clipboard from 2.0.10 to 2.0.11 in /frontend
2022-05-31 23:55:07 +09:00
wiz
8c8299ebe0 Merge pull request #1750 from mempool/simon/dropdown-button-links-fix
Changed menu buttons to links
2022-05-31 23:52:47 +09:00
wiz
8d8fe8c528 Merge branch 'master' into simon/dropdown-button-links-fix 2022-05-31 23:15:25 +09:00
wiz
48b051f892 Merge pull request #1742 from mempool/simon/update-packages
Upgrading packages
2022-05-31 19:05:52 +09:00
wiz
44215a2108 Merge branch 'master' into simon/update-packages 2022-05-31 18:54:34 +09:00
wiz
6b2b10960a Merge branch 'master' into nymkappa/feature/remove-fee-calculation-frontend 2022-05-31 18:34:49 +09:00
wiz
cee15020fd Merge pull request #1738 from mempool/nymkappa/feature/additional-fee-tiers
Add `economyFee` field in /api/fees/recommended API
2022-05-31 18:34:32 +09:00
wiz
1cb772da39 Merge branch 'master' into nymkappa/feature/additional-fee-tiers 2022-05-31 18:28:33 +09:00
wiz
9a9be2538a Merge pull request #1739 from mempool/nymkappa/bugfix/block-url-link
Use block hash instead of block height in urls
2022-05-31 18:28:18 +09:00
wiz
260fd030b5 Merge branch 'master' into nymkappa/bugfix/block-url-link 2022-05-31 18:20:47 +09:00
wiz
8dd68728fa Merge pull request #1730 from hunicus/doc-page-titles
Fix doc page titles
2022-05-31 18:20:37 +09:00
nymkappa
c246ed958f Create rates table on all networks 2022-05-31 11:20:31 +02:00
wiz
d182128069 Merge branch 'master' into doc-page-titles 2022-05-31 18:13:27 +09:00
nymkappa
f20cf266b6 Remove frontend fee calculation and read it from the websocket instead 2022-05-31 10:41:43 +02:00
nymkappa
09b2e21fea Add economyFee field in /api/fees/recommended API 2022-05-31 10:40:58 +02:00
wiz
0ecc03e484 Merge branch 'master' into nymkappa/feature/historical-rates 2022-05-31 17:35:54 +09:00
wiz
ac0e430495 Merge pull request #1719 from mempool/nymkappa/bugfix/pool-parser-db-check
Don't try to run pools parser if db is not enabled
2022-05-31 17:35:15 +09:00
wiz
82161d4edf Use SVG logo for mempool.space 2022-05-31 17:31:31 +09:00
wiz
288a96ed43 Merge branch 'master' into nymkappa/bugfix/pool-parser-db-check 2022-05-31 17:09:41 +09:00
wiz
768be0cc70 Merge pull request #1716 from mempool/nymkappa/feature/bitcoind-offline-support
Mining dashboard still runs fine if Bitcoin Core becomes unavailable
2022-05-31 17:09:08 +09:00
wiz
687310f6f0 Merge branch 'master' into nymkappa/feature/bitcoind-offline-support 2022-05-31 16:50:11 +09:00
softsimon
85b17927d6 Handle nonstandard inputs
fixes #1744
2022-05-31 04:13:13 +04:00
softsimon
9ce4057ad4 Changed menu buttons to links
fixes #1073
2022-05-31 03:49:03 +04:00
softsimon
d542671993 Updating some more packages 2022-05-31 02:21:05 +04:00
softsimon
3935aef841 Upgrading packages 2022-05-31 02:21:05 +04:00
wiz
69f06ae257 Merge pull request #1747 from mempool/simon/transifex-pull
Transifex pull
2022-05-30 18:35:16 +09:00
softsimon
7be22b8236 Transifex pull 2022-05-30 13:26:54 +04:00
nymkappa
99902e70c7 Use block hash instead of block height in urls 2022-05-27 20:43:14 +02:00
wiz
fcbf7d9c57 Merge pull request #1733 from mempool/simon/angular-13.3-update
Angular 13.3.10 update
2022-05-27 18:59:20 +09:00
wiz
b63b02b8ad Merge pull request #1736 from hunicus/update-faq-stuck
Adjust stuck tx faqs for angry people
2022-05-27 18:49:41 +09:00
wiz
ec4ea7e732 Merge pull request #1735 from hunicus/remove-keybase
Remove keybase link from about page
2022-05-27 18:46:58 +09:00
wiz
41f0e784e2 Merge branch 'master' into simon/angular-13.3-update 2022-05-27 18:45:52 +09:00
wiz
6718bd7332 Merge pull request #1718 from mempool/nymkappa/feature/block-list-loading
Add loading spinner in /blocks page
2022-05-27 18:45:48 +09:00
wiz
18143a3807 Merge pull request #1728 from hunicus/add-faq-emptyblocks
Add faq on empty blocks
2022-05-27 18:42:57 +09:00
wiz
a8a5313eb4 Merge branch 'master' into nymkappa/feature/block-list-loading 2022-05-27 18:38:36 +09:00
wiz
dd9a704af8 Merge pull request #1717 from mempool/simon/ngb-boostrap-imports
NgBootstrap library import optimization
2022-05-27 18:38:24 +09:00
wiz
dea1e0acca Merge branch 'master' into add-faq-emptyblocks 2022-05-27 18:29:21 +09:00
nymkappa
be3d8b5ed9 Mining dashboard still runs fine if Bitcoin Core becomes unavailable 2022-05-27 11:26:56 +02:00
wiz
4d748eb585 Merge branch 'master' into simon/ngb-boostrap-imports 2022-05-27 18:23:51 +09:00
wiz
1ba0077666 Merge pull request #1714 from hunicus/install-manual
Move manual install notes to separate docs
2022-05-27 18:22:13 +09:00
wiz
36eeb84359 Merge pull request #1699 from mempool/simon/liquid-fixes
Liquid empty miner UX fix
2022-05-27 18:15:03 +09:00
nymkappa
e590759b7b Don't try to run pools parser if db is not enabled 2022-05-27 10:31:49 +02:00
hunicus
b7c918b79d Mention "esplora" value for blockstream/electrs 2022-05-26 22:13:37 -04:00
hunicus
d944362c7d Broaden guidance for hosting frontend 2022-05-26 19:33:54 -04:00
hunicus
28439bff7d Add recommended versions for node and npm 2022-05-26 18:19:58 -04:00
hunicus
c69d0e8148 Add note on mysql install brought up in #1731 2022-05-26 17:57:48 -04:00
hunicus
24e745e85d Add manual frontend setup notes to frontend/ readme 2022-05-26 17:42:15 -04:00
hunicus
3e82e432c6 Add manual backend setup notes to backend/ readme 2022-05-26 17:42:15 -04:00
hunicus
9a45dea52f Caution about manual installs in docker readme 2022-05-26 17:42:14 -04:00
hunicus
24f4644379 Orient stuck tx faqs for normies 2022-05-26 17:27:11 -04:00
softsimon
e5470b9e40 Angular 13.3.10 update 2022-05-26 18:31:11 +04:00
hunicus
68b4b66058 Fix doc page titles 2022-05-25 23:59:48 -04:00
hunicus
b7f4444d14 Remove keybase link from about page 2022-05-25 22:53:22 -04:00
hunicus
f0acff2f42 Add faq on empty blocks 2022-05-25 22:44:26 -04:00
softsimon
63ab2d7c2b Reseting statistics fix 2022-05-25 23:43:31 +04:00
softsimon
36f56de4f1 Liquid UX fixes
fixes #1683
fixes #1681
2022-05-25 23:43:31 +04:00
softsimon
3bdd11ab37 Merge pull request #1727 from mempool/simon/i18n-extract-25-5
i18n extract
2022-05-25 19:03:43 +04:00
softsimon
428401891e i18n extract 2022-05-25 19:03:25 +04:00
softsimon
7a51572082 NgBootstrap library import optimization 2022-05-25 18:56:10 +04:00
wiz
cba9930410 Merge pull request #1687 from mempool/nymkappa/feature/use-block-count-timespan
Replace all oldestIndexedBlockTimestamp with X-total-count header
2022-05-25 20:32:44 +09:00
wiz
2a486a1762 Merge pull request #1701 from hunicus/lighthouse-parents-2
Add role attributes for doc nav elements
2022-05-25 20:30:45 +09:00
wiz
989d5b3263 Merge branch 'master' into lighthouse-parents-2 2022-05-25 20:17:56 +09:00
wiz
df9c9e334d Merge branch 'master' into nymkappa/feature/use-block-count-timespan 2022-05-25 20:16:32 +09:00
wiz
07797d36bc Merge pull request #1712 from mempool/simon/npm-audit-fix-24-5
npm audit fix
2022-05-25 20:16:21 +09:00
wiz
aac92404d2 Merge branch 'master' into simon/npm-audit-fix-24-5 2022-05-25 20:09:34 +09:00
wiz
8372ca1cf0 Merge pull request #1700 from mempool/simon/block-transactions-error-catcher
Block transactions list error handling
2022-05-25 20:09:05 +09:00
wiz
1880e3a59b Merge branch 'master' into simon/block-transactions-error-catcher 2022-05-25 19:22:31 +09:00
wiz
b8463b833b Merge pull request #1696 from mempool/nymkappa/feature/merge-blocks
Merge legacy and mining /blocks components and APIs
2022-05-25 19:22:24 +09:00
nymkappa
f9bcdfb1e5 Update API documentation 2022-05-25 12:10:10 +02:00
nymkappa
c402422682 Remove last trace of legacy oldestIndexedBlockTimestamp 2022-05-25 12:10:09 +02:00
wiz
aac9dda9ef Merge branch 'master' into nymkappa/feature/merge-blocks 2022-05-25 18:55:13 +09:00
wiz
e059b9d379 Merge pull request #1685 from mempool/nymkappa/feature/update-api-case
Update case in some mining API endpoint response
2022-05-25 18:54:47 +09:00
wiz
ce04942803 Merge pull request #1710 from hunicus/add-schildbach
Add schildbach bitcoin wallet to about page
2022-05-25 18:37:46 +09:00
wiz
fae54797e8 Merge branch 'master' into add-schildbach 2022-05-25 18:26:21 +09:00
wiz
b136db933f Merge pull request #1707 from mempool/nymkappa/feature/chart-button-bitcoin-only
Hide graph selection button on non bitcoin networks
2022-05-25 18:26:11 +09:00
wiz
aebeb600a3 Merge pull request #1708 from mempool/nymkappa/bugfix/blocks-list-widget
Fix missing tx column in main dashboard on mobile
2022-05-25 18:18:01 +09:00
nymkappa
875040c329 Save bisq aggregate exchange rates in the database for each new block 2022-05-25 10:51:35 +02:00
wiz
72014eb0b3 Merge branch 'master' into nymkappa/feature/chart-button-bitcoin-only 2022-05-25 17:27:43 +09:00
wiz
c16c7ee0cd Merge branch 'master' into nymkappa/bugfix/blocks-list-widget 2022-05-25 17:13:45 +09:00
hunicus
f55590269e Move manual install docs away from main readme
Replace with links to docker/, frontend/, and /backend.
2022-05-24 12:38:05 -04:00
nymkappa
406d4101c0 Add loading spinner in /blocks page 2022-05-24 11:55:43 +02:00
nymkappa
584fb47de7 Fix widget size mining dashboard 2022-05-24 11:19:09 +02:00
nymkappa
9e0fdec053 Merge branch 'master' into nymkappa/feature/merge-blocks 2022-05-24 10:14:06 +02:00
wiz
b91654886a Merge pull request #1635 from mempool/nymkappa/bugfix/reindex-when-fast-forward 2022-05-24 14:37:13 +09:00
Felipe Knorr Kuhn
9fbd014df9 Merge branch 'master' into nymkappa/bugfix/reindex-when-fast-forward 2022-05-23 21:08:54 -07:00
softsimon
2e9eb46caa npm audit fix 2022-05-24 04:57:08 +04:00
hunicus
f8d6dd7c7b Add schildbach bitcoin wallet to about page 2022-05-23 08:34:04 -04:00
nymkappa
88fba3f506 For non Bitcoin network, run legacy API code, but keep the same endpoint 2022-05-23 13:02:18 +02:00
nymkappa
8f57272ea0 Fix /blocks skeleton on Liquid 2022-05-23 12:08:52 +02:00
nymkappa
dc81f7cfeb Fix missing tx column in main dashboard on mobile 2022-05-23 10:56:12 +02:00
nymkappa
3723380a36 Hide graph selection button on non bitcoin networks 2022-05-23 09:44:09 +02:00
nymkappa
2da7ec2519 Use ngClass to avoid multiple [class] conflict 2022-05-23 09:08:42 +02:00
nymkappa
ffcfa4a659 Setup redirect from /mining/blocks to /blocks - Update router links 2022-05-23 09:08:41 +02:00
nymkappa
8db440f164 Update cache warmer 2022-05-23 09:08:41 +02:00
nymkappa
37b7ea6702 Merge legacy and mining /blocks components and APIs 2022-05-23 09:08:40 +02:00
hunicus
49074cc3df Add role attributes for doc nav elements
To address #1668.
2022-05-21 08:20:35 -04:00
softsimon
a1fb89963c Block transactions list error handling 2022-05-21 02:30:38 +04:00
wiz
f42da0e3ac Merge branch 'master' into nymkappa/feature/update-api-case 2022-05-21 03:18:57 +09:00
wiz
b4beb29f31 Merge pull request #1657 from mempool/nymkappa/bugfix/update-log
Add escaped slug into logs when slug does not match any pool
2022-05-21 03:13:09 +09:00
wiz
6cd3c312dd Merge branch 'master' into nymkappa/bugfix/update-log 2022-05-21 03:03:56 +09:00
wiz
3a6f64b2e3 Merge pull request #1643 from mempool/simon/lazy-load-inputs
Lazy load tx inputs in Bitcoin Core mode
2022-05-21 03:03:35 +09:00
softsimon
521418bd25 Progressbar calculation fix 2022-05-20 21:50:01 +04:00
wiz
dabfa05337 Merge branch 'master' into simon/lazy-load-inputs 2022-05-21 02:47:24 +09:00
wiz
e58b10d552 Merge pull request #1697 from hunicus/fix-ws
Fix websockets tab
2022-05-21 02:36:02 +09:00
softsimon
e092fa6286 Adding fee reveal text 2022-05-20 21:30:01 +04:00
softsimon
fb63817282 Lazy load tx inputs in Bitcoin Core mode
fixes #465
2022-05-20 21:30:01 +04:00
wiz
85ce3ba9af Merge branch 'master' into fix-ws 2022-05-21 02:23:44 +09:00
wiz
2ba506515c Merge pull request #1695 from mempool/simon/round-miners-reward
Round miners reward to full dollar
2022-05-21 02:22:35 +09:00
hunicus
85defd076f Fix websockets tab
Caused by show/hide property for JS examples
introduced in e8ef4a39ec.
2022-05-20 12:46:30 -04:00
softsimon
0ba51a9362 Round miners reward to full dollar 2022-05-20 19:21:20 +04:00
wiz
20301b9e0c Merge pull request #1694 from mempool/simon/reward-stats-i18n-fix
Reward stats i18n fix
2022-05-20 23:57:50 +09:00
wiz
ad9cf2ada3 Merge pull request #1677 from mempool/simon/transifex-pull-19-05
Pull from transifex
2022-05-20 23:56:04 +09:00
softsimon
3d425c366f Reward stats i18n fix 2022-05-20 18:49:14 +04:00
wiz
7962d5a8d8 Merge branch 'master' into simon/transifex-pull-19-05 2022-05-20 23:46:42 +09:00
wiz
774cd98aa2 Merge pull request #1690 from mempool/simon/liquid-routing-fix
Fixes for Liquid module routing
2022-05-20 23:32:55 +09:00
wiz
639364bd60 Merge pull request #1667 from mempool/simon/loading-indicator-ux
Improving loading indicator UX
2022-05-20 23:27:56 +09:00
softsimon
75b3b0fde5 Fixing the /graphs link and make it consistent 2022-05-20 18:22:04 +04:00
softsimon
db1720e3b4 Fixes for Liquid module routing 2022-05-20 17:54:06 +04:00
wiz
159b6ad04b Merge branch 'master' into nymkappa/feature/update-api-case 2022-05-20 21:03:41 +09:00
wiz
55f2cf06af Merge pull request #1688 from mempool/simon/mempool-tx-fee-bug
Fixes broken fee rate calculation for mempool transactions
2022-05-20 21:03:34 +09:00
wiz
7617cedae3 Merge pull request #1686 from mempool/nymkappa/bugfix/mining-blocks-api-expiration
Set /mining/blocks/xxx APIs expiration to 60 seconds instead of 5 min
2022-05-20 21:01:02 +09:00
wiz
b76f20f780 Merge pull request #1680 from hunicus/mining-doc-rev2
Add feedback for mining API docs
2022-05-20 21:00:32 +09:00
wiz
97e0a5092b Merge branch 'master' into simon/mempool-tx-fee-bug 2022-05-20 20:56:57 +09:00
wiz
c872c07b71 Merge pull request #1682 from mempool/simon/lazy-loaded-modules
Moving graphs and mining dashboard to a lazy loaded module
2022-05-20 20:56:40 +09:00
softsimon
062a864a17 Pre-load all lazy loaded modules 2022-05-20 15:08:45 +04:00
softsimon
5028df31ba Fixes broken fee rate calculation for mempool transactions
fixes #1684
2022-05-20 13:41:30 +04:00
nymkappa
018914a4b6 Set /mining/blocks/xxx APIs expiration to 60 seconds instead of 5 minutes 2022-05-20 09:53:24 +02:00
nymkappa
897126d56f Update API documentation for e101c4e2 2022-05-20 09:49:13 +02:00
nymkappa
e101c4e218 Replace all avg_XXX with avgXXX for consistency 2022-05-20 09:44:29 +02:00
nymkappa
cac8c717ad Merge branch 'master' into simon/loading-indicator-ux 2022-05-20 09:16:32 +02:00
softsimon
e6c4b87b8b Moving graphs and mining dashboard to a lazy loaded module 2022-05-20 04:34:41 +04:00
Felipe Knorr Kuhn
449d6b17aa Merge branch 'master' into nymkappa/bugfix/reindex-when-fast-forward 2022-05-19 10:01:06 -07:00
hunicus
a402c5c861 Remove smaller time periods for hashrate endpoints
And clarify real-time hashrate data in /mining/hashrate.
2022-05-19 12:55:20 -04:00
wiz
0f0a46cd5c Merge pull request #1654 from hunicus/mining-api-docs
Add mining api docs
2022-05-20 01:39:53 +09:00
hunicus
5e5ff91280 Make small wording change for reward-stats 2022-05-19 12:21:41 -04:00
softsimon
e531289d46 Pull from transifex 2022-05-19 20:12:21 +04:00
wiz
dae9af7864 Merge branch 'master' into mining-api-docs 2022-05-20 01:05:43 +09:00
wiz
f3c20d91d9 Merge pull request #1676 from mempool/nymkappa/bugfix/duplicate-stats-call
Additional expiration header for mining pool API endpoints
2022-05-20 00:48:15 +09:00
nymkappa
a58d5b84b6 Set expiration to 1 min for /mining/reward-stats/:blockCount and /blocks-extras/:height 2022-05-19 17:20:42 +02:00
nymkappa
2a8314efc5 Move indexing logic into Indexer class 2022-05-19 16:41:14 +02:00
nymkappa
7f8696c88d Make sure to re-index skipped block when backend is offline for too long 2022-05-19 16:41:13 +02:00
wiz
6562a35f14 Merge branch 'master' into mining-api-docs 2022-05-19 20:45:20 +09:00
wiz
ae13f6119e Merge pull request #1674 from mempool/nymkappa/feature/block-api-cache
Cache /block API response for 10 min on user side
2022-05-19 19:38:15 +09:00
wiz
b2775509e2 Merge branch 'master' into nymkappa/feature/block-api-cache 2022-05-19 19:31:32 +09:00
wiz
63890a654f Merge pull request #1673 from mempool/nymkappa/feature/index-block-hash
Index blocks.hash
2022-05-19 19:31:19 +09:00
nymkappa
75dcfdd851 Cache /block API response for 10 min on user side 2022-05-19 12:17:26 +02:00
nymkappa
04bc41df3b Index blocks.hash 2022-05-19 12:13:43 +02:00
wiz
50b040524e Merge pull request #1670 from mempool/wiz/fix-about-page-resource-URLs
Don't prepend apiBasePath for services backend resources
2022-05-19 18:51:43 +09:00
wiz
2176af7ef9 Merge pull request #1672 from knorrium/cypress_961
Upgrade Cypress to v9.6.1
2022-05-19 18:49:36 +09:00
hunicus
ec3e1f9e70 Add testnet and signet for mining api docs 2022-05-19 05:39:35 -04:00
Felipe Knorr Kuhn
1da44cd4a6 Upgrade Cypress to v9.6.1 2022-05-18 22:01:28 -07:00
hunicus
e8ef4a39ec Hide js tabs for mining endpoints 2022-05-18 17:33:52 -04:00
hunicus
455412d2a0 Add mining api docs 2022-05-18 13:48:54 -04:00
wiz
b75f263c7e Don't prepend apiBasePath for services backend resources 2022-05-19 01:54:08 +09:00
wiz
aa08ac6edc Merge pull request #1669 from mempool/wiz/fix-prod-install-script-nodejs-v16.15
[installer] Add base64 to list of OS package deps
2022-05-19 01:31:49 +09:00
wiz
feafe02ac1 [installer] Add base64 to list of OS package deps 2022-05-19 01:30:02 +09:00
nymkappa
f402bfb097 Remove unescessary log 2022-05-18 15:01:24 +02:00
wiz
6f3739feb7 Merge branch 'master' into simon/loading-indicator-ux 2022-05-18 21:37:40 +09:00
wiz
4dd75cd24e Merge pull request #1664 from mempool/simon/i18n-additions
Adding some missing i18n strings
2022-05-18 21:37:24 +09:00
wiz
b7ed45cbe7 Merge branch 'master' into simon/i18n-additions 2022-05-18 21:18:05 +09:00
wiz
cf1ea34dad Merge pull request #1660 from mempool/wiz/fix-prod-install-script-nodejs-v16.15
Production installation fixes
2022-05-18 21:16:35 +09:00
wiz
4d213a89cc Merge pull request #1666 from ayanamitech/fix-nginx
Remove unused config from nginx
2022-05-18 21:13:50 +09:00
wiz
b22cae8da1 Merge pull request #1649 from ayanamitech/fix-poolupdater
pools-updater: Support secure Tor connection to sync data with Github
2022-05-18 21:11:32 +09:00
wiz
82ced490f2 Merge pull request #1637 from mempool/simon/optimize-reconnection
Tweaking the websocket retry timers
2022-05-18 20:52:23 +09:00
wiz
8022cec36b Merge branch 'master' into simon/optimize-reconnection 2022-05-18 20:41:03 +09:00
wiz
bd324fe287 Merge pull request #1632 from mempool/simon/outspends-cache-fix
Reset outspends cache when switching to new tx page.
2022-05-18 20:39:53 +09:00
wiz
a9012234f1 Merge branch 'master' into simon/outspends-cache-fix 2022-05-18 20:28:32 +09:00
wiz
d84ee4b264 Merge pull request #1665 from mempool/simon/getrawtransaction-recursive-fix
Fix for transaction inputs being fetched recursively
2022-05-18 20:26:50 +09:00
wiz
f91d9239e6 Merge branch 'master' into simon/getrawtransaction-recursive-fix 2022-05-18 20:11:20 +09:00
wiz
eadabf6e62 Merge pull request #1661 from mempool/nymkappa/feature/10min-blocktime-after-adjustment
Define avg block time to 10 min until we have at least 146 block in the current epoch
2022-05-18 20:10:08 +09:00
softsimon
b12b7d38d7 Adding some missing i18n strings 2022-05-18 15:06:58 +04:00
softsimon
2dad8ba8ec Fix for transactions being fetched recursively 2022-05-18 15:06:44 +04:00
wiz
dddf83a2d3 Merge branch 'master' into nymkappa/feature/10min-blocktime-after-adjustment 2022-05-18 20:02:29 +09:00
wiz
f42c9e1497 Merge pull request #1659 from mempool/nymkappa/feature/cleanup-mining-api-endpoints
Cleanup mining API endpoints
2022-05-18 20:01:05 +09:00
wiz
3fd2d74f81 Merge branch 'master' into nymkappa/feature/cleanup-mining-api-endpoints 2022-05-18 19:51:38 +09:00
wiz
383addc470 Merge pull request #1658 from mempool/nymkappa/bugfix/passive-listener
Use passive listeners to improve scrolling performance
2022-05-18 19:51:04 +09:00
wiz
25d5b31f1f Merge branch 'master' into nymkappa/bugfix/passive-listener 2022-05-18 19:38:31 +09:00
wiz
39660243b3 Merge pull request #1653 from mempool/nymkappa/feature/ctrlf-addresses
Allow CTRL F an address on the transaction list component
2022-05-18 19:30:07 +09:00
wiz
9c73e5be78 Merge branch 'master' into nymkappa/feature/ctrlf-addresses 2022-05-18 19:15:48 +09:00
wiz
b07826347a Merge pull request #1652 from mempool/nymkappa/bugfix/always-use-btc-mining
Always use BTC unit in blocks list
2022-05-18 19:14:49 +09:00
wiz
6fb8a88fc8 Merge branch 'master' into nymkappa/bugfix/always-use-btc-mining 2022-05-18 19:01:42 +09:00
softsimon
1093efe844 Improving loading indicator UX 2022-05-18 08:43:24 +04:00
Ayanami
fdb035c0d2 Remove unused config from nginx 2022-05-18 11:23:51 +09:00
Ayanami
d1671c4f1b add contributor sign for ayanamidev 2022-05-18 11:20:28 +09:00
Ayanami
0b351b9fcb pools-updater: Support secure Tor connection to sync data with Github
Use Axios instead of native https
2022-05-18 11:20:28 +09:00
softsimon
68116ab055 Merge pull request #1663 from mempool/simon/i18-corrections
Minor i18n corrections
2022-05-17 21:16:56 +04:00
softsimon
c09c694fb1 Minor i18n corrections 2022-05-17 19:27:41 +04:00
wiz
ca418e8c2a Merge pull request #1627 from mempool/simon/i18n-2.4
Correcting and harmonizing i18n strings
2022-05-18 00:01:33 +09:00
wiz
7cf01d6e34 Merge branch 'master' into simon/i18n-2.4 2022-05-17 23:04:38 +09:00
wiz
8af9c1d64f Merge pull request #1662 from mempool/nymkappa/bugfix/remove-useless-log
Delete useless log
2022-05-17 22:59:27 +09:00
nymkappa
5da94fa793 Delete useless log 2022-05-17 15:58:11 +02:00
wiz
1697f6df8e Merge pull request #1629 from mempool/nymkappa/feature/widget-size-align
Polish dashboards second widgets line
2022-05-17 22:33:55 +09:00
wiz
d364a53368 Merge branch 'master' into nymkappa/feature/widget-size-align 2022-05-17 21:58:51 +09:00
wiz
cabf486394 Merge pull request #1625 from knorrium/update_node_version
Update the recommended node version to v16.15.0 (LTS)
2022-05-17 21:57:27 +09:00
nymkappa
47bb073b9a Define avg block time to 10 min until we have at least 146 block in the current epoch 2022-05-17 14:40:18 +02:00
nymkappa
df59c21cfe Cleanup mining API endpoints 2022-05-17 12:02:50 +02:00
nymkappa
4463dae46b Use passive listeners to improve scrolling performance #1605 2022-05-17 11:39:13 +02:00
wiz
ece1cbbaa9 [installer] Fix mempool checkout for bisq instance 2022-05-17 17:43:35 +09:00
wiz
30337095cf [prod] Clarify syslog.conf syntax for priorities to keybase 2022-05-17 17:26:05 +09:00
wiz
5698468fbf [installer] Checkout top-level mempool using master branch 2022-05-17 17:25:31 +09:00
wiz
d2e041ec65 [installer] Fix electrs patch sed pattern typo introduced in #1628 2022-05-17 17:13:17 +09:00
wiz
c505ed5f0b [installer] Configure nvm to install Node.js v16.15.0 / npm v8.5.5 2022-05-17 17:13:03 +09:00
wiz
da3f516388 Merge pull request #1639 from hunicus/add-fullmempool-faqs
Add simple faq on full mempool
2022-05-17 17:08:58 +09:00
wiz
f879887fc5 Merge pull request #1556 from mempool/nymkappa/feature/update-block-api
Update block API
2022-05-17 16:20:11 +09:00
wiz
094257a9df Merge branch 'master' into nymkappa/feature/update-block-api 2022-05-17 15:57:05 +09:00
wiz
2fd0c06092 Merge pull request #1591 from mempool/nymkappa/bugfix/chain-validation-block-height
Skip missing blocks during block hash chain validation
2022-05-17 15:56:27 +09:00
wiz
4e96b1885e Merge pull request #1644 from mempool/nymkappa/feature/img-alt
Added some missing alt tags on some img
2022-05-17 15:55:48 +09:00
nymkappa
9be6f80cb9 Allow CTRL F an address on the transaction list component 2022-05-16 16:50:42 +02:00
nymkappa
fd42b12fcf Always use BTC unit in blocks list 2022-05-16 11:24:38 +02:00
nymkappa
0f39914a60 Added some missing alt tags on some img 2022-05-13 15:34:26 +02:00
nymkappa
7e8e4b1e6c If bisq data folder is not ready, retry every 3 minutes instead of exit 2022-05-13 11:54:52 +02:00
nymkappa
9377faea9c Skip missing blocks during block hash chain validation 2022-05-13 10:34:32 +02:00
wiz
e63aaedbc0 Merge pull request #1640 from knorrium/fix_electrum_tls_enabled_var 2022-05-13 03:12:05 +09:00
Felipe Knorr Kuhn
9f4ef70682 Merge branch 'master' into fix_electrum_tls_enabled_var 2022-05-12 10:21:21 -07:00
Felipe Knorr Kuhn
5d5be6f05d Fix ELECTRUM_TLS_ENABLED Docker variable 2022-05-12 10:17:53 -07:00
hunicus
858ad752c8 Add simple faq on "full" mempool 2022-05-12 11:50:23 -04:00
nymkappa
e59637128e Polish dashboards second widgets line 2022-05-12 17:05:31 +02:00
softsimon
a8d8a360ec Tweaking the websocket retry timers
fixes 1560
2022-05-12 15:21:27 +04:00
wiz
25e497ce2b Merge pull request #1636 from mempool/wiz/fix-minfee-node-bitcoin.conf
Modify minfee node bitcoin.conf to connect to external peers
2022-05-12 19:43:00 +09:00
wiz
4fdcf39639 Modify minfee node bitcoin.conf to connect to external peers 2022-05-12 19:35:58 +09:00
wiz
0b0b37b5aa Merge pull request #1633 from knorrium/fix_socks5_connection
Fix the socks5 connection after updating the socks lib
2022-05-12 16:20:42 +09:00
nymkappa
433bddab1f Remove unused pools.json observable definition 2022-05-12 08:13:42 +02:00
nymkappa
d26b1436b5 Always expose /block/{hash} API in the node backend 2022-05-12 08:13:42 +02:00
nymkappa
6ae44c6f7e Call node backend block API instead of electrs 2022-05-12 08:13:42 +02:00
nymkappa
384c8d17cf Only process mining pools on Bitcoin networks 2022-05-12 08:13:41 +02:00
nymkappa
964bf2671e Delete MinerComponent 2022-05-12 08:13:41 +02:00
nymkappa
ff74e6ea8c If block exists in memory cache, return it directly for /block API 2022-05-12 08:13:41 +02:00
nymkappa
067d160f33 Use block.extras on bitcoin network for fees/subsidy 2022-05-12 08:13:41 +02:00
nymkappa
057b5bd2e1 Update block API to use indexing if available 2022-05-12 08:13:40 +02:00
Felipe Knorr Kuhn
5ca9de5a42 Fix the socks5 connection after updating the socks lib 2022-05-11 19:08:41 -07:00
softsimon
3be67ea023 Reset outspends cache when switching to new tx page.
fixes #1613
fixes #1164
2022-05-12 03:28:34 +04:00
softsimon
9d33270970 Restoring the Confirmed string and re-localized the Multisig tag 2022-05-12 02:42:24 +04:00
softsimon
98c33ab08b Correcting and harmonizing i18n strings 2022-05-11 16:29:45 +04:00
wiz
b50f9b4e2d Merge pull request #1628 from mempool/wiz/reduce-production-electrs-loop-time-1s
[ops] Reduce electrs loop time from 5 seconds to 1 second
2022-05-11 19:01:55 +09:00
wiz
074e484cee Merge pull request #1630 from hunicus/update-issue-templates 2022-05-11 13:03:47 +09:00
hunicus
ec5d2134aa Remove bulb emoji
So users pay max attention to option titles and
pick the right one.
2022-05-10 18:31:42 -04:00
wiz
ab1bbaf8fd Merge pull request #1597 from mempool/nymkappa/feature/block-size-weight
Add block sizes vs weights graph
2022-05-10 23:59:19 +09:00
nymkappa
e9620b7b48 Add block sizes and weights graph 2022-05-10 16:41:40 +02:00
nymkappa
3e90650536 Add /api/v1/mining/blocks/sizes-weights/:interval API 2022-05-10 16:41:23 +02:00
wiz
250978ea91 Merge pull request #1561 from antonilol/recvd-htlcs
detect received lighting HTLC outputs
2022-05-10 23:23:45 +09:00
wiz
b17f882c64 Merge branch 'master' into recvd-htlcs 2022-05-10 23:11:28 +09:00
wiz
61a054b40f Merge pull request #1596 from mempool/nymkappa/feature/indexing-progress
Create indexing progress sticky notification
2022-05-10 23:02:48 +09:00
nymkappa
df177e0ea7 Localize indexing progress notifications 2022-05-10 15:48:21 +02:00
nymkappa
8398c3bcc5 Hide indexing notification in widget mode 2022-05-10 15:48:21 +02:00
nymkappa
de7c4774ec Added indexing progress indicator for hashrates, update logging 2022-05-10 15:48:21 +02:00
nymkappa
802e10e0a9 Create indexing sticky notification that show indexing progress in all mining dashboard related pages 2022-05-10 15:48:20 +02:00
wiz
11cdbb3118 Merge pull request #1601 from mempool/nymkappa/feature/chart-download
Add graph download feature
2022-05-10 22:45:14 +09:00
wiz
b47e4a93b6 Merge branch 'master' into nymkappa/feature/chart-download 2022-05-10 22:41:01 +09:00
wiz
8fb41eed44 [ops] Reduce electrs loop time from 5 seconds to 1 second 2022-05-10 21:52:07 +09:00
wiz
6803562daa Merge pull request #1617 from hunicus/address-lookups-faq
Add faq on address lookups
2022-05-10 21:44:07 +09:00
wiz
1988769c5f Merge branch 'master' into nymkappa/feature/chart-download 2022-05-10 21:43:33 +09:00
nymkappa
271f3c2317 [Chart download] Add .svg to file name, fix chart background colors 2022-05-10 14:32:57 +02:00
nymkappa
c62ed62db6 Change download button position so it's not hidden on mobile 2022-05-10 14:32:57 +02:00
nymkappa
7a487046b9 Add download button on pool ranking and mempool graphs 2022-05-10 14:32:57 +02:00
nymkappa
e8bb18fbc3 Add download feature on mining charts 2022-05-10 14:32:57 +02:00
wiz
7b15b2a475 Merge pull request #1618 from hunicus/remove-fiat-prompts-2
Remove $ from commands in repo docs
2022-05-10 20:48:16 +09:00
Felipe Knorr Kuhn
212cced969 Update the recommended node version to v16.5.0 (LTS) 2022-05-09 21:59:09 -07:00
dependabot[bot]
20db11f9d8 Bump clipboard from 2.0.10 to 2.0.11 in /frontend
Bumps [clipboard](https://github.com/zenorocha/clipboard.js) from 2.0.10 to 2.0.11.
- [Release notes](https://github.com/zenorocha/clipboard.js/releases)
- [Commits](https://github.com/zenorocha/clipboard.js/compare/v2.0.10...v2.0.11)

---
updated-dependencies:
- dependency-name: clipboard
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-10 02:09:37 +00:00
hunicus
8dde4510b5 Remove keybase from issue templates
Also link to #mempool.support instead of #mempool
matrix rooms.
2022-05-09 17:57:43 -04:00
hunicus
7fe425360c Remove keybase link and emphasize matrix link
By using a bolder emoji.
2022-05-09 17:57:43 -04:00
hunicus
0548263213 Make electrum server faq answer a list 2022-05-09 15:04:34 -04:00
Antoni Spaanderman
f61b8bf0fd detect received lighting HTLC outputs 2022-05-09 17:08:59 +02:00
hunicus
9a2043fab2 Remove $ from commands in repo docs 2022-05-09 02:35:03 -04:00
wiz
953f9405fc Merge pull request #1611 from hunicus/refine-prod-readme
Refine production deployment doc
2022-05-09 15:19:49 +09:00
wiz
2b9d9f985b Merge branch 'master' into address-lookups-faq 2022-05-09 15:18:42 +09:00
wiz
2d4401a336 Merge pull request #1594 from mempool/dependabot/npm_and_yarn/backend/express-4.18.1
Bump express from 4.17.1 to 4.18.1 in /backend
2022-05-09 15:17:23 +09:00
wiz
f359e956c1 Merge pull request #1593 from mempool/dependabot/npm_and_yarn/backend/ws-8.6.0
Bump ws from 8.3.0 to 8.6.0 in /backend
2022-05-09 15:09:36 +09:00
hunicus
48ed9fe824 Add faq link to address lookup error 2022-05-09 01:17:59 -04:00
hunicus
c019c7bc76 Add faq on address lookups / electrs issues 2022-05-09 01:17:59 -04:00
hunicus
f8cec63ad3 Add versions for node.js and npm 2022-05-09 01:07:21 -04:00
hunicus
88711b1d54 Remove fiat from commands 2022-05-09 00:57:48 -04:00
wiz
468ee7bcb1 Merge pull request #1585 from mempool/dependabot/npm_and_yarn/backend/typescript-4.6.4
Bump typescript from 4.4.4 to 4.6.4 in /backend
2022-05-09 11:49:35 +09:00
wiz
d5069985ef Merge pull request #1538 from mempool/dependabot/npm_and_yarn/backend/crypto-js-4.1.1
Bump crypto-js from 4.0.0 to 4.1.1 in /backend
2022-05-09 11:48:34 +09:00
dependabot[bot]
072c192d9a Bump ws from 8.3.0 to 8.6.0 in /backend
Bumps [ws](https://github.com/websockets/ws) from 8.3.0 to 8.6.0.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.3.0...8.6.0)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 02:42:41 +00:00
dependabot[bot]
06451f5342 Bump crypto-js from 4.0.0 to 4.1.1 in /backend
Bumps [crypto-js](https://github.com/brix/crypto-js) from 4.0.0 to 4.1.1.
- [Release notes](https://github.com/brix/crypto-js/releases)
- [Commits](https://github.com/brix/crypto-js/compare/4.0.0...4.1.1)

---
updated-dependencies:
- dependency-name: crypto-js
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 02:40:04 +00:00
dependabot[bot]
074104e973 Bump typescript from 4.4.4 to 4.6.4 in /backend
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.4.4 to 4.6.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.4.4...v4.6.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 02:39:48 +00:00
wiz
f13816a5d9 Merge pull request #1598 from antonilol/fix-lightning-csv-delay
fix lightning force close label with CSV delay <= 16
2022-05-09 10:55:18 +09:00
wiz
a892e569a3 Merge pull request #1590 from mempool/nymkappa/feature/hashrate-around-midnight
Run hashrate indexing after midnight
2022-05-09 10:45:24 +09:00
wiz
dd8dc74fe9 Merge pull request #1609 from hunicus/fix-readme-intro 2022-05-08 13:20:16 +09:00
wiz
61e2297f52 Merge pull request #1610 from hunicus/revert-docker-link 2022-05-08 13:19:19 +09:00
hunicus
e3c7dc1e4d Refine production readme 2022-05-07 18:35:17 -04:00
hunicus
015a419bb8 Change faq docker link since docker docs moved 2022-05-07 17:36:54 -04:00
hunicus
57bba2f806 Add back overwritten sentence to main readme 2022-05-07 17:20:58 -04:00
wiz
2b0270042a Merge pull request #1565 from mempool/nymkappa/bugfix/initial-indexing
Update pools table before fetching the first blocks
2022-05-07 15:25:51 +09:00
wiz
5281c48697 Merge branch 'master' into nymkappa/bugfix/initial-indexing 2022-05-07 13:51:24 +09:00
dependabot[bot]
3baf6fdcdc Bump express from 4.17.1 to 4.18.1 in /backend
Bumps [express](https://github.com/expressjs/express) from 4.17.1 to 4.18.1.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.18.1)

---
updated-dependencies:
- dependency-name: express
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-06 06:27:56 +00:00
wiz
da3c7588b8 Merge pull request #1584 from mempool/simon/npm-audit-fix-04-28
Upgrading npm packages and
2022-05-06 15:26:55 +09:00
wiz
5336ba8160 Merge branch 'master' into simon/npm-audit-fix-04-28 2022-05-06 15:11:28 +09:00
wiz
d385924777 Merge pull request #1568 from mempool/simon/docs-module
Moving Docs and Faq to separate lazy loaded module
2022-05-06 15:09:59 +09:00
wiz
023f8222f3 Merge branch 'master' into simon/docs-module 2022-05-06 15:01:51 +09:00
wiz
e00a6aa123 Merge pull request #1587 from knorrium/fix_tiny_typo
Fix datababse typo
2022-05-06 15:01:23 +09:00
wiz
ff57762935 Merge pull request #1600 from hunicus/update-screenshot-2.4.0
Add screenshot for 2.4.0 to readme
2022-05-06 15:00:05 +09:00
wiz
6b7e8f457b Merge branch 'master' into update-screenshot-2.4.0 2022-05-06 14:59:38 +09:00
wiz
7672deef31 Merge pull request #1599 from hunicus/refresh-readme
Revise main readme and docker install docs
2022-05-06 14:58:03 +09:00
wiz
1ff51e60db Merge branch 'master' into nymkappa/bugfix/initial-indexing 2022-05-06 14:55:29 +09:00
wiz
f45dc25a08 Merge pull request #1592 from mempool/nymkappa/feature/realtime-estimated-hashrate
Show current network hashrate and difficulty using core RPC
2022-05-06 14:35:30 +09:00
wiz
ab28c0344c Merge branch 'master' into nymkappa/feature/realtime-estimated-hashrate 2022-05-06 13:40:11 +09:00
wiz
178251370e Merge pull request #1580 from mempool/nymkappa/bugfix/skeleton-titles
Fix reward stats skeleton titles
2022-05-06 13:31:10 +09:00
wiz
452e9277b0 Merge branch 'master' into nymkappa/bugfix/skeleton-titles 2022-05-06 13:23:02 +09:00
hunicus
e27892e597 Clarify dependencies for manual install
h/t to antonilol.
2022-05-04 11:59:23 -04:00
hunicus
0aca907a67 Adjust main readme 2022-05-03 14:08:26 -04:00
hunicus
38b2beb9f7 Edit manual install section 2022-05-03 14:08:26 -04:00
hunicus
9753af1fed Move docker docs to ./docker/readme + edit 2022-05-03 14:08:26 -04:00
hunicus
f92036f8da Edit installation methods list + 1-click section
Remove HA item.
2022-05-03 14:08:26 -04:00
hunicus
a02e443130 Adjust opening readme description 2022-05-03 14:08:26 -04:00
hunicus
2a75aae628 Add screenshot for 2.4.0 to readme 2022-05-03 14:07:14 -04:00
Antoni Spaanderman
222696f859 fix lightning force close label with CSV delay <= 16 2022-05-03 17:26:32 +02:00
softsimon
9dcf421216 Upgrading npm packages and 2022-05-02 20:04:04 +04:00
nymkappa
3972e7b8f0 Show current network hashrate and difficulty even if indexing is in progress 2022-05-02 17:39:03 +09:00
nymkappa
1f4cf1710a Show getnetworkhashps core result in dashboard + update unit formatting 2022-05-02 17:33:52 +09:00
wiz
b6fcf40565 Merge pull request #1579 from mempool/nymkappa/bugfix/bisq-dump-loading
Clean local block cache before loading dump
2022-05-02 11:47:51 +09:00
wiz
0aac410958 Merge branch 'master' into nymkappa/bugfix/bisq-dump-loading 2022-05-02 11:29:05 +09:00
nymkappa
b56f110f28 Run hashrate indexing after midnight 2022-04-30 17:54:49 +09:00
Felipe Knorr Kuhn
0f4e0c7413 Fix datababse typo 2022-04-29 22:01:22 -07:00
nymkappa
540a8da64c Fix reward stats skeleton titles 2022-04-27 17:50:25 +09:00
nymkappa
6565c363f8 Update pools table before fetching the first blocks 2022-04-27 16:57:07 +09:00
nymkappa
6d308fc81c Clean local block cache before loading dump: 2022-04-27 13:06:16 +09:00
softsimon
9b4c6b9e2c Moving Docs and Faq to separate lazy loaded module 2022-04-26 13:02:13 +04:00
wiz
bf314be7eb Merge pull request #1571 from hunicus/docker-faq-link 2022-04-25 23:31:42 +00:00
wiz
14e23831eb Merge pull request #1569 from mempool/nymkappa/bugfix/bisq-dump-loading
Read bisq dump blocks line by line and parse manually
2022-04-25 23:06:03 +00:00
wiz
addfa45548 Merge branch 'master' into nymkappa/bugfix/bisq-dump-loading 2022-04-25 22:55:56 +00:00
wiz
d701bbb2d8 Merge pull request #1564 from mempool/nymkappa/bugfix/binance-regex
Ignore case on coinbase tag regexes
2022-04-25 22:38:49 +00:00
hunicus
a3bbd286d6 Update docker faq 2022-04-24 23:12:35 -04:00
nymkappa
0ad267b07f Read bisq dump blocks line by line and parse manually 2022-04-25 11:49:04 +09:00
wiz
58d361df06 Merge pull request #1563 from mempool/nymkappa/feature/remove-block-extras-loading-indicator
Remove loading indicator for blocks-extras API
2022-04-24 07:25:27 +00:00
wiz
3189525bb6 Merge pull request #1554 from mempool/nymkappa/bugfix/fast-forward-re-org
Validate block hash chain after indexing and for new blocks
2022-04-24 06:53:15 +00:00
wiz
8d279edfe7 Merge branch 'master' into nymkappa/bugfix/fast-forward-re-org 2022-04-24 05:54:42 +00:00
wiz
e15abe6851 Merge pull request #1553 from mempool/nymkappa/bufix/blocks-list-skeleton
Update blocks list skeleton
2022-04-24 04:03:19 +00:00
wiz
97bd7ebbdd Merge branch 'master' into nymkappa/bufix/blocks-list-skeleton 2022-04-24 03:52:18 +00:00
wiz
71334516e2 Merge pull request #1548 from mempool/nymkappa/feature/timespan-selector-update
Use block count instead of oldest block for timespan selection
2022-04-24 03:51:47 +00:00
nymkappa
0803fed0f4 Fix pool component hashrate api response handling 2022-04-23 15:51:00 +09:00
wiz
6ae20ead63 Merge branch 'master' into nymkappa/feature/timespan-selector-update 2022-04-23 06:23:23 +00:00
wiz
369a986714 Merge pull request #1521 from mempool/nymkappa/feature/fee-range-chart
Add block fee rates percentiles chart
2022-04-23 06:08:34 +00:00
wiz
ed495cc019 Merge branch 'master' into nymkappa/feature/fee-range-chart 2022-04-23 04:44:03 +00:00
wiz
aea86e520e Merge pull request #1558 from mempool/nymkappa/bugfix/liquid-icons 2022-04-23 00:51:36 +00:00
nymkappa
c51216f97c Remove hardcoded liquid.network in asset icons url 2022-04-23 08:56:55 +09:00
nymkappa
0565471ecf Wait for external assets file writers to complete 2022-04-22 04:03:08 -04:00
nymkappa
0860e16b2b Ignore case on coinbase tag regexes 2022-04-22 03:25:34 -04:00
nymkappa
77fddc7ed9 Remove loading indicator for blocks-extras API 2022-04-22 00:49:02 -04:00
softsimon
e8d6872620 Merge pull request #1555 from mempool/wiz/add-mercury-wallet
Add mercury wallet in the about page
2022-04-20 14:07:42 +04:00
nymkappa
a68bab2c96 Add Mercury Wallet on About page as Wallet Integration 2022-04-19 22:38:25 +09:00
nymkappa
84b72f8b32 Manually re-index the last 10 blocks when the new block previoushash does not match latest block hash 2022-04-19 15:45:06 +09:00
nymkappa
900e02d9a5 Validate block hash chain after indexing and for new blocks 2022-04-18 17:49:22 +09:00
nymkappa
a2ad69beb1 Update blocks list skeleton 2022-04-18 11:54:52 +09:00
nymkappa
f7d57a2737 Use block count instead of oldest block for timespan selection 2022-04-15 20:43:10 +09:00
nymkappa
d0b27813b0 Save fee rates legend preference - Fix xaxis label 2022-04-15 19:39:27 +09:00
nymkappa
31ded69a4c Update cache warmer 2022-04-15 18:05:58 +09:00
nymkappa
b79fb6265c 24h/3d block fee rates chart is clickable 2022-04-15 16:16:18 +09:00
nymkappa
3ce6e81a39 Add block fee rate percentiles chart 2022-04-15 16:16:15 +09:00
nymkappa
078c7ac228 Add /api/v1/mining/blocks/fee-rates/{interval} API 2022-04-15 16:14:20 +09:00
wiz
653ce3e40c Merge pull request #1546 from mempool/nymkappa/bugfix/liquid-icon 2022-04-15 05:02:54 +00:00
nymkappa
4f4f76f067 Add try/catch liquid icon loading 2022-04-15 13:20:54 +09:00
wiz
ae98c49986 Merge pull request #1433 from knorrium/download_assets_over_tor
Allow syncing external backend assets using Tor
2022-04-14 21:46:55 +00:00
wiz
89d62b7be2 Merge branch 'master' into download_assets_over_tor 2022-04-14 21:35:59 +00:00
wiz
1c3d0363b0 Merge pull request #1341 from naveensrinivasan/naveen/pin-workflow-actions
Pin actions by SHA and set permissions for workflow
2022-04-14 21:34:40 +00:00
wiz
9cb8f64bbd Merge pull request #1518 from mempool/simon/remove-locutus-lib
Breaking out strtotime from locutus lib
2022-04-14 21:33:21 +00:00
wiz
026e66302a Merge branch 'master' into simon/remove-locutus-lib 2022-04-14 21:25:36 +00:00
wiz
3ea854dad2 Merge pull request #1339 from naveensrinivasan/naveensrinivasan/dependabot
Create dependabot.yml
2022-04-14 21:11:48 +00:00
wiz
45cc8b8775 Merge pull request #1505 from mempool/simon/sponsor-page-ux
Sponsor page revamped
2022-04-14 21:05:15 +00:00
wiz
bba4b5d32c Merge branch 'master' into simon/sponsor-page-ux 2022-04-14 20:51:49 +00:00
wiz
417542a217 Merge branch 'master' into simon/remove-locutus-lib 2022-04-14 20:27:58 +00:00
wiz
97f5e5883c Merge pull request #1517 from mempool/nymkappa/feature/refactor-db
Refactor database pool use
2022-04-14 20:12:11 +00:00
wiz
05f58026b0 Merge branch 'master' into nymkappa/feature/refactor-db 2022-04-14 20:11:53 +00:00
softsimon
14f25e7d63 Merge pull request #1499 from mempool/wiz/fix-newsyslog-for-backend
Fix log rotation configuration for mempool backend logs
2022-04-13 18:13:39 +04:00
softsimon
6919393e6c Refactored the DB class into a regular singleton class. 2022-04-13 17:38:42 +04:00
nymkappa
6fb0571b06 Refactor database pool use 2022-04-13 21:46:39 +09:00
softsimon
ec4405b07a Merge pull request #1519 from mempool/nymkappa/feature/cleanup-logs
Cleanup mining related backend logs
2022-04-13 14:58:18 +04:00
nymkappa
bee0dbd400 Cleanup mining related backend logs 2022-04-13 16:30:49 +09:00
softsimon
762c75803a Merge pull request #1473 from hunicus/add-faq
Add faq
2022-04-13 02:34:35 +04:00
hunicus
01f474628a Add websocket service to avoid issues with blocks 2022-04-12 18:06:32 -04:00
hunicus
1348e953a6 Merge branch 'master' into add-faq 2022-04-12 16:03:28 -04:00
hunicus
e50b58b8aa Add live mempool blocks to faq (h/t @softsimon) 2022-04-12 15:58:20 -04:00
hunicus
88c50f7107 Resolve conflict resulting from 315b759 2022-04-12 15:33:24 -04:00
hunicus
039e6bbe77 Add answers, fix accordions, tweak footer styling
Main purpose of this commit is to remove iframes from git
history. This commit squashes several commits that came
after iframes were added.
2022-04-12 15:31:45 -04:00
softsimon
cb894221dd Merge pull request #1502 from antonilol/script-display-2
fix wrong display of other sighash types + p2sh redeemScript when <=4 bytes + consistency with esplora backend + tapscript fixes
2022-04-12 22:32:21 +04:00
softsimon
b273f71d60 Breaking out strtotime from locutus lib 2022-04-12 17:52:30 +04:00
Antoni Spaanderman
b9127538ce Merge branch 'master' into script-display-2 2022-04-11 21:46:06 +02:00
softsimon
dd03629d20 Merge pull request #1495 from mempool/nymkappa/bugfix/fix-z-warning
Set zlevel for all graphs series
2022-04-11 17:18:57 +04:00
softsimon
d97bf332d1 Merge branch 'master' into nymkappa/bugfix/fix-z-warning 2022-04-11 16:54:04 +04:00
softsimon
5633fcb955 Merge pull request #1513 from mempool/nymkappa/feature/block-reward-graph
Add block rewards graph
2022-04-11 16:53:36 +04:00
nymkappa
d8915ad385 Update cache warmer 2022-04-11 21:20:20 +09:00
nymkappa
25c55b53a2 Set zlevel for all graphs series 2022-04-11 21:17:15 +09:00
nymkappa
8fb488a675 Add block rewards chart 2022-04-11 20:57:13 +09:00
softsimon
233af87eb4 Merge pull request #1512 from mempool/nymkappa/feature/reward-fee-graph
Add block fees graph
2022-04-11 15:17:11 +04:00
nymkappa
7dd0173e84 Improve mining graphs timespan selection UX 2022-04-11 18:17:36 +09:00
nymkappa
848e02eca0 Add new api to cache warmer 2022-04-11 15:32:17 +09:00
nymkappa
08e19a612c Add block fees graph 2022-04-11 15:32:16 +09:00
nymkappa
15cc503387 Move graph mining chart link into dropdown 2022-04-11 15:31:39 +09:00
softsimon
4b57dc8833 Merge pull request #1369 from nymkappa/feature/detect-re-org
[Indexing] - Support 10 blocks depth reorgs
2022-04-10 12:48:45 +04:00
softsimon
2abd22778f Merge pull request #1514 from antonilol/fix-address-labels
Fix Lightning HTLC detection with options_anchors
2022-04-10 12:48:12 +04:00
nymkappa
90ca668bcb [Indexing] - Support 10 blocks depth reorgs 2022-04-10 16:28:22 +09:00
Antoni Spaanderman
b4fce5cb00 Fix Lightning HTLC detection with options_anchors
rename `OP_CHECKSEQUENCEVERIFY` to `OP_CSV` in regex
2022-04-10 00:20:19 +02:00
softsimon
ac5749f493 Merge pull request #1506 from TechMiX/rtlFixes2
fix RTL layout issues
2022-04-10 00:32:13 +04:00
softsimon
627ff46541 Merge pull request #1511 from mempool/nymkappa/feature/handle-poolsjson-change
Use github api to fetch and update the pools database, once a week
2022-04-08 14:26:19 +04:00
nymkappa
ba12b10f9d Handle empty pools table error 2022-04-07 18:14:28 +09:00
nymkappa
e451b40084 Catch http request error - Fix 24h retry period 2022-04-07 16:14:43 +09:00
nymkappa
2d29b9ef89 Upon error, re-run the PoolsUpdater within 24h instead of 7d 2022-04-07 14:51:23 +09:00
nymkappa
1969f2a275 Use github api to fetch and update the pools database, once a week 2022-04-07 14:37:16 +09:00
softsimon
4d0f47b2ca Merge pull request #1510 from mempool/simon/fix-broken-npm-start
Npm run start broke
2022-04-06 15:40:48 +04:00
softsimon
bc9063e490 Npm run start broke 2022-04-06 15:40:26 +04:00
softsimon
f5c558e055 Merge pull request #1492 from mempool/nymkappa/bugfix/unknown-miner-tag
If mining dashboard is enabled, set block miner to "Unknown" by default
2022-04-06 14:35:50 +04:00
softsimon
33001ce96c Merge pull request #1503 from mempool/nymkappa/feature/additional-pool-data
Updated pool summary page to display more info on hashrate and blocks
2022-04-06 14:31:53 +04:00
nymkappa
6d876ad219 Update addresses button 2022-04-06 15:02:24 +09:00
TechMiX
9a389cc9cd add contributer signiture for TechMiX 2022-04-05 21:26:17 +02:00
TechMiX
0c3f9c895e fix RTL layout issues 2022-04-05 20:37:18 +02:00
softsimon
1a35c8ce42 Sponsor page revamped 2022-04-05 21:00:36 +04:00
softsimon
cec857eb63 Merge pull request #1504 from mempool/nymkappa/feature/update-link
Update AS142052 link
2022-04-05 12:46:26 +04:00
nymkappa
c733782d04 Update AS142052 link 2022-04-05 01:57:45 +09:00
nymkappa
c4db7ec5f6 Updated pool summary page to display more info on hashrate and blocks 2022-04-05 00:36:00 +09:00
Antoni Spaanderman
53d68a3571 name tapscript by its name + OP_CHECKSIGADD tapscript opcode detection 2022-04-04 17:16:34 +02:00
softsimon
6386f4c68a Merge pull request #1486 from mempool/simon/bitcoin-api-roundings
Rounding bitcoin api satoshis
2022-04-04 13:18:10 +04:00
Antoni Spaanderman
096f2172c6 more direct opcode comparison 2022-04-03 21:58:53 +02:00
Antoni Spaanderman
dfb5ba5c36 Completely rewrote convertScriptSigAsm
it now gives identical output to esplora, tested with the following TXs (testnet):

88710a9a6751827490f260e307757543f533c0f18bcd6865794713d263d5f5a4
446b2aad074de94efa28a1e82d2e6016dcb8a8ca38aca1a5a8eac6ef54e56a2e
4cfc410092e9514c14f48b61e20d2d3baf540ae7e981a821dd8c05dd4b7cd591
4b55dde38173174ab09e5571ebffffca798ba11143d28b9770600ff376dc778a
2022-04-03 21:41:12 +02:00
softsimon
ba92284e44 Merge pull request #1487 from mempool/nymkappa/bugfix/invalid-pool-handling
Send 404 when accessing non existing mining pool
2022-04-03 17:37:09 +04:00
softsimon
effe85f7c0 Merge pull request #1498 from mempool/nymkappa/bugfix/avoid-duplicated-indexing
Avoid parralel hashrate indexing when initial query is too slow
2022-04-03 15:57:43 +04:00
softsimon
ab8d0a02c7 Merge pull request #1501 from mempool/simon/opcode-coloring
Correcting op_code coloring
2022-04-03 15:31:11 +04:00
softsimon
4bd3030322 Correcting op_code coloring 2022-04-03 15:22:35 +04:00
softsimon
e27d80865f Merge pull request #1500 from mempool/simon/opcodes-fixes
Correcting wrong or missing op_codes display
2022-04-03 14:49:15 +04:00
softsimon
3115dcbe52 Correcting wrong or missing op_codes display
fixes #1210
2022-04-03 13:59:26 +04:00
nymkappa
f393cb0839 Wrap initial query in try/catch to reset the flag upon error 2022-04-03 15:47:33 +09:00
nymkappa
2ef2a34766 Avoid parralel hashrate indexing when initial query is too slow 2022-04-03 15:47:29 +09:00
softsimon
8d97351598 Merge pull request #1488 from mempool/nymkappa/feature/testnet-signet-empty-pool-addresses
Return empty pool addresses on testnet and signet
2022-04-03 01:13:35 +04:00
softsimon
f6b7a94b36 Merge pull request #1496 from mempool/nymkappa/bugfix/dont-assume-init-block-count
Mining stats does not depends on the websocket blocks number anymore
2022-04-03 01:08:24 +04:00
softsimon
d2fb80fb2c Merge pull request #1464 from antonilol/lightning-scripts
Detect more lightning scripts
2022-04-03 00:28:18 +04:00
softsimon
c9d4f90c15 Merge pull request #1401 from mempool/nymkappa/bugfix/mobile-ui-mining-dashboard
Fix some mobile UI issues on mining dashboard
2022-04-02 23:02:05 +04:00
nymkappa
2b79d6c935 Fix some mobile UI issues on mining dashboard 2022-04-03 03:19:25 +09:00
wiz
918798aca3 Fix newsyslog configuration for mempool backend 2022-04-02 10:14:22 -04:00
nymkappa
c3a3289fcf Mining stats does not depends on the websocket blocks number anymore 2022-04-01 12:41:25 +09:00
softsimon
2374f98ca8 Merge pull request #1482 from mempool/nymkappa/feature/remove-unused-endpoint
Remove unused `/api/v1/mining/difficulty/{interval}` endpoint
2022-03-31 19:38:24 +04:00
softsimon
94e0416951 Merge pull request #1493 from mempool/nymkappa/bugfix/websocket-graphs
Subscribe to websocket blocks update for all graphs components
2022-03-31 19:36:26 +04:00
nymkappa
52735553dd Subscribe to websocket blocks update for all graphs components 2022-04-01 00:25:46 +09:00
nymkappa
2521661c69 Remove unfiltered using input from log 2022-03-31 18:35:03 +09:00
softsimon
08accbca5d Merge pull request #1491 from hunicus/docs-scrolling
Apply smooth scrolling to docs only
2022-03-31 13:30:13 +04:00
nymkappa
0b5cba15d6 If mining dashboard is enabled, set block miner to "Unknown" by default 2022-03-31 00:14:12 +09:00
softsimon
b89eb58928 Merge pull request #1490 from mempool/nymkappa/bugfix/miner-tag-no-slug
Don't use `slugs` if it's not available in pools.json frontend
2022-03-30 17:48:16 +04:00
hunicus
315b7593bf Apply smooth scrolling to docs only 2022-03-30 09:44:41 -04:00
nymkappa
68f3022420 Don't use slugs if it's not available in pools.json frontend 2022-03-30 22:18:03 +09:00
wiz
ad89d9d9e8 Merge pull request #1475 from mempool/wiz/enable-nginx-warm-caching-for-all-mining-apis
Enable nginx warm cache for all /api/v1/mining API endpoints
2022-03-30 12:26:47 +00:00
wiz
188723cb55 Merge pull request #1483 from mempool/nymkappa/feature/cache-warn-mining
Add missing mining API endpoint to cache warmer
2022-03-30 12:25:50 +00:00
softsimon
0503bc6de8 Merge pull request #1485 from mempool/nymkappa/bugfix/pool-page-label
Update pool detail page label - Fix no data text
2022-03-30 16:24:53 +04:00
softsimon
a79a410859 Merge pull request #1489 from mempool/nymkappa/bugfix/single-call-pool-page
Fix spam call to `/api/v1/mining/pool/{slug}`
2022-03-30 15:42:08 +04:00
nymkappa
d70e183236 Add missing endpoints to cache warmer 2022-03-30 19:52:06 +09:00
nymkappa
12ec6bbf67 /api/v1/mining/difficulty/{interval} is not used 2022-03-30 19:46:17 +09:00
nymkappa
4b2698eee6 Use local block buffer to trigger pagination api call 2022-03-30 19:02:05 +09:00
nymkappa
a20c401c83 Fix spam call to /api/v1/mining/pool/{slug} 2022-03-30 18:43:01 +09:00
nymkappa
84394e13fa Return empty pool addresses on testnet and signet 2022-03-30 16:49:28 +09:00
softsimon
fb0e7ec240 Merge pull request #1484 from mempool/nymkappa/feature/block-reward-all-network
Show block reward on blockchain blocks for all Bitcoin networks
2022-03-30 11:39:36 +04:00
nymkappa
ccafe4a066 Send 404 when accessing non existing mining pool 2022-03-30 16:27:17 +09:00
softsimon
9a4d3817c5 Rounding bitcoin api satoshis
fixes #1466
2022-03-30 11:12:55 +04:00
nymkappa
f3847e483d Update pool detail page label - Fix no data text 2022-03-30 16:11:18 +09:00
nymkappa
1f20a56ae7 Show block reward on blockchain blocks for all Bitcoin networks 2022-03-30 15:47:47 +09:00
wiz
b1749ee6b6 Enable nginx warm cache for all /api/v1/mining API endpoints 2022-03-29 12:07:16 -05:00
wiz
796db0de4b Merge pull request #1474 from mempool/nymkappa/bugfix/cache-warmer-pool-slug
Use slugs in cache warmer
2022-03-29 16:43:00 +00:00
wiz
a33d558294 Fix nginx cache warmer script for url slugs 2022-03-29 11:40:37 -05:00
wiz
0561a207d9 Add jq to production deps in install script 2022-03-29 11:25:25 -05:00
nymkappa
1088655b1f Use slugs in cache warmer 2022-03-30 01:06:42 +09:00
softsimon
021a748e11 Merge pull request #1472 from mempool/nymkappa/feature/pool-chart-timespan
Add data zoom on pool hashrate chart
2022-03-29 19:52:56 +04:00
softsimon
51ddc3a959 Merge branch 'master' into nymkappa/feature/pool-chart-timespan 2022-03-29 19:00:19 +04:00
Antoni Spaanderman
105b67e566 Merge branch 'master' into lightning-scripts 2022-03-29 16:26:20 +02:00
Antoni Spaanderman
493b44d4b9 detect bare multisigs with handleVout 2022-03-29 16:16:20 +02:00
Antoni Spaanderman
b5ef148b82 replace 3 seperate labels with one AddressLabelsComponent.label?: string
+ consistency: move comments in the `if` blocks
2022-03-29 15:47:48 +02:00
softsimon
0965140bd5 Merge pull request #1457 from mempool/nymkappa/feature/address-list-collapse
Pool addresses collapse - Cleanup mobile layout
2022-03-29 15:28:36 +04:00
nymkappa
b465b7abba Add data zoom on pool hashrate chart 2022-03-29 18:20:00 +09:00
softsimon
ae8830d68b Merge branch 'master' into nymkappa/feature/address-list-collapse 2022-03-29 13:08:11 +04:00
softsimon
ec36faf98f Merge pull request #1468 from mempool/nymkappa/feature/blocks-pool-link
Use mining pool slug in block component
2022-03-29 13:07:43 +04:00
softsimon
cbb157a94c Merge pull request #1470 from mempool/nymkappa/bugfix/insert-unknown-pool
Fix query to insert unknown mining pool
2022-03-29 11:45:28 +04:00
nymkappa
7ab950d03c Add slug when we insert a mining pool for the first time 2022-03-29 16:31:26 +09:00
nymkappa
f51ea5b537 Fix query to insert unknown mining pool 2022-03-29 14:37:17 +09:00
nymkappa
8fba450033 Use mining pool slug in block component 2022-03-29 13:34:25 +09:00
wiz
7f7f8a490d Merge pull request #1459 from mempool/simon/about-page-wallets-arrange
Rearrange wallet providers on About page.
2022-03-29 04:24:53 +00:00
wiz
cb1a5ed976 Merge branch 'master' into simon/about-page-wallets-arrange 2022-03-29 04:14:43 +00:00
wiz
d516566f90 Merge pull request #1467 from mempool/nymkappa/bugfix/pool-slug-missing
Use slug instead of id in mining blocks list component
2022-03-29 04:14:33 +00:00
nymkappa
cc27b963d3 Use slug instead of id in mining blocks list component 2022-03-29 12:50:57 +09:00
nymkappa
5d9e8d0177 Fix pool page skeleton 2022-03-29 10:52:50 +09:00
Antoni Spaanderman
56656839b3 Detect more lightning scripts:
- expired htlc
- anchor
- swept anchor

Fix indentation what i messed up in 7565aa7

Add explanation
2022-03-27 16:13:48 +02:00
softsimon
9de8f78b30 Merge pull request #1463 from mempool/simon/3-27-audit-fix
npm audit fix
2022-03-27 14:33:57 +04:00
softsimon
32792f4f74 npm audit fix 2022-03-27 14:26:06 +04:00
hunicus
663cf100d1 Add no-sanitize pipe 2022-03-27 01:19:48 -04:00
hunicus
c6c335921c Finish adding non-graphical faq content 2022-03-26 23:31:49 -04:00
hunicus
ef2c845714 Generalize api-docs components to accommodate faq
Also add chunk of faq content.
2022-03-26 09:09:37 -04:00
softsimon
dc9ef154d4 Merge pull request #1456 from mempool/nymkappa/feature/pool-slug-url
Use mining pool slug in urls
2022-03-26 11:07:48 +04:00
nymkappa
9b04b3bcd6 Merge branch 'master' into nymkappa/feature/pool-slug-url 2022-03-26 12:08:39 +09:00
softsimon
3198feb46d Rearrange wallet providers on About page. 2022-03-25 21:52:00 +04:00
softsimon
b02c690924 Merge pull request #1458 from mempool/nymkappa/bugfix/jumping-tooltip
Disable glitchy angular tooltips animation
2022-03-25 19:15:02 +04:00
softsimon
7f6c8fdbac Merge pull request #1451 from mempool/nymkappa/bugfix/handle-crash-pool-parser
If pool slug does not exist, generate one on the fly, avoid crash
2022-03-25 19:11:46 +04:00
softsimon
fc5b769e2b Merge pull request #1450 from mempool/nymkappa/bugfix/relative-pool-url
Use relative pipe for pie chart click event
2022-03-25 18:27:28 +04:00
softsimon
7e7dd1213e Merge branch 'master' into nymkappa/bugfix/relative-pool-url 2022-03-25 17:20:30 +04:00
nymkappa
0a57f57a93 Disable angular tooltip animation globally 2022-03-25 22:15:16 +09:00
softsimon
acd4ab5357 Merge pull request #1449 from mempool/nymkappa/bugfix/echart-warning
Remove unnecessary echart init option
2022-03-25 16:54:26 +04:00
softsimon
f87da211dc Merge pull request #1428 from mempool/bugfix/blocks-list-css
Fix blocks list mobile layout
2022-03-25 16:52:45 +04:00
softsimon
fcaa6100b7 Merge pull request #1445 from mempool/nymkappa/bugfix/avg-fee-rounding
Fix rounding issue in reward stats
2022-03-25 16:52:08 +04:00
nymkappa
ef49457ec6 Pool addresses collapse - Cleanup mobile layout 2022-03-25 17:48:24 +09:00
nymkappa
352ea950a2 Use mining pool slug in urls 2022-03-25 14:22:22 +09:00
nymkappa
810c335759 If pool slug does not exist, generate one on the fly, avoid crash 2022-03-25 12:31:09 +09:00
nymkappa
c5837ab9df Round using AmountShortenerPipe 2022-03-25 11:39:29 +09:00
nymkappa
b075fedd7c Use relative pipe for pie chart click event 2022-03-25 10:57:34 +09:00
nymkappa
27d2127d46 Remove unnecessary echart init option 2022-03-25 10:08:20 +09:00
wiz
a016d1c071 Merge branch 'master' into nymkappa/bugfix/avg-fee-rounding 2022-03-24 16:30:57 +00:00
wiz
8114ffe1c8 Merge pull request #1446 from mempool/nymkappa/feature/pool-slug
Added slug into `pools` table
2022-03-24 16:29:54 +00:00
hunicus
289ed7b9b3 Make faq tab default when navigating to docs 2022-03-24 10:52:50 -04:00
hunicus
61faf31644 Fix routing for faq tab
Make API links relative + add routing for signet and
testnet.
2022-03-24 10:41:09 -04:00
hunicus
37e2786c5e Add faq tab placeholder 2022-03-24 08:55:20 -04:00
nymkappa
bb0fd78f28 Added slug into pools table 2022-03-24 19:44:22 +09:00
nymkappa
f1bb742341 Fix rounding issue in reward stats 2022-03-24 18:03:12 +09:00
wiz
a384328f50 Merge branch 'master' into bugfix/blocks-list-css 2022-03-24 00:55:36 +00:00
wiz
77df0c524c Merge pull request #1437 from mempool/nymkappa/bugfix/truncate-hashrates
Truncate hashrates after #1435 - Fix hashrate indexing logs
2022-03-24 00:55:15 +00:00
nymkappa
185dddd8c7 Truncate hashrates after #1435 - Fix hashrate indexing logs 2022-03-24 07:40:03 +09:00
wiz
80a103acab Merge pull request #1435 from mempool/simon/last-hashrate-indexing-millisecond-check
Last hashrate indexing check needs to be in milliseconds
2022-03-23 20:34:27 +00:00
softsimon
dcaa7fc4e8 Last hashrate indexing check needs to be in milliseconds 2022-03-24 00:24:17 +04:00
wiz
46405438d3 Merge pull request #1434 from knorrium/fix_git_commit_error
Fix git commit error
2022-03-23 19:49:14 +00:00
wiz
223dc46bd5 Merge branch 'master' into fix_git_commit_error 2022-03-23 19:49:04 +00:00
Felipe Knorr Kuhn
9c3fc9f75a Update frontend git commit hash logic 2022-03-23 12:33:47 -07:00
Felipe Knorr Kuhn
230fbdbc8e Fix empty revision case 2022-03-23 12:33:15 -07:00
Felipe Knorr Kuhn
4bb6f49950 Copy the git commit hash logic to the backend 2022-03-23 12:17:23 -07:00
Felipe Knorr Kuhn
f88af9c3f9 Add the DOCKER_COMMIT_HASH env var to the backend Dockerfile 2022-03-23 12:16:21 -07:00
wiz
3f58145e7b Merge pull request #1424 from mempool/nymkappa/bugfix/hashrate-native-js-timestamp
Set weekly hashrates timestamp to midnight
2022-03-23 18:28:33 +00:00
Felipe Knorr Kuhn
3e2e23417a Allow syncing external backend assets using Tor 2022-03-23 08:11:22 -07:00
nymkappa
fae49ba66e Merge branch 'master' into bugfix/blocks-list-css 2022-03-23 19:10:55 +09:00
nymkappa
a91fa797fa Merge branch 'master' into nymkappa/bugfix/hashrate-native-js-timestamp 2022-03-23 19:10:21 +09:00
softsimon
aaa8945b09 Merge pull request #1427 from mempool/nymkappa/feature/reward-stats-api
More dynamic mining reward
2022-03-23 11:41:57 +04:00
nymkappa
dcd50802e4 Use fee estimation box layout for reward stats and show USD amounts 2022-03-23 12:15:58 +09:00
nymkappa
fb7e81af57 Add more verbose description for stats + i18n 2022-03-23 11:54:36 +09:00
nymkappa
8cc005cb2c Refresh reward stats when a new block is mined 2022-03-23 11:54:36 +09:00
nymkappa
2644f2fb07 Move reward stats to component - Add /api/v1/mining/reward-stats/{blockCount} 2022-03-23 11:54:31 +09:00
wiz
7ace0cfbc0 Merge branch 'master' into nymkappa/bugfix/hashrate-native-js-timestamp 2022-03-23 00:09:55 +00:00
softsimon
5c629dfe98 Merge pull request #1430 from mempool/nymkappa/feature/pool-page-skeleton
Improve skeleton on pool detail page
2022-03-23 01:49:14 +04:00
softsimon
a1c796766e Merge branch 'master' into nymkappa/feature/pool-page-skeleton 2022-03-23 01:34:24 +04:00
softsimon
829ee9f460 Merge pull request #1429 from mempool/nymkappa/feature/format-incoming-vbytes-sec
Format Transaction vBytes per second (vB/s) tooltip value
2022-03-23 01:29:38 +04:00
softsimon
7a88f28a1d Merge branch 'master' into nymkappa/feature/format-incoming-vbytes-sec 2022-03-23 01:07:49 +04:00
softsimon
2ddb23beb5 Merge pull request #1431 from mempool/nymkappa/feature/remove-hover-blocks-dashboard
Don't show coinbase tooltip on mining dashboard
2022-03-22 14:21:01 +04:00
nymkappa
e9b83e6167 Don't show coinbase tooltip on mining dashboard 2022-03-22 18:31:28 +09:00
nymkappa
1566a831ed Improve skeleton on pool detail page 2022-03-22 17:19:34 +09:00
nymkappa
ff77a8ef47 Format Transaction vBytes per second (vB/s) tooltip value 2022-03-22 16:03:54 +09:00
nymkappa
7c1155ec93 Make sure blocks list container is at least 100vh on mobile 2022-03-22 15:43:04 +09:00
nymkappa
e1623b9234 Fix blocks list pagination on mobile 2022-03-22 15:16:15 +09:00
nymkappa
e5fd92b734 Most recent week was missing from indexing - Post merge fixes 2022-03-22 09:20:16 +09:00
nymkappa
74f4a6fcb4 Work using native javascript milliseconds timestamp 2022-03-22 08:44:54 +09:00
wiz
502ef29e54 Merge pull request #1423 from mempool/nymkappa/bugfix/hashrate-indexing
If we have incomplete data for the day/week, don't index hashrate
2022-03-21 22:11:26 +00:00
wiz
e9d8245d26 Merge branch 'master' into nymkappa/bugfix/hashrate-indexing 2022-03-21 22:11:18 +00:00
wiz
0bada4b079 Merge pull request #1425 from mempool/wiz/disable-cluster-for-bisq-backend
Disable cluster mode in prod bisq backend config
2022-03-21 18:15:31 +00:00
wiz
07612a144b Disable cluster mode in prod bisq backend config 2022-03-21 15:03:36 +00:00
nymkappa
077177ecc4 If we have incomplete data for the day/week, don't index hashrate 2022-03-21 20:32:57 +09:00
wiz
4c14278da6 Merge pull request #1422 from mempool/nymkappa/bugfix/halving-calculation
Use 10 minutes avg block time for halving calculation
2022-03-21 03:32:45 +00:00
nymkappa
3e8a34f3fd Use 10 minutes avg block time for halving calculation 2022-03-21 12:16:41 +09:00
wiz
14a4be743a Merge pull request #1420 from mempool/wiz/add-minfee-node-to-install-script
Add minfee node setup to production install script
2022-03-20 23:14:51 +00:00
wiz
46437919f9 Merge pull request #1419 from mempool/wiz/fix-crontab-backup-script-path
Fix path in mempool crontab for daily backup script
2022-03-20 23:14:40 +00:00
wiz
b23fd886aa Merge pull request #1416 from mempool/wiz/enable-full-indexing-all-networks
Enable full block indexing on all Bitcoin networks
2022-03-20 23:14:27 +00:00
wiz
dc54ed5b12 Add minfee node setup to production install script 2022-03-20 23:01:28 +00:00
wiz
5e58db23bb Fix path in mempool crontab for daily backup script 2022-03-20 22:19:03 +00:00
softsimon
69e4e194df Merge pull request #1417 from knorrium/address_highlighting_tests
Address highlighting tests
2022-03-20 13:45:21 +04:00
softsimon
153c63b242 Merge branch 'master' into address_highlighting_tests 2022-03-20 13:34:12 +04:00
softsimon
ebc9894bf7 Merge pull request #1418 from knorrium/cypress_9_5_2
Update Cypress to v9.5.2
2022-03-20 13:33:51 +04:00
Felipe Knorr Kuhn
a69719ad36 Update Cypress to v9.5.2 2022-03-19 22:33:56 -07:00
Felipe Knorr Kuhn
827760cae5 Add tests for the address highlighting feature 2022-03-19 22:16:22 -07:00
Felipe Knorr Kuhn
bbc6b8cfbf Use the new data-cy directive for deterministic tx locators 2022-03-19 22:15:37 -07:00
Felipe Knorr Kuhn
2d4d9d80bd Add new directive for UI tests 2022-03-19 22:14:37 -07:00
Felipe Knorr Kuhn
db4a13389a Update liquid tests to use the new css selector 2022-03-19 22:12:44 -07:00
Felipe Knorr Kuhn
cacbad38cc Change table-vx-* from id to class 2022-03-19 22:11:46 -07:00
wiz
d077098154 Enable full block indexing on all Bitcoin networks 2022-03-20 01:29:01 +01:00
wiz
6123f94785 Merge pull request #1415 from mempool/simon/miner-dashboard-websocket-push-fix
Subscribe to blocks and mempool updates in the mining dashboard
2022-03-19 20:38:21 +00:00
softsimon
4f441d3f30 Subscribe to blocks and mempool updates in the mining dashboard
fixes #1414
2022-03-19 23:32:01 +04:00
wiz
91d55e02d6 Merge pull request #1413 from mempool/wiz/create-zfs-filesystem-for-backups
Create zfs filesystem for /backup and chown to mempool
2022-03-19 16:08:29 +00:00
wiz
d8de9cb934 Create zfs filesystem for /backup and chown to mempool 2022-03-19 16:02:14 +00:00
wiz
cc0fbace18 Merge pull request #1412 from mempool/wiz/install-mempool-crontab
Install mempool crontab from install script
2022-03-19 15:57:26 +00:00
wiz
97e280f876 Install mempool crontab from install script 2022-03-19 15:56:29 +00:00
wiz
51b2f9581d Merge pull request #1411 from mempool/wiz/fix-upgrade-script-for-keybase-alerts
Set build script to notify new location based Keybase channels
2022-03-19 15:55:06 +00:00
wiz
28bd7d059f Merge pull request #1410 from mempool/wiz/configure-syslog-from-install-script
Configure syslog for keybase alerts from install script
2022-03-19 15:54:50 +00:00
wiz
7222198c48 Set build script to notify new location based Keybase channels 2022-03-19 15:44:00 +00:00
wiz
b99eb1d533 Add keybase to install script packages for alerts 2022-03-19 15:31:47 +00:00
wiz
bdc028ecc0 Install syslog and newsyslog configuration for keybase alerts 2022-03-19 15:29:45 +00:00
wiz
58ab9cce46 Merge pull request #1400 from mempool/simon/default-redirect-fix
Don't navigate to root when sub network url is wrong.
2022-03-17 18:57:31 +00:00
wiz
d1ca91985f Merge branch 'master' into simon/default-redirect-fix 2022-03-17 18:47:08 +00:00
softsimon
e700cc36bc Merge pull request #1398 from mempool/nymkappa/feature/blocks-list-link
Show pools in main dashboard in mining dashboard is enabled
2022-03-17 19:23:34 +01:00
nymkappa
a7900f6466 If mining dashboard is enabled, shows pools instead of timestamp 2022-03-17 19:04:12 +01:00
nymkappa
7481e27ec2 If mining dashboard is enabled, opens /mining/blocks instead of /blocks 2022-03-17 19:04:11 +01:00
softsimon
a117e325e8 Don't navigate to root when sub network url is wrong.
fixes #1399
2022-03-17 18:51:59 +01:00
wiz
bdfe31c601 Merge pull request #1390 from mempool/nymkappa/feature/mining-pool-data-ref-update
Use our forked repo of mining pool data
2022-03-17 16:38:36 +00:00
nymkappa
e8e4fd3457 mempool.space/.../pools.json => raw.githubusercontent.com/.../pools.json 2022-03-17 16:07:58 +01:00
nymkappa
84006b2012 Use our forked repo of mining pool data 2022-03-17 14:16:57 +01:00
softsimon
b781b3b065 Merge pull request #1373 from antonilol/difficulty
fix and improve block time predictions
2022-03-17 12:17:27 +01:00
softsimon
18e9fc8717 Merge branch 'master' into difficulty 2022-03-17 11:43:29 +01:00
wiz
9001369eeb Merge pull request #1383 from mempool/nymkappa/bugfix/hashrate-difficulty-crash
Fix javascript crash when disable hashrate/difficulty chart line
2022-03-16 20:30:04 +00:00
nymkappa
07deaa23ef Fix javascript crash when disable hashrate/difficulty chart line 2022-03-16 21:20:42 +01:00
wiz
5bc1dfcfba Merge pull request #1376 from nymkappa/bugfix/blocks-list-pagination
Fix pagination on /mining/blocks
2022-03-16 20:17:54 +00:00
wiz
cf9a258a7b Merge branch 'master' into bugfix/blocks-list-pagination 2022-03-16 20:17:44 +00:00
softsimon
35f9658d3b Merge pull request #1382 from mempool/nymkappa/feature/coinbase-tooltip-style
Apply coinbase style to blocks list tooltip
2022-03-16 21:10:20 +01:00
nymkappa
9252a45971 Fix pagination on /mining/blocks 2022-03-16 21:00:40 +01:00
nymkappa
f8c5584be7 Apply coinbase style to blocks list tooltip 2022-03-16 20:54:32 +01:00
softsimon
5c4aa6efac Merge pull request #1381 from mempool/nymkappa/feature/pool-page-blocks
Updated blocks list in pool details page
2022-03-16 20:43:22 +01:00
nymkappa
41fed984cb Fix pool get blocks API undefined start block behavior 2022-03-16 20:19:39 +01:00
nymkappa
dfff57d204 Fix pool page skeleton 2022-03-16 20:10:01 +01:00
nymkappa
96dc3fb24a Rename ScriptSig to Coinbase Tag 2022-03-16 19:26:56 +01:00
nymkappa
63a47c14d9 Fix duplicated blocks in pool details page 2022-03-16 19:17:33 +01:00
nymkappa
56bf267664 Updated blocks list in /pool/{id} page 2022-03-16 18:12:02 +01:00
softsimon
226b345c0a Merge pull request #1380 from mempool/nymkappa/bugfix/disable-mining-non-bitcoin
Force disable mining dashboard if base_module not mempool
2022-03-16 18:11:25 +01:00
nymkappa
71648bf01e Force disable mining dashboard if base_module not mempool 2022-03-16 17:28:00 +01:00
softsimon
32f3acd2f0 Merge pull request #1379 from mempool/nymkappa/bugfix/hide-mining-charts-non-bitcoin
Hide tabs in /graphs page is mining not available
2022-03-16 15:03:12 +01:00
nymkappa
92142cd531 Hide tabs in /graphs page is mining not available 2022-03-16 14:48:37 +01:00
wiz
4ecacde10b Merge pull request #1375 from nymkappa/feature/index-coinbase-scriptsig
Index asciiScriptSig and display it in /mining/blocks
2022-03-16 11:30:50 +00:00
nymkappa
ffb5db69a8 Store hex in coinbase raw - Improve scripsig parsing 2022-03-16 12:10:18 +01:00
nymkappa
94dbec46cf Index asciiScriptSig and display it in /mining/blocks 2022-03-15 23:33:51 +01:00
wiz
9c60c7ba79 Merge pull request #1374 from nymkappa/feature/improve-rpc-calls
Optimize RPC calls
2022-03-15 20:24:45 +00:00
nymkappa
3cd1505128 Optimize RPC calls 2022-03-15 21:16:02 +01:00
Antoni Spaanderman
dbcc46be5f fix and improve block time predictions
dce775e but then on the backed after refractor #1352
2022-03-15 20:39:25 +01:00
softsimon
53777e84c9 Merge pull request #1371 from mempool/simon/address-amount-fix
Address value did not calculate self transfers
2022-03-15 18:01:57 +01:00
softsimon
7854b6fcb3 Address value did not calculate self transfers 2022-03-15 16:26:49 +01:00
wiz
a292745ea7 Merge pull request #1370 from mempool/simon/merge-rpc-api
Merge node-bitcoin into the project
2022-03-15 15:26:41 +00:00
softsimon
e26beee44c Merge node-bitcoin into the project 2022-03-15 14:44:31 +01:00
wiz
622a003a2a Merge pull request #1354 from hunicus/mobile-refinements
Fix docs navigation on mobile
2022-03-15 09:38:17 +00:00
wiz
d769226061 Merge branch 'master' into mobile-refinements 2022-03-15 09:28:10 +00:00
wiz
32b24b8eeb Merge pull request #1366 from nymkappa/bugfix/hashrate-widget-typo 2022-03-14 21:46:41 +00:00
nymkappa
aac3bd5942 Fix typo in hashrate widget 2022-03-14 21:12:29 +01:00
wiz
b846e9fbda Merge pull request #1361 from hunicus/code-link-labels
Capitalize js package labels in docs
2022-03-14 19:25:21 +00:00
wiz
39598ad4c7 Merge pull request #1362 from nymkappa/feature/update-hashrate-widget
Make the hashrate/difficulty widget simpler
2022-03-14 19:24:16 +00:00
wiz
b3847bcbcb Merge branch 'master' into feature/update-hashrate-widget 2022-03-14 19:12:31 +00:00
wiz
46b0a8da8f Merge pull request #1363 from mempool/simon/double-websocket-fix
Remove duplicate websocket push.
2022-03-14 19:12:11 +00:00
nymkappa
b19d9c1af2 Cleanup hashrate/difficulty widget 2022-03-14 20:00:19 +01:00
softsimon
96ba7f7456 Remove duplicate websocket push. 2022-03-14 19:52:34 +01:00
hunicus
5a58ce0ab3 Fix loose ends
Add space above footer, add better delay for height
adjustment, and add conditions to prevent errors for
websocket endpoint and no endpoint.
2022-03-14 14:41:32 -04:00
wiz
dbd58ca53a Merge pull request #1364 from mempool/simon/websocket-difficulty-mock-data
Updated websocket mock data with difficulty adjustment
2022-03-14 18:39:10 +00:00
softsimon
e3dc90f40f Updated websocket mock data with difficulty adjustment 2022-03-14 19:25:17 +01:00
wiz
d1ecfccfdb Merge pull request #1309 from nymkappa/feature/graphs-reorg
Move all charts into /graphs page
2022-03-14 18:00:53 +00:00
hunicus
4c8ac3a585 Resize docs code templates on open (mobile) 2022-03-14 13:49:16 -04:00
hunicus
838725a862 Implement custom accordion for mobile docs 2022-03-14 13:48:45 -04:00
hunicus
85100a93f8 Remove mobile docs menu 2022-03-14 13:31:46 -04:00
nymkappa
8e61720e09 Add active router links - Disable graph touch scroll 2022-03-14 18:25:16 +01:00
nymkappa
77a99a97cc Move all charts into /graphs page - Fix mining charts layouts 2022-03-14 18:07:35 +01:00
wiz
c4e5e45855 Merge pull request #1352 from mempool/simon/difficulty-adjustment-refactor
Difficulty adjustment refactor
2022-03-14 16:33:55 +00:00
softsimon
8637059119 Difficulty adjustment refactor
fixes #1157
2022-03-14 16:48:59 +01:00
softsimon
8d18a143cb Merge pull request #1342 from hunicus/desktop-refinements
Fix docs navigation on desktop
2022-03-14 16:46:46 +01:00
wiz
ab3f80220c Merge branch 'master' into desktop-refinements 2022-03-14 15:31:57 +00:00
wiz
74e8c18b9d Merge pull request #1304 from mempool/simon/highlight-address
Address page highlight and transfer value
2022-03-14 15:31:23 +00:00
softsimon
f466498988 Address page highlight and transfer value 2022-03-14 16:19:37 +01:00
wiz
822c4256d7 Merge pull request #1358 from mempool/wiz/increase-default-indexing-blocks-amount
Increase default INDEXING_BLOCKS_AMOUNT by 10x to 11000 blocks
2022-03-14 13:15:54 +00:00
wiz
4d9dfaa260 Merge pull request #1360 from dsbaars/feature/backend-unixsocket2
Add support for MySQL connections over UNIX sockets
2022-03-14 13:15:16 +00:00
wiz
2023d36603 Cleanup MySQL unix socket code and add to sample config 2022-03-14 13:11:04 +00:00
Djuri Baars
465529b03f sed and config fix for MySQL socket, accept CLA for @dsbaars 2022-03-14 13:45:50 +01:00
Djuri Baars
7fd9e27cc2 Add MySQL socket support 2022-03-14 13:45:34 +01:00
wiz
1052b19fae Merge pull request #1351 from nymkappa/bugfix/hashrates-indexing-duplicates
Fix duplicate hashrate data points in "difficulty vs hashrate" chart
2022-03-13 23:05:45 +00:00
nymkappa
edddf25917 Remove unnecessary migration version 15 2022-03-13 16:08:33 +01:00
nymkappa
0730053d5d Use bitcoin RPC getblock because esplora returns int for difficulty - Fix some css in mining dashboard 2022-03-13 16:08:33 +01:00
nymkappa
bec3f214b5 Make sure to set avg_hashrate field to double unsigned 2022-03-13 16:08:32 +01:00
nymkappa
ab486bfe6e Use correct url for blocks-extras API - Fix amountShortner pipe 2022-03-13 16:08:32 +01:00
nymkappa
33897b029f Set db connection to UTC - Fix hashrate indexing 2022-03-13 16:08:31 +01:00
wiz
81984e9df5 Increase default INDEXING_BLOCKS_AMOUNT by 10x to 11000 blocks 2022-03-13 13:57:20 +00:00
wiz
456e6a7296 Merge pull request #1357 from mempool/simon/reorg-integrations
Reorganizing community integrations
2022-03-13 13:22:24 +00:00
softsimon
b8e30ad91f Reorganizing community integrations 2022-03-13 13:13:47 +00:00
hunicus
142566f4f9 Rename method
Method scope widened in #1354. Changing its name here to
avoid merge conflicts later.
2022-03-12 16:07:45 -05:00
softsimon
d4cd614bbc Merge pull request #1353 from nymkappa/bugfix/mining-dashboard-font-size
Fix font size in reward stat widget
2022-03-12 18:04:43 +01:00
nymkappa
9f5d64cf4a Fix font size in reward stat widget 2022-03-12 17:56:00 +01:00
softsimon
0dbee1461d Merge pull request #1335 from nymkappa/feature/new-blocks-page
Create new /mining/blocks page
2022-03-12 17:45:50 +01:00
nymkappa
a893e87347 Add more padding to the blocks list page 2022-03-12 17:33:07 +01:00
nymkappa
11de94cf90 Pool icon clickable - blocks list pagination margin 2022-03-12 16:49:16 +01:00
nymkappa
d6a0d84d71 Update mining/blocks in real time 2022-03-12 16:49:16 +01:00
nymkappa
123af53de2 Added latest block on mining dashboard 2022-03-12 16:49:15 +01:00
nymkappa
d8e986996f Add pagination on /mining/blocks 2022-03-12 16:49:15 +01:00
nymkappa
0e0331d8ab Create working template for the new blocks page 2022-03-12 16:49:15 +01:00
softsimon
77334e130d Merge pull request #1336 from nymkappa/feature/fix-empty-diff-adjust
Fix empty diff adjust table
2022-03-12 16:47:13 +01:00
softsimon
fe7f14f9a2 Merge pull request #1340 from nymkappa/bugfix/only-reset-hashrate-state-bitcoin
Fix database migration/typing issues
2022-03-12 15:48:51 +01:00
nymkappa
0dbc725c39 int -> bigint for all satoshis related indexed data 2022-03-12 15:48:22 +01:00
nymkappa
cd12e9bde9 Only insert hashrate states for bitcoin 2022-03-12 15:48:21 +01:00
nymkappa
87405ec4a5 Don't try to reset hashrates states if not bitcoin 2022-03-12 15:48:14 +01:00
wiz
d17a78715a Merge pull request #1347 from mempool/wiz/add-mysql-to-install-script
Add mariadb-server and mysql db creation to install script
2022-03-12 13:16:40 +00:00
wiz
4b9eef5464 Merge pull request #1350 from mempool/wiz/add-symlinks-for-mempool-scripts-to-installer
Create symlinks for mempool scripts in installation script
2022-03-12 12:45:54 +00:00
wiz
6073d4559b Create symlinks for mempool scripts in installation script 2022-03-12 12:41:33 +00:00
wiz
32bbee960c Merge pull request #1349 from mempool/wiz/set-git-to-always-rebase
Set git to always rebase from install script
2022-03-12 12:28:03 +00:00
nymkappa
1ea9c13a26 Fix empty diff adjust table 2022-03-12 13:27:45 +01:00
wiz
03faa18bfc Set git to always rebase from install script 2022-03-12 12:27:24 +00:00
wiz
0daf49b8ad Add mariadb-server and mysql db creation to install script 2022-03-12 12:19:49 +00:00
wiz
800fff1744 Merge pull request #1346 from mempool/wiz/remove-old-mempool-install-script
Remove old install script, merge remaining stuff into upgrade script
2022-03-12 11:59:31 +00:00
wiz
ed488a763d Remove old install script, merge remaining stuff into upgrade script 2022-03-12 11:52:19 +00:00
wiz
d84bf66c35 Merge pull request #1345 from mempool/wiz/add-production-frontend-configurations
Install production backend/frontend configurations from master
2022-03-12 10:55:59 +00:00
wiz
9786f1794f Install production backend/frontend configurations from master 2022-03-12 10:53:37 +00:00
wiz
b3cbe8a60e Merge pull request #1344 from mempool/wiz/add-production-frontend-configurations
Add production frontend configurations
2022-03-12 10:50:41 +00:00
wiz
597c62ede3 Remove INDEXING_BLOCKS_AMOUNT from mainnet frontend configuration 2022-03-12 10:39:28 +00:00
wiz
f8787e525b Add production frontend configurations 2022-03-12 10:34:17 +00:00
Naveen
486f9a126d Merge branch 'master' into naveensrinivasan/dependabot 2022-03-11 18:36:40 -06:00
hunicus
b71df774f5 Fix anchor links when navigating to current anchor 2022-03-11 19:09:42 -05:00
naveensrinivasan
8f8c22b829 Pin actions by SHA and set permissions for workflow
- Pinned dependencies https://github.com/ossf/scorecard/blob/main/docs/checks.md#pinned-dependencies
- Restricting permissions for github actions https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
2022-03-11 22:48:15 +00:00
Naveen
b456419de7 Create dependabot.yml
Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
2022-03-11 22:46:44 +00:00
hunicus
2d4b824862 Add smooth scrolling 2022-03-11 16:28:52 -05:00
wiz
dab6dd4a0e Merge pull request #1338 from nymkappa/bugfix/increase-fee-data-type
Make blocks.fees larger data type
2022-03-11 20:39:31 +00:00
nymkappa
afe7a360f7 Make blocks.fees larger data type 2022-03-11 20:42:07 +01:00
softsimon
e4f4a421d7 Merge pull request #1337 from mempool/revert-1327-bugfix/overflow-y
Revert "Always show scrolbar to avoid horizontal jumpy UI"
2022-03-11 20:10:15 +01:00
softsimon
bd55f65714 Revert "Always show scrolbar to avoid horizontal jumpy UI" 2022-03-11 20:09:57 +01:00
wiz
387c51b5e8 Merge pull request #1321 from mempool/wiz/installer2
Add new production installation script and related files
2022-03-11 16:42:31 +00:00
hunicus
6dbc621fef Capitalize js package labels in docs 2022-03-11 11:25:17 -05:00
wiz
6fc0311b8e Merge branch 'master' into wiz/installer2 2022-03-11 16:17:51 +00:00
wiz
e7ab595811 Fix order of operations in install script breaking things 2022-03-11 15:03:14 +00:00
wiz
ca2e29acf8 Install nvm.sh and build NodeJS from install script 2022-03-11 14:51:08 +00:00
wiz
589f3c5bb5 Create $HOME/.zshrc file for all users in install script 2022-03-11 14:35:58 +00:00
wiz
22f1ef9d22 Remove sudoers file modifications from install script 2022-03-11 14:14:45 +00:00
wiz
bee0cf2c65 Fix electrs-start-liquidtestnet configuration in install script 2022-03-11 14:11:38 +00:00
softsimon
9dbfd96249 Merge pull request #1320 from antonilol/regtest-1
regtest fixes
2022-03-11 14:07:58 +01:00
softsimon
5caaa1633a Merge pull request #1330 from nymkappa/feature/index-more-data
Index more data using getblockstats core RPC
2022-03-11 14:05:03 +01:00
nymkappa
9a71c15b49 Fix block indexing log 2022-03-10 14:23:29 +01:00
nymkappa
8ca3f6e72b Index more data using getblockstats core RPC 2022-03-10 14:21:11 +01:00
nymkappa
d82f9c4998 Index more data using getblockstats core RPC 2022-03-10 14:08:01 +01:00
softsimon
e83e1067c1 Merge pull request #1331 from nymkappa/feature/show-indexing-progress
Show current indexing progress in charts without data
2022-03-10 14:07:15 +01:00
nymkappa
609bb15b77 Split difficult adjustment table - Update indexing progress every 60sec 2022-03-10 14:02:43 +01:00
nymkappa
18f3018170 Show current indexing progress in charts without data 2022-03-10 14:02:43 +01:00
softsimon
ba3a737ab9 Merge pull request #1327 from nymkappa/bugfix/overflow-y
Always show scrolbar to avoid horizontal jumpy UI
2022-03-10 13:56:30 +01:00
wiz
a140d28a0e Fix zfs filesystems and permissions in installation script 2022-03-10 12:14:40 +00:00
nymkappa
758381725f Always show scrolbar to avoid horizontal jumpy UI 2022-03-10 13:11:02 +01:00
softsimon
8535599e34 Merge pull request #1326 from nymkappa/bugfix/firefox-pool
Fix pool detail page on Firefox
2022-03-10 12:50:03 +01:00
nymkappa
7957ca8f94 Fix pool detail page on Firefox 2022-03-10 12:42:11 +01:00
softsimon
192c61f9cb Merge pull request #1333 from nymkappa/feature/weekly-hashrate-indexing-monday
Index weekly hashrates using last Monday midnight - Fix charts tooltip
2022-03-10 12:39:31 +01:00
nymkappa
9ccb23f651 Index weekly hashrates using last Monday midnight - Fix charts tooltip 2022-03-10 11:53:49 +01:00
wiz
1bc9f106a1 Add signet and liquidtestnet to install script 2022-03-09 20:59:12 +01:00
softsimon
f62146a649 Merge pull request #1328 from antonilol/testnet-block-estimation
improve testnet block time estimations
2022-03-09 20:38:42 +01:00
softsimon
3f0befc055 Merge pull request #1329 from nymkappa/bugfix/missing-db-version-increment
Increment db version to 10 (26ee4204ac)
2022-03-09 18:53:02 +01:00
nymkappa
643e5ceb7f Increment db version to 10 (26ee4204ac) 2022-03-09 18:51:27 +01:00
Antoni Spaanderman
2cd24624b9 Merge branch 'master' into regtest-1 2022-03-09 17:55:09 +01:00
Antoni Spaanderman
2be18fe179 improve testnet block time estimations 2022-03-09 17:38:37 +01:00
softsimon
fd1514177f Merge pull request #1323 from mempool/simon/unknown-output-support
Display unknown for non standard output types
2022-03-09 16:29:04 +01:00
softsimon
381a310216 Display unknown for non standard output types
fixes #1262
2022-03-09 16:28:26 +01:00
softsimon
211e5ab3fe Merge pull request #1325 from nymkappa/feature/add-plus-sign-diff-adjust
Show `+` sign on positive diff adjust
2022-03-09 13:47:40 +01:00
nymkappa
1995eef37d Show + sign on positive diff adjust 2022-03-09 13:47:10 +01:00
softsimon
18d83b6f3a Merge pull request #1324 from nymkappa/bugfix/difficulty-adj-table-skeleton
Fix skeleton for difficulty adjustment table
2022-03-09 12:19:26 +01:00
nymkappa
47da8c023b Add message if on mining charts if there is no data to display 2022-03-09 12:17:31 +01:00
nymkappa
8d7546d2b5 Fix skeleton for difficulty adjustment table 2022-03-09 12:17:31 +01:00
Antoni Spaanderman
8d42b38234 simplify if statement 2022-03-09 11:51:36 +01:00
wiz
742df00701 Add missing electrs-start-liquid in install script 2022-03-08 21:22:11 +01:00
Antoni Spaanderman
b2f9c7db2d add non null assertion 2022-03-08 20:59:46 +01:00
softsimon
f0f9d33dac Merge pull request #1317 from nymkappa/feature/pool-hashrate
Added pool hashrate chart
2022-03-08 20:52:16 +01:00
wiz
1e87c3857b Add new production installation script and related files 2022-03-08 20:46:58 +01:00
nymkappa
171246f4ef Fix skeleton layout jumping in pool detail page 2022-03-08 20:46:20 +01:00
nymkappa
71d500d750 Fix pool detail page layout - add loading skeleton 2022-03-08 20:46:19 +01:00
nymkappa
f23f7f1cfa Cleanup empty block in api response - Update cache warmer 2022-03-08 20:46:19 +01:00
nymkappa
2b5d972e8d Only show relevant hashrate in the pool page 2022-03-08 20:46:18 +01:00
nymkappa
ad2dcc46e4 Added pool hashrate chart 2022-03-08 20:46:14 +01:00
Antoni Spaanderman
7a1a903599 oops 2022-03-08 20:40:44 +01:00
Antoni Spaanderman
71402f21c6 revert "add network regtest" 1f0ae60 2022-03-08 19:59:18 +01:00
Antoni Spaanderman
d179a563e4 Merge branch 'master' into regtest-1 2022-03-08 19:45:03 +01:00
softsimon
0cc82bbf1d Merge pull request #1318 from mempool/simon/rbf-cache
Replace by fee storage
2022-03-08 19:20:14 +01:00
softsimon
8267344cdc Don't push full RBF-transactions to prevent old states. 2022-03-08 18:54:49 +01:00
softsimon
b15de021f7 Fixing bug where RBF wasn't detected when using bitcoind 2022-03-08 18:39:53 +01:00
softsimon
f85771e03f Replace by fee storage
fixes #1222
2022-03-08 18:39:53 +01:00
softsimon
d504d0ecc0 Merge pull request #1319 from nymkappa/feature/index-blocks-timestamps
Index blocks.blockTimestamp for faster hashrates indexing
2022-03-08 17:23:12 +01:00
nymkappa
26ee4204ac Index blocks.blockTimestamp 2022-03-08 17:10:29 +01:00
wiz
39f1f4c05a Merge pull request #1316 from Bosch-0/zeus 2022-03-08 16:12:59 +09:00
bosch
2ea78566a6 Added new Zeus logo. 2022-03-08 11:09:43 +08:00
softsimon
ba12a75532 Merge pull request #1311 from nymkappa/feature/difficulty-table-update
Replace difficulty adjustment timestamp with block height
2022-03-07 20:46:50 +01:00
nymkappa
b7254e7aca Replace difficulty adjustment timestamp with block height 2022-03-07 20:42:59 +01:00
softsimon
5d16a30cf2 Merge pull request #1312 from nymkappa/feature/shorter-stats
Shorten reward stats
2022-03-07 20:37:06 +01:00
softsimon
9e68b0a597 Merge branch 'master' into feature/shorter-stats 2022-03-07 20:36:53 +01:00
softsimon
5a373f6518 Merge pull request #1313 from nymkappa/bugfix/pie-chart-click-fix
Fix broken navigation when clicking on pie chart
2022-03-07 20:36:03 +01:00
softsimon
81a82b619e Merge branch 'master' into bugfix/pie-chart-click-fix 2022-03-07 20:35:49 +01:00
softsimon
42cd08798c Merge pull request #1315 from nymkappa/feature/mining-dashboard-skeleton
Add skeleton in the mining dashboard page
2022-03-07 20:34:01 +01:00
softsimon
593e82d8f4 Merge branch 'master' into feature/mining-dashboard-skeleton 2022-03-07 20:33:54 +01:00
softsimon
47e46b7996 Merge pull request #1314 from mempool/simon/utxo-tracking-refactor
UTXO spent tracking refactor
2022-03-07 20:07:40 +01:00
nymkappa
2b91ced4d6 Add skeleton in the mining dashboard page 2022-03-07 19:54:17 +01:00
softsimon
6f3443faba UTXO spent tracking refactor
refs #1301
2022-03-07 19:45:09 +01:00
nymkappa
1318c4aa36 Fix broken navigation when clicking on pie chart 2022-03-07 18:42:47 +01:00
nymkappa
2435e7bfe9 Shorten reward stats 2022-03-07 18:19:02 +01:00
softsimon
09e3791cee Merge pull request #1310 from nymkappa/bugfix/auto-refresh-reward-stats
Bugfix/auto refresh reward stats
2022-03-07 17:18:57 +01:00
nymkappa
8837b8c882 Actually use the past 8 blocks for reward stats 2022-03-07 17:17:08 +01:00
softsimon
beae88778b Merge pull request #1308 from nymkappa/bugfix/fix-db-migration
Truncate hashrates table only for bitcoin (db migration v9)
2022-03-07 15:57:20 +01:00
nymkappa
32d66c03c6 Truncate hashrates table only for bitcoin (db migration v9) 2022-03-07 15:56:07 +01:00
softsimon
ecdd9bdf91 Merge pull request #1306 from mempool/simon/liquid-missing-asset-inputs
Handle missing asset registry for inputs
2022-03-07 15:24:47 +01:00
softsimon
8d4bc201ff Merge pull request #1305 from mempool/simon/track-utxos
UTXO spent tracking
2022-03-07 15:12:49 +01:00
softsimon
00ad58c26d Merge branch 'master' into simon/track-utxos 2022-03-07 15:12:36 +01:00
softsimon
d188ab3c09 Handle missing asset registry for inputs
refs #1246
2022-03-07 13:14:34 +01:00
softsimon
641fa91a48 Merge pull request #1303 from nymkappa/feature/update-mining-dashboard
Mining dashboard polishing
2022-03-07 12:03:09 +01:00
nymkappa
05342079b3 Disable mining charts iteration on mobile widgets 2022-03-07 11:51:00 +01:00
nymkappa
bc13393778 Implement temporary reward stats for the mining dashboard 2022-03-07 11:51:00 +01:00
nymkappa
84ef424752 Fix halving calculation 2022-03-07 11:50:59 +01:00
nymkappa
d45f3c32cf Show more stats in pool ranking pie widget 2022-03-07 11:50:59 +01:00
nymkappa
f9e361a9c0 "view more" links - placeholders 2022-03-07 11:50:59 +01:00
nymkappa
cf4336eb2e Move small pie share into "other" - align labels 2022-03-07 11:50:58 +01:00
nymkappa
6cdd41a8f7 Add difficulty adjustment table in mining dashboard 2022-03-07 11:50:58 +01:00
nymkappa
b2dec5e20a Mining dashboard layout matches main dashboard layout 2022-03-07 11:50:57 +01:00
softsimon
16331d1be7 Merge pull request #1302 from nymkappa/bugfix/weekly-pool-hashrate-indexing
Fix hashrate indexing backend logic (split daily/weekly indexing logic, timezone issue, unclosed db connection)
2022-03-06 20:32:17 +01:00
softsimon
059e82a805 UTXO spent tracking
fixes #1301
2022-03-06 18:27:13 +01:00
nymkappa
2570dbfab4 Fix incorrect state naming 2022-03-06 17:06:55 +01:00
nymkappa
3d1a10cdfc Use the latest timestamp in hashrate data ticker 2022-03-06 16:57:40 +01:00
nymkappa
2a170c07d1 Remove unnecessary await 2022-03-06 16:50:59 +01:00
nymkappa
4b859eb4f6 Re-index hashrates because we have different timestamp handling 2022-03-06 16:48:14 +01:00
nymkappa
89411f23d8 Set connection pool timezone to UTC - Close mysql connections upon error 2022-03-06 16:44:09 +01:00
nymkappa
1ced44d970 Remove useless mining function wrapper in backend 2022-03-06 12:52:39 +01:00
nymkappa
8532d13a0d Update hashrate indexing logs 2022-03-06 12:52:39 +01:00
nymkappa
7314582dd1 Split network daily hashrate indexing and weekly pool hashrate indexing 2022-03-06 12:52:38 +01:00
softsimon
3e50e4541b Merge pull request #1185 from antonilol/fee-visibility
fix 0 sat/vB not displaying
2022-03-06 10:28:51 +01:00
softsimon
50cd8e01bd Merge branch 'master' into fee-visibility 2022-03-06 10:28:43 +01:00
softsimon
35f81200d0 Merge pull request #1293 from mempool/simon/shorten-address-prefix-result
Shorten address search with middle ellipsis
2022-03-05 17:09:29 +01:00
softsimon
5de77c7ae4 Merge branch 'master' into simon/shorten-address-prefix-result 2022-03-05 17:09:23 +01:00
softsimon
5ac2c1cf34 Merge pull request #1291 from mempool/simon/address-prefix-bug
Only return unique address prefix autocomplete
2022-03-05 17:08:29 +01:00
softsimon
552c717693 Merge branch 'master' into simon/address-prefix-bug 2022-03-05 17:08:23 +01:00
softsimon
f990d30a22 Merge pull request #1300 from nymkappa/bugfix/stop-block-chunk-indexing-upon-error
Pause block indexing chunk upon error and retry later
2022-03-05 16:30:35 +01:00
softsimon
8b1a0fe706 Merge branch 'master' into bugfix/stop-block-chunk-indexing-upon-error 2022-03-05 16:30:26 +01:00
softsimon
e131ec883b Merge pull request #1298 from nymkappa/feature/fix-hashrate-indexing-try-catch
Make sure to reset hashrates indexing flags upon error
2022-03-05 16:30:12 +01:00
nymkappa
92dc5a78d8 Make sure to reset hashrates indexing flags upon error 2022-03-05 16:25:38 +01:00
nymkappa
773ac4d44b Pause block indexing chunk upon error and retry later 2022-03-05 15:50:48 +01:00
softsimon
c398d164ba Merge pull request #1297 from nymkappa/feature/fix-hashrate-indexing
Only reset hashrate state flag after database migration - Fix weekly …
2022-03-05 14:59:26 +01:00
softsimon
daa7079338 Address search with middle ellipsis mobile fix 2022-03-05 14:19:44 +01:00
nymkappa
5f6c1c6ccf Only reset hashrate state flag after database migration - Fix weekly hashrate indexing bug 2022-03-05 13:54:07 +01:00
Antoni Spaanderman
590170a0df Merge branch 'master' into fee-visibility 2022-02-28 13:10:12 +01:00
Antoni Spaanderman
e2ef58c5dd Merge branch 'master' into regtest-1 2022-02-28 13:09:51 +01:00
softsimon
e5b2440b45 Shorten address search with middle ellipsis 2022-02-27 20:05:32 +03:00
softsimon
056a31fc79 Only return unique address prefix autocomplete
fixes #1290
2022-02-27 15:58:09 +03:00
wiz
5f19b6dd07 Merge pull request #1288 from nymkappa/feature/merge-hashrate-pool-ranking
Merge pool share and dominance into one widget
2022-02-25 21:44:05 +09:00
nymkappa
b427548973 Merge pool pie and dominance into one widget 2022-02-25 21:16:35 +09:00
softsimon
7228d07b52 Merge pull request #1285 from nymkappa/feature/pool-hashrate
Create pools hashrate dominance chart
2022-02-25 13:20:29 +04:00
nymkappa
434b60ef8b Removed debug console.log 2022-02-25 18:17:43 +09:00
nymkappa
88dd956354 Hide 'dot' when hovering charts 2022-02-25 13:06:33 +09:00
nymkappa
c419b7dd1a Add new api endpoint to cache warmer 2022-02-25 10:21:16 +09:00
nymkappa
ec40231f93 warn on re-index - fix hash indexing state issue - cleanup ui mining 2022-02-24 20:21:14 +09:00
nymkappa
54ccfe070e Move pool pie chart at the bottom of the mining dashboard 2022-02-24 20:21:14 +09:00
nymkappa
e358a553c1 Match pool color between pools pie and pools stack 2022-02-24 20:21:13 +09:00
nymkappa
78fa3e33cd Create stacked pools historical hashrates to see dominance over time 2022-02-24 20:21:12 +09:00
nymkappa
a214c5ca20 Disable difficulty adjustment table for now until loadMore is implemented 2022-02-24 20:21:12 +09:00
wiz
4060c05015 Merge pull request #1284 from mempool/simon/update-package-versions
Upgrade frontend deps: Angular 13.2, echarts 5.3, fortawesome
2022-02-24 10:35:40 +00:00
softsimon
204e1c2a84 Npm install 2022-02-23 21:07:49 +04:00
softsimon
ab7b66c9a8 Bumping echarts 2022-02-23 20:52:38 +04:00
wiz
b1d6021406 Merge pull request #1283 from knorrium/update_cypress_to_v9.5.0 2022-02-23 06:53:46 +00:00
wiz
238b398cc0 Merge branch 'master' into update_cypress_to_v9.5.0 2022-02-23 06:30:42 +00:00
wiz
0dfd7ea26b Merge pull request #1282 from knorrium/fix_footer_test 2022-02-23 06:30:34 +00:00
Felipe Knorr Kuhn
30e41007a2 Update Cypress to v9.5.0 2022-02-22 22:14:59 -08:00
Felipe Knorr Kuhn
ac4d54950a Fix status page regex 2022-02-22 22:11:18 -08:00
wiz
b2d591b5bd Merge pull request #1281 from mempool/simon/footer-transactions-bar-fix 2022-02-23 03:35:54 +00:00
wiz
d05d7f1e27 Merge branch 'master' into simon/footer-transactions-bar-fix 2022-02-23 03:19:06 +00:00
wiz
57e6348936 Merge pull request #1280 from mempool/simon/display-unblinded-tx-sum
Show tx value sum if complete unblinding data is provided
2022-02-23 03:18:39 +00:00
wiz
e617e14901 Merge branch 'master' into simon/display-unblinded-tx-sum 2022-02-23 03:09:44 +00:00
wiz
5f0a0c0ac7 Merge pull request #1279 from mempool/simon/liquid-testnet-proxy
Add proxy support for Liquid Testnet
2022-02-23 03:09:34 +00:00
wiz
96ab1aae6e Merge branch 'master' into simon/liquid-testnet-proxy 2022-02-23 03:09:09 +00:00
wiz
e3e6e63a1e Merge pull request #1278 from mempool/simon/liquid-asset-issuance-output
Handle missing asset registry assets
2022-02-23 03:08:59 +00:00
wiz
dd2a52be65 Merge branch 'master' into simon/liquid-asset-issuance-output 2022-02-23 02:55:15 +00:00
wiz
c52f1c6973 Merge pull request #1277 from nymkappa/feature/mempool-show-only-fees
Remove block subsidy from mempool blocks
2022-02-23 02:55:03 +00:00
wiz
6c5253a7c4 Merge branch 'master' into feature/mempool-show-only-fees 2022-02-23 02:19:14 +00:00
wiz
8d1a60028b Merge pull request #1275 from nymkappa/feature/merge-hashrate-difficulty
Merge hashrate and difficulty components - Cleanup mining design overall
2022-02-23 02:19:00 +00:00
nymkappa
c1092adfd9 Add blocks.extras.totalFees and show it in blockchain blocks component 2022-02-22 23:57:54 +09:00
nymkappa
807ef2288a Don't assume two difficulty with the same value is impossible 2022-02-22 22:53:47 +09:00
softsimon
cd7cb56890 Fixed incoming transactions bar on the status page
fixes #1106
2022-02-22 17:37:04 +04:00
nymkappa
8aa1fe48dc Remove debug console.log 2022-02-22 22:04:52 +09:00
softsimon
f11c703e87 Show tx value sum if complete unblinding data is provided
fixes #1174
2022-02-22 16:53:59 +04:00
softsimon
411ac8d019 Add proxy support for Liquid Testnet 2022-02-22 16:39:53 +04:00
softsimon
78c0fe0e04 Handle missing asset registry assets
fixes #1246
2022-02-22 16:32:54 +04:00
nymkappa
201eff593b Remove block subsidy from mempool blocks 2022-02-22 20:37:17 +09:00
nymkappa
38eb8cbcfd Fix tooltip text alignment in mining dashboard 2022-02-22 20:30:14 +09:00
nymkappa
3f0bf81726 Improve hashrate chart and mining dashboard design 2022-02-22 20:16:19 +09:00
nymkappa
dcd84680fc Remove difficulty component 2022-02-22 20:16:19 +09:00
nymkappa
cfbf863a44 Move difficulty adjustment table in the merged hashrate component 2022-02-22 20:16:18 +09:00
nymkappa
83a382a0cb Merge hashrate and difficulty into one chart 2022-02-22 20:16:18 +09:00
wiz
98e0e1e9c1 Merge pull request #1273 from mempool/simon/asset-amount-filter
Display asset circulating amount more nicely fixing overflow
2022-02-22 03:11:42 +00:00
wiz
d750b5ccd3 Merge branch 'master' into simon/asset-amount-filter 2022-02-22 03:11:17 +00:00
wiz
55ca5087e0 Merge pull request #1274 from nymkappa/feature/mempool-blocks-reward
Show block reward in the mining dashboard
2022-02-22 03:11:09 +00:00
wiz
e748775f96 Merge branch 'master' into feature/mempool-blocks-reward 2022-02-22 02:59:08 +00:00
wiz
84cbb0222d Merge pull request #1272 from nymkappa/feature/cleanup-tooltips
Tweak new charts design
2022-02-22 02:57:47 +00:00
nymkappa
d23b9d8cf6 Replace block size => block reward in the mining dashboard 2022-02-22 11:16:18 +09:00
softsimon
3e6dba2d58 Display asset circulating amount more nicely fixing overflow
fixes #1264
2022-02-21 22:33:03 +04:00
nymkappa
e770520f0e Add data zoom to difficulty 2022-02-22 00:26:16 +09:00
nymkappa
7da4187638 Tweak charts color - Apply mempool tooltip style 2022-02-22 00:26:16 +09:00
wiz
3f5a749352 Merge pull request #1269 from nymkappa/feature/hashrate-chart
Created hashrate chart component
2022-02-21 15:08:27 +00:00
nymkappa
976017dbef Update database migration log levels 2022-02-21 23:57:44 +09:00
nymkappa
938a978900 Make sure to try/catch indexing code in case db is not available 2022-02-21 23:46:25 +09:00
nymkappa
b2f872c4cc Show unit in the yaxis for hashrate chart 2022-02-21 18:37:34 +09:00
nymkappa
beeda5fa87 Fix hashrate chart padding 2022-02-21 18:24:24 +09:00
nymkappa
413cf3ccaa Fix 'active' menu when using mining dashboard 2022-02-21 18:19:03 +09:00
nymkappa
6e62c62855 Add /api/v1/mining/hashrate/* apis to the cache warmer 2022-02-21 18:01:09 +09:00
nymkappa
649ad2e859 Hashrates indexing waits for blocks indexing - Batch hashrates I/O ops 2022-02-21 17:34:07 +09:00
nymkappa
537e50c682 Reduce log spam during hashrate indexing 2022-02-21 16:54:43 +09:00
nymkappa
bb1c5d0b31 Add --reindex command line parameter to force full re-indexing 2022-02-21 16:38:18 +09:00
nymkappa
e5907159b8 Refactor power of ten conversion into one wrapper 2022-02-21 15:55:27 +09:00
nymkappa
e4721e8574 Improve hashrate indexing logs 2022-02-21 14:49:00 +09:00
nymkappa
ac118141ce Make hashrate chart more responsive 2022-02-21 14:49:00 +09:00
nymkappa
53a8d5b246 Add network hashrate to mining dashboard 2022-02-21 14:48:59 +09:00
nymkappa
e61df324ea Index new hashrates once every 24 hours 2022-02-21 14:48:59 +09:00
nymkappa
358604ad85 Added hashrate chart 2022-02-21 14:48:58 +09:00
nymkappa
6fe8f6fa1e Generate daily average hashrate data 2022-02-21 14:48:57 +09:00
nymkappa
38b37a3ee7 Re-define sub mining routes properly and use router outlet 2022-02-21 14:48:50 +09:00
softsimon
50f86ba152 Merge pull request #1223 from antonilol/address-labels
detect lightning htlc and unilateral close + fix multisig badge
2022-02-20 20:14:40 +04:00
softsimon
cd00953fa7 Merge branch 'master' into address-labels 2022-02-20 20:12:20 +04:00
wiz
a4db02e1f9 Merge pull request #1268 from mempool/wiz/inline-enterprise-sponsor-logos
Inline all Enterprise Sponsor logos on About page
2022-02-20 11:20:25 +00:00
wiz
3b7d36e9e9 Fix mouseover CSS for inline SVG on About page 2022-02-20 20:11:31 +09:00
wiz
ce41e1e65d Merge branch 'master' into wiz/inline-enterprise-sponsor-logos 2022-02-20 11:09:11 +00:00
softsimon
b70df576d4 Fixing enterprise sponsors margin 2022-02-20 13:33:46 +04:00
wiz
0e037d5c8f Merge pull request #1267 from mempool/wiz/move-sponsor-button-on-about-page 2022-02-20 08:43:56 +00:00
wiz
22087bf6cd Merge branch 'master' into wiz/move-sponsor-button-on-about-page 2022-02-20 08:14:08 +00:00
wiz
1545dad2d2 Merge pull request #1265 from mempool/wiz/add-nixbitcoin-to-community-integrations 2022-02-20 08:13:34 +00:00
wiz
d837bcb791 Merge branch 'master' into wiz/add-nixbitcoin-to-community-integrations 2022-02-20 08:06:00 +00:00
softsimon
aa22aafe1d Merge pull request #1266 from mempool/wiz/tweak-about-page-text
Tweak text on About page so it can be displayed on all networks
2022-02-20 12:01:56 +04:00
wiz
edb8f5ecd1 Inline all Enterprise Sponsor logos on About page 2022-02-20 13:01:02 +09:00
wiz
a37430cc9e Move the Become Sponsor button higher on About page 2022-02-20 11:48:46 +09:00
wiz
6f939e1bad Tweak text on About page so it can be displayed on all networks 2022-02-20 09:19:31 +09:00
wiz
af8d4a8514 Add nix-bitcoin to Community Integrations on About page 2022-02-20 08:43:59 +09:00
wiz
3a0e272aff Merge pull request #1245 from mempool/simon/dashboard-assets
Display top featured assets on Liquid dashboard
2022-02-18 19:11:28 +00:00
softsimon
b111d576b5 Merge branch 'master' into simon/dashboard-assets
# Conflicts:
#	frontend/src/app/app.module.ts
2022-02-18 22:49:32 +04:00
wiz
a6abfd3ca6 Merge pull request #1259 from nymkappa/feature/show-miner-blocks
Show miner tag under blocks in the mining dashboard
2022-02-18 15:37:50 +00:00
wiz
47c88891b6 Merge branch 'master' into feature/show-miner-blocks 2022-02-18 15:25:51 +00:00
nymkappa
008a4b51cc Remove duplicated ChangeDetectorRef in blockchains blocks component 2022-02-18 22:25:31 +09:00
wiz
efada32440 Merge pull request #1261 from knorrium/update_default_loglevel
Update docker default min loglevel to info
2022-02-18 06:11:35 +00:00
Felipe Knorr Kuhn
0740049cbc Update docker default min loglevel to info 2022-02-17 20:51:04 -08:00
softsimon
e816f53637 Flip Liquid dashboard locations 2022-02-18 00:37:37 +04:00
Antoni Spaanderman
3679f197ba Merge branch 'master' into address-labels 2022-02-17 16:05:53 +01:00
Antoni Spaanderman
e32ef6c0df Merge branch 'master' into fee-visibility 2022-02-17 16:05:40 +01:00
Antoni Spaanderman
243055ceae Merge branch 'master' into regtest-1 2022-02-17 16:05:22 +01:00
nymkappa
fb2c0345a7 Show miner tag under blocks in the mining dashboard 2022-02-17 22:57:10 +09:00
wiz
5ab4c0e611 Merge pull request #1258 from nymkappa/feature/truncate-blocks-schema-change
When blocks need re-indexing, truncate the table
2022-02-17 11:19:07 +00:00
wiz
1d26390da7 Merge branch 'master' into feature/truncate-blocks-schema-change 2022-02-17 11:18:54 +00:00
wiz
49dd475b4e Merge pull request #1254 from nymkappa/feature/mining-dashboard
Create mining dashboard page
2022-02-17 11:18:24 +00:00
nymkappa
2e2c144cc9 Fix widgets title in mining dashboard 2022-02-17 18:51:16 +09:00
nymkappa
6d4458db8b Fix difficulty chart xaxis label 2022-02-17 18:30:52 +09:00
nymkappa
9b4e7a5fe1 View more mining dashboard links are centered 2022-02-17 18:10:50 +09:00
nymkappa
b18115f71a Reverts part of 6f25ecd98d9fdf1079dd550ecde4162ebe8d62d5 2022-02-17 18:08:00 +09:00
nymkappa
7761e75d4c Fix routes for /mining - Share blockchain component instances - remove animations 2022-02-17 18:08:00 +09:00
nymkappa
538ae3b757 [mempool | blockchain] position changes between main/mining dashboards 2022-02-17 18:07:59 +09:00
nymkappa
b1bd6f8fdb Database schema version 6 truncate the blocks table 2022-02-17 18:07:59 +09:00
nymkappa
1c575f1c93 Added difficulty chart to mining dashboard 2022-02-17 18:07:58 +09:00
nymkappa
8f9804a996 Fix pools ranking titles 2022-02-17 18:07:57 +09:00
nymkappa
750ea033f2 Renamed /mining/dashboard -> /mining 2022-02-17 18:07:57 +09:00
nymkappa
923a2ce7f6 Create basic layout for mining dashboard page - Show miner in blocks 2022-02-17 18:07:56 +09:00
wiz
86aa45f7e0 Merge branch 'master' into feature/truncate-blocks-schema-change 2022-02-17 09:07:39 +00:00
wiz
4a86699199 Merge pull request #1257 from nymkappa/feature/pool-pie-chart-colors
Change pool ranking pie chart colors
2022-02-17 09:07:28 +00:00
nymkappa
15ba487ee4 When blocks need re-indexing, truncate the table 2022-02-17 18:02:55 +09:00
nymkappa
c131c865ee Change pool ranking pie chart colors 2022-02-17 17:52:12 +09:00
wiz
53ff599ccd Merge pull request #1255 from nymkappa/feature/difficulty-chart
Create difficulty chart component
2022-02-17 02:15:11 +00:00
nymkappa
1630ff717e On mobile, show power of ten difficulty instead of full number 2022-02-17 10:15:41 +09:00
nymkappa
f45103e7e3 Add difficulty chart timespan selection 2022-02-17 09:41:05 +09:00
nymkappa
9fa7e58d82 Show all difficulty adjustment in a table - Need pagination 2022-02-16 22:56:06 +09:00
softsimon
b6f89b1a3e Moving ticker to circulating amount 2022-02-16 17:32:12 +04:00
nymkappa
7270b1ccac Create difficulty chart component 2022-02-16 21:20:28 +09:00
wiz
e2e3546934 Merge pull request #1253 from nymkappa/feature/index-more-data
Index more block data
2022-02-16 11:39:44 +00:00
nymkappa
0c1fa2b4aa Cleanup blocks/pools fields data type - Index more block data 2022-02-16 15:22:55 +09:00
softsimon
0a529ea98a Merge pull request #1242 from nymkappa/feature/pool-stats-page
Created mining pool stats page
2022-02-15 15:56:55 +04:00
nymkappa
5448e8c292 Merge branch 'master' into feature/pool-stats-page 2022-02-15 20:42:06 +09:00
softsimon
afe228f2c3 Merge pull request #1250 from nymkappa/feature/disable-mining
Provide a way to completely disable block indexing and mining menu
2022-02-15 15:23:48 +04:00
nymkappa
ca766bf40d Provide a way to completely disable block indexing and mining menu 2022-02-15 19:51:26 +09:00
nymkappa
fa8607c57d [Pool page] - Parse regexes and addresses in the backend 2022-02-15 18:45:53 +09:00
nymkappa
1e96c93557 Fix rendering issue when clicking on block link from pool page 2022-02-15 18:36:58 +09:00
softsimon
02523f574d Merge pull request #1252 from nymkappa/bugfix/fix-duplicated-tests
Remove duplicated tests
2022-02-15 12:09:40 +04:00
softsimon
a064f2931a Merge branch 'master' into bugfix/fix-duplicated-tests 2022-02-15 12:09:03 +04:00
softsimon
93f872efe5 Merge pull request #1243 from nymkappa/feature/start-indexing-before-mempool-sync
Don't wait for 100% mempool sync before starting block indexing
2022-02-15 12:07:30 +04:00
nymkappa
e9ba38755c Re-apply test updates from bogus commit 73019b485f 2022-02-15 16:19:58 +09:00
nymkappa
1c928582a2 Revert "Update tests - Replace button click blocks -> pools"
This reverts commit 73019b485f.
2022-02-15 15:56:40 +09:00
nymkappa
a88d6d2fca Don't wait for 100% mempool sync before starting block indexing 2022-02-14 17:57:55 +09:00
nymkappa
87170247bd Revert "Merge pull request #1240 from nymkappa/feature/mempool-sync-threshold"
This reverts commit 2f921f4cc7, reversing
changes made to 877be47e5b.
2022-02-14 17:57:03 +09:00
softsimon
820daf377e Merge pull request #1248 from antonilol/api-mempool
implement /api/mempool for home users (romanz/electrs backend)
2022-02-14 12:24:16 +04:00
nymkappa
f381da0f78 Show correct reward in pool stat page 2022-02-14 14:11:55 +09:00
nymkappa
a436d3a173 Fix label width being too small on mobile 2022-02-14 14:08:34 +09:00
nymkappa
09180c4f91 Renamed /mining/pool-blocks/xxx -> /mining/pool/:poolId/blocks 2022-02-14 14:08:34 +09:00
nymkappa
4f02efd7fe Fix block link in pool page - Click on chart slice open pool page 2022-02-14 14:08:33 +09:00
nymkappa
d8e58ee622 Set reward to 0 by default until reward indexing is available 2022-02-14 14:08:33 +09:00
nymkappa
c28f3fd4b6 Disable query logger spam 2022-02-14 14:08:33 +09:00
nymkappa
763ea0ce6f Show pool addresses in a scrollable div with href 2022-02-14 14:08:32 +09:00
nymkappa
9e64592aca Add mining pool logo in the pool stats page 2022-02-14 14:08:32 +09:00
nymkappa
e1f3c662b2 Show block reward in the pool stat page 2022-02-14 14:08:31 +09:00
nymkappa
f2abedfbaa Add timespan switch for pool stats and load more for pool's blocks 2022-02-14 14:08:31 +09:00
nymkappa
3f55aabc53 Mining pool detail page draft PoC 2022-02-14 14:08:30 +09:00
nymkappa
a168a22360 Link PoolRanking page with new pool page 2022-02-14 14:08:11 +09:00
nymkappa
fbda0d8186 Added /mining/pool/:poolId empty page 2022-02-14 14:08:11 +09:00
nymkappa
b854c071d0 Added mining/pool/:poolId and mining/pool/:poolId/:interval APIs 2022-02-14 14:08:10 +09:00
Antoni Spaanderman
3a3392423d set fee_histogram to [] 2022-02-13 16:13:46 +01:00
Antoni Spaanderman
2e1348550e implement /api/mempool 2022-02-13 13:52:04 +01:00
wiz
219c1a8615 Merge branch 'master' into simon/dashboard-assets 2022-02-13 11:21:39 +00:00
softsimon
294d7915e1 Liquid dashboard assets updates 2022-02-13 00:46:42 +04:00
wiz
039a627d1c Merge pull request #1235 from nymkappa/feature/blocks-extras
Added /api/v1/blocks-extras endpoint
2022-02-12 11:30:49 +00:00
Antoni Spaanderman
9796b87975 Merge branch 'master' into address-labels 2022-02-12 12:29:05 +01:00
Antoni Spaanderman
effab583ee Merge branch 'master' into fee-visibility 2022-02-12 12:28:49 +01:00
Antoni Spaanderman
9c992a61c5 Merge branch 'master' into regtest-1 2022-02-12 12:28:37 +01:00
nymkappa
ba36ab3134 Merge branch 'feature/blocks-extras' of github.com:nymkappa/mempool into feature/blocks-extras 2022-02-12 20:18:22 +09:00
nymkappa
b8e40494aa Remove fields that won't be used in the frontend for now 2022-02-12 20:16:51 +09:00
wiz
82350b5331 Merge branch 'master' into feature/blocks-extras 2022-02-12 10:35:57 +00:00
wiz
7e82967444 Merge pull request #1239 from hunicus/refactor-docs-2
Refactor docs
2022-02-12 10:19:45 +00:00
wiz
43e604507d Merge branch 'master' into refactor-docs-2 2022-02-12 10:07:52 +00:00
softsimon
738381702f Display top featured assets on Liquid dashboard 2022-02-12 00:15:13 +04:00
nymkappa
aa0e6b807a Add missing docker configuration variable 2022-02-11 14:22:59 +09:00
hunicus
d7b4e4b698 Use variables for empty code examples 2022-02-10 16:51:12 -05:00
nymkappa
ef43da05c9 Improve block indexing logging 2022-02-10 23:02:12 +09:00
nymkappa
fac49d0b98 Added /api/v1/blocksExtras endpoint 2022-02-10 22:11:10 +09:00
softsimon
2f921f4cc7 Merge pull request #1240 from nymkappa/feature/mempool-sync-threshold
Consider we're synced with the mempool if we cached 99% of pending txs
2022-02-10 16:28:13 +04:00
softsimon
b7f93a5726 Merge branch 'master' into feature/mempool-sync-threshold 2022-02-10 16:28:05 +04:00
softsimon
877be47e5b Merge pull request #1220 from nymkappa/bugfix/fix-duplicate-indexing
Duplicated db blocks insertion attempts are expected
2022-02-10 16:23:07 +04:00
softsimon
98d819b3d2 Merge branch 'master' into bugfix/fix-duplicate-indexing 2022-02-10 16:23:00 +04:00
nymkappa
af02e9b533 Consider we're synced with the mempool if we cached 99% of pending txs 2022-02-10 19:19:54 +09:00
softsimon
11e6602315 Merge pull request #1192 from nymkappa/feature/tv-view-timespan-switch
Allow TV view time span switch through url fragment
2022-02-10 11:52:07 +04:00
nymkappa
055c587351 Fix bug when loading /tv and cleanup Observable flow 2022-02-10 00:24:01 +09:00
nymkappa
cd9eaf816b Refactor TV component subscription 2022-02-10 00:24:01 +09:00
nymkappa
aa77faf314 Use switchMap param instead of re-reading this.route.snapshot.fragment 2022-02-10 00:24:00 +09:00
nymkappa
c9ad316ed5 Allow /tv view timespan to be changed through url fragment 2022-02-10 00:23:55 +09:00
softsimon
4b6ff5e776 Merge pull request #1232 from mempool/bugfix/remove-debug-return
Remove debug return which break the UX the first time we open mempool
2022-02-09 17:13:23 +04:00
softsimon
4e076566db Merge branch 'master' into bugfix/remove-debug-return 2022-02-09 17:13:13 +04:00
Antoni Spaanderman
42fa7c1023 Merge branch 'master' into address-labels 2022-02-09 10:42:41 +01:00
Antoni Spaanderman
8e0394e837 Merge branch 'master' into regtest-1 2022-02-09 10:42:23 +01:00
Antoni Spaanderman
89d811096c Merge branch 'master' into fee-visibility 2022-02-09 10:42:05 +01:00
hunicus
ac21c47540 Fix url for mempool post endpoint 2022-02-08 17:51:19 -05:00
hunicus
bb6a22192c Improve spacing at top of navs 2022-02-08 14:30:18 -05:00
hunicus
22137fef5a Add liquidtestnet endpoints 2022-02-08 13:44:50 -05:00
hunicus
82f70eaefe Show liquid link for liquid endpoint
Error from previous PR.
2022-02-08 13:44:50 -05:00
hunicus
ee8eef2806 Implement 27ce863735 2022-02-08 13:44:50 -05:00
hunicus
4979187468 Implement b1c9334119 2022-02-08 13:44:50 -05:00
hunicus
60160ac0f6 Implement 31c911cb59 2022-02-08 13:44:50 -05:00
hunicus
1a23a9c1c5 Rebase 1036 to master manually 2022-02-08 13:44:50 -05:00
wiz
b232a9b6c2 Merge pull request #1233 from nymkappa/feature/add-mining-pool-logos
sync-assets: Download pool logos from github
2022-02-08 05:53:31 +00:00
wiz
f485c702bd Merge branch 'master' into feature/add-mining-pool-logos 2022-02-08 05:41:22 +00:00
wiz
59530e0f95 Merge pull request #1234 from knorrium/cypress_improvements
Cypress improvements
2022-02-08 05:36:03 +00:00
wiz
ac60ee6857 Merge branch 'master' into feature/add-mining-pool-logos 2022-02-08 05:29:26 +00:00
Felipe Knorr Kuhn
e513b464d8 Add tests status badge to the top level README 2022-02-07 21:24:05 -08:00
Felipe Knorr Kuhn
0c7a907451 Update Cypress event trigers to master and PRs 2022-02-07 21:15:40 -08:00
Felipe Knorr Kuhn
37ba43d0eb Adjust merge messages and add tags for pushes and PRs 2022-02-07 20:50:10 -08:00
nymkappa
c704bfedeb Download pool logos from github 2022-02-08 12:56:26 +09:00
nymkappa
f9a6110c69 Remove debug return which break the UX the first time we open mempool 2022-02-08 11:20:19 +09:00
wiz
4b871468bc Merge branch 'master' into bugfix/fix-duplicate-indexing 2022-02-07 14:55:38 +00:00
wiz
5ede05c67c Merge pull request #1180 from antonilol/log-priority
add log priority option for stdout log
2022-02-07 12:38:31 +00:00
wiz
8868a02716 Merge branch 'master' into log-priority 2022-02-07 12:23:22 +00:00
wiz
e60aff2618 Merge pull request #1230 from mempool/simon/remove-liquidtestnet-asset-test
Disable featured assets test for testnet
2022-02-07 12:23:04 +00:00
softsimon
e36fb27704 Disable featured assets test for testnet 2022-02-07 14:49:14 +04:00
wiz
bd10d3f9b3 Merge branch 'master' into log-priority 2022-02-07 10:36:54 +00:00
softsimon
f260203833 Disable Featured assets on Liquid testnet
fixes #1229
2022-02-07 14:24:18 +04:00
Antoni Spaanderman
62990a95f8 Merge branch 'master' into log-priority
i first forgot to fetch upstream in github, conflicts are fixed
2022-02-07 09:15:42 +01:00
Antoni Spaanderman
5c4f6d6ada Merge branch 'master' into log-priority 2022-02-07 08:59:01 +01:00
wiz
1649cfbde0 Merge pull request #1225 from knorrium/external_assets_defaults
Add EXTERNAL_ASSETS defaults to the Docker start script and the README
2022-02-07 06:35:00 +00:00
wiz
3448d1be2a Merge branch 'master' into external_assets_defaults 2022-02-07 06:34:54 +00:00
wiz
32c6ca5e89 Merge pull request #1224 from mempool/simon/liquid-asset-grouping
Featured assets and asset groups
2022-02-07 03:24:00 +00:00
softsimon
f5193218e5 Mobile responsiveness fixes 2022-02-07 03:34:16 +04:00
softsimon
cd88692d3d Changing Asset proxy redirects to liquid.network 2022-02-07 03:34:16 +04:00
softsimon
99c7d7fac4 Removing /liquid from asset grouping base path. 2022-02-07 03:34:16 +04:00
wiz
01d6f4f737 Fix nginx configuration for liquid assets APIs 2022-02-07 03:34:16 +04:00
softsimon
4c2c6396ba Renaming assets-group to assets/group 2022-02-07 03:34:15 +04:00
wiz
f0398e906d Add nginx configuration for liquid assets APIs 2022-02-07 03:34:15 +04:00
softsimon
b634984ca6 Correcting more tests. 2022-02-07 03:34:15 +04:00
softsimon
1dbae4cd62 Fixing liquidtestnet tests. 2022-02-07 03:34:15 +04:00
softsimon
0863405671 Correcting tests. i18n strings and asset links. 2022-02-07 03:34:15 +04:00
softsimon
ff4c097c48 Mobile layout fixes. 2022-02-07 03:34:15 +04:00
softsimon
91082f27e7 SEO and various render fixes. 2022-02-07 03:34:15 +04:00
softsimon
d33c12cdee Asset search 2022-02-07 03:34:15 +04:00
softsimon
2e5c8bdfd3 Featured assets and asset groups 2022-02-07 03:34:14 +04:00
softsimon
755c1da8b3 Merge pull request #1228 from knorrium/add_staging_targets
Run tests in Staging
2022-02-07 03:33:50 +04:00
Felipe Knorr Kuhn
90784ea1ee Update CI Cypress config to hit staging 2022-02-06 15:13:31 -08:00
Felipe Knorr Kuhn
18a7b13077 Add new targets to run locally hitting the staging backends 2022-02-06 15:12:03 -08:00
Felipe Knorr Kuhn
4af0a75aad Add new proxy config for staging 2022-02-06 15:11:13 -08:00
Felipe Knorr Kuhn
ad38e5fa2d Add mining pools resources route 2022-02-06 15:10:35 -08:00
Antoni Spaanderman
9f3a3bd4d7 also detect uncompressed pubkeys + fix errors 2022-02-06 12:41:37 +01:00
wiz
b383f9fc67 Merge pull request #1213 from knorrium/fetch_conversion_rates_over_tor
Fetch conversion rates over Tor
2022-02-06 08:04:50 +00:00
wiz
aae780de6e Merge branch 'master' into fetch_conversion_rates_over_tor 2022-02-06 07:53:59 +00:00
Felipe Knorr Kuhn
81ee0e39bc Add EXTERNAL_ASSETS defaults to the Docker start script and the README 2022-02-05 21:24:24 -08:00
Felipe Knorr Kuhn
4afeb3998a Change fiat conversion logs to DEBUG 2022-02-05 15:38:03 -08:00
Antoni Spaanderman
bb8bfa0e3a copy paste moment 2022-02-05 17:29:42 +01:00
Antoni Spaanderman
148e340ea6 actually test htlc, fix indentation (again) and detect multisig 2022-02-05 17:26:50 +01:00
Antoni Spaanderman
7565aa7a25 fix indentation + detect htlc with option_anchors 2022-02-05 16:58:41 +01:00
Felipe Knorr Kuhn
6b2900345a Rename PRICENODE to PRICE_DATA_SERVER 2022-02-05 07:58:35 -08:00
Antoni Spaanderman
1f6504898a detect lightning htlc and unilateral close 2022-02-05 16:50:10 +01:00
softsimon
e2bcb82b59 Merge pull request #1218 from mempool/simon/dev-proxy-refactor
Local dev proxy working with all base modules
2022-02-05 13:58:14 +04:00
wiz
46ac307329 Merge branch 'master' into simon/dev-proxy-refactor 2022-02-05 09:47:08 +00:00
wiz
d3969afef5 Merge pull request #1219 from mempool/simon/add-mixed-proxy
Adding a "mixed" dev proxy
2022-02-05 09:13:16 +00:00
softsimon
a45c371e27 Adding a "mixed" dev proxy 2022-02-05 13:05:52 +04:00
softsimon
006ed39bf2 Local dev proxy working with all base modules 2022-02-05 13:02:22 +04:00
Felipe Knorr Kuhn
ee7f8d8d18 Reduce currency rates polling interval from 1 hour to 10 minutes 2022-02-05 00:33:16 -08:00
nymkappa
12b53d9ace Duplicated db blocks insertion attempts are expected 2022-02-05 15:50:57 +09:00
Felipe Knorr Kuhn
452375aaf7 Make the Currency Conversion Service URLs configurable and log when queried 2022-02-04 22:48:16 -08:00
Antoni Spaanderman
20996cfb49 Update docker/backend/mempool-config.json
oops (2)

Co-authored-by: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com>
2022-02-04 20:03:36 +01:00
Antoni Spaanderman
30c79a2025 Update docker/backend/start.sh
oops i just copied the line above and forgot that one

Co-authored-by: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com>
2022-02-04 20:03:25 +01:00
Antoni Spaanderman
174907cf6a add STDOUT_LOG_MIN_PRIORITY to README and docker config 2022-02-04 19:19:32 +01:00
wiz
1ada92f03e Merge pull request #1212 from nymkappa/feature/blocks-refactoring
Wrap custom blocks fields into a sub object of IEsplora.Blocks
2022-02-04 17:16:11 +00:00
wiz
2c60a81c1e Merge branch 'master' into feature/blocks-refactoring 2022-02-04 16:53:42 +00:00
wiz
c60e355453 Merge pull request #1215 from mempool/simon/fixing-local-proxy-endpoints
Proxy all /api and /api/v1 requests to local nodejs server
2022-02-04 16:52:41 +00:00
Antoni Spaanderman
d08d2a16d3 Merge branch 'master' into regtest-1
for cla bot
2022-02-04 12:34:42 +01:00
Antoni Spaanderman
9e9837133b Merge branch 'master' into log-priority
fix conflicts in backend/src/config.ts and backend/mempool-config.sample.json
2022-02-04 12:32:08 +01:00
Antoni Spaanderman
9fc4297e86 Merge branch 'master' into fee-visibility
for cla bot
2022-02-04 12:26:47 +01:00
nymkappa
456bd5a18e Renamed extra to extras 2022-02-04 19:28:00 +09:00
softsimon
02e15cbea4 Proxy all /api and /api/v1 requests to local nodejs server 2022-02-04 13:47:34 +04:00
Felipe Knorr Kuhn
b1dde4d8b1 Query conversion rates service over clearnet or Tor with mempool User-Agent 2022-02-03 23:23:57 -08:00
Felipe Knorr Kuhn
8a996cedb4 Update README, reference config files and Docker with the new SOCKS config 2022-02-03 23:21:19 -08:00
Felipe Knorr Kuhn
0a954e8bcf Allow synthetic default imports due to the socks library 2022-02-03 23:16:30 -08:00
Felipe Knorr Kuhn
0400deacf2 Add socks-proxy-agent dependency 2022-02-03 23:14:56 -08:00
nymkappa
9f0b09295d Move our custom fields to a BlockExtension sub object of the IEsploraApi.Block interface 2022-02-04 12:51:45 +09:00
softsimon
5c1fc7344d Merge pull request #1160 from antonilol/genesis-outspend
outputs of genesis coinbase are always unspent
2022-02-03 13:48:30 +04:00
softsimon
319f646fe2 Merge branch 'master' into genesis-outspend 2022-02-03 13:48:19 +04:00
wiz
1ae08aff66 Merge pull request #1207 from nymkappa/feature/fix-mining-pool-page-title
Set proper mining pool page title - Rename "Name" to "Pool"
2022-02-02 14:59:32 +00:00
wiz
4b79f09538 Merge branch 'master' into feature/fix-mining-pool-page-title 2022-02-02 14:47:50 +00:00
wiz
5fd05b3602 Merge pull request #1208 from nymkappa/feature/pools-api-endpoint-update
Replaced /mining/pools?interval=X by /mining/pools/X
2022-02-02 14:26:24 +00:00
wiz
77e75d3d8c Merge branch 'master' into feature/pools-api-endpoint-update 2022-02-02 14:26:15 +00:00
wiz
117f3eb99a Merge pull request #1189 from antonilol/cla
sign cla
2022-02-02 14:03:39 +00:00
nymkappa
e48a2f73e4 Replaced /mining/pools?interval=X by /mining/pools/X 2022-02-02 19:03:07 +09:00
nymkappa
ae9afe2f81 Set proper mining pool page title - Rename "Name" to "Pool" 2022-02-02 18:46:06 +09:00
wiz
95c8e72b58 Merge pull request #1200 from mempool/wiz/add-contributor-cla-files
Add staff contributor/{username}.txt files for new CLA bot
2022-01-29 08:23:50 +00:00
wiz
19dda17d50 Add staff contributor/{username}.txt files for CLA bot 2022-01-29 07:48:58 +00:00
wiz
a913a85dea Merge pull request #1199 from mempool/wiz/let-backend-set-its-own-http-cache-time-headers
Let backend set its own HTTP cache time headers for APIs
2022-01-29 04:28:22 +00:00
wiz
f842316636 Let backend set its own HTTP cache time headers for APIs 2022-01-28 13:59:04 +00:00
wiz
05fd433ad7 Merge pull request #1198 from mempool/wiz/enable-nginx-warm-cache-for-mining-pools-data
Enable nginx warm cache for mining pools API data
2022-01-28 13:51:44 +00:00
wiz
55652130a8 Enable nginx warm cache for mining pools API data 2022-01-28 13:33:29 +00:00
wiz
6a8874a9e0 Merge pull request #1193 from mempool/wiz/increase-nginx-timeouts
Increase nginx send_timeout and keepalive_requests
2022-01-28 13:22:21 +00:00
wiz
0afcb53abd Merge pull request #1162 from nymkappa/feature/backend-block-pool-data
Mining dashboard (2/2) - Dashboard PoC
2022-01-28 10:09:17 +00:00
nymkappa
620a7f0718 Fix mining pools wrong default timespan value 2022-01-28 18:49:06 +09:00
nymkappa
9df490373b Fixes post rebase 2022-01-28 15:01:24 +09:00
nymkappa
6ebbc5667d Small improvements on the mining page UX
- INDEXING_BLOCKS_AMOUNT = 0 disable indexing, INDEXING_BLOCKS_AMOUNT = -1 indexes everything
- Show only available timespan in the mining page according to available datas
- Change default INDEXING_BLOCKS_AMOUNT to 1100

Don't use unfiltered mysql user input

Enable http cache header for mining pools (1 min)
2022-01-28 15:01:24 +09:00
nymkappa
d66bc57165 Move block indexing start logic in blocks.ts 2022-01-28 15:01:23 +09:00
nymkappa
73019b485f Update tests - Replace button click blocks -> pools 2022-01-28 15:01:23 +09:00
nymkappa
647f12ffaa Added MEMPOOL.INDEXING_BLOCKS_AMOUNT in the config (default 432 blocks) 2022-01-28 15:01:23 +09:00
nymkappa
a271c39ba8 Wrap block indexing into a try/catch since we don't use async when calling that function 2022-01-28 15:01:22 +09:00
nymkappa
f8f9108ae1 Polish mining page UI
Make sure to wait for all mining pools queries before continuing
2022-01-28 15:01:22 +09:00
nymkappa
40e529ece7 Don't try to identify the mining pool on liquid/bisq 2022-01-28 15:01:21 +09:00
nymkappa
df960ab9ba Import pools file for testnet and signet as well - Added missing express routes 2022-01-28 15:01:21 +09:00
nymkappa
8eaa9b3c7b Add share % in pie chart label 2022-01-28 15:01:21 +09:00
nymkappa
5b32ab6dde DROP -> DROP IF EXISTS 2022-01-28 15:01:20 +09:00
nymkappa
f982f6b4b6 Hide epoch data from the mining page 2022-01-28 15:01:20 +09:00
nymkappa
aa457e316b Drop legacy blocks table during migration - Fix linter issues 2022-01-28 15:01:19 +09:00
nymkappa
b8410f00d9 Fix xxxWindowPreference management 2022-01-28 15:01:19 +09:00
nymkappa
4b9bfd6ca0 Basic block indexing WIP - Default mining pool icon - Only show mining hashrate on 1d scale 2022-01-28 15:01:15 +09:00
nymkappa
b9a047b22d Add difficulty adjustment in mining page + Fix pools table on mobile 2022-01-28 14:52:12 +09:00
nymkappa
091027cc79 When a new blocks is mined, refresh the mining stats 2022-01-28 13:54:59 +09:00
nymkappa
0a267affaf Add pie chart and rewrite the pool ranking component 2022-01-28 13:54:59 +09:00
nymkappa
18a63933fa Increment migration schema version to 3 and re-add pools and blocks table creation queries 2022-01-28 13:53:29 +09:00
nymkappa
bfe9f99c35 Generate mining basic pool ranking (sorted by block found) for a specified timeframe 2022-01-28 13:52:35 +09:00
nymkappa
37031ec913 Refactor blocks.ts and index 10k block headers at launch 2022-01-28 13:51:14 +09:00
nymkappa
031f69a403 Add backend README - Backend watchers setup 2022-01-28 13:50:58 +09:00
nymkappa
1a22923cd8 Migrate pools.json to the database in one command - Updated latest pools.json file from Blockchain-Known-Pools master 2022-01-28 13:50:58 +09:00
wiz
4212a649f1 Merge pull request #1194 from AaronDewes/patch-1
Change Citadel link to core
2022-01-27 09:03:12 +00:00
Aaron Dewes
8a4a003620 Change Citadel link to core 2022-01-27 08:11:18 +01:00
wiz
493dbb1b1a Increase nginx send_timeout and keepalive_requests
Fixes #425
2022-01-27 05:56:38 +00:00
Antoni Spaanderman
2aaa42716a sign cla 2022-01-25 16:50:03 +01:00
wiz
356dda96c8 Merge pull request #1188 from mempool/wiz/add-cla
Add new Contributor License Agreement policy
2022-01-25 10:22:21 +00:00
softsimon
f2a9933d21 Accept the CLA for @softsimon 2022-01-25 13:41:28 +04:00
wiz
bd033541b7 Update copyright years in legal notices 2022-01-25 09:36:02 +00:00
wiz
707ae7be01 Accept the CLA for @wiz 2022-01-25 09:35:48 +00:00
wiz
000dfc4d9e Add new Contributor License Agreement policy 2022-01-25 09:30:11 +00:00
wiz
cba46a82aa Merge pull request #1173 from mempool/simon/liquid-asset-precision-fix
Fixing Liquid asset precision
2022-01-25 08:15:20 +00:00
wiz
1263d05ac8 Merge pull request #1187 from nymkappa/bugfix/mysql-transactions
Remove useless autocommit=0 in db migration script
2022-01-25 07:51:31 +00:00
nymkappa
703b4cc92a Remove useless autocommit=0 in db migration script 2022-01-25 16:45:52 +09:00
wiz
6ad0344ea5 Merge pull request #1163 from nymkappa/feature/pools-migration
Mining dashboard (1/2) - Import mining pools into the database - Increment db schema to 3
2022-01-25 06:27:10 +00:00
Antoni Spaanderman
7902f68ada fix 0 sat/vB not displaying 2022-01-24 21:35:13 +01:00
Antoni Spaanderman
f68ac944ed fix dashboard TXs issue 2022-01-24 20:51:30 +01:00
Antoni Spaanderman
1beafd137b fix dashboard blocks issue 2022-01-24 20:44:05 +01:00
Antoni Spaanderman
f111c006ce fix block height out of range on full page blocks viewer 2022-01-24 20:26:02 +01:00
Antoni Spaanderman
44021a3cb3 prefer const over let 2022-01-24 20:25:22 +01:00
softsimon
eb32b13acb Merge pull request #1182 from nymkappa/bugfix/statistics-db-error-handling
Wrap statistics db ops with try/catch
2022-01-24 17:05:48 +04:00
softsimon
f1400909a8 Merge pull request #1183 from nymkappa/feature/cleanup-master-page
Cleanup master-page template
2022-01-24 17:03:16 +04:00
softsimon
c91b6b473a Merge pull request #1177 from knorrium/fix_broken_bisq_tx_link
Fix broken link on the Bisq transaction page
2022-01-24 13:23:11 +04:00
nymkappa
68320dc117 Cleanup master-page template 2022-01-24 18:22:15 +09:00
nymkappa
a805c86697 Wrap statistics db ops with try/catch 2022-01-24 16:22:38 +09:00
nymkappa
1322298a06 Make sure to wait for all mining pools queries before continuing 2022-01-24 14:34:03 +09:00
Antoni Spaanderman
3ceab1493e add log priority option for stdout log 2022-01-23 12:20:32 +01:00
softsimon
230f563235 Merge pull request #1178 from knorrium/update_e2e_tests
Update e2e tests: new scenarios for Liquid, Bisq and refactor button selectors
2022-01-23 14:25:11 +04:00
softsimon
d1ed3c4b93 Merge pull request #1179 from mempool/simon/frontend-npm-audit-fix
Npm audit fix
2022-01-23 12:58:39 +04:00
softsimon
c1f90e0c26 Npm audit fix 2022-01-23 12:58:16 +04:00
Felipe Knorr Kuhn
0ff6cd19c3 Update tests: use ids for nav bar items and new scenarios for bisq and liquid 2022-01-22 14:23:09 -08:00
Felipe Knorr Kuhn
a5ca0cda14 Add ids to nav bar items, liquid and bisq components 2022-01-22 14:21:46 -08:00
Antoni Spaanderman
30632e9e11 fix error with invalid chaintips 2022-01-22 15:13:10 +01:00
Felipe Knorr Kuhn
0560496154 Fix broken link on the Bisq transaction page 2022-01-21 23:12:18 -08:00
softsimon
e2dfdc0064 Merge pull request #1175 from knorrium/update_to_cypress_931
Update Cypress to v9.3.1
2022-01-21 15:37:54 +04:00
softsimon
a09910522b Merge pull request #1176 from knorrium/update_liquid_tests
Update Liquid tests
2022-01-21 15:37:20 +04:00
wiz
145bdca3af Merge pull request #1172 from mempool/simon/liquid-asset-overflow
Asset name overflow fix
2022-01-21 08:55:50 +00:00
Felipe Knorr Kuhn
af38ef8ee7 Merge branch 'master' into update_liquid_tests 2022-01-20 21:54:23 -08:00
Felipe Knorr Kuhn
7bb95ff177 Update Cypress GHA spec list 2022-01-20 21:43:13 -08:00
Felipe Knorr Kuhn
c885187971 Add an amount class vins and vouts to improve testing 2022-01-20 21:31:14 -08:00
Felipe Knorr Kuhn
6637477ac9 Update Liquid tests 2022-01-20 21:30:22 -08:00
Felipe Knorr Kuhn
cf5cce23f3 Add Liquid Testnet tests 2022-01-20 21:30:03 -08:00
Felipe Knorr Kuhn
9f2d0c5172 Update config script defaults 2022-01-20 21:29:45 -08:00
Felipe Knorr Kuhn
80e4141612 Update Cypress to v9.3.1 2022-01-20 21:27:52 -08:00
softsimon
a8c04624f0 Fixing liqud asset precision
fixes #1166
2022-01-21 01:32:19 +04:00
softsimon
36b4812e93 Asset name overflow fix 2022-01-21 00:16:18 +04:00
softsimon
347c386815 Merge pull request #1171 from knorrium/fix_liquid_proxy
Fix Liquid proxy settings
2022-01-20 23:42:57 +04:00
softsimon
b2fac709f9 Merge pull request #1170 from mempool/simon/liquid-loading-fixes
Liquid asset loading fixes
2022-01-20 23:30:44 +04:00
Felipe Knorr Kuhn
35e69f2e3d Fix Liquid proxy settings 2022-01-20 11:27:50 -08:00
softsimon
88a9e22abe Liquid asset loading fixes 2022-01-20 23:00:43 +04:00
Antoni Spaanderman
e8986e5fdc stop for loop after genesis block
prevHash == undefined for the genesis block
2022-01-20 19:24:30 +01:00
Antoni Spaanderman
e581ef7fe3 add regtest class 2022-01-20 19:10:36 +01:00
Antoni Spaanderman
1f0ae601c5 add network regtest 2022-01-20 17:19:16 +01:00
wiz
2b1367afd8 Merge pull request #1167 from mempool/simon/asset-icons
Display Liquid asset icons
2022-01-20 16:11:12 +00:00
softsimon
a2b167fc07 Display Liquid asset icons 2022-01-20 19:51:02 +04:00
Antoni Spaanderman
4bf167d3e1 fixed arrow not pointing to genesis block 2022-01-20 15:57:53 +01:00
nymkappa
87175869dd Fix typescript miss use 2022-01-20 23:31:32 +09:00
nymkappa
a1a2e9363f Make sure to release all db connections 2022-01-20 23:07:20 +09:00
nymkappa
19a564062b Add pools.json file in default config.ts - Handle file exception - Only import pools for MAINNET 2022-01-20 22:59:10 +09:00
nymkappa
8d1cc40459 Fix add 'Unknown' pool logic 2022-01-20 16:56:25 +09:00
nymkappa
1210643e8e Fix linter issues and typo 2022-01-20 16:34:14 +09:00
nymkappa
979c52d3c4 Add pools.json to EXTERNAL_ASSETS - Now supports updating the table 2022-01-20 13:53:08 +09:00
Antoni Spaanderman
e59f610a75 display genesis block 2022-01-19 17:11:35 +01:00
Antoni Spaanderman
3608fa6f19 load blocks with height under INITIAL_BLOCKS_AMOUNT 2022-01-19 16:58:56 +01:00
nymkappa
2848f56c2b Import mining pools into the database - Increment db schema to 3 2022-01-19 18:50:52 +09:00
softsimon
ab6a0eae09 Merge pull request #1158 from antonilol/coinbase
dont use hardcoded genesis coinbase and block hash
2022-01-19 13:33:45 +04:00
softsimon
bc925a409f Merge pull request #1152 from nymkappa/feature/split-difficulty-component
Move difficulty adjustment code to separate module
2022-01-19 13:19:17 +04:00
Antoni Spaanderman
fac40b1515 rethrow the error if it wasnt the genesis coinbase 2022-01-19 08:27:51 +01:00
Antoni Spaanderman
63939ddbe4 outputs of genesis coinbase are always unspent 2022-01-18 22:25:38 +01:00
Antoni Spaanderman
d4719245f5 dont use hardcoded genesis coinbase and block hash
fixes #1128
2022-01-18 21:55:09 +01:00
wiz
3a67bc6425 Merge pull request #1154 from nymkappa/bugfix/extreme-filter-only-mainnet
Only apply vbytes/sec cap on Bitcoin mainnet - Fix linter issues
2022-01-17 21:06:02 +09:00
nymkappa
08a9cc30ba Only apply vbytes/sec cap on Bitcoin mainnet - Fix linter issues 2022-01-17 20:19:20 +09:00
wiz
9641a00bb4 Merge pull request #1151 from nymkappa/feature/save-zeroed-statistics
Insert zeroed statistics in the database if the mempool is empty
2022-01-17 19:08:35 +09:00
nymkappa
fcca911377 Move difficulty adjustment code to separate module 2022-01-17 13:33:07 +09:00
wiz
274ca33664 Merge pull request #1150 from mempool/release/v2.3.0 2022-01-16 18:56:08 +09:00
nymkappa
a570812d70 Insert zeroed statistics in the database if the mempool is empty 2022-01-16 16:20:45 +09:00
wiz
dbdc87eeae Bump version number to v2.4.0-dev 2022-01-16 15:41:23 +09:00
wiz
b9067ed912 Release v2.3.0 2022-01-16 15:36:48 +09:00
wiz
11cc14f5b0 Merge pull request #1149 from mempool/wiz/20220116-pull-from-transifex
Pull translated strings from Transifex
2022-01-16 15:31:44 +09:00
wiz
4133bf31c6 Merge pull request #1147 from mempool/simon/gettxout
Utilize gettxout to display spent/unspent
2022-01-16 15:29:53 +09:00
wiz
bfeee747c2 Merge pull request #1148 from mempool/simon/liquid-testnet-statuspage
Adding missing Liquid Testnet Status page
2022-01-16 15:00:42 +09:00
wiz
31fb6f70ab Pull translated strings from Transifex 2022-01-16 14:42:25 +09:00
softsimon
cb38258cf7 Adding missing Liquid Testnet Status page 2022-01-15 23:49:08 +04:00
softsimon
2a16dc5a7f Utilize gettxout to display spent/outspent
fixes #1088
2022-01-15 22:09:04 +04:00
softsimon
20476e1366 Merge pull request #1145 from mempool/wiz/fix-html-theme-color
Fix HTML theme color for iOS status bar
2022-01-15 21:00:01 +04:00
wiz
57b0ccee60 Fix HTML theme color for iOS status bar 2022-01-16 00:19:29 +09:00
wiz
80ec15193c Merge pull request #1132 from mempool/simon/translators
Adding translators to About page
2022-01-15 06:49:01 +00:00
wiz
d61eba8c68 Fix translation for Project Translators on About page 2022-01-15 06:47:51 +00:00
wiz
4787b6353a Merge pull request #1142 from mempool/wiz/update-nginx-conf-for-services-apis
Update nginx.conf for mempool.space services APIs
2022-01-15 06:22:44 +00:00
softsimon
debcd1808e Displaying translators as twitter photos 2022-01-15 04:19:50 +04:00
softsimon
85f471ad08 Adding translators to About page 2022-01-15 04:01:53 +04:00
wiz
c7fa785346 Merge pull request #1144 from mempool/wiz/update-nginx-conf-for-resource-caching 2022-01-14 15:06:11 +00:00
wiz
a710934830 Update production nginx.conf resource cache times 2022-01-14 22:35:25 +09:00
wiz
69e006f640 Merge pull request #1143 from mempool/simon/fix-critical-vulnerability
Fixing high vulnerabilities
2022-01-14 12:53:15 +00:00
softsimon
78c32af062 Fixing high vulnerabilities 2022-01-14 16:43:56 +04:00
wiz
9a47191e10 Update nginx.conf for mempool.space services APIs 2022-01-14 20:56:41 +09:00
wiz
ace5da94a4 Merge pull request #1140 from mempool/wiz/fix-newsyslog-owner-and-pidfile
Fix newsyslog.conf owner and pidfile location
2022-01-14 10:54:27 +00:00
wiz
e7f2f75b05 Merge pull request #1141 from nymkappa/feature/remove-unused-data-statistics
Remove unused fields from statistics queries since we don't use them in the front end
2022-01-14 10:39:07 +00:00
nymkappa
5b39ad2130 Remove id, unconfirmed_transactions and tx_per_second from the statistics queries since we don't use them in the front end 2022-01-14 19:21:54 +09:00
wiz
ee1985bb3d Fix newsyslog.conf owner and pidfile location 2022-01-14 19:21:42 +09:00
wiz
9caa57e81d Merge pull request #1139 from nymkappa/feature/improve-statistics-query-perf
Order by native `statistics.added` field for better query performances
2022-01-14 09:30:01 +00:00
nymkappa
8797ef261f Order by native statistics.added field for better query performances 2022-01-14 18:13:34 +09:00
wiz
fb9a548dfc Merge pull request #1136 from mempool/docker_readme_fixes 2022-01-13 13:53:27 +00:00
Felipe Knorr Kuhn
ad4bfefee7 Fix Docker README 2022-01-13 05:51:36 -08:00
wiz
cd9157488f Merge pull request #1135 from mempool/wiz/fix-typo-nginx-cache-warmer
Fix typo in nginx-cache-warmer script
2022-01-13 09:05:33 +00:00
wiz
b501f7228c Fix typo in nginx-cache-warmer script 2022-01-13 17:59:51 +09:00
wiz
11483852da Merge pull request #1120 from knorrium/docker_updates
Updates to the docker-compose setup
2022-01-13 08:52:08 +00:00
wiz
a6fadc840d Merge pull request #1134 from mempool/wiz/add-nginx-cache-warmer 2022-01-13 08:34:48 +00:00
Felipe Knorr Kuhn
af8c8a2088 Fix typos in the JSON keys 2022-01-13 00:08:07 -08:00
wiz
573cb8f993 Merge pull request #1133 from nymkappa/feature/disable-graph-interaction-mobile
Disable graph touch interaction in dashboard on mobile so we can scroll properly
2022-01-13 07:20:58 +00:00
Felipe Knorr Kuhn
d70c610741 Fetch the dereferenced commit from the tag 2022-01-12 22:36:24 -08:00
wiz
985d19778f Merge pull request #1130 from mempool/simon/remove-backend-cache
Removing statistics cache and setting headers
2022-01-13 06:07:36 +00:00
wiz
2cb50c2351 Add nginx cache warmer script for production use 2022-01-13 15:06:13 +09:00
Felipe Knorr Kuhn
359e111ae4 Normalize Docker environment variables and backend JSON keys 2022-01-12 21:20:14 -08:00
wiz
548f38292f Merge pull request #1131 from hunicus/update-liquidtestnet-docs
Update liquidtestnet docs
2022-01-13 04:12:48 +00:00
nymkappa
5f2350b763 Disable graph touch interaction in dashboard on mobile so we can scroll properly 2022-01-13 12:00:49 +09:00
Felipe Knorr Kuhn
831cd580e0 Delete Docker README 2022-01-12 17:18:52 -08:00
Felipe Knorr Kuhn
47a6969dc9 Move Docker instructions to the top level README 2022-01-12 17:18:33 -08:00
softsimon
29581f325f Removing statistics cache and setting headers 2022-01-12 20:57:25 +04:00
hunicus
fbce72b7fc Update transactions endpoints 2022-01-12 11:51:10 -05:00
hunicus
a894fa5bc0 Update mempool endpoints 2022-01-12 11:51:10 -05:00
hunicus
9ac3c420eb Update fees endpoints 2022-01-12 11:51:10 -05:00
hunicus
10df6985fc Update blocks endpoints 2022-01-12 11:51:10 -05:00
hunicus
27ce863735 Fix block-height endpoint across networks 2022-01-12 11:51:10 -05:00
hunicus
d840d79aea Update block and block-header 2022-01-12 11:51:10 -05:00
hunicus
80dfc81900 Make minor grammatical changes to GET Asset Icons 2022-01-12 11:51:10 -05:00
hunicus
31c911cb59 Rename 'GET Assets' to 'GET Asset'
Confusing since it gets information on 1
asset..."asset" should be singular.
2022-01-12 11:51:10 -05:00
hunicus
0d4160b232 Reorder assets nav items to fit content order 2022-01-12 11:51:10 -05:00
hunicus
f0022f6af9 Update assets endpoints
Currently no testnet assets have icons, so those
responses are blank.
2022-01-12 11:51:10 -05:00
hunicus
a16decfb94 Fix urls in code examples 2022-01-12 11:51:10 -05:00
wiz
ea2a2310a0 Merge pull request #1129 from mempool/wiz/nginx-redirects-for-localized-urls
Improve nginx caching and use redirects for i18n
2022-01-12 16:44:11 +00:00
wiz
7f17ade65c Merge pull request #1113 from mempool/simon/network-language-fix
Adding current language to network dropdown links
2022-01-12 16:41:47 +00:00
softsimon
c8d38740cc Minor language service refactor 2022-01-12 19:08:56 +04:00
wiz
efffd1a929 Suggested changes for Simon's PR #1113 2022-01-12 23:52:52 +09:00
wiz
f0c53a4e5b Improve nginx caching and use redirects for i18n 2022-01-12 23:12:49 +09:00
wiz
a9c1dc3726 Merge pull request #1121 from nymkappa/feature/database-migration-update
Wrap migration with transactions
2022-01-12 11:28:14 +00:00
nymkappa
2944f0b805 Added missing log tags 2022-01-12 17:43:32 +09:00
nymkappa
f494bd6d6a Sleep 10 seconds before ending the process after critical error in database migration 2022-01-12 17:26:10 +09:00
nymkappa
ae2cb05dc5 Extract all CREATE commands from transaction 2022-01-12 16:41:27 +09:00
nymkappa
4e322fe006 Print database engine version when migration script starts 2022-01-12 16:06:45 +09:00
hunicus
5d06d02d64 Fix urls
So that /liquidtestnet is in links and link text.
2022-01-12 01:36:26 -05:00
hunicus
7eabbe30e6 Add /liquidtestnet/ to links 2022-01-12 01:36:26 -05:00
hunicus
c232f6a11d Add boilerplate liquidtestnet examples
Also adjust logic to show them. Doing this prevents
compilation errors and will allow for endpoints to
be reviewed as they are modified.
2022-01-12 01:36:26 -05:00
hunicus
04ffa6d7bb Update address-utxo 2022-01-12 01:36:44 -05:00
hunicus
d46655e5f4 Update address-tx-chain and address-tx-mempool 2022-01-12 01:36:37 -05:00
hunicus
1438300763 Update address and address-tx 2022-01-12 01:36:26 -05:00
nymkappa
cce49bdb7e MariaDB 10.2 does not supports CAST as FLOAT -> Replace with CAST as DOUBLE 2022-01-12 14:51:16 +09:00
nymkappa
fc878b696d Only create statistics.index if needed (supports old mariadb) - Make sure all db connections are released - Fix linter issues - Remove .toString() 2022-01-12 14:10:16 +09:00
wiz
c09fdb656f Merge pull request #1111 from mempool/wiz/add-production-torrc
Add production Tor configuration to repo
2022-01-12 03:45:09 +00:00
wiz
9ac9eb9cc8 Merge pull request #1124 from mempool/simon/bump-angular-ngboostrap
Bumping minor Angular version and major ngBootstrap
2022-01-12 03:44:33 +00:00
wiz
ff5367b0e7 Merge pull request #1125 from knorrium/link_to_commit
Link the git commit hash to GitHub on the About page
2022-01-12 03:32:45 +00:00
Felipe Knorr Kuhn
503adc20dc Link the git commit hash to GitHub on the About page 2022-01-11 17:02:48 -08:00
softsimon
2f5cad9d0a Bumping minor Angular version and major ngBootstrap 2022-01-12 02:42:33 +04:00
hunicus
871329e0fd Remove websocket and js tabs
Since npm packages don't work with liquidtestnet yet.
2022-01-11 17:21:35 -05:00
hunicus
7825b8d732 Remove difficulty endpoint from nav 2022-01-11 15:32:35 -05:00
nymkappa
6bfd9da08c Refactor migrations - Wrap with TRANSACTION 2022-01-11 20:43:59 +09:00
Felipe Knorr Kuhn
ce8518ad58 List all environment variables to override in the README 2022-01-10 23:31:05 -08:00
Felipe Knorr Kuhn
865fe488bf Make the RPC user and pass explicit in the example docker-compose file 2022-01-10 23:30:31 -08:00
Felipe Knorr Kuhn
467cac7d4d Remove the troubleshooting section from the Docker README 2022-01-10 22:11:02 -08:00
Felipe Knorr Kuhn
3a0fb2015a Address feedback on the Docker README 2022-01-10 22:06:15 -08:00
Felipe Knorr Kuhn
bfb5abaa71 Update Docker README file 2022-01-10 21:10:58 -08:00
Felipe Knorr Kuhn
6cb2625303 Update the reference docker-compose.yml file 2022-01-10 21:09:06 -08:00
Felipe Knorr Kuhn
2d292e27b9 Add the empty directories needed by docker-compose 2022-01-10 20:31:36 -08:00
wiz
9b6d679739 Merge pull request #1119 from nymkappa/feature/order-statistics-by-added
statistics: `ORDER BY id` => `ORDER BY added`
2022-01-11 03:38:24 +00:00
wiz
8099349dcc Merge pull request #1118 from nymkappa/bugfix/graph-scroll-main-page
Mouse scroll is not captured anymore by graphs in the dashboard page
2022-01-11 03:31:07 +00:00
nymkappa
b1df17d7a3 statistics: ORDER BY id => ORDER BY added 2022-01-11 12:25:45 +09:00
nymkappa
02798db449 Mouse scroll is not capture anymore by graphs in the dashboard page 2022-01-11 12:16:09 +09:00
wiz
4b71cb6e28 Merge pull request #1116 from mempool/wiz/20220111-pull-from-transifex
Pull translated strings from Transifex
2022-01-11 03:09:44 +00:00
wiz
cee52e69f1 Merge pull request #1112 from nymkappa/feature/index-added-field
INDEX 'added' in statistics table
2022-01-11 03:09:20 +00:00
wiz
a4a8fb64b1 Merge pull request #1110 from nymkappa/feature/filter-out-extreme-values
Cap extreme vbytes_per_second values
2022-01-11 03:07:44 +00:00
nymkappa
0e6cc67c0a Only create INDEX 'added' when it does not already exist 2022-01-11 11:47:04 +09:00
wiz
cc621b10ce Update Tor onion hostnames for bisq.markets and liquid.network 2022-01-11 11:18:22 +09:00
wiz
2eaea44182 Pull translated strings from Transifex 2022-01-11 10:07:50 +09:00
wiz
50734bafbf Merge pull request #1114 from mempool/simon/mempool.js-2.3.0
Bumping mempool.js lib to 2.3.0
2022-01-11 00:50:22 +00:00
Felipe Knorr Kuhn
745b7d6f65 Set statistics to enabled by default 2022-01-10 16:10:34 -08:00
softsimon
4ca730697c Adding current language to network dropdown links
fixes  #1094
2022-01-10 18:00:01 +04:00
softsimon
dc06a3f62a Bumping mempool.js lib to 2.3.0 2022-01-10 15:55:18 +04:00
nymkappa
1e78326ee4 INDEX 'added' in statistics table 2022-01-10 19:48:29 +09:00
nymkappa
45542d5f06 Apply AVG() on vbytes_per_second - Cap extreme vbytes_per_second values 2022-01-10 18:52:56 +09:00
wiz
0106f44129 Add production/torrc file to git repo 2022-01-10 18:37:54 +09:00
Felipe Knorr Kuhn
ba895559bf Fix a few sed commands in the Docker backend start script that needed escaping 2022-01-10 00:42:42 -08:00
Felipe Knorr Kuhn
513886f6d2 Fix typo on the docker start script 2022-01-10 00:08:42 -08:00
Felipe Knorr Kuhn
09fe7346bc Make every backend parameter configurable via environment variables 2022-01-09 22:19:04 -08:00
Felipe Knorr Kuhn
4173486f4d Update the template backend mempool-config.json file used by the Docker image 2022-01-09 22:18:29 -08:00
wiz
d809e85dde Merge pull request #1109 from mempool/wiz/20220110-pull-from-transifex
Pull translated strings from Transifex
2022-01-10 04:21:04 +00:00
wiz
6414f0045e Pull translated strings from Transifex 2022-01-10 13:20:39 +09:00
wiz
39c5393e3b Merge pull request #1107 from mempool/wiz/20220109-pull-from-transifex
Pull translated strings from Transifex
2022-01-09 07:27:49 +00:00
wiz
d2cd396c75 Pull translated strings from Transifex 2022-01-09 16:23:47 +09:00
wiz
ccbb28c8a0 Merge pull request #1104 from mempool/simon/remove-local-bisq-liquid
Ending support for /bisq /liquid and /liquidtestnet
2022-01-09 06:29:46 +00:00
softsimon
afbced3f4d Adapting tests 2022-01-08 20:44:45 +04:00
softsimon
08f2287def Ending support for /bisq /liquid and /liquidtestnet 2022-01-08 17:33:37 +04:00
wiz
5175027948 Merge pull request #1103 from mempool/wiz/fix-matomo-for-bisq-markets
Fix matomo hostname for bisq.markets html
2022-01-08 10:17:46 +00:00
wiz
d0cda447c0 Fix matomo hostname for bisq.markets html 2022-01-08 19:05:06 +09:00
wiz
fd288cd106 Merge pull request #1100 from mempool/simon/configurable-network-urls
Making frontend network URLs configurable
2022-01-08 10:01:52 +00:00
wiz
2d0d7df704 Merge pull request #1102 from mempool/simon/bisq-footer-buttons
Bisq: Adding missing privacy policy, locale selector
2022-01-08 09:37:05 +00:00
softsimon
c41ac34978 Bisq: Adding missing privacy policy, locale selector
fixes #1096
2022-01-07 23:38:31 +04:00
softsimon
47307bc755 Making frontend network URLs configurable
fixes #1095
2022-01-07 20:17:14 +04:00
wiz
bfe5d3ae49 Merge pull request #1099 from mempool/simon/transifex-pull 2022-01-07 09:27:52 +00:00
softsimon
a060816e2c Transifex pull 2022-01-07 12:32:23 +04:00
wiz
898ff5da23 Merge pull request #1093 from mempool/simon/transifex-pull
Transifex pull
2022-01-06 08:33:58 +00:00
softsimon
d78d2c0eca Transifex pull 2022-01-06 12:32:08 +04:00
wiz
a08e77ff3e Merge pull request #1092 from mempool/simon/transifex-pull 2022-01-05 20:17:54 +00:00
softsimon
1e39eb0fa5 Transifex pull 2022-01-06 00:04:02 +04:00
wiz
5de133ae6a Merge pull request #1087 from mempool/simon/removing-sql-import-references
Remove all references to SQL tables import
2022-01-05 10:03:36 +00:00
softsimon
d27b125848 Merge branch 'master' into simon/removing-sql-import-references
# Conflicts:
#	production/README.md
2022-01-05 13:51:58 +04:00
wiz
ad36d53bb5 Merge pull request #1081 from mempool/wiz/update-production-configuration-for-v2.3
Update production configurations + README for v2.3
2022-01-05 09:45:57 +00:00
softsimon
24f76f2f37 Remove all references to SQL tables import
fixes #1045
2022-01-05 13:26:36 +04:00
wiz
691bdda523 Merge pull request #1086 from mempool/simon/transifex-pull
Transifex pull
2022-01-05 09:19:03 +00:00
wiz
81bb31090e Use upstream hostnames in production nginx configuration 2022-01-05 18:12:05 +09:00
softsimon
cc0a0719b6 Transifex pull 2022-01-05 13:10:58 +04:00
softsimon
7dca8ae1a0 Merge pull request #1085 from mempool/wiz/add-citadel-to-about-page
Add Citadel as Community Integration on About page
2022-01-05 13:04:50 +04:00
softsimon
84027d5568 Merge pull request #1084 from mempool/wiz/tweak-page-titles-descriptions
Tweak html description meta tags / SEO service page titles
2022-01-05 13:04:09 +04:00
wiz
4116186c1a Add Citadel as Community Integration on About page 2022-01-05 17:15:11 +09:00
wiz
358301020f Tweak html description meta tags / SEO service page titles 2022-01-05 16:57:24 +09:00
wiz
642022bfd8 Merge pull request #1083 from mempool/simon/transifex-pull
Transifex pull
2022-01-05 01:52:26 +00:00
softsimon
70f25b6c9c Transifex pull 2022-01-04 22:43:09 +04:00
wiz
c778e84247 Add missing } at end of nginx/server-common.conf 2022-01-04 17:27:37 +09:00
wiz
4de1d017ad Update production configurations + README for v2.3
* Refactor production nginx configuration files
* Update README for new networks, SQL, etc.
2022-01-04 16:38:12 +09:00
wiz
61851be23a Merge pull request #1079 from mempool/simon/liquid-fee-range-dropdown
Liquid support to the Graph fee filter dropdown
2022-01-04 04:51:10 +00:00
wiz
5de949eaed Merge pull request #1067 from mempool/simon/liquid-testnet-navbar-color
Liquid testnet navbar color
2022-01-04 04:32:12 +00:00
wiz
de6434a5ba Merge pull request #1080 from mempool/simon/liquid-testnet-asset-data
Fixing missing assets data for Liquid Testnet native asset
2022-01-04 04:24:19 +00:00
softsimon
c8639ec71d Fixing missing assets data for Liquid Testnet native asset
fixes #1068
2022-01-04 05:26:46 +04:00
softsimon
e1275c62cc Liquid support to the Graph fee filter dropdown
fixes #1072
2022-01-04 04:42:19 +04:00
softsimon
be45e88056 Liquid testnet navbar color 2022-01-01 13:37:20 +04:00
softsimon
990ab3da5f Merge pull request #1066 from mempool/simon/liquid-backend-detection-refactor
Refactoring the Liquid and LiquidTestnet check to a common function.
2022-01-01 12:54:39 +04:00
wiz
d1d74ebf37 Merge pull request #1065 from mempool/simon/block-navigation-routing-fix
Block navigation routing fix
2021-12-30 22:31:05 +00:00
softsimon
6ab79b3c35 Refactoring the Liquid and LiquidTestnet check to a common function. 2021-12-31 02:28:40 +04:00
softsimon
4f21fc0d87 Block navigation routing fix 2021-12-31 02:21:12 +04:00
wiz
10c4e47091 Merge pull request #1064 from mempool/wiz/add-liquidtestnet-to-upgrade-script
Add missing liquidtestnet backend to upgrade script
2021-12-30 21:59:37 +00:00
wiz
dd49ff0084 Merge pull request #1062 from mempool/simon/liquidtestnet-backend-fix
Fix backend support for 'liquidtestnet' network
2021-12-30 21:56:55 +00:00
wiz
853314ba58 Add missing liquidtestnet backend to upgrade script 2021-12-31 06:55:16 +09:00
wiz
784e2470df Merge pull request #1060 from mempool/simon/coinbase-unknown-fix
Fixing misplaced Unknown text after the Coinbase
2021-12-30 21:30:18 +00:00
softsimon
350b4922da Fix backend support for 'liquidtestnet' network 2021-12-31 01:26:45 +04:00
softsimon
40fb1792f4 Fixing misplaces Unknown text after the Coinbase 2021-12-30 16:55:42 +04:00
wiz
7ce1cc5103 Merge pull request #1052 from mempool/simon/liquid-testnet
Adding Liquid Testnet as frontend option
2021-12-29 23:34:19 +00:00
wiz
71a4e24900 Delete duplicate production/mempool-config.liquid-testnet.json file 2021-12-30 08:25:44 +09:00
softsimon
a48c2c07b0 Display the transaction grapg instead of L-BTC peg for Liquid Testnet 2021-12-30 03:12:35 +04:00
softsimon
d89d7efbe6 Fix issue when switching between testnet and liquid mainnet 2021-12-30 03:07:08 +04:00
softsimon
5ea4b043d9 Use relativeUrl when redirecting from the Searchbar 2021-12-30 02:30:46 +04:00
softsimon
dd4710b602 Handle Liquid native asset issuance transaction. 2021-12-30 02:18:16 +04:00
wiz
832c0cb3cc Merge pull request #1057 from mempool/wiz/remove-hover-effect-on-about-page
Tweak hover effect on profile photos on About page
2021-12-29 22:03:23 +00:00
wiz
04216e952a Tweak hover effect on profile photos on About page 2021-12-30 06:48:40 +09:00
softsimon
951d0f0039 Merge pull request #1056 from mempool/wiz/update-specter-logo-on-about-page
Update Specter logo on About page
2021-12-30 01:33:20 +04:00
wiz
706f4bbc55 Update Specter logo on About page 2021-12-30 06:11:12 +09:00
softsimon
3fd96e412b Merge pull request #1053 from mempool/wiz/add-liquid-testnet-backend
Add support for liquidtestnet in production backend and nginx
2021-12-29 01:07:38 +04:00
softsimon
766803ded1 Liquid testnet asset frontend support 2021-12-29 00:42:34 +04:00
softsimon
504f46cad9 Support for Test Liquid Native Asset 2021-12-29 00:40:55 +04:00
softsimon
fd34761a93 Adding Liquid Testnet as frontend option
fixes #976
2021-12-28 11:16:33 +04:00
wiz
96e8f45e5b Add support for liquidtestnet in production backend and nginx 2021-12-28 15:20:11 +09:00
wiz
195fae670b Merge pull request #1044 from nymkappa/feature/increase-resolution-charts
Increase graphs data resolution
2021-12-28 05:19:20 +00:00
wiz
dd767f9468 Merge pull request #1043 from mempool/simon/transifex-pull
Pulled from transifex
2021-12-26 21:09:07 +00:00
nymkappa
bc8104eeb4 Increase graphs data resolution 2021-12-26 17:51:38 +09:00
softsimon
2c61eb6227 Pulled from transifex 2021-12-26 11:15:19 +04:00
wiz
5d360d4156 Merge pull request #1003 from mempool/simon/database-migration-feature
Automated database creation and migration
2021-12-23 21:50:10 +00:00
softsimon
91e30fbc3c Merge branch 'master' into simon/database-migration-feature
# Conflicts:
#	backend/src/index.ts
2021-12-24 00:26:33 +04:00
wiz
5b22e2a000 Merge pull request #1010 from mempool/simon/liquid-icons-api
Liquid icons api
2021-12-23 12:28:54 +00:00
softsimon
533653e54a Change Asset Icon API example to only show HTML 2021-12-23 15:35:17 +04:00
wiz
3dc0dc13ad Merge pull request #1038 from nymkappa/feature/increase-resolution-24h
Switch the 24h chart to 1 min data ticks
2021-12-22 18:33:32 +00:00
softsimon
e332789afc Bumping mempool.js to 2.3.0-dev1 and removing unused tsc build step 2021-12-22 19:33:10 +04:00
nymkappa
e4a9fd06b4 Switch the 24h chart to 1 min data ticks 2021-12-22 23:01:32 +09:00
softsimon
5845f2380e Adding sync external assets feature. 2021-12-21 02:00:50 +04:00
softsimon
c29311d831 Upgrading mempool-js with separated Liquid and Bisq 2021-12-20 23:48:26 +04:00
softsimon
252db109bc Adding icons.json to .gitignore 2021-12-20 04:01:40 +04:00
softsimon
b1c9334119 Changing API path and updating API Docs for asset icons. 2021-12-20 04:01:04 +04:00
wiz
ab04247726 Merge pull request #1033 from mempool/simon/extract-i18n
Extracting i18n string
2021-12-19 19:06:11 +00:00
softsimon
e94a85b989 Extracting i18n string 2021-12-19 22:57:31 +04:00
softsimon
a4569788f8 Liquid icons api 2021-12-19 22:09:49 +04:00
wiz
b455814e90 Merge pull request #1027 from hunicus/change-docs-layout
Revamp docs layout
2021-12-19 17:48:26 +00:00
softsimon
7afd0f3fe7 Merge pull request #1032 from mempool/wiz/update-about-page-links
Update links on About page
2021-12-19 21:36:10 +04:00
hunicus
a2a85469cf Streamline api-docs-navs conditionals 2021-12-19 12:29:52 -05:00
wiz
94488a6029 Merge pull request #1031 from mempool/wiz/update-issue-templates
Update GitHub issue templates to redirect support requests to chat
2021-12-19 17:02:57 +00:00
wiz
8e4829146a Rename About page section: Project Staff -> Project Members 2021-12-20 01:54:06 +09:00
wiz
08f185525c Update About page chat links: replace telegram with matrix 2021-12-20 01:52:58 +09:00
wiz
d6b00fe39e Update GitHub issue templates to redirect support requests to chat 2021-12-20 01:31:29 +09:00
softsimon
cec3baeaa4 Merge pull request #1024 from nymkappa/feature/blocks-mouse-scroll
User can drag the blockchain blocks horizontally with the mouse
2021-12-19 12:59:04 +04:00
nymkappa
6e59733cac User can drag the blockchain blocks horizontally with the mouse 2021-12-19 15:20:21 +09:00
hunicus
c5b705ede7 Adjust bisq cypress tests 2021-12-17 16:22:16 -05:00
hunicus
2819e24efe Remove unnecessary file change 2021-12-17 15:08:21 -05:00
hunicus
5f9bc4497a Customize mobile nav button appearance point
Since there are different numbers of topics across
bitcoin, liquid, bisq, faq, etc.
2021-12-17 14:42:21 -05:00
hunicus
086b14e816 Add various ux improvements for mobile doc menu 2021-12-17 11:42:54 -05:00
hunicus
958bfe6d25 Separate docs-nav into new component
Since same markup will be needed for desktop
and mobile menus.
2021-12-16 19:11:54 -05:00
hunicus
e01ab449cf Add skeleton for mobile docs nav 2021-12-16 18:44:39 -05:00
hunicus
9a18019d9d Add :before element for space before anchors
@angular-router's `scrollOffset` property seems to be
global, so it might mess up something else, and it also
wasn't taking effect when navigating directly to an
anchor anyway (i.e. from browser's address bar).
2021-12-16 13:20:30 -05:00
hunicus
5d8c970351 Update anchor links and add on-page links 2021-12-16 11:30:03 -05:00
hunicus
89fede9e48 Fix inconsistencies in api-docs markup 2021-12-16 09:54:07 -05:00
hunicus
f8a54784d0 Improve styling + switch section headings for tags 2021-12-16 09:54:07 -05:00
hunicus
010381aac4 Convert accordions to plain html 2021-12-16 08:46:51 -05:00
hunicus
1a8fd23b05 Add links and styling to fixed desktop docs nav 2021-12-16 00:04:47 -05:00
hunicus
3ae46e6ba1 Make desktop docs-nav sticky on scroll 2021-12-15 22:57:10 -05:00
hunicus
40f1949654 Create skeleton layout for desktop docs nav
This includes switching to a 2-column layout
(1 for nav and 1 for content) and moving footer
links to docs component so floats can be cleared
properly.
2021-12-15 13:17:37 -05:00
softsimon
2281116504 Automated database creation and migration
fixes #1002
2021-12-13 11:32:04 +04:00
439 changed files with 107317 additions and 86552 deletions

View File

@@ -1,37 +0,0 @@
<!--
SUPPORT REQUESTS: This is for reporting bugs in Mempool.
If you have a support request, please join our Keybase group:
https://keybase.io/team/mempool
-->
### Description
<!-- brief description of the bug -->
#### Version
<!-- commit id or version number -->
### Steps to reproduce
<!--if you can reliably reproduce the bug, list the steps here -->
### Expected behaviour
<!--description of the expected behavior -->
### Actual behaviour
<!-- explain what happened instead of the expected behaviour -->
### Screenshots
<!--Screenshots if gui related, drag and drop to add to the issue -->
#### Device or machine
<!-- device/machine used, operating system -->
#### Additional info
<!-- Additional information useful for debugging (e.g. logs) -->

43
.github/ISSUE_TEMPLATE/00-bug-issue.md vendored Normal file
View File

@@ -0,0 +1,43 @@
---
name: 🐛 Bug Report
about: Report bugs (no support requests, please)
---
<!--
SUPPORT REQUESTS:
This is for reporting bugs in Mempool, not for support requests.
If you have a support request, please reach out on Matrix:
https://matrix.to/#/#mempool.support:bitcoin.kyoto
-->
### Description
<!-- brief description of the bug -->
#### Version
<!-- commit id or version number -->
### Steps to reproduce
<!-- if you can reliably reproduce the bug, list the steps here -->
### Expected behaviour
<!-- description of the expected behavior -->
### Actual behaviour
<!-- explain what happened instead of the expected behaviour -->
### Screenshots
<!-- Screenshots if gui related, drag and drop to add to the issue -->
#### Device or machine
<!-- device/machine used, operating system -->
#### Additional info
<!-- Additional information useful for debugging (e.g. logs) -->

View File

@@ -0,0 +1,27 @@
---
name: ✨ Feature Request
about: Request a feature or suggest other enhancements
---
<!--
SUPPORT REQUESTS:
This is for requesting features in Mempool, not for support requests.
If you have a support request, please reach out on Matrix:
https://matrix.to/#/#mempool.support:bitcoin.kyoto
-->
### Description
<!-- brief description of the feature request -->
### Problem to be solved
<!-- description of the the problem you're having -->
### Proposed solution
<!-- explain how you think we should solve the problem -->
#### Additional info
<!-- Additional information useful for implementing (e.g. docs, links, etc.) -->

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: 🙋 Need help? Chat with us on Matrix
url: https://matrix.to/#/#mempool.support:bitcoin.kyoto
about: For support requests or general questions
- name: 🌐 Want to help with translations? Use Transifex
url: https://www.transifex.com/mempool/mempool
about: All translations work is done on Transifex

20
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/backend"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: npm
directory: "/frontend"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/docker/backend"
schedule:
interval: weekly
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

6
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,6 @@
<!--
Please do not open pull requests for translations.
All translations work is done on Transifex:
https://www.transifex.com/mempool/mempool
-->

View File

@@ -1,7 +1,6 @@
name: Cypress Tests
on: [push, pull_request]
jobs:
cypress:
runs-on: ${{ matrix.os }}
@@ -18,63 +17,75 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16.10.0
node-version: 16.15.0
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: ${{ matrix.browser }} browser tests (Mempool)
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v4
with:
tag: ${{ github.event_name }}
working-directory: frontend
build: npm run config:defaults:mempool
start: npm run start:local-prod
start: npm run start:local-staging
wait-on: 'http://localhost:4200'
wait-on-timeout: 120
record: true
parallel: true
spec: |
cypress/e2e/mainnet/*.spec.ts
cypress/e2e/signet/*.spec.ts
cypress/e2e/testnet/*.spec.ts
group: Tests on ${{ matrix.browser }} (Mempool)
browser: ${{ matrix.browser }}
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
env:
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
- name: ${{ matrix.browser }} browser tests (Liquid)
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v4
if: always()
with:
tag: ${{ github.event_name }}
working-directory: frontend
build: npm run config:defaults:liquid
start: npm run start:local-prod
start: npm run start:local-staging
wait-on: 'http://localhost:4200'
wait-on-timeout: 120
record: true
parallel: true
spec: cypress/integration/liquid/liquid.spec.ts
spec: |
cypress/e2e/liquid/liquid.spec.ts
cypress/e2e/liquidtestnet/liquidtestnet.spec.ts
group: Tests on ${{ matrix.browser }} (Liquid)
browser: ${{ matrix.browser }}
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
env:
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
- name: ${{ matrix.browser }} browser tests (Bisq)
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v4
if: always()
with:
tag: ${{ github.event_name }}
working-directory: frontend
build: npm run config:defaults:bisq
start: npm run start:local-prod
start: npm run start:local-staging
wait-on: 'http://localhost:4200'
wait-on-timeout: 120
record: true
parallel: true
spec: cypress/integration/bisq/bisq.spec.ts
spec: cypress/e2e/bisq/bisq.spec.ts
group: Tests on ${{ matrix.browser }} (Bisq)
browser: ${{ matrix.browser }}
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
env:
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}

View File

@@ -11,6 +11,9 @@ on:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-*
permissions:
contents: read
jobs:
build:
strategy:
@@ -35,24 +38,24 @@ jobs:
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2
- name: Init repo for Dockerization
run: docker/init.sh "$TAG"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # v1
id: qemu
- name: Setup Docker buildx action
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # v1
id: buildx
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@661fd3eb7f2f20d8c7c84bc2b0509efd7a826628 # v2
id: cache
with:
path: /tmp/.buildx-cache

2
.nvmrc
View File

@@ -1 +1 @@
v16.10.0
v16.15.0

49
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,49 @@
# Contributing to The Mempool Open Source Project
Thank you for contributing to The Mempool Open Source Project managed by Mempool Space K.K. (“Mempool”).
In order to clarify the intellectual property license granted with Contributions from any person or entity, Mempool must have a statement on file from each Contributor indicating their agreement to the Contributor License Agreement (“Agreement”). This license is for your protection as a Contributor as well as the protection of Mempool and its other contributors and users; it does not change your rights to use your own Contributions for any other purpose.
When submitting a pull request for the first time, please create a file with a name like `/contributors/{github_username}.txt`, and in the content of that file indicate your agreement to the Contributor License Agreement terms below. An example of what that file should contain can be seen in wiz's agreement file. (This method of CLA "signing" is borrowed from Medium's open source project.)
# Contributor License Agreement
Last Updated: January 25, 2022
By accepting this Agreement, You agree to the following terms and conditions for Your present and future Contributions submitted to Mempool. Except for the license granted herein to Mempool and recipients of software distributed by Mempool, You reserve all right, title, and interest in and to Your Contributions.
### 1. Definitions
“You” (or “Your”) shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Mempool. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
“Contribution” shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Mempool for inclusion in, or documentation of, any of the products owned or managed by Mempool (“Work”). For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to Mempool or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Mempool for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as “Not a Contribution.”
### 2. Grant of Copyright License
Subject to the terms and conditions of this Agreement, You hereby grant to Mempool and to recipients of software distributed by Mempool a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
### 3. Grant of Patent License
Subject to the terms and conditions of this Agreement, You hereby grant to Mempool and to recipients of software distributed by Mempool a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
### 4. Authority
You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to Mempool, or that your employer has executed a separate Corporate Contributor License Agreement with Mempool.
### 5. Originality
You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware, and which are associated with any part of Your Contributions.
### 6. Support
You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
### 7. Third Party Contributions
Should You wish to submit work that is not Your original creation, You may submit it to Mempool separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as “Submitted on behalf of a third-party: [named here]”.
### 8. Notifications
You agree to notify Mempool of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.
EOF

View File

@@ -25,8 +25,7 @@ help:
.PHONY: init
init:
@echo ''
mkdir -p $(DATA) $(DATA)/mysql $(DATA)/mysql/db-scripts $(DATA)/mysql/data
install -v mariadb-structure.sql $(DATA)/mysql/db-scripts
mkdir -p $(DATA) $(DATA)/mysql $(DATA)/mysql/data
#REF: https://github.com/mempool/mempool/blob/master/docker/README.md
cat docker/docker-compose.yml > docker-compose.yml
cat backend/mempool-config.sample.json > backend/mempool-config.json

View File

@@ -1,5 +1,5 @@
The Mempool Open Source Project
Copyright (c) 2019-2021 The Mempool Open Source Project Developers
Copyright (c) 2019-2022 The Mempool Open Source Project Developers
This program is free software; you can redistribute it and/or modify it under
the terms of (at your option) either:

197
README.md
View File

@@ -1,188 +1,33 @@
# The Mempool Open Source Project™
# The Mempool Open Source Project™ [![mempool](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/ry4br7/master&style=flat-square)](https://dashboard.cypress.io/projects/ry4br7/runs)
Mempool is the fully featured visualizer, explorer, and API service running on [mempool.space](https://mempool.space/), an open source project developed and operated for the benefit of the Bitcoin community, with a focus on the emerging transaction fee market to help our transition into a multi-layer ecosystem.
Mempool is the fully-featured mempool visualizer, explorer, and API service running at [mempool.space](https://mempool.space/).
![mempool](https://mempool.space/resources/screenshots/v2.3.0-dashboard.png)
It is an open-source project developed and operated for the benefit of the Bitcoin community, with a focus on the emerging transaction fee market that is evolving Bitcoin into a multi-layer ecosystem.
## Installation Methods
![mempool](https://mempool.space/resources/screenshots/v2.4.0-dashboard.png)
Mempool can be self-hosted on a wide variety of your own hardware, ranging from a simple one-click installation on a Raspberry Pi distro, all the way to an advanced high availability cluster of powerful servers for a production instance. We support the following installation methods, ranked in order from simple to advanced:
# Installation Methods
1) One-click installation on: [Umbrel](https://github.com/getumbrel/umbrel), [RaspiBlitz](https://github.com/rootzoll/raspiblitz), [RoninDojo](https://code.samourai.io/ronindojo/RoninDojo), or [MyNode](https://github.com/mynodebtc/mynode).
2) [Docker installation on Linux using docker-compose](https://github.com/mempool/mempool/tree/master/docker)
3) [Manual installation on Linux or FreeBSD](https://github.com/mempool/mempool#manual-installation)
4) [Production installation on a powerful FreeBSD server](https://github.com/mempool/mempool/tree/master/production)
5) [High Availability cluster using powerful FreeBSD servers](https://github.com/mempool/mempool/tree/master/production#high-availability)
Mempool can be self-hosted on a wide variety of your own hardware, ranging from a simple one-click installation on a Raspberry Pi full-node distro all the way to a robust production instance on a powerful FreeBSD server.
# Manual Installation
**Most people should use a one-click install method.** Other install methods are meant for developers and others with experience managing servers.
The following instructions are for a manual installation on Linux or FreeBSD. The file and directory paths may need to be changed to match your OS.
<a id="one-click-installation"></a>
## One-Click Installation
## Dependencies
Mempool can be conveniently installed on the following full-node distros:
- [Umbrel](https://github.com/getumbrel/umbrel)
- [RaspiBlitz](https://github.com/rootzoll/raspiblitz)
- [RoninDojo](https://code.samourai.io/ronindojo/RoninDojo)
- [myNode](https://github.com/mynodebtc/mynode)
- [Start9](https://github.com/Start9Labs/embassy-os)
* [Bitcoin](https://github.com/bitcoin/bitcoin)
* [Electrum](https://github.com/romanz/electrs)
* [NodeJS](https://github.com/nodejs/node)
* [MariaDB](https://github.com/mariadb/server)
* [Nginx](https://github.com/nginx/nginx)
**We highly recommend you deploy your own Mempool instance this way.** No matter which option you pick, you'll be able to get your own fully-sovereign instance of Mempool up quickly without needing to fiddle with any settings.
## Mempool
## Advanced Installation Methods
Clone the mempool repo, and checkout the latest release tag:
```bash
git clone https://github.com/mempool/mempool
cd mempool
latestrelease=$(curl -s https://api.github.com/repos/mempool/mempool/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
git checkout $latestrelease
```
Mempool can be installed in other ways too, but we only recommend doing so if you're a developer, have experience managing servers, or otherwise know what you're doing.
## Bitcoin Core (bitcoind)
Enable RPC and txindex in `bitcoin.conf`:
```bash
rpcuser=mempool
rpcpassword=mempool
txindex=1
```
## MySQL
Install MariaDB from OS package manager:
```bash
# Linux
apt-get install mariadb-server mariadb-client
# macOS
brew install mariadb
mysql.server start
```
Create database and grant privileges:
```bash
MariaDB [(none)]> drop database mempool;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create database mempool;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on mempool.* to 'mempool'@'%' identified by 'mempool';
Query OK, 0 rows affected (0.00 sec)
```
From the mempool repo's top-level folder, import the database structure:
```bash
mysql -u mempool -p mempool < mariadb-structure.sql
```
## Mempool Backend
Install mempool dependencies from npm and build the backend:
```bash
# backend
cd backend
npm install --prod
npm run build
```
In the `backend` folder, make a copy of the sample config and modify it to fit your settings.
```bash
cp mempool-config.sample.json mempool-config.json
```
Edit `mempool-config.json` to add your Bitcoin Core node RPC credentials:
```bash
{
"MEMPOOL": {
"NETWORK": "mainnet",
"BACKEND": "electrum",
"HTTP_PORT": 8999
},
"CORE_RPC": {
"HOST": "127.0.0.1",
"PORT": 8332,
"USERNAME": "mempool",
"PASSWORD": "mempool"
},
"ELECTRUM": {
"HOST": "127.0.0.1",
"PORT": 50002,
"TLS_ENABLED": true
},
"DATABASE": {
"ENABLED": true,
"HOST": "127.0.0.1",
"PORT": 3306,
"USERNAME": "mempool",
"PASSWORD": "mempool",
"DATABASE": "mempool"
}
}
```
Start the backend:
```bash
npm run start
```
When it's running you should see output like this:
```bash
Mempool updated in 0.189 seconds
Updating mempool
Mempool updated in 0.096 seconds
Updating mempool
Mempool updated in 0.099 seconds
Updating mempool
Calculated fee for transaction 1 / 10
Calculated fee for transaction 2 / 10
Calculated fee for transaction 3 / 10
Calculated fee for transaction 4 / 10
Calculated fee for transaction 5 / 10
Calculated fee for transaction 6 / 10
Calculated fee for transaction 7 / 10
Calculated fee for transaction 8 / 10
Calculated fee for transaction 9 / 10
Calculated fee for transaction 10 / 10
Mempool updated in 0.243 seconds
Updating mempool
```
## Mempool Frontend
Install mempool dependencies from npm and build the frontend static HTML/CSS/JS:
```bash
# frontend
cd frontend
npm install --prod
npm run build
```
Install the output into nginx webroot folder:
```bash
sudo rsync -av --delete dist/mempool/ /var/www/
```
## nginx + certbot
Install the supplied nginx.conf and nginx-mempool.conf in /etc/nginx
```bash
# install nginx and certbot
apt-get install -y nginx python3-certbot-nginx
# install the mempool configuration for nginx
cp nginx.conf nginx-mempool.conf /etc/nginx/
# replace example.com with your domain name
certbot --nginx -d example.com
```
If everything went okay you should see the beautiful mempool :grin:
If you get stuck on "loading blocks", this means the websocket can't connect.
Check your nginx proxy setup, firewalls, etc. and open an issue if you need help.
- See the [`docker/`](./docker/) directory for instructions on deploying Mempool with Docker.
- See the [`backend/`](./backend/) and [`frontend/`](./frontend/) directories for manual install instructions oriented for developers and small-scale deployments.
- See the [`production/`](./production/) directory for guidance on setting up a more serious Mempool instance designed for high performance at scale.

7
backend/.gitignore vendored
View File

@@ -1,7 +1,10 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# production config
mempool-config.json
# production config and external assets
*.json
!mempool-config.sample.json
icons.json
# compiled output
/dist

161
backend/README.md Normal file
View File

@@ -0,0 +1,161 @@
# Mempool Backend
These instructions are mostly intended for developers, but can be used as a basis for personal or small-scale production setups.
If you choose to use these instructions for a production setup, be aware that you will still probably need to do additional configuration for your specific OS, environment, use-case, etc. We do our best here to provide a good starting point, but only proceed if you know what you're doing. Mempool does not provide support for custom setups.
See other ways to set up Mempool on [the main README](/../../#installation-methods).
Jump to a section in this doc:
- [Set Up the Backend](#setup)
- [Development Tips](#development-tips)
## Setup
### 1. Clone Mempool Repository
Get the latest Mempool code:
```
git clone https://github.com/mempool/mempool
cd mempool
```
Check out the latest release:
```
latestrelease=$(curl -s https://api.github.com/repos/mempool/mempool/releases/latest|grep tag_name|head -1|cut -d '"' -f4)
git checkout $latestrelease
```
### 2. Configure Bitcoin Core
Turn on `txindex`, enable RPC, and set RPC credentials in `bitcoin.conf`:
```
txindex=1
server=1
rpcuser=mempool
rpcpassword=mempool
```
### 3. Configure Electrum Server
[Pick an Electrum Server implementation](https://mempool.space/docs/faq#address-lookup-issues), configure it, and make sure it's synced.
**This step is optional.** You can run Mempool without configuring an Electrum Server for it, but address lookups will be disabled.
### 4. Configure MariaDB
_Mempool needs MariaDB v10.5 or later. If you already have MySQL installed, make sure to migrate any existing databases **before** installing MariaDB._
Get MariaDB from your operating system's package manager:
```
# Debian, Ubuntu, etc.
apt-get install mariadb-server mariadb-client
# macOS
brew install mariadb
mysql.server start
```
Create a database and grant privileges:
```
MariaDB [(none)]> drop database mempool;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create database mempool;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on mempool.* to 'mempool'@'%' identified by 'mempool';
Query OK, 0 rows affected (0.00 sec)
```
### 5. Prepare Mempool Backend
#### Build
_Make sure to use Node.js 16.15 and npm 7._
Install dependencies with `npm` and build the backend:
```
cd backend
npm install # add --prod for production
npm run build
```
#### Configure
In the backend folder, make a copy of the sample config file:
```
cp mempool-config.sample.json mempool-config.json
```
Edit `mempool-config.json` as needed.
In particular, make sure:
- the correct Bitcoin Core RPC credentials are specified in `CORE_RPC`
- the correct `BACKEND` is specified in `MEMPOOL`:
- "electrum" if you're using [romanz/electrs](https://github.com/romanz/electrs) or [cculianu/Fulcrum](https://github.com/cculianu/Fulcrum)
- "esplora" if you're using [Blockstream/electrs](https://github.com/Blockstream/electrs)
- "none" if you're not using any Electrum Server
### 6. Run Mempool Backend
Run the Mempool backend:
```
npm run start
```
When it's running, you should see output like this:
```
Mempool updated in 0.189 seconds
Updating mempool
Mempool updated in 0.096 seconds
Updating mempool
Mempool updated in 0.099 seconds
Updating mempool
Calculated fee for transaction 1 / 10
Calculated fee for transaction 2 / 10
Calculated fee for transaction 3 / 10
Calculated fee for transaction 4 / 10
Calculated fee for transaction 5 / 10
Calculated fee for transaction 6 / 10
Calculated fee for transaction 7 / 10
Calculated fee for transaction 8 / 10
Calculated fee for transaction 9 / 10
Calculated fee for transaction 10 / 10
Mempool updated in 0.243 seconds
Updating mempool
```
### 7. Set Up Mempool Frontend
With the backend configured and running, proceed to set up the [Mempool frontend](../frontend#manual-setup).
## Development Tips
### Set Up Backend Watchers
The Mempool backend is static. TypeScript scripts are compiled into the `dist` folder and served through a Node.js web server.
As a result, for development purposes, you may find it helpful to set up backend watchers to avoid the manual shutdown/recompile/restart command-line cycle.
First, install `nodemon` and `ts-node`:
```
npm install -g ts-node nodemon
```
Then, run the watcher:
```
nodemon src/index.ts --ignore cache/ --ignore pools.json
```
`nodemon` should be in npm's global binary folder. If needed, you can determine where that is with `npm -g bin`.

View File

@@ -12,8 +12,14 @@
"BLOCK_WEIGHT_UNITS": 4000000,
"INITIAL_BLOCKS_AMOUNT": 8,
"MEMPOOL_BLOCKS_AMOUNT": 8,
"PRICE_FEED_UPDATE_INTERVAL": 3600,
"USE_SECOND_NODE_FOR_MINFEE": false
"INDEXING_BLOCKS_AMOUNT": 11000,
"PRICE_FEED_UPDATE_INTERVAL": 600,
"USE_SECOND_NODE_FOR_MINFEE": false,
"EXTERNAL_ASSETS": [],
"EXTERNAL_MAX_RETRY": 1,
"EXTERNAL_RETRY_INTERVAL": 0,
"USER_AGENT": "mempool",
"STDOUT_LOG_MIN_PRIORITY": "debug"
},
"CORE_RPC": {
"HOST": "127.0.0.1",
@@ -39,6 +45,7 @@
"ENABLED": true,
"HOST": "127.0.0.1",
"PORT": 3306,
"SOCKET": "/var/run/mysql/mysql.sock",
"DATABASE": "mempool",
"USERNAME": "mempool",
"PASSWORD": "mempool"
@@ -57,5 +64,25 @@
"BISQ": {
"ENABLED": false,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db"
},
"SOCKS5PROXY": {
"ENABLED": false,
"USE_ONION": true,
"HOST": "127.0.0.1",
"PORT": 9050,
"USERNAME": "",
"PASSWORD": ""
},
"PRICE_DATA_SERVER": {
"TOR_URL": "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices",
"CLEARNET_URL": "https://price.bisq.wiz.biz/getAllMarketPrices"
},
"EXTERNAL_DATA_SERVER": {
"MEMPOOL_API": "https://mempool.space/api/v1",
"MEMPOOL_ONION": "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/api/v1",
"LIQUID_API": "https://liquid.network/api/v1",
"LIQUID_ONION": "http://liquidmom47f6s3m53ebfxn47p76a6tlnxib3wp6deux7wuzotdr6cyd.onion/api/v1",
"BISQ_URL": "https://bisq.markets/api",
"BISQ_ONION": "http://bisqmktse2cabavbr2xjq7xw3h6g5ottemo5rolfcwt6aly6tp5fdryd.onion/api"
}
}

1085
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "mempool-backend",
"version": "2.3.0-dev",
"version": "2.4.0-dev",
"description": "Bitcoin mempool visualizer and blockchain explorer backend",
"license": "GNU Affero General Public License v3.0",
"homepage": "https://mempool.space",
@@ -28,23 +28,21 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@mempool/bitcoin": "^3.0.3",
"@mempool/electrum-client": "^1.1.7",
"@types/ws": "8.2.2",
"axios": "0.24.0",
"axios": "~0.27.2",
"bitcoinjs-lib": "6.0.1",
"crypto-js": "^4.0.0",
"express": "^4.17.1",
"locutus": "^2.0.12",
"express": "^4.18.0",
"mysql2": "2.3.3",
"node-worker-threads-pool": "^1.4.3",
"typescript": "4.4.4",
"ws": "8.3.0"
"node-worker-threads-pool": "^1.5.1",
"socks-proxy-agent": "^6.2.0",
"typescript": "~4.7.2",
"ws": "~8.7.0"
},
"devDependencies": {
"@types/compression": "^1.0.1",
"@types/express": "^4.17.2",
"@types/locutus": "^0.0.6",
"@types/compression": "^1.7.2",
"@types/ws": "~8.5.3",
"@types/express": "^4.17.13",
"tslint": "^6.1.0"
}
}

View File

@@ -2,6 +2,7 @@ import * as fs from 'fs';
import * as os from 'os';
import logger from '../logger';
import { IBackendInfo } from '../mempool.interfaces';
const { spawnSync } = require('child_process');
class BackendInfo {
private gitCommitHash = '';
@@ -27,10 +28,23 @@ class BackendInfo {
}
private setLatestCommitHash(): void {
try {
this.gitCommitHash = fs.readFileSync('../.git/refs/heads/master').toString().trim();
} catch (e) {
logger.err('Could not load git commit info: ' + (e instanceof Error ? e.message : e));
//TODO: share this logic with `generate-config.js`
if (process.env.DOCKER_COMMIT_HASH) {
this.gitCommitHash = process.env.DOCKER_COMMIT_HASH;
} else {
try {
const gitRevParse = spawnSync('git', ['rev-parse', '--short', 'HEAD']);
if (!gitRevParse.error) {
const output = gitRevParse.stdout.toString('utf-8').replace(/[\n\r\s]+$/, '');
this.gitCommitHash = output ? output : '?';
} else if (gitRevParse.error.code === 'ENOENT') {
console.log('git not found, cannot parse git hash');
this.gitCommitHash = '?';
}
} catch (e: any) {
console.log('Could not load git commit info: ' + e.message);
this.gitCommitHash = '?';
}
}
}

View File

@@ -1,10 +1,14 @@
import config from '../../config';
import * as fs from 'fs';
import axios from 'axios';
import axios, { AxiosResponse } from 'axios';
import * as http from 'http';
import * as https from 'https';
import { SocksProxyAgent } from 'socks-proxy-agent';
import { BisqBlocks, BisqBlock, BisqTransaction, BisqStats, BisqTrade } from './interfaces';
import { Common } from '../common';
import { BlockExtended } from '../../mempool.interfaces';
import { StaticPool } from 'node-worker-threads-pool';
import backendInfo from '../backend-info';
import logger from '../../logger';
class Bisq {
@@ -35,7 +39,13 @@ class Bisq {
constructor() {}
startBisqService(): void {
this.checkForBisqDataFolder();
try {
this.checkForBisqDataFolder();
} catch (e) {
logger.info('Retrying to start bisq service in 3 minutes');
setTimeout(this.startBisqService.bind(this), 180000);
return;
}
this.loadBisqDumpFile();
setInterval(this.updatePrice.bind(this), 1000 * 60 * 60);
this.updatePrice();
@@ -90,7 +100,7 @@ class Bisq {
private checkForBisqDataFolder() {
if (!fs.existsSync(Bisq.BLOCKS_JSON_FILE_PATH)) {
logger.warn(Bisq.BLOCKS_JSON_FILE_PATH + ` doesn't exist. Make sure Bisq is running and the config is correct before starting the server.`);
return process.exit(1);
throw new Error(`Cannot load BISQ ${Bisq.BLOCKS_JSON_FILE_PATH} file`);
}
}
@@ -137,12 +147,59 @@ class Bisq {
}, 2000);
});
}
private async updatePrice() {
type axiosOptions = {
headers: {
'User-Agent': string
};
timeout: number;
httpAgent?: http.Agent;
httpsAgent?: https.Agent;
}
const setDelay = (secs: number = 1): Promise<void> => new Promise(resolve => setTimeout(() => resolve(), secs * 1000));
const BISQ_URL = (config.SOCKS5PROXY.ENABLED === true) && (config.SOCKS5PROXY.USE_ONION === true) ? config.EXTERNAL_DATA_SERVER.BISQ_ONION : config.EXTERNAL_DATA_SERVER.BISQ_URL;
const isHTTP = (new URL(BISQ_URL).protocol.split(':')[0] === 'http') ? true : false;
const axiosOptions: axiosOptions = {
headers: {
'User-Agent': (config.MEMPOOL.USER_AGENT === 'mempool') ? `mempool/v${backendInfo.getBackendInfo().version}` : `${config.MEMPOOL.USER_AGENT}`
},
timeout: config.SOCKS5PROXY.ENABLED ? 30000 : 10000
};
let retry = 0;
private updatePrice() {
axios.get<BisqTrade[]>('https://bisq.markets/api/trades/?market=bsq_btc', { timeout: 10000 })
.then((response) => {
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
if (config.SOCKS5PROXY.ENABLED) {
const socksOptions: any = {
agentOptions: {
keepAlive: true,
},
hostname: config.SOCKS5PROXY.HOST,
port: config.SOCKS5PROXY.PORT
};
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
socksOptions.username = config.SOCKS5PROXY.USERNAME;
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
} else {
// Retry with different tor circuits https://stackoverflow.com/a/64960234
socksOptions.username = `circuit${retry}`;
}
// Handle proxy agent for onion addresses
if (isHTTP) {
axiosOptions.httpAgent = new SocksProxyAgent(socksOptions);
} else {
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
}
}
const data: AxiosResponse = await axios.get(`${BISQ_URL}/trades/?market=bsq_btc`, axiosOptions);
if (data.statusText === 'error' || !data.data) {
throw new Error(`Could not fetch data from Bisq market, Error: ${data.status}`);
}
const prices: number[] = [];
response.data.forEach((trade) => {
data.data.forEach((trade) => {
prices.push(parseFloat(trade.price) * 100000000);
});
prices.sort((a, b) => a - b);
@@ -150,19 +207,24 @@ class Bisq {
if (this.priceUpdateCallbackFunction) {
this.priceUpdateCallbackFunction(this.price);
}
}).catch((err) => {
logger.err('Error updating Bisq market price: ' + err);
});
logger.debug('Successfully updated Bisq market price');
break;
} catch (e) {
logger.err('Error updating Bisq market price: ' + (e instanceof Error ? e.message : e));
await setDelay(config.MEMPOOL.EXTERNAL_RETRY_INTERVAL);
retry++;
}
}
}
private async loadBisqDumpFile(): Promise<void> {
this.allBlocks = [];
try {
const data = await this.loadData();
await this.loadBisqBlocksDump(data);
await this.loadData();
this.buildIndex();
this.calculateStats();
} catch (e) {
logger.info('loadBisqDumpFile() error.' + (e instanceof Error ? e.message : e));
logger.info('Cannot load bisq dump file because: ' + (e instanceof Error ? e.message : e));
}
}
@@ -241,36 +303,61 @@ class Bisq {
};
}
private async loadBisqBlocksDump(cacheData: string): Promise<void> {
const start = new Date().getTime();
if (cacheData && cacheData.length !== 0) {
logger.debug('Processing Bisq data dump...');
const data: BisqBlocks = await this.jsonParsePool.exec(cacheData);
if (data.blocks && data.blocks.length !== this.allBlocks.length) {
this.allBlocks = data.blocks;
this.allBlocks.reverse();
this.blocks = this.allBlocks.filter((block) => block.txs.length > 0);
this.latestBlockHeight = data.chainHeight;
const time = new Date().getTime() - start;
logger.debug('Bisq dump processed in ' + time + ' ms (worker thread)');
} else {
throw new Error(`Bisq dump didn't contain any blocks`);
}
private async loadData(): Promise<any> {
if (!fs.existsSync(Bisq.BLOCKS_JSON_FILE_PATH)) {
throw new Error(Bisq.BLOCKS_JSON_FILE_PATH + ` doesn't exist`);
}
}
private loadData(): Promise<string> {
return new Promise((resolve, reject) => {
if (!fs.existsSync(Bisq.BLOCKS_JSON_FILE_PATH)) {
return reject(Bisq.BLOCKS_JSON_FILE_PATH + ` doesn't exist`);
}
fs.readFile(Bisq.BLOCKS_JSON_FILE_PATH, 'utf8', (err, data) => {
if (err) {
reject(err);
}
resolve(data);
});
const readline = require('readline');
const events = require('events');
const rl = readline.createInterface({
input: fs.createReadStream(Bisq.BLOCKS_JSON_FILE_PATH),
crlfDelay: Infinity
});
let blockBuffer = '';
let readingBlock = false;
let lineCount = 1;
const start = new Date().getTime();
logger.debug('Processing Bisq data dump...');
rl.on('line', (line) => {
if (lineCount === 2) {
line = line.replace(' "chainHeight": ', '');
this.latestBlockHeight = parseInt(line, 10);
}
if (line === ' {') {
readingBlock = true;
} else if (line === ' },') {
blockBuffer += '}';
try {
const block: BisqBlock = JSON.parse(blockBuffer);
this.allBlocks.push(block);
readingBlock = false;
blockBuffer = '';
} catch (e) {
logger.debug(blockBuffer);
throw Error(`Unable to parse Bisq data dump at line ${lineCount}` + (e instanceof Error ? e.message : e));
}
}
if (readingBlock === true) {
blockBuffer += line;
}
++lineCount;
});
await events.once(rl, 'close');
this.allBlocks.reverse();
this.blocks = this.allBlocks.filter((block) => block.txs.length > 0);
const time = new Date().getTime() - start;
logger.debug('Bisq dump processed in ' + time + ' ms');
}
}

View File

@@ -1,7 +1,7 @@
import { Currencies, OffersData, TradesData, Depth, Currency, Interval, HighLowOpenClose,
Markets, Offers, Offer, BisqTrade, MarketVolume, Tickers, Ticker, SummarizedIntervals, SummarizedInterval } from './interfaces';
import * as datetime from 'locutus/php/datetime';
const strtotime = require('./strtotime');
class BisqMarketsApi {
private cryptoCurrencyData: Currency[] = [];
@@ -312,7 +312,7 @@ class BisqMarketsApi {
getTickerFromMarket(market: string): Ticker | null {
let ticker: Ticker;
const timestamp_from = datetime.strtotime('-24 hour');
const timestamp_from = strtotime('-24 hour');
const timestamp_to = new Date().getTime() / 1000;
const trades = this.getTradesByCriteria(market, timestamp_to, timestamp_from,
undefined, undefined, undefined, 'asc', Number.MAX_SAFE_INTEGER);
@@ -638,13 +638,13 @@ class BisqMarketsApi {
case 'half_day':
return (ts - (ts % (3600 * 12)));
case 'day':
return datetime.strtotime('midnight today', ts);
return strtotime('midnight today', ts);
case 'week':
return datetime.strtotime('midnight sunday last week', ts);
return strtotime('midnight sunday last week', ts);
case 'month':
return datetime.strtotime('midnight first day of this month', ts);
return strtotime('midnight first day of this month', ts);
case 'year':
return datetime.strtotime('midnight first day of january', ts);
return strtotime('midnight first day of january', ts);
default:
throw new Error('Unsupported interval: ' + interval);
}

View File

@@ -26,7 +26,13 @@ class Bisq {
constructor() {}
startBisqService(): void {
this.checkForBisqDataFolder();
try {
this.checkForBisqDataFolder();
} catch (e) {
logger.info('Retrying to start bisq service (markets) in 3 minutes');
setTimeout(this.startBisqService.bind(this), 180000);
return;
}
this.loadBisqDumpFile();
this.startBisqDirectoryWatcher();
}
@@ -34,7 +40,7 @@ class Bisq {
private checkForBisqDataFolder() {
if (!fs.existsSync(Bisq.MARKET_JSON_PATH + Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency)) {
logger.err(Bisq.MARKET_JSON_PATH + Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency + ` doesn't exist. Make sure Bisq is running and the config is correct before starting the server.`);
return process.exit(1);
throw new Error(`Cannot load BISQ ${Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency} file`);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@ import { IEsploraApi } from './esplora-api.interface';
export interface AbstractBitcoinApi {
$getRawMempool(): Promise<IEsploraApi.Transaction['txid'][]>;
$getRawTransaction(txId: string, skipConversion?: boolean, addPrevout?: boolean): Promise<IEsploraApi.Transaction>;
$getRawTransaction(txId: string, skipConversion?: boolean, addPrevout?: boolean, lazyPrevouts?: boolean): Promise<IEsploraApi.Transaction>;
$getBlockHeightTip(): Promise<number>;
$getTxIdsForBlock(hash: string): Promise<string[]>;
$getBlockHash(height: number): Promise<string>;
@@ -12,6 +12,7 @@ export interface AbstractBitcoinApi {
$getAddressTransactions(address: string, lastSeenTxId: string): Promise<IEsploraApi.Transaction[]>;
$getAddressPrefix(prefix: string): string[];
$sendRawTransaction(rawTransaction: string): Promise<string>;
$getOutspends(txId: string): Promise<IEsploraApi.Outspend[]>;
}
export interface BitcoinRpcCredentials {
host: string;

View File

@@ -4,6 +4,7 @@ export namespace IBitcoinApi {
size: number; // (numeric) Current tx count
bytes: number; // (numeric) Sum of all virtual transaction sizes as defined in BIP 141.
usage: number; // (numeric) Total memory usage for the mempool
total_fee: number; // (numeric) Total fees of transactions in the mempool
maxmempool: number; // (numeric) Maximum memory usage for the mempool
mempoolminfee: number; // (numeric) Minimum fee rate in BTC/kB for tx to be accepted.
minrelaytxfee: number; // (numeric) Current minimum relay fee for transactions

View File

@@ -14,33 +14,54 @@ class BitcoinApi implements AbstractBitcoinApi {
this.bitcoindClient = bitcoinClient;
}
$getRawTransaction(txId: string, skipConversion = false, addPrevout = false): Promise<IEsploraApi.Transaction> {
static convertBlock(block: IBitcoinApi.Block): IEsploraApi.Block {
return {
id: block.hash,
height: block.height,
version: block.version,
timestamp: block.time,
bits: parseInt(block.bits, 16),
nonce: block.nonce,
difficulty: block.difficulty,
merkle_root: block.merkleroot,
tx_count: block.nTx,
size: block.size,
weight: block.weight,
previousblockhash: block.previousblockhash,
};
}
$getRawTransaction(txId: string, skipConversion = false, addPrevout = false, lazyPrevouts = false): Promise<IEsploraApi.Transaction> {
// If the transaction is in the mempool we already converted and fetched the fee. Only prevouts are missing
const txInMempool = mempool.getMempool()[txId];
if (txInMempool && addPrevout) {
return this.$addPrevouts(txInMempool);
}
// Special case to fetch the Coinbase transaction
if (txId === '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b') {
return this.$returnCoinbaseTransaction();
}
return this.bitcoindClient.getRawTransaction(txId, true)
.then((transaction: IBitcoinApi.Transaction) => {
if (skipConversion) {
transaction.vout.forEach((vout) => {
vout.value = vout.value * 100000000;
vout.value = Math.round(vout.value * 100000000);
});
return transaction;
}
return this.$convertTransaction(transaction, addPrevout);
return this.$convertTransaction(transaction, addPrevout, lazyPrevouts);
})
.catch((e: Error) => {
if (e.message.startsWith('The genesis block coinbase')) {
return this.$returnCoinbaseTransaction();
}
throw e;
});
}
$getBlockHeightTip(): Promise<number> {
return this.bitcoindClient.getChainTips()
.then((result: IBitcoinApi.ChainTips[]) => result[0].height);
.then((result: IBitcoinApi.ChainTips[]) => {
return result.find(tip => tip.status === 'active')!.height;
});
}
$getTxIdsForBlock(hash: string): Promise<string[]> {
@@ -67,7 +88,7 @@ class BitcoinApi implements AbstractBitcoinApi {
}
return this.bitcoindClient.getBlock(hash)
.then((block: IBitcoinApi.Block) => this.convertBlock(block));
.then((block: IBitcoinApi.Block) => BitcoinApi.convertBlock(block));
}
$getAddress(address: string): Promise<IEsploraApi.Address> {
@@ -83,26 +104,49 @@ class BitcoinApi implements AbstractBitcoinApi {
}
$getAddressPrefix(prefix: string): string[] {
const found: string[] = [];
const found: { [address: string]: string } = {};
const mp = mempool.getMempool();
for (const tx in mp) {
for (const vout of mp[tx].vout) {
if (vout.scriptpubkey_address.indexOf(prefix) === 0) {
found.push(vout.scriptpubkey_address);
if (found.length >= 10) {
return found;
found[vout.scriptpubkey_address] = '';
if (Object.keys(found).length >= 10) {
return Object.keys(found);
}
}
}
}
return found;
return Object.keys(found);
}
$sendRawTransaction(rawTransaction: string): Promise<string> {
return this.bitcoindClient.sendRawTransaction(rawTransaction);
}
protected async $convertTransaction(transaction: IBitcoinApi.Transaction, addPrevout: boolean): Promise<IEsploraApi.Transaction> {
async $getOutspends(txId: string): Promise<IEsploraApi.Outspend[]> {
const outSpends: IEsploraApi.Outspend[] = [];
const tx = await this.$getRawTransaction(txId, true, false);
for (let i = 0; i < tx.vout.length; i++) {
if (tx.status && tx.status.block_height === 0) {
outSpends.push({
spent: false
});
} else {
const txOut = await this.bitcoindClient.getTxOut(txId, i);
outSpends.push({
spent: txOut === null,
});
}
}
return outSpends;
}
$getEstimatedHashrate(blockHeight: number): Promise<number> {
// 120 is the default block span in Core
return this.bitcoindClient.getNetworkHashPs(120, blockHeight);
}
protected async $convertTransaction(transaction: IBitcoinApi.Transaction, addPrevout: boolean, lazyPrevouts = false): Promise<IEsploraApi.Transaction> {
let esploraTransaction: IEsploraApi.Transaction = {
txid: transaction.txid,
version: transaction.version,
@@ -117,11 +161,11 @@ class BitcoinApi implements AbstractBitcoinApi {
esploraTransaction.vout = transaction.vout.map((vout) => {
return {
value: vout.value * 100000000,
value: Math.round(vout.value * 100000000),
scriptpubkey: vout.scriptPubKey.hex,
scriptpubkey_address: vout.scriptPubKey && vout.scriptPubKey.address ? vout.scriptPubKey.address
: vout.scriptPubKey.addresses ? vout.scriptPubKey.addresses[0] : '',
scriptpubkey_asm: vout.scriptPubKey.asm ? this.convertScriptSigAsm(vout.scriptPubKey.asm) : '',
scriptpubkey_asm: vout.scriptPubKey.asm ? this.convertScriptSigAsm(vout.scriptPubKey.hex) : '',
scriptpubkey_type: this.translateScriptPubKeyType(vout.scriptPubKey.type),
};
});
@@ -131,7 +175,7 @@ class BitcoinApi implements AbstractBitcoinApi {
is_coinbase: !!vin.coinbase,
prevout: null,
scriptsig: vin.scriptSig && vin.scriptSig.hex || vin.coinbase || '',
scriptsig_asm: vin.scriptSig && this.convertScriptSigAsm(vin.scriptSig.asm) || '',
scriptsig_asm: vin.scriptSig && this.convertScriptSigAsm(vin.scriptSig.hex) || '',
sequence: vin.sequence,
txid: vin.txid || '',
vout: vin.vout || 0,
@@ -148,35 +192,15 @@ class BitcoinApi implements AbstractBitcoinApi {
};
}
if (transaction.confirmations) {
esploraTransaction = await this.$calculateFeeFromInputs(esploraTransaction, addPrevout);
} else {
if (addPrevout) {
esploraTransaction = await this.$calculateFeeFromInputs(esploraTransaction, false, lazyPrevouts);
} else if (!transaction.confirmations) {
esploraTransaction = await this.$appendMempoolFeeData(esploraTransaction);
if (addPrevout) {
esploraTransaction = await this.$calculateFeeFromInputs(esploraTransaction, addPrevout);
}
}
return esploraTransaction;
}
private convertBlock(block: IBitcoinApi.Block): IEsploraApi.Block {
return {
id: block.hash,
height: block.height,
version: block.version,
timestamp: block.time,
bits: parseInt(block.bits, 16),
nonce: block.nonce,
difficulty: block.difficulty,
merkle_root: block.merkleroot,
tx_count: block.nTx,
size: block.size,
weight: block.weight,
previousblockhash: block.previousblockhash,
};
}
private translateScriptPubKeyType(outputType: string): string {
const map = {
'pubkey': 'p2pk',
@@ -186,13 +210,14 @@ class BitcoinApi implements AbstractBitcoinApi {
'witness_v0_scripthash': 'v0_p2wsh',
'witness_v1_taproot': 'v1_p2tr',
'nonstandard': 'nonstandard',
'multisig': 'multisig',
'nulldata': 'op_return'
};
if (map[outputType]) {
return map[outputType];
} else {
return '';
return 'unknown';
}
}
@@ -209,7 +234,7 @@ class BitcoinApi implements AbstractBitcoinApi {
} else {
mempoolEntry = await this.$getMempoolEntry(transaction.txid);
}
transaction.fee = mempoolEntry.fees.base * 100000000;
transaction.fee = Math.round(mempoolEntry.fees.base * 100000000);
return transaction;
}
@@ -218,7 +243,7 @@ class BitcoinApi implements AbstractBitcoinApi {
if (vin.prevout) {
continue;
}
const innerTx = await this.$getRawTransaction(vin.txid, false);
const innerTx = await this.$getRawTransaction(vin.txid, false, false);
vin.prevout = innerTx.vout[vin.vout];
this.addInnerScriptsToVin(vin);
}
@@ -226,12 +251,14 @@ class BitcoinApi implements AbstractBitcoinApi {
}
protected $returnCoinbaseTransaction(): Promise<IEsploraApi.Transaction> {
return this.bitcoindClient.getBlock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', 2)
.then((block: IBitcoinApi.Block) => {
return this.$convertTransaction(Object.assign(block.tx[0], {
confirmations: blocks.getCurrentBlockHeight() + 1,
blocktime: 1231006505 }), false);
});
return this.bitcoindClient.getBlockHash(0).then((hash: string) =>
this.bitcoindClient.getBlock(hash, 2)
.then((block: IBitcoinApi.Block) => {
return this.$convertTransaction(Object.assign(block.tx[0], {
confirmations: blocks.getCurrentBlockHeight() + 1,
blocktime: block.time }), false);
})
);
}
private $getMempoolEntry(txid: string): Promise<IBitcoinApi.MempoolEntry> {
@@ -242,42 +269,95 @@ class BitcoinApi implements AbstractBitcoinApi {
return this.bitcoindClient.getRawMemPool(true);
}
private async $calculateFeeFromInputs(transaction: IEsploraApi.Transaction, addPrevout: boolean): Promise<IEsploraApi.Transaction> {
private async $calculateFeeFromInputs(transaction: IEsploraApi.Transaction, addPrevout: boolean, lazyPrevouts: boolean): Promise<IEsploraApi.Transaction> {
if (transaction.vin[0].is_coinbase) {
transaction.fee = 0;
return transaction;
}
let totalIn = 0;
for (const vin of transaction.vin) {
const innerTx = await this.$getRawTransaction(vin.txid, !addPrevout);
if (addPrevout) {
vin.prevout = innerTx.vout[vin.vout];
this.addInnerScriptsToVin(vin);
for (let i = 0; i < transaction.vin.length; i++) {
if (lazyPrevouts && i > 12) {
transaction.vin[i].lazy = true;
continue;
}
totalIn += innerTx.vout[vin.vout].value;
const innerTx = await this.$getRawTransaction(transaction.vin[i].txid, false, false);
transaction.vin[i].prevout = innerTx.vout[transaction.vin[i].vout];
this.addInnerScriptsToVin(transaction.vin[i]);
totalIn += innerTx.vout[transaction.vin[i].vout].value;
}
if (lazyPrevouts && transaction.vin.length > 12) {
transaction.fee = -1;
} else {
const totalOut = transaction.vout.reduce((p, output) => p + output.value, 0);
transaction.fee = parseFloat((totalIn - totalOut).toFixed(8));
}
const totalOut = transaction.vout.reduce((p, output) => p + output.value, 0);
transaction.fee = parseFloat((totalIn - totalOut).toFixed(8));
return transaction;
}
private convertScriptSigAsm(str: string): string {
const a = str.split(' ');
private convertScriptSigAsm(hex: string): string {
const buf = Buffer.from(hex, 'hex');
const b: string[] = [];
a.forEach((chunk) => {
if (chunk.substr(0, 3) === 'OP_') {
chunk = chunk.replace(/^OP_(\d+)/, 'OP_PUSHNUM_$1');
chunk = chunk.replace('OP_CHECKSEQUENCEVERIFY', 'OP_CSV');
b.push(chunk);
} else {
chunk = chunk.replace('[ALL]', '01');
if (chunk === '0') {
b.push('OP_0');
let i = 0;
while (i < buf.length) {
const op = buf[i];
if (op >= 0x01 && op <= 0x4e) {
i++;
let push: number;
if (op === 0x4c) {
push = buf.readUInt8(i);
b.push('OP_PUSHDATA1');
i += 1;
} else if (op === 0x4d) {
push = buf.readUInt16LE(i);
b.push('OP_PUSHDATA2');
i += 2;
} else if (op === 0x4e) {
push = buf.readUInt32LE(i);
b.push('OP_PUSHDATA4');
i += 4;
} else {
b.push('OP_PUSHBYTES_' + Math.round(chunk.length / 2) + ' ' + chunk);
push = op;
b.push('OP_PUSHBYTES_' + push);
}
const data = buf.slice(i, i + push);
if (data.length !== push) {
break;
}
b.push(data.toString('hex'));
i += data.length;
} else {
if (op === 0x00) {
b.push('OP_0');
} else if (op === 0x4f) {
b.push('OP_PUSHNUM_NEG1');
} else if (op === 0xb1) {
b.push('OP_CLTV');
} else if (op === 0xb2) {
b.push('OP_CSV');
} else if (op === 0xba) {
b.push('OP_CHECKSIGADD');
} else {
const opcode = bitcoinjs.script.toASM([ op ]);
if (opcode && op < 0xfd) {
if (/^OP_(\d+)$/.test(opcode)) {
b.push(opcode.replace(/^OP_(\d+)$/, 'OP_PUSHNUM_$1'));
} else {
b.push(opcode);
}
} else {
b.push('OP_RETURN_' + op);
}
}
i += 1;
}
});
}
return b.join(' ');
}
@@ -288,21 +368,21 @@ class BitcoinApi implements AbstractBitcoinApi {
if (vin.prevout.scriptpubkey_type === 'p2sh') {
const redeemScript = vin.scriptsig_asm.split(' ').reverse()[0];
vin.inner_redeemscript_asm = this.convertScriptSigAsm(bitcoinjs.script.toASM(Buffer.from(redeemScript, 'hex')));
vin.inner_redeemscript_asm = this.convertScriptSigAsm(redeemScript);
if (vin.witness && vin.witness.length > 2) {
const witnessScript = vin.witness[vin.witness.length - 1];
vin.inner_witnessscript_asm = this.convertScriptSigAsm(bitcoinjs.script.toASM(Buffer.from(witnessScript, 'hex')));
vin.inner_witnessscript_asm = this.convertScriptSigAsm(witnessScript);
}
}
if (vin.prevout.scriptpubkey_type === 'v0_p2wsh' && vin.witness) {
const witnessScript = vin.witness[vin.witness.length - 1];
vin.inner_witnessscript_asm = this.convertScriptSigAsm(bitcoinjs.script.toASM(Buffer.from(witnessScript, 'hex')));
vin.inner_witnessscript_asm = this.convertScriptSigAsm(witnessScript);
}
if (vin.prevout.scriptpubkey_type === 'v1_p2tr' && vin.witness && vin.witness.length > 1) {
const witnessScript = vin.witness[vin.witness.length - 2];
vin.inner_witnessscript_asm = this.convertScriptSigAsm(bitcoinjs.script.toASM(Buffer.from(witnessScript, 'hex')));
vin.inner_witnessscript_asm = this.convertScriptSigAsm(witnessScript);
}
}

View File

@@ -1,5 +1,5 @@
import config from '../../config';
import * as bitcoin from '@mempool/bitcoin';
const bitcoin = require('../../rpc-api/index');
import { BitcoinRpcCredentials } from './bitcoin-api-abstract-factory';
const nodeRpcCredentials: BitcoinRpcCredentials = {

View File

@@ -1,5 +1,5 @@
import config from '../../config';
import * as bitcoin from '@mempool/bitcoin';
const bitcoin = require('../../rpc-api/index');
import { BitcoinRpcCredentials } from './bitcoin-api-abstract-factory';
const nodeRpcCredentials: BitcoinRpcCredentials = {

View File

@@ -33,6 +33,8 @@ export namespace IEsploraApi {
// Elements
is_pegin?: boolean;
issuance?: Issuance;
// Custom
lazy?: boolean;
}
interface Issuance {
@@ -113,9 +115,9 @@ export namespace IEsploraApi {
export interface Outspend {
spent: boolean;
txid: string;
vin: number;
status: Status;
txid?: string;
vin?: number;
status?: Status;
}
export interface Asset {

View File

@@ -60,6 +60,10 @@ class ElectrsApi implements AbstractBitcoinApi {
$sendRawTransaction(rawTransaction: string): Promise<string> {
throw new Error('Method not implemented.');
}
$getOutspends(): Promise<IEsploraApi.Outspend[]> {
throw new Error('Method not implemented.');
}
}
export default ElectrsApi;

View File

@@ -2,11 +2,23 @@ import config from '../config';
import bitcoinApi from './bitcoin/bitcoin-api-factory';
import logger from '../logger';
import memPool from './mempool';
import { BlockExtended, TransactionExtended } from '../mempool.interfaces';
import { BlockExtended, PoolTag, TransactionExtended, TransactionMinerInfo } from '../mempool.interfaces';
import { Common } from './common';
import diskCache from './disk-cache';
import transactionUtils from './transaction-utils';
import bitcoinClient from './bitcoin/bitcoin-client';
import { IEsploraApi } from './bitcoin/esplora-api.interface';
import poolsRepository from '../repositories/PoolsRepository';
import blocksRepository from '../repositories/BlocksRepository';
import loadingIndicators from './loading-indicators';
import BitcoinApi from './bitcoin/bitcoin-api';
import { prepareBlock } from '../utils/blocks-utils';
import BlocksRepository from '../repositories/BlocksRepository';
import HashratesRepository from '../repositories/HashratesRepository';
import indexer from '../indexer';
import fiatConversion from './fiat-conversion';
import RatesRepository from '../repositories/RatesRepository';
import poolsParser from './pools-parser';
class Blocks {
private blocks: BlockExtended[] = [];
@@ -30,11 +42,264 @@ class Blocks {
this.newBlockCallbacks.push(fn);
}
/**
* Return the list of transaction for a block
* @param blockHash
* @param blockHeight
* @param onlyCoinbase - Set to true if you only need the coinbase transaction
* @returns Promise<TransactionExtended[]>
*/
private async $getTransactionsExtended(
blockHash: string,
blockHeight: number,
onlyCoinbase: boolean,
quiet: boolean = false,
): Promise<TransactionExtended[]> {
const transactions: TransactionExtended[] = [];
const txIds: string[] = await bitcoinApi.$getTxIdsForBlock(blockHash);
const mempool = memPool.getMempool();
let transactionsFound = 0;
let transactionsFetched = 0;
for (let i = 0; i < txIds.length; i++) {
if (mempool[txIds[i]]) {
// We update blocks before the mempool (index.ts), therefore we can
// optimize here by directly fetching txs in the "outdated" mempool
transactions.push(mempool[txIds[i]]);
transactionsFound++;
} else if (config.MEMPOOL.BACKEND === 'esplora' || !memPool.hasPriority() || i === 0) {
// Otherwise we fetch the tx data through backend services (esplora, electrum, core rpc...)
if (!quiet && (i % (Math.round((txIds.length) / 10)) === 0 || i + 1 === txIds.length)) { // Avoid log spam
logger.debug(`Indexing tx ${i + 1} of ${txIds.length} in block #${blockHeight}`);
}
try {
const tx = await transactionUtils.$getTransactionExtended(txIds[i]);
transactions.push(tx);
transactionsFetched++;
} catch (e) {
if (i === 0) {
const msg = `Cannot fetch coinbase tx ${txIds[i]}. Reason: ` + (e instanceof Error ? e.message : e);
logger.err(msg);
throw new Error(msg);
} else {
logger.err(`Cannot fetch tx ${txIds[i]}. Reason: ` + (e instanceof Error ? e.message : e));
}
}
}
if (onlyCoinbase === true) {
break; // Fetch the first transaction and exit
}
}
transactions.forEach((tx) => {
if (!tx.cpfpChecked) {
Common.setRelativesAndGetCpfpInfo(tx, mempool); // Child Pay For Parent
}
});
if (!quiet) {
logger.debug(`${transactionsFound} of ${txIds.length} found in mempool. ${transactionsFetched} fetched through backend service.`);
}
return transactions;
}
/**
* Return a block with additional data (reward, coinbase, fees...)
* @param block
* @param transactions
* @returns BlockExtended
*/
private async $getBlockExtended(block: IEsploraApi.Block, transactions: TransactionExtended[]): Promise<BlockExtended> {
const blockExtended: BlockExtended = Object.assign({ extras: {} }, block);
blockExtended.extras.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
blockExtended.extras.coinbaseTx = transactionUtils.stripCoinbaseTransaction(transactions[0]);
blockExtended.extras.coinbaseRaw = blockExtended.extras.coinbaseTx.vin[0].scriptsig;
if (block.height === 0) {
blockExtended.extras.medianFee = 0; // 50th percentiles
blockExtended.extras.feeRange = [0, 0, 0, 0, 0, 0, 0];
blockExtended.extras.totalFees = 0;
blockExtended.extras.avgFee = 0;
blockExtended.extras.avgFeeRate = 0;
} else {
const stats = await bitcoinClient.getBlockStats(block.id, [
'feerate_percentiles', 'minfeerate', 'maxfeerate', 'totalfee', 'avgfee', 'avgfeerate'
]);
blockExtended.extras.medianFee = stats.feerate_percentiles[2]; // 50th percentiles
blockExtended.extras.feeRange = [stats.minfeerate, stats.feerate_percentiles, stats.maxfeerate].flat();
blockExtended.extras.totalFees = stats.totalfee;
blockExtended.extras.avgFee = stats.avgfee;
blockExtended.extras.avgFeeRate = stats.avgfeerate;
}
if (['mainnet', 'testnet', 'signet', 'regtest'].includes(config.MEMPOOL.NETWORK)) {
let pool: PoolTag;
if (blockExtended.extras?.coinbaseTx !== undefined) {
pool = await this.$findBlockMiner(blockExtended.extras?.coinbaseTx);
} else {
if (config.DATABASE.ENABLED === true) {
pool = await poolsRepository.$getUnknownPool();
} else {
pool = poolsParser.unknownPool;
}
}
if (!pool) { // We should never have this situation in practise
logger.warn(`Cannot assign pool to block ${blockExtended.height} and 'unknown' pool does not exist. ` +
`Check your "pools" table entries`);
return blockExtended;
}
blockExtended.extras.pool = {
id: pool.id,
name: pool.name,
slug: pool.slug,
};
}
return blockExtended;
}
/**
* Try to find which miner found the block
* @param txMinerInfo
* @returns
*/
private async $findBlockMiner(txMinerInfo: TransactionMinerInfo | undefined): Promise<PoolTag> {
if (txMinerInfo === undefined || txMinerInfo.vout.length < 1) {
if (config.DATABASE.ENABLED === true) {
return await poolsRepository.$getUnknownPool();
} else {
return poolsParser.unknownPool;
}
}
const asciiScriptSig = transactionUtils.hex2ascii(txMinerInfo.vin[0].scriptsig);
const address = txMinerInfo.vout[0].scriptpubkey_address;
let pools: PoolTag[] = [];
if (config.DATABASE.ENABLED === true) {
pools = await poolsRepository.$getPools();
} else {
pools = poolsParser.miningPools;
}
for (let i = 0; i < pools.length; ++i) {
if (address !== undefined) {
const addresses: string[] = JSON.parse(pools[i].addresses);
if (addresses.indexOf(address) !== -1) {
return pools[i];
}
}
const regexes: string[] = JSON.parse(pools[i].regexes);
for (let y = 0; y < regexes.length; ++y) {
const regex = new RegExp(regexes[y], 'i');
const match = asciiScriptSig.match(regex);
if (match !== null) {
return pools[i];
}
}
}
if (config.DATABASE.ENABLED === true) {
return await poolsRepository.$getUnknownPool();
} else {
return poolsParser.unknownPool;
}
}
/**
* [INDEXING] Index all blocks metadata for the mining dashboard
*/
public async $generateBlockDatabase() {
const blockchainInfo = await bitcoinClient.getBlockchainInfo();
if (blockchainInfo.blocks !== blockchainInfo.headers) { // Wait for node to sync
return;
}
try {
let currentBlockHeight = blockchainInfo.blocks;
let indexingBlockAmount = Math.min(config.MEMPOOL.INDEXING_BLOCKS_AMOUNT, blockchainInfo.blocks);
if (indexingBlockAmount <= -1) {
indexingBlockAmount = currentBlockHeight + 1;
}
const lastBlockToIndex = Math.max(0, currentBlockHeight - indexingBlockAmount + 1);
logger.debug(`Indexing blocks from #${currentBlockHeight} to #${lastBlockToIndex}`);
loadingIndicators.setProgress('block-indexing', 0);
const chunkSize = 10000;
let totalIndexed = await blocksRepository.$blockCountBetweenHeight(currentBlockHeight, lastBlockToIndex);
let indexedThisRun = 0;
let newlyIndexed = 0;
const startedAt = new Date().getTime() / 1000;
let timer = new Date().getTime() / 1000;
while (currentBlockHeight >= lastBlockToIndex) {
const endBlock = Math.max(0, lastBlockToIndex, currentBlockHeight - chunkSize + 1);
const missingBlockHeights: number[] = await blocksRepository.$getMissingBlocksBetweenHeights(
currentBlockHeight, endBlock);
if (missingBlockHeights.length <= 0) {
currentBlockHeight -= chunkSize;
continue;
}
logger.info(`Indexing ${missingBlockHeights.length} blocks from #${currentBlockHeight} to #${endBlock}`);
for (const blockHeight of missingBlockHeights) {
if (blockHeight < lastBlockToIndex) {
break;
}
++indexedThisRun;
++totalIndexed;
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - timer));
if (elapsedSeconds > 5 || blockHeight === lastBlockToIndex) {
const runningFor = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt));
const blockPerSeconds = Math.max(1, Math.round(indexedThisRun / elapsedSeconds));
const progress = Math.round(totalIndexed / indexingBlockAmount * 10000) / 100;
const timeLeft = Math.round((indexingBlockAmount - totalIndexed) / blockPerSeconds);
logger.debug(`Indexing block #${blockHeight} | ~${blockPerSeconds.toFixed(2)} blocks/sec | total: ${totalIndexed}/${indexingBlockAmount} (${progress}%) | elapsed: ${runningFor} seconds | left: ~${timeLeft} seconds`);
timer = new Date().getTime() / 1000;
indexedThisRun = 0;
loadingIndicators.setProgress('block-indexing', progress, false);
}
const blockHash = await bitcoinApi.$getBlockHash(blockHeight);
const block = BitcoinApi.convertBlock(await bitcoinClient.getBlock(blockHash));
const transactions = await this.$getTransactionsExtended(blockHash, block.height, true, true);
const blockExtended = await this.$getBlockExtended(block, transactions);
newlyIndexed++;
await blocksRepository.$saveBlockInDatabase(blockExtended);
}
currentBlockHeight -= chunkSize;
}
logger.info(`Indexed ${newlyIndexed} blocks`);
loadingIndicators.setProgress('block-indexing', 100);
} catch (e) {
logger.err('Block indexing failed. Trying again later. Reason: ' + (e instanceof Error ? e.message : e));
loadingIndicators.setProgress('block-indexing', 100);
return;
}
const chainValid = await BlocksRepository.$validateChain();
if (!chainValid) {
indexer.reindex();
}
}
public async $updateBlocks() {
let fastForwarded = false;
const blockHeightTip = await bitcoinApi.$getBlockHeightTip();
if (this.blocks.length === 0) {
this.currentBlockHeight = blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT;
this.currentBlockHeight = Math.max(blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT, -1);
} else {
this.currentBlockHeight = this.blocks[this.blocks.length - 1].height;
}
@@ -42,6 +307,9 @@ class Blocks {
if (blockHeightTip - this.currentBlockHeight > config.MEMPOOL.INITIAL_BLOCKS_AMOUNT * 2) {
logger.info(`${blockHeightTip - this.currentBlockHeight} blocks since tip. Fast forwarding to the ${config.MEMPOOL.INITIAL_BLOCKS_AMOUNT} recent blocks`);
this.currentBlockHeight = blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT;
fastForwarded = true;
logger.info(`Re-indexing skipped blocks and corresponding hashrates data`);
indexer.reindex(); // Make sure to index the skipped blocks #1619
}
if (!this.lastDifficultyAdjustmentTime) {
@@ -49,69 +317,53 @@ class Blocks {
if (blockchainInfo.blocks === blockchainInfo.headers) {
const heightDiff = blockHeightTip % 2016;
const blockHash = await bitcoinApi.$getBlockHash(blockHeightTip - heightDiff);
const block = await bitcoinApi.$getBlock(blockHash);
const block = BitcoinApi.convertBlock(await bitcoinClient.getBlock(blockHash));
this.lastDifficultyAdjustmentTime = block.timestamp;
this.currentDifficulty = block.difficulty;
const previousPeriodBlockHash = await bitcoinApi.$getBlockHash(blockHeightTip - heightDiff - 2016);
const previousPeriodBlock = await bitcoinApi.$getBlock(previousPeriodBlockHash);
this.previousDifficultyRetarget = (block.difficulty - previousPeriodBlock.difficulty) / previousPeriodBlock.difficulty * 100;
logger.debug(`Initial difficulty adjustment data set.`);
if (blockHeightTip >= 2016) {
const previousPeriodBlockHash = await bitcoinApi.$getBlockHash(blockHeightTip - heightDiff - 2016);
const previousPeriodBlock = await bitcoinApi.$getBlock(previousPeriodBlockHash);
this.previousDifficultyRetarget = (block.difficulty - previousPeriodBlock.difficulty) / previousPeriodBlock.difficulty * 100;
logger.debug(`Initial difficulty adjustment data set.`);
}
} else {
logger.debug(`Blockchain headers (${blockchainInfo.headers}) and blocks (${blockchainInfo.blocks}) not in sync. Waiting...`);
}
}
while (this.currentBlockHeight < blockHeightTip) {
if (this.currentBlockHeight === 0) {
if (this.currentBlockHeight < blockHeightTip - config.MEMPOOL.INITIAL_BLOCKS_AMOUNT) {
this.currentBlockHeight = blockHeightTip;
} else {
this.currentBlockHeight++;
logger.debug(`New block found (#${this.currentBlockHeight})!`);
}
const transactions: TransactionExtended[] = [];
const blockHash = await bitcoinApi.$getBlockHash(this.currentBlockHeight);
const block = await bitcoinApi.$getBlock(blockHash);
const block = BitcoinApi.convertBlock(await bitcoinClient.getBlock(blockHash));
const txIds: string[] = await bitcoinApi.$getTxIdsForBlock(blockHash);
const transactions = await this.$getTransactionsExtended(blockHash, block.height, false);
const blockExtended: BlockExtended = await this.$getBlockExtended(block, transactions);
const mempool = memPool.getMempool();
let transactionsFound = 0;
for (let i = 0; i < txIds.length; i++) {
if (mempool[txIds[i]]) {
transactions.push(mempool[txIds[i]]);
transactionsFound++;
} else if (config.MEMPOOL.BACKEND === 'esplora' || memPool.isInSync() || i === 0) {
logger.debug(`Fetching block tx ${i} of ${txIds.length}`);
try {
const tx = await transactionUtils.$getTransactionExtended(txIds[i]);
transactions.push(tx);
} catch (e) {
logger.debug('Error fetching block tx: ' + (e instanceof Error ? e.message : e));
if (i === 0) {
throw new Error('Failed to fetch Coinbase transaction: ' + txIds[i]);
if (Common.indexingEnabled()) {
if (!fastForwarded) {
const lastBlock = await blocksRepository.$getBlockByHeight(blockExtended.height - 1);
if (lastBlock !== null && blockExtended.previousblockhash !== lastBlock['hash']) {
logger.warn(`Chain divergence detected at block ${lastBlock['height']}, re-indexing most recent data`);
// We assume there won't be a reorg with more than 10 block depth
await BlocksRepository.$deleteBlocksFrom(lastBlock['height'] - 10);
await HashratesRepository.$deleteLastEntries();
for (let i = 10; i >= 0; --i) {
await this.$indexBlock(lastBlock['height'] - i);
}
}
await blocksRepository.$saveBlockInDatabase(blockExtended);
}
}
transactions.forEach((tx) => {
if (!tx.cpfpChecked) {
Common.setRelativesAndGetCpfpInfo(tx, mempool);
}
});
logger.debug(`${transactionsFound} of ${txIds.length} found in mempool. ${txIds.length - transactionsFound} not found.`);
const blockExtended: BlockExtended = Object.assign({}, block);
blockExtended.reward = transactions[0].vout.reduce((acc, curr) => acc + curr.value, 0);
blockExtended.coinbaseTx = transactionUtils.stripCoinbaseTransaction(transactions[0]);
transactions.shift();
transactions.sort((a, b) => b.effectiveFeePerVsize - a.effectiveFeePerVsize);
blockExtended.medianFee = transactions.length > 0 ? Common.median(transactions.map((tx) => tx.effectiveFeePerVsize)) : 0;
blockExtended.feeRange = transactions.length > 0 ? Common.getFeesInRange(transactions, 8) : [0, 0];
if (fiatConversion.ratesInitialized === true && config.DATABASE.ENABLED === true) {
await RatesRepository.$saveRate(blockExtended.height, fiatConversion.getConversionRates());
}
if (block.height % 2016 === 0) {
this.previousDifficultyRetarget = (block.difficulty - this.currentDifficulty) / this.currentDifficulty * 100;
@@ -127,12 +379,111 @@ class Blocks {
if (this.newBlockCallbacks.length) {
this.newBlockCallbacks.forEach((cb) => cb(blockExtended, txIds, transactions));
}
if (memPool.isInSync()) {
if (!memPool.hasPriority()) {
diskCache.$saveCacheToDisk();
}
}
}
/**
* Index a block if it's missing from the database. Returns the block after indexing
*/
public async $indexBlock(height: number): Promise<BlockExtended> {
const dbBlock = await blocksRepository.$getBlockByHeight(height);
if (dbBlock != null) {
return prepareBlock(dbBlock);
}
const blockHash = await bitcoinApi.$getBlockHash(height);
const block = BitcoinApi.convertBlock(await bitcoinClient.getBlock(blockHash));
const transactions = await this.$getTransactionsExtended(blockHash, block.height, true);
const blockExtended = await this.$getBlockExtended(block, transactions);
await blocksRepository.$saveBlockInDatabase(blockExtended);
return prepareBlock(blockExtended);
}
/**
* Index a block by hash if it's missing from the database. Returns the block after indexing
*/
public async $getBlock(hash: string): Promise<BlockExtended | IEsploraApi.Block> {
// Check the memory cache
const blockByHash = this.getBlocks().find((b) => b.id === hash);
if (blockByHash) {
return blockByHash;
}
// Block has already been indexed
if (Common.indexingEnabled()) {
const dbBlock = await blocksRepository.$getBlockByHash(hash);
if (dbBlock != null) {
return prepareBlock(dbBlock);
}
}
const block = await bitcoinApi.$getBlock(hash);
// Not Bitcoin network, return the block as it
if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) {
return block;
}
// Bitcoin network, add our custom data on top
const transactions = await this.$getTransactionsExtended(hash, block.height, true);
const blockExtended = await this.$getBlockExtended(block, transactions);
if (Common.indexingEnabled()) {
delete(blockExtended['coinbaseTx']);
await blocksRepository.$saveBlockInDatabase(blockExtended);
}
return blockExtended;
}
public async $getBlocks(fromHeight?: number, limit: number = 15): Promise<BlockExtended[]> {
try {
let currentHeight = fromHeight !== undefined ? fromHeight : this.getCurrentBlockHeight();
const returnBlocks: BlockExtended[] = [];
if (currentHeight < 0) {
return returnBlocks;
}
if (currentHeight === 0 && Common.indexingEnabled()) {
currentHeight = await blocksRepository.$mostRecentBlockHeight();
}
// Check if block height exist in local cache to skip the hash lookup
const blockByHeight = this.getBlocks().find((b) => b.height === currentHeight);
let startFromHash: string | null = null;
if (blockByHeight) {
startFromHash = blockByHeight.id;
} else if (!Common.indexingEnabled()) {
startFromHash = await bitcoinApi.$getBlockHash(currentHeight);
}
let nextHash = startFromHash;
for (let i = 0; i < limit && currentHeight >= 0; i++) {
let block = this.getBlocks().find((b) => b.height === currentHeight);
if (block) {
returnBlocks.push(block);
} else if (Common.indexingEnabled()) {
block = await this.$indexBlock(currentHeight);
returnBlocks.push(block);
} else if (nextHash != null) {
block = prepareBlock(await bitcoinApi.$getBlock(nextHash));
nextHash = block.previousblockhash;
returnBlocks.push(block);
}
currentHeight--;
}
return returnBlocks;
} catch (e) {
throw e;
}
}
public getLastDifficultyAdjustmentTime(): number {
return this.lastDifficultyAdjustmentTime;
}

View File

@@ -1,7 +1,14 @@
import { CpfpInfo, TransactionExtended, TransactionStripped } from '../mempool.interfaces';
import config from '../config';
export class Common {
static nativeAssetId = '6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
static nativeAssetId = config.MEMPOOL.NETWORK === 'liquidtestnet' ?
'144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49'
: '6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
static _isLiquid = config.MEMPOOL.NETWORK === 'liquid' || config.MEMPOOL.NETWORK === 'liquidtestnet';
static isLiquid(): boolean {
return this._isLiquid;
}
static median(numbers: number[]) {
let medianNr = 0;
@@ -70,7 +77,7 @@ export class Common {
};
}
static sleep(ms: number): Promise<void> {
static sleep$(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
@@ -107,7 +114,7 @@ export class Common {
totalFees += tx.bestDescendant.fee;
}
tx.effectiveFeePerVsize = Math.max(config.MEMPOOL.NETWORK === 'liquid' ? 0.1 : 1, totalFees / (totalWeight / 4));
tx.effectiveFeePerVsize = Math.max(Common.isLiquid() ? 0.1 : 1, totalFees / (totalWeight / 4));
tx.cpfpChecked = true;
return {
@@ -147,4 +154,27 @@ export class Common {
});
return parents;
}
static getSqlInterval(interval: string | null): string | null {
switch (interval) {
case '24h': return '1 DAY';
case '3d': return '3 DAY';
case '1w': return '1 WEEK';
case '1m': return '1 MONTH';
case '3m': return '3 MONTH';
case '6m': return '6 MONTH';
case '1y': return '1 YEAR';
case '2y': return '2 YEAR';
case '3y': return '3 YEAR';
default: return null;
}
}
static indexingEnabled(): boolean {
return (
['mainnet', 'testnet', 'signet', 'regtest'].includes(config.MEMPOOL.NETWORK) &&
config.DATABASE.ENABLED === true &&
config.MEMPOOL.INDEXING_BLOCKS_AMOUNT !== 0
);
}
}

View File

@@ -0,0 +1,503 @@
import config from '../config';
import DB from '../database';
import logger from '../logger';
import { Common } from './common';
class DatabaseMigration {
private static currentVersion = 19;
private queryTimeout = 120000;
private statisticsAddedIndexed = false;
constructor() { }
/**
* Entry point
*/
public async $initializeOrMigrateDatabase(): Promise<void> {
logger.debug('MIGRATIONS: Running migrations');
await this.$printDatabaseVersion();
// First of all, if the `state` database does not exist, create it so we can track migration version
if (!await this.$checkIfTableExists('state')) {
logger.debug('MIGRATIONS: `state` table does not exist. Creating it.');
try {
await this.$createMigrationStateTable();
} catch (e) {
logger.err('MIGRATIONS: Unable to create `state` table, aborting in 10 seconds. ' + e);
await Common.sleep$(10000);
process.exit(-1);
}
logger.debug('MIGRATIONS: `state` table initialized.');
}
let databaseSchemaVersion = 0;
try {
databaseSchemaVersion = await this.$getSchemaVersionFromDatabase();
} catch (e) {
logger.err('MIGRATIONS: Unable to get current database migration version, aborting in 10 seconds. ' + e);
await Common.sleep$(10000);
process.exit(-1);
}
logger.debug('MIGRATIONS: Current state.schema_version ' + databaseSchemaVersion);
logger.debug('MIGRATIONS: Latest DatabaseMigration.version is ' + DatabaseMigration.currentVersion);
if (databaseSchemaVersion >= DatabaseMigration.currentVersion) {
logger.debug('MIGRATIONS: Nothing to do.');
return;
}
// Now, create missing tables. Those queries cannot be wrapped into a transaction unfortunately
try {
await this.$createMissingTablesAndIndexes(databaseSchemaVersion);
} catch (e) {
logger.err('MIGRATIONS: Unable to create required tables, aborting in 10 seconds. ' + e);
await Common.sleep$(10000);
process.exit(-1);
}
if (DatabaseMigration.currentVersion > databaseSchemaVersion) {
logger.notice('MIGRATIONS: Upgrading database schema');
try {
await this.$migrateTableSchemaFromVersion(databaseSchemaVersion);
logger.notice(`MIGRATIONS: OK. Database schema have been migrated from version ${databaseSchemaVersion} to ${DatabaseMigration.currentVersion} (latest version)`);
} catch (e) {
logger.err('MIGRATIONS: Unable to migrate database, aborting. ' + e);
}
}
return;
}
/**
* Create all missing tables
*/
private async $createMissingTablesAndIndexes(databaseSchemaVersion: number) {
await this.$setStatisticsAddedIndexedFlag(databaseSchemaVersion);
const isBitcoin = ['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK);
try {
await this.$executeQuery(this.getCreateElementsTableQuery(), await this.$checkIfTableExists('elements_pegs'));
await this.$executeQuery(this.getCreateStatisticsQuery(), await this.$checkIfTableExists('statistics'));
if (databaseSchemaVersion < 2 && this.statisticsAddedIndexed === false) {
await this.$executeQuery(`CREATE INDEX added ON statistics (added);`);
}
if (databaseSchemaVersion < 3) {
await this.$executeQuery(this.getCreatePoolsTableQuery(), await this.$checkIfTableExists('pools'));
}
if (databaseSchemaVersion < 4) {
await this.$executeQuery('DROP table IF EXISTS blocks;');
await this.$executeQuery(this.getCreateBlocksTableQuery(), await this.$checkIfTableExists('blocks'));
}
if (databaseSchemaVersion < 5 && isBitcoin === true) {
logger.warn(`'blocks' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE blocks;'); // Need to re-index
await this.$executeQuery('ALTER TABLE blocks ADD `reward` double unsigned NOT NULL DEFAULT "0"');
}
if (databaseSchemaVersion < 6 && isBitcoin === true) {
logger.warn(`'blocks' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE blocks;'); // Need to re-index
// Cleanup original blocks fields type
await this.$executeQuery('ALTER TABLE blocks MODIFY `height` integer unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `tx_count` smallint unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `size` integer unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `weight` integer unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `difficulty` double NOT NULL DEFAULT "0"');
// We also fix the pools.id type so we need to drop/re-create the foreign key
await this.$executeQuery('ALTER TABLE blocks DROP FOREIGN KEY IF EXISTS `blocks_ibfk_1`');
await this.$executeQuery('ALTER TABLE pools MODIFY `id` smallint unsigned AUTO_INCREMENT');
await this.$executeQuery('ALTER TABLE blocks MODIFY `pool_id` smallint unsigned NULL');
await this.$executeQuery('ALTER TABLE blocks ADD FOREIGN KEY (`pool_id`) REFERENCES `pools` (`id`)');
// Add new block indexing fields
await this.$executeQuery('ALTER TABLE blocks ADD `version` integer unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks ADD `bits` integer unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks ADD `nonce` bigint unsigned NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks ADD `merkle_root` varchar(65) NOT NULL DEFAULT ""');
await this.$executeQuery('ALTER TABLE blocks ADD `previous_block_hash` varchar(65) NULL');
}
if (databaseSchemaVersion < 7 && isBitcoin === true) {
await this.$executeQuery('DROP table IF EXISTS hashrates;');
await this.$executeQuery(this.getCreateDailyStatsTableQuery(), await this.$checkIfTableExists('hashrates'));
}
if (databaseSchemaVersion < 8 && isBitcoin === true) {
logger.warn(`'hashrates' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE hashrates;'); // Need to re-index
await this.$executeQuery('ALTER TABLE `hashrates` DROP INDEX `PRIMARY`');
await this.$executeQuery('ALTER TABLE `hashrates` ADD `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
await this.$executeQuery('ALTER TABLE `hashrates` ADD `share` float NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE `hashrates` ADD `type` enum("daily", "weekly") DEFAULT "daily"');
}
if (databaseSchemaVersion < 9 && isBitcoin === true) {
logger.warn(`'hashrates' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE hashrates;'); // Need to re-index
await this.$executeQuery('ALTER TABLE `state` CHANGE `name` `name` varchar(100)');
await this.$executeQuery('ALTER TABLE `hashrates` ADD UNIQUE `hashrate_timestamp_pool_id` (`hashrate_timestamp`, `pool_id`)');
}
if (databaseSchemaVersion < 10 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `blocks` ADD INDEX `blockTimestamp` (`blockTimestamp`)');
}
if (databaseSchemaVersion < 11 && isBitcoin === true) {
logger.warn(`'blocks' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE blocks;'); // Need to re-index
await this.$executeQuery(`ALTER TABLE blocks
ADD avg_fee INT UNSIGNED NULL,
ADD avg_fee_rate INT UNSIGNED NULL
`);
await this.$executeQuery('ALTER TABLE blocks MODIFY `reward` BIGINT UNSIGNED NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `median_fee` INT UNSIGNED NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `fees` INT UNSIGNED NOT NULL DEFAULT "0"');
}
if (databaseSchemaVersion < 12 && isBitcoin === true) {
// No need to re-index because the new data type can contain larger values
await this.$executeQuery('ALTER TABLE blocks MODIFY `fees` BIGINT UNSIGNED NOT NULL DEFAULT "0"');
}
if (databaseSchemaVersion < 13 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE blocks MODIFY `difficulty` DOUBLE UNSIGNED NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `median_fee` BIGINT UNSIGNED NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `avg_fee` BIGINT UNSIGNED NOT NULL DEFAULT "0"');
await this.$executeQuery('ALTER TABLE blocks MODIFY `avg_fee_rate` BIGINT UNSIGNED NOT NULL DEFAULT "0"');
}
if (databaseSchemaVersion < 14 && isBitcoin === true) {
logger.warn(`'hashrates' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE hashrates;'); // Need to re-index
await this.$executeQuery('ALTER TABLE `hashrates` DROP FOREIGN KEY `hashrates_ibfk_1`');
await this.$executeQuery('ALTER TABLE `hashrates` MODIFY `pool_id` SMALLINT UNSIGNED NOT NULL DEFAULT "0"');
}
if (databaseSchemaVersion < 16 && isBitcoin === true) {
logger.warn(`'hashrates' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery('TRUNCATE hashrates;'); // Need to re-index because we changed timestamps
}
if (databaseSchemaVersion < 17 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `pools` ADD `slug` CHAR(50) NULL');
}
if (databaseSchemaVersion < 18 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `blocks` ADD INDEX `hash` (`hash`);');
}
if (databaseSchemaVersion < 19) {
await this.$executeQuery(this.getCreateRatesTableQuery(), await this.$checkIfTableExists('rates'));
}
} catch (e) {
throw e;
}
}
/**
* Special case here for the `statistics` table - It appeared that somehow some dbs already had the `added` field indexed
* while it does not appear in previous schemas. The mariadb command "CREATE INDEX IF NOT EXISTS" is not supported on
* older mariadb version. Therefore we set a flag here in order to know if the index needs to be created or not before
* running the migration process
*/
private async $setStatisticsAddedIndexedFlag(databaseSchemaVersion: number) {
if (databaseSchemaVersion >= 2) {
this.statisticsAddedIndexed = true;
return;
}
try {
// We don't use "CREATE INDEX IF NOT EXISTS" because it is not supported on old mariadb version 5.X
const query = `SELECT COUNT(1) hasIndex FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema=DATABASE() AND table_name='statistics' AND index_name='added';`;
const [rows] = await this.$executeQuery(query, true);
if (rows[0].hasIndex === 0) {
logger.debug('MIGRATIONS: `statistics.added` is not indexed');
this.statisticsAddedIndexed = false;
} else if (rows[0].hasIndex === 1) {
logger.debug('MIGRATIONS: `statistics.added` is already indexed');
this.statisticsAddedIndexed = true;
}
} catch (e) {
// Should really never happen but just in case it fails, we just don't execute
// any query related to this indexing so it won't fail if the index actually already exists
logger.err('MIGRATIONS: Unable to check if `statistics.added` INDEX exist or not.');
this.statisticsAddedIndexed = true;
}
}
/**
* Small query execution wrapper to log all executed queries
*/
private async $executeQuery(query: string, silent: boolean = false): Promise<any> {
if (!silent) {
logger.debug('MIGRATIONS: Execute query:\n' + query);
}
return DB.query({ sql: query, timeout: this.queryTimeout });
}
/**
* Check if 'table' exists in the database
*/
private async $checkIfTableExists(table: string): Promise<boolean> {
const query = `SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${config.DATABASE.DATABASE}' AND TABLE_NAME = '${table}'`;
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return rows[0]['COUNT(*)'] === 1;
}
/**
* Get current database version
*/
private async $getSchemaVersionFromDatabase(): Promise<number> {
const query = `SELECT number FROM state WHERE name = 'schema_version';`;
const [rows] = await this.$executeQuery(query, true);
return rows[0]['number'];
}
/**
* Create the `state` table
*/
private async $createMigrationStateTable(): Promise<void> {
try {
const query = `CREATE TABLE IF NOT EXISTS state (
name varchar(25) NOT NULL,
number int(11) NULL,
string varchar(100) NULL,
CONSTRAINT name_unique UNIQUE (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
await this.$executeQuery(query);
// Set initial values
await this.$executeQuery(`INSERT INTO state VALUES('schema_version', 0, NULL);`);
await this.$executeQuery(`INSERT INTO state VALUES('last_elements_block', 0, NULL);`);
} catch (e) {
throw e;
}
}
/**
* We actually execute the migrations queries here
*/
private async $migrateTableSchemaFromVersion(version: number): Promise<void> {
const transactionQueries: string[] = [];
for (const query of this.getMigrationQueriesFromVersion(version)) {
transactionQueries.push(query);
}
transactionQueries.push(this.getUpdateToLatestSchemaVersionQuery());
try {
await this.$executeQuery('START TRANSACTION;');
for (const query of transactionQueries) {
await this.$executeQuery(query);
}
await this.$executeQuery('COMMIT;');
} catch (e) {
await this.$executeQuery('ROLLBACK;');
throw e;
}
}
/**
* Generate migration queries based on schema version
*/
private getMigrationQueriesFromVersion(version: number): string[] {
const queries: string[] = [];
const isBitcoin = ['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK);
if (version < 1) {
if (config.MEMPOOL.NETWORK !== 'liquid' && config.MEMPOOL.NETWORK !== 'liquidtestnet') {
queries.push(this.getShiftStatisticsQuery());
}
}
if (version < 7 && isBitcoin === true) {
queries.push(`INSERT INTO state(name, number, string) VALUES ('last_hashrates_indexing', 0, NULL)`);
}
if (version < 9 && isBitcoin === true) {
queries.push(`INSERT INTO state(name, number, string) VALUES ('last_weekly_hashrates_indexing', 0, NULL)`);
}
return queries;
}
/**
* Save the schema version in the database
*/
private getUpdateToLatestSchemaVersionQuery(): string {
return `UPDATE state SET number = ${DatabaseMigration.currentVersion} WHERE name = 'schema_version';`;
}
/**
* Print current database version
*/
private async $printDatabaseVersion() {
try {
const [rows] = await this.$executeQuery('SELECT VERSION() as version;', true);
logger.debug(`MIGRATIONS: Database engine version '${rows[0].version}'`);
} catch (e) {
logger.debug(`MIGRATIONS: Could not fetch database engine version. ` + e);
}
}
// Couple of wrappers to clean the main logic
private getShiftStatisticsQuery(): string {
return `UPDATE statistics SET
vsize_1 = vsize_1 + vsize_2, vsize_2 = vsize_3,
vsize_3 = vsize_4, vsize_4 = vsize_5,
vsize_5 = vsize_6, vsize_6 = vsize_8,
vsize_8 = vsize_10, vsize_10 = vsize_12,
vsize_12 = vsize_15, vsize_15 = vsize_20,
vsize_20 = vsize_30, vsize_30 = vsize_40,
vsize_40 = vsize_50, vsize_50 = vsize_60,
vsize_60 = vsize_70, vsize_70 = vsize_80,
vsize_80 = vsize_90, vsize_90 = vsize_100,
vsize_100 = vsize_125, vsize_125 = vsize_150,
vsize_150 = vsize_175, vsize_175 = vsize_200,
vsize_200 = vsize_250, vsize_250 = vsize_300,
vsize_300 = vsize_350, vsize_350 = vsize_400,
vsize_400 = vsize_500, vsize_500 = vsize_600,
vsize_600 = vsize_700, vsize_700 = vsize_800,
vsize_800 = vsize_900, vsize_900 = vsize_1000,
vsize_1000 = vsize_1200, vsize_1200 = vsize_1400,
vsize_1400 = vsize_1800, vsize_1800 = vsize_2000, vsize_2000 = 0;`;
}
private getCreateStatisticsQuery(): string {
return `CREATE TABLE IF NOT EXISTS statistics (
id int(11) NOT NULL AUTO_INCREMENT,
added datetime NOT NULL,
unconfirmed_transactions int(11) UNSIGNED NOT NULL,
tx_per_second float UNSIGNED NOT NULL,
vbytes_per_second int(10) UNSIGNED NOT NULL,
mempool_byte_weight int(10) UNSIGNED NOT NULL,
fee_data longtext NOT NULL,
total_fee double UNSIGNED NOT NULL,
vsize_1 int(11) NOT NULL,
vsize_2 int(11) NOT NULL,
vsize_3 int(11) NOT NULL,
vsize_4 int(11) NOT NULL,
vsize_5 int(11) NOT NULL,
vsize_6 int(11) NOT NULL,
vsize_8 int(11) NOT NULL,
vsize_10 int(11) NOT NULL,
vsize_12 int(11) NOT NULL,
vsize_15 int(11) NOT NULL,
vsize_20 int(11) NOT NULL,
vsize_30 int(11) NOT NULL,
vsize_40 int(11) NOT NULL,
vsize_50 int(11) NOT NULL,
vsize_60 int(11) NOT NULL,
vsize_70 int(11) NOT NULL,
vsize_80 int(11) NOT NULL,
vsize_90 int(11) NOT NULL,
vsize_100 int(11) NOT NULL,
vsize_125 int(11) NOT NULL,
vsize_150 int(11) NOT NULL,
vsize_175 int(11) NOT NULL,
vsize_200 int(11) NOT NULL,
vsize_250 int(11) NOT NULL,
vsize_300 int(11) NOT NULL,
vsize_350 int(11) NOT NULL,
vsize_400 int(11) NOT NULL,
vsize_500 int(11) NOT NULL,
vsize_600 int(11) NOT NULL,
vsize_700 int(11) NOT NULL,
vsize_800 int(11) NOT NULL,
vsize_900 int(11) NOT NULL,
vsize_1000 int(11) NOT NULL,
vsize_1200 int(11) NOT NULL,
vsize_1400 int(11) NOT NULL,
vsize_1600 int(11) NOT NULL,
vsize_1800 int(11) NOT NULL,
vsize_2000 int(11) NOT NULL,
CONSTRAINT PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
private getCreateElementsTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS elements_pegs (
block int(11) NOT NULL,
datetime int(11) NOT NULL,
amount bigint(20) NOT NULL,
txid varchar(65) NOT NULL,
txindex int(11) NOT NULL,
bitcoinaddress varchar(100) NOT NULL,
bitcointxid varchar(65) NOT NULL,
bitcoinindex int(11) NOT NULL,
final_tx int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
private getCreatePoolsTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS pools (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
link varchar(255) NOT NULL,
addresses text NOT NULL,
regexes text NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`;
}
private getCreateBlocksTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS blocks (
height int(11) unsigned NOT NULL,
hash varchar(65) NOT NULL,
blockTimestamp timestamp NOT NULL,
size int(11) unsigned NOT NULL,
weight int(11) unsigned NOT NULL,
tx_count int(11) unsigned NOT NULL,
coinbase_raw text,
difficulty bigint(20) unsigned NOT NULL,
pool_id int(11) DEFAULT -1,
fees double unsigned NOT NULL,
fee_span json NOT NULL,
median_fee double unsigned NOT NULL,
PRIMARY KEY (height),
INDEX (pool_id),
FOREIGN KEY (pool_id) REFERENCES pools (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
private getCreateDailyStatsTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS hashrates (
hashrate_timestamp timestamp NOT NULL,
avg_hashrate double unsigned DEFAULT '0',
pool_id smallint unsigned NULL,
PRIMARY KEY (hashrate_timestamp),
INDEX (pool_id),
FOREIGN KEY (pool_id) REFERENCES pools (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
private getCreateRatesTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS rates (
height int(10) unsigned NOT NULL,
bisq_rates JSON NOT NULL,
PRIMARY KEY (height)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
public async $truncateIndexedData(tables: string[]) {
const allowedTables = ['blocks', 'hashrates'];
try {
for (const table of tables) {
if (!allowedTables.includes(table)) {
logger.debug(`Table ${table} cannot to be re-indexed (not allowed)`);
continue;
}
await this.$executeQuery(`TRUNCATE ${table}`, true);
if (table === 'hashrates') {
await this.$executeQuery('UPDATE state set number = 0 where name = "last_hashrates_indexing"', true);
}
logger.notice(`Table ${table} has been truncated`);
}
} catch (e) {
logger.warn(`Unable to erase indexed data`);
}
}
}
export default new DatabaseMigration();

View File

@@ -0,0 +1,67 @@
import config from '../config';
import { IDifficultyAdjustment } from '../mempool.interfaces';
import blocks from './blocks';
class DifficultyAdjustmentApi {
constructor() { }
public getDifficultyAdjustment(): IDifficultyAdjustment {
const DATime = blocks.getLastDifficultyAdjustmentTime();
const previousRetarget = blocks.getPreviousDifficultyRetarget();
const blockHeight = blocks.getCurrentBlockHeight();
const blocksCache = blocks.getBlocks();
const latestBlock = blocksCache[blocksCache.length - 1];
const now = new Date().getTime() / 1000;
const diff = now - DATime;
const blocksInEpoch = blockHeight % 2016;
const progressPercent = (blocksInEpoch >= 0) ? blocksInEpoch / 2016 * 100 : 100;
const remainingBlocks = 2016 - blocksInEpoch;
const nextRetargetHeight = blockHeight + remainingBlocks;
let difficultyChange = 0;
if (remainingBlocks < 1870) {
if (blocksInEpoch > 0) {
difficultyChange = (600 / (diff / blocksInEpoch) - 1) * 100;
}
if (difficultyChange > 300) {
difficultyChange = 300;
}
if (difficultyChange < -75) {
difficultyChange = -75;
}
}
let timeAvgMins = blocksInEpoch && blocksInEpoch > 146 ? diff / blocksInEpoch / 60 : 10;
// Testnet difficulty is set to 1 after 20 minutes of no blocks,
// therefore the time between blocks will always be below 20 minutes (1200s).
let timeOffset = 0;
if (config.MEMPOOL.NETWORK === 'testnet') {
if (timeAvgMins > 20) {
timeAvgMins = 20;
}
if (now - latestBlock.timestamp + timeAvgMins * 60 > 1200) {
timeOffset = -Math.min(now - latestBlock.timestamp, 1200) * 1000;
}
}
const timeAvg = timeAvgMins * 60 * 1000 ;
const remainingTime = (remainingBlocks * timeAvg) + (now * 1000);
const estimatedRetargetDate = remainingTime + now;
return {
progressPercent,
difficultyChange,
estimatedRetargetDate,
remainingBlocks,
remainingTime,
previousRetarget,
nextRetargetHeight,
timeAvg,
timeOffset,
};
}
}
export default new DifficultyAdjustmentApi();

View File

@@ -9,6 +9,8 @@ import { TransactionExtended } from '../mempool.interfaces';
import { Common } from './common';
class DiskCache {
private cacheSchemaVersion = 1;
private static FILE_NAME = config.MEMPOOL.CACHE_DIR + '/cache.json';
private static FILE_NAMES = config.MEMPOOL.CACHE_DIR + '/cache{number}.json';
private static CHUNK_FILES = 25;
@@ -39,6 +41,7 @@ class DiskCache {
const chunkSize = Math.floor(mempoolArray.length / DiskCache.CHUNK_FILES);
await fsPromises.writeFile(DiskCache.FILE_NAME, JSON.stringify({
cacheSchemaVersion: this.cacheSchemaVersion,
blocks: blocks.getBlocks(),
mempool: {},
mempoolArray: mempoolArray.splice(0, chunkSize),
@@ -57,6 +60,13 @@ class DiskCache {
}
}
wipeCache() {
fs.unlinkSync(DiskCache.FILE_NAME);
for (let i = 1; i < DiskCache.CHUNK_FILES; i++) {
fs.unlinkSync(DiskCache.FILE_NAMES.replace('{number}', i.toString()));
}
}
loadMempoolCache() {
if (!fs.existsSync(DiskCache.FILE_NAME)) {
return;
@@ -67,6 +77,11 @@ class DiskCache {
if (cacheData) {
logger.info('Restoring mempool and blocks data from disk cache');
data = JSON.parse(cacheData);
if (data.cacheSchemaVersion === undefined || data.cacheSchemaVersion !== this.cacheSchemaVersion) {
logger.notice('Disk cache contains an outdated schema version. Clearing it and skipping the cache loading.');
return this.wipeCache();
}
if (data.mempoolArray) {
for (const tx of data.mempoolArray) {
data.mempool[tx.txid] = tx;
@@ -88,14 +103,14 @@ class DiskCache {
}
}
} catch (e) {
logger.debug('Error parsing ' + fileName + '. Skipping.');
logger.info('Error parsing ' + fileName + '. Skipping. Reason: ' + (e instanceof Error ? e.message : e));
}
}
memPool.setMempool(data.mempool);
blocks.setBlocks(data.blocks);
} catch (e) {
logger.warn('Failed to parse mempoool and blocks cache. Skipping.');
logger.warn('Failed to parse mempoool and blocks cache. Skipping. Reason: ' + (e instanceof Error ? e.message : e));
}
}
}

View File

@@ -1,12 +1,12 @@
import config from '../config';
import { MempoolBlock } from '../mempool.interfaces';
import { Common } from './common';
import mempool from './mempool';
import projectedBlocks from './mempool-blocks';
class FeeApi {
constructor() { }
defaultFee = config.MEMPOOL.NETWORK === 'liquid' ? 0.1 : 1;
defaultFee = Common.isLiquid() ? 0.1 : 1;
public getRecommendedFee() {
const pBlocks = projectedBlocks.getMempoolBlocks();
@@ -18,6 +18,7 @@ class FeeApi {
'fastestFee': this.defaultFee,
'halfHourFee': this.defaultFee,
'hourFee': this.defaultFee,
'economyFee': minimumFee,
'minimumFee': minimumFee,
};
}
@@ -30,6 +31,7 @@ class FeeApi {
'fastestFee': firstMedianFee,
'halfHourFee': secondMedianFee,
'hourFee': thirdMedianFee,
'economyFee': Math.min(2 * minimumFee, thirdMedianFee),
'minimumFee': minimumFee,
};
}

View File

@@ -1,22 +1,39 @@
import logger from '../logger';
import axios from 'axios';
import * as http from 'http';
import * as https from 'https';
import axios, { AxiosResponse } from 'axios';
import { IConversionRates } from '../mempool.interfaces';
import config from '../config';
import backendInfo from './backend-info';
import { SocksProxyAgent } from 'socks-proxy-agent';
class FiatConversion {
private conversionRates: IConversionRates = {
'USD': 0
};
private debasingFiatCurrencies = ['AED', 'AUD', 'BDT', 'BHD', 'BMD', 'BRL', 'CAD', 'CHF', 'CLP',
'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'KWD',
'LKR', 'MMK', 'MXN', 'MYR', 'NGN', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SAR', 'SEK',
'SGD', 'THB', 'TRY', 'TWD', 'UAH', 'USD', 'VND', 'ZAR'];
private conversionRates: IConversionRates = {};
private ratesChangedCallback: ((rates: IConversionRates) => void) | undefined;
public ratesInitialized = false; // If true, it means rates are ready for use
constructor() { }
constructor() {
for (const fiat of this.debasingFiatCurrencies) {
this.conversionRates[fiat] = 0;
}
}
public setProgressChangedCallback(fn: (rates: IConversionRates) => void) {
this.ratesChangedCallback = fn;
}
public startService() {
const fiatConversionUrl = (config.SOCKS5PROXY.ENABLED === true) && (config.SOCKS5PROXY.USE_ONION === true) ? config.PRICE_DATA_SERVER.TOR_URL : config.PRICE_DATA_SERVER.CLEARNET_URL;
logger.info('Starting currency rates service');
if (config.SOCKS5PROXY.ENABLED) {
logger.info(`Currency rates service will be queried over the Tor network using ${fiatConversionUrl}`);
} else {
logger.info(`Currency rates service will be queried over clearnet using ${config.PRICE_DATA_SERVER.CLEARNET_URL}`);
}
setInterval(this.updateCurrency.bind(this), 1000 * config.MEMPOOL.PRICE_FEED_UPDATE_INTERVAL);
this.updateCurrency();
}
@@ -26,17 +43,79 @@ class FiatConversion {
}
private async updateCurrency(): Promise<void> {
try {
const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices', { timeout: 10000 });
const usd = response.data.data.find((item: any) => item.currencyCode === 'USD');
this.conversionRates = {
'USD': usd.price,
type axiosOptions = {
headers: {
'User-Agent': string
};
if (this.ratesChangedCallback) {
this.ratesChangedCallback(this.conversionRates);
timeout: number;
httpAgent?: http.Agent;
httpsAgent?: https.Agent;
}
const setDelay = (secs: number = 1): Promise<void> => new Promise(resolve => setTimeout(() => resolve(), secs * 1000));
const fiatConversionUrl = (config.SOCKS5PROXY.ENABLED === true) && (config.SOCKS5PROXY.USE_ONION === true) ? config.PRICE_DATA_SERVER.TOR_URL : config.PRICE_DATA_SERVER.CLEARNET_URL;
const isHTTP = (new URL(fiatConversionUrl).protocol.split(':')[0] === 'http') ? true : false;
const axiosOptions: axiosOptions = {
headers: {
'User-Agent': (config.MEMPOOL.USER_AGENT === 'mempool') ? `mempool/v${backendInfo.getBackendInfo().version}` : `${config.MEMPOOL.USER_AGENT}`
},
timeout: config.SOCKS5PROXY.ENABLED ? 30000 : 10000
};
let retry = 0;
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
if (config.SOCKS5PROXY.ENABLED) {
let socksOptions: any = {
agentOptions: {
keepAlive: true,
},
hostname: config.SOCKS5PROXY.HOST,
port: config.SOCKS5PROXY.PORT
};
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
socksOptions.username = config.SOCKS5PROXY.USERNAME;
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
} else {
// Retry with different tor circuits https://stackoverflow.com/a/64960234
socksOptions.username = `circuit${retry}`;
}
// Handle proxy agent for onion addresses
if (isHTTP) {
axiosOptions.httpAgent = new SocksProxyAgent(socksOptions);
} else {
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
}
}
logger.debug('Querying currency rates service...');
const response: AxiosResponse = await axios.get(`${fiatConversionUrl}`, axiosOptions);
if (response.statusText === 'error' || !response.data) {
throw new Error(`Could not fetch data from ${fiatConversionUrl}, Error: ${response.status}`);
}
for (const rate of response.data.data) {
if (this.debasingFiatCurrencies.includes(rate.currencyCode) && rate.provider === 'Bisq-Aggregate') {
this.conversionRates[rate.currencyCode] = Math.round(100 * rate.price) / 100;
}
}
this.ratesInitialized = true;
logger.debug(`USD Conversion Rate: ${this.conversionRates.USD}`);
if (this.ratesChangedCallback) {
this.ratesChangedCallback(this.conversionRates);
}
break;
} catch (e) {
logger.err('Error updating fiat conversion rates: ' + (e instanceof Error ? e.message : e));
await setDelay(config.MEMPOOL.EXTERNAL_RETRY_INTERVAL);
retry++;
}
} catch (e) {
logger.err('Error updating fiat conversion rates: ' + (e instanceof Error ? e.message : e));
}
}
}

View File

@@ -2,7 +2,7 @@ import { IBitcoinApi } from '../bitcoin/bitcoin-api.interface';
import bitcoinClient from '../bitcoin/bitcoin-client';
import bitcoinSecondClient from '../bitcoin/bitcoin-second-client';
import { Common } from '../common';
import { DB } from '../../database';
import DB from '../../database';
import logger from '../../logger';
class ElementsParser {
@@ -18,12 +18,12 @@ class ElementsParser {
this.isRunning = true;
const result = await bitcoinClient.getChainTips();
const tip = result[0].height;
const latestBlock = await this.$getLatestBlockFromDatabase();
for (let height = latestBlock.block + 1; height <= tip; height++) {
const latestBlockHeight = await this.$getLatestBlockHeightFromDatabase();
for (let height = latestBlockHeight + 1; height <= tip; height++) {
const blockHash: IBitcoinApi.ChainTips = await bitcoinClient.getBlockHash(height);
const block: IBitcoinApi.Block = await bitcoinClient.getBlock(blockHash, 2);
await this.$parseBlock(block);
await this.$saveLatestBlockToDatabase(block.height, block.time, block.hash);
await this.$saveLatestBlockToDatabase(block.height);
}
this.isRunning = false;
} catch (e) {
@@ -33,10 +33,8 @@ class ElementsParser {
}
public async $getPegDataByMonth(): Promise<any> {
const connection = await DB.pool.getConnection();
const query = `SELECT SUM(amount) AS amount, DATE_FORMAT(FROM_UNIXTIME(datetime), '%Y-%m-01') AS date FROM elements_pegs GROUP BY DATE_FORMAT(FROM_UNIXTIME(datetime), '%Y%m')`;
const [rows] = await connection.query<any>(query);
connection.release();
const [rows] = await DB.query(query);
return rows;
}
@@ -79,7 +77,6 @@ class ElementsParser {
protected async $savePegToDatabase(height: number, blockTime: number, amount: number, txid: string,
txindex: number, bitcoinaddress: string, bitcointxid: string, bitcoinindex: number, final_tx: number): Promise<void> {
const connection = await DB.pool.getConnection();
const query = `INSERT INTO elements_pegs(
block, datetime, amount, txid, txindex, bitcoinaddress, bitcointxid, bitcoinindex, final_tx
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`;
@@ -87,24 +84,19 @@ class ElementsParser {
const params: (string | number)[] = [
height, blockTime, amount, txid, txindex, bitcoinaddress, bitcointxid, bitcoinindex, final_tx
];
await connection.query(query, params);
connection.release();
await DB.query(query, params);
logger.debug(`Saved L-BTC peg from block height #${height} with TXID ${txid}.`);
}
protected async $getLatestBlockFromDatabase(): Promise<any> {
const connection = await DB.pool.getConnection();
const query = `SELECT block, datetime, block_hash FROM last_elements_block`;
const [rows] = await connection.query<any>(query);
connection.release();
return rows[0];
protected async $getLatestBlockHeightFromDatabase(): Promise<number> {
const query = `SELECT number FROM state WHERE name = 'last_elements_block'`;
const [rows] = await DB.query(query);
return rows[0]['number'];
}
protected async $saveLatestBlockToDatabase(blockHeight: number, datetime: number, blockHash: string) {
const connection = await DB.pool.getConnection();
const query = `UPDATE last_elements_block SET block = ?, datetime = ?, block_hash = ?`;
await connection.query<any>(query, [blockHeight, datetime, blockHash]);
connection.release();
protected async $saveLatestBlockToDatabase(blockHeight: number) {
const query = `UPDATE state SET number = ? WHERE name = 'last_elements_block'`;
await DB.query(query, [blockHeight]);
}
}

View File

@@ -0,0 +1,38 @@
import * as fs from 'fs';
import logger from '../../logger';
class Icons {
private static FILE_NAME = './icons.json';
private iconIds: string[] = [];
private icons: { [assetId: string]: string; } = {};
constructor() {}
public loadIcons() {
if (!fs.existsSync(Icons.FILE_NAME)) {
logger.warn(`${Icons.FILE_NAME} does not exist. No Liquid icons loaded.`);
return;
}
const cacheData = fs.readFileSync(Icons.FILE_NAME, 'utf8');
this.icons = JSON.parse(cacheData);
for (const i in this.icons) {
this.iconIds.push(i);
}
logger.debug(`Liquid icons has been loaded.`);
}
public getIconByAssetId(assetId: string): Buffer | undefined {
const icon = this.icons[assetId];
if (icon) {
return Buffer.from(icon, 'base64');
}
}
public getAllIconIds() {
return this.iconIds;
}
}
export default new Icons();

View File

@@ -12,8 +12,8 @@ class LoadingIndicators {
this.progressChangedCallback = fn;
}
public setProgress(name: string, progressPercent: number) {
const newProgress = Math.round(progressPercent);
public setProgress(name: string, progressPercent: number, rounded: boolean = true) {
const newProgress = rounded === true ? Math.round(progressPercent) : progressPercent;
if (newProgress >= 100) {
delete this.loadingIndicators[name];
} else {

View File

@@ -1,10 +1,11 @@
import logger from '../logger';
import { MempoolBlock, TransactionExtended, MempoolBlockWithTransactions } from '../mempool.interfaces';
import { MempoolBlock, TransactionExtended, TransactionStripped, MempoolBlockWithTransactions, MempoolBlockDelta } from '../mempool.interfaces';
import { Common } from './common';
import config from '../config';
class MempoolBlocks {
private mempoolBlocks: MempoolBlockWithTransactions[] = [];
private mempoolBlockDeltas: MempoolBlockDelta[] = [];
constructor() {}
@@ -25,6 +26,10 @@ class MempoolBlocks {
return this.mempoolBlocks;
}
public getMempoolBlockDeltas(): MempoolBlockDelta[] {
return this.mempoolBlockDeltas;
}
public updateMempoolBlocks(memPool: { [txid: string]: TransactionExtended }): void {
const latestMempool = memPool;
const memPoolArray: TransactionExtended[] = [];
@@ -66,11 +71,15 @@ class MempoolBlocks {
const time = end - start;
logger.debug('Mempool blocks calculated in ' + time / 1000 + ' seconds');
this.mempoolBlocks = this.calculateMempoolBlocks(memPoolArray);
const { blocks, deltas } = this.calculateMempoolBlocks(memPoolArray, this.mempoolBlocks);
this.mempoolBlocks = blocks;
this.mempoolBlockDeltas = deltas;
}
private calculateMempoolBlocks(transactionsSorted: TransactionExtended[]): MempoolBlockWithTransactions[] {
private calculateMempoolBlocks(transactionsSorted: TransactionExtended[], prevBlocks: MempoolBlockWithTransactions[]):
{ blocks: MempoolBlockWithTransactions[], deltas: MempoolBlockDelta[] } {
const mempoolBlocks: MempoolBlockWithTransactions[] = [];
const mempoolBlockDeltas: MempoolBlockDelta[] = [];
let blockWeight = 0;
let blockSize = 0;
let transactions: TransactionExtended[] = [];
@@ -90,7 +99,43 @@ class MempoolBlocks {
if (transactions.length) {
mempoolBlocks.push(this.dataToMempoolBlocks(transactions, blockSize, blockWeight, mempoolBlocks.length));
}
return mempoolBlocks;
// Calculate change from previous block states
for (let i = 0; i < Math.max(mempoolBlocks.length, prevBlocks.length); i++) {
let added: TransactionStripped[] = [];
let removed: string[] = [];
if (mempoolBlocks[i] && !prevBlocks[i]) {
added = mempoolBlocks[i].transactions;
} else if (!mempoolBlocks[i] && prevBlocks[i]) {
removed = prevBlocks[i].transactions.map(tx => tx.txid);
} else if (mempoolBlocks[i] && prevBlocks[i]) {
const prevIds = {};
const newIds = {};
prevBlocks[i].transactions.forEach(tx => {
prevIds[tx.txid] = true;
});
mempoolBlocks[i].transactions.forEach(tx => {
newIds[tx.txid] = true;
});
prevBlocks[i].transactions.forEach(tx => {
if (!newIds[tx.txid]) {
removed.push(tx.txid);
}
});
mempoolBlocks[i].transactions.forEach(tx => {
if (!prevIds[tx.txid]) {
added.push(tx);
}
});
}
mempoolBlockDeltas.push({
added,
removed
});
}
return {
blocks: mempoolBlocks,
deltas: mempoolBlockDeltas
};
}
private dataToMempoolBlocks(transactions: TransactionExtended[],
@@ -112,6 +157,7 @@ class MempoolBlocks {
medianFee: Common.percentile(transactions.map((tx) => tx.effectiveFeePerVsize), config.MEMPOOL.RECOMMENDED_FEE_PERCENTILE),
feeRange: Common.getFeesInRange(transactions, rangeLength),
transactionIds: transactions.map((tx) => tx.txid),
transactions: transactions.map((tx) => Common.stripTransaction(tx)),
};
}
}

View File

@@ -8,13 +8,15 @@ import { IBitcoinApi } from './bitcoin/bitcoin-api.interface';
import loadingIndicators from './loading-indicators';
import bitcoinClient from './bitcoin/bitcoin-client';
import bitcoinSecondClient from './bitcoin/bitcoin-second-client';
import rbfCache from './rbf-cache';
class Mempool {
private static WEBSOCKET_REFRESH_RATE_MS = 10000;
private static LAZY_DELETE_AFTER_SECONDS = 30;
private inSync: boolean = false;
private mempoolCacheDelta: number = -1;
private mempoolCache: { [txId: string]: TransactionExtended } = {};
private mempoolInfo: IBitcoinApi.MempoolInfo = { loaded: false, size: 0, bytes: 0, usage: 0,
private mempoolInfo: IBitcoinApi.MempoolInfo = { loaded: false, size: 0, bytes: 0, usage: 0, total_fee: 0,
maxmempool: 300000000, mempoolminfee: 0.00001000, minrelaytxfee: 0.00001000 };
private mempoolChangedCallback: ((newMempool: {[txId: string]: TransactionExtended; }, newTransactions: TransactionExtended[],
deletedTransactions: TransactionExtended[]) => void) | undefined;
@@ -32,6 +34,17 @@ class Mempool {
setInterval(this.deleteExpiredTransactions.bind(this), 20000);
}
/**
* Return true if we should leave resources available for mempool tx caching
*/
public hasPriority(): boolean {
if (this.inSync) {
return false;
} else {
return this.mempoolCacheDelta == -1 || this.mempoolCacheDelta > 25;
}
}
public isInSync(): boolean {
return this.inSync;
}
@@ -100,6 +113,8 @@ class Mempool {
const diff = transactions.length - currentMempoolSize;
const newTransactions: TransactionExtended[] = [];
this.mempoolCacheDelta = Math.abs(diff);
if (!this.inSync) {
loadingIndicators.setProgress('mempool', Object.keys(this.mempoolCache).length / transactions.length * 100);
}
@@ -174,6 +189,8 @@ class Mempool {
loadingIndicators.setProgress('mempool', 100);
}
this.mempoolCacheDelta = Math.abs(transactions.length - Object.keys(this.mempoolCache).length);
if (this.mempoolChangedCallback && (hasChange || deletedTransactions.length)) {
this.mempoolChangedCallback(this.mempoolCache, newTransactions, deletedTransactions);
}
@@ -184,6 +201,17 @@ class Mempool {
logger.debug('Mempool updated in ' + time / 1000 + ' seconds');
}
public handleRbfTransactions(rbfTransactions: { [txid: string]: TransactionExtended; }) {
for (const rbfTransaction in rbfTransactions) {
if (this.mempoolCache[rbfTransaction]) {
// Store replaced transactions
rbfCache.add(rbfTransaction, rbfTransactions[rbfTransaction].txid);
// Erase the replaced transactions from the local mempool
delete this.mempoolCache[rbfTransaction];
}
}
}
private updateTxPerSecond() {
const nowMinusTimeSpan = new Date().getTime() - (1000 * config.STATISTICS.TX_PER_SECOND_SAMPLE_PERIOD);
this.txPerSecondArray = this.txPerSecondArray.filter((unixTime) => unixTime > nowMinusTimeSpan);

405
backend/src/api/mining.ts Normal file
View File

@@ -0,0 +1,405 @@
import { PoolInfo, PoolStats, RewardStats } from '../mempool.interfaces';
import BlocksRepository from '../repositories/BlocksRepository';
import PoolsRepository from '../repositories/PoolsRepository';
import HashratesRepository from '../repositories/HashratesRepository';
import bitcoinClient from './bitcoin/bitcoin-client';
import logger from '../logger';
import { Common } from './common';
import loadingIndicators from './loading-indicators';
import { escape } from 'mysql2';
class Mining {
constructor() {
}
/**
* Get historical block total fee
*/
public async $getHistoricalBlockFees(interval: string | null = null): Promise<any> {
return await BlocksRepository.$getHistoricalBlockFees(
this.getTimeRange(interval),
Common.getSqlInterval(interval)
);
}
/**
* Get historical block rewards
*/
public async $getHistoricalBlockRewards(interval: string | null = null): Promise<any> {
return await BlocksRepository.$getHistoricalBlockRewards(
this.getTimeRange(interval),
Common.getSqlInterval(interval)
);
}
/**
* Get historical block fee rates percentiles
*/
public async $getHistoricalBlockFeeRates(interval: string | null = null): Promise<any> {
return await BlocksRepository.$getHistoricalBlockFeeRates(
this.getTimeRange(interval),
Common.getSqlInterval(interval)
);
}
/**
* Get historical block sizes
*/
public async $getHistoricalBlockSizes(interval: string | null = null): Promise<any> {
return await BlocksRepository.$getHistoricalBlockSizes(
this.getTimeRange(interval),
Common.getSqlInterval(interval)
);
}
/**
* Get historical block weights
*/
public async $getHistoricalBlockWeights(interval: string | null = null): Promise<any> {
return await BlocksRepository.$getHistoricalBlockWeights(
this.getTimeRange(interval),
Common.getSqlInterval(interval)
);
}
/**
* Generate high level overview of the pool ranks and general stats
*/
public async $getPoolsStats(interval: string | null): Promise<object> {
const poolsStatistics = {};
const poolsInfo: PoolInfo[] = await PoolsRepository.$getPoolsInfo(interval);
const emptyBlocks: any[] = await BlocksRepository.$countEmptyBlocks(null, interval);
const poolsStats: PoolStats[] = [];
let rank = 1;
poolsInfo.forEach((poolInfo: PoolInfo) => {
const emptyBlocksCount = emptyBlocks.filter((emptyCount) => emptyCount.poolId === poolInfo.poolId);
const poolStat: PoolStats = {
poolId: poolInfo.poolId, // mysql row id
name: poolInfo.name,
link: poolInfo.link,
blockCount: poolInfo.blockCount,
rank: rank++,
emptyBlocks: emptyBlocksCount.length > 0 ? emptyBlocksCount[0]['count'] : 0,
slug: poolInfo.slug,
};
poolsStats.push(poolStat);
});
poolsStatistics['pools'] = poolsStats;
const blockCount: number = await BlocksRepository.$blockCount(null, interval);
poolsStatistics['blockCount'] = blockCount;
const totalBlock24h: number = await BlocksRepository.$blockCount(null, '24h');
try {
poolsStatistics['lastEstimatedHashrate'] = await bitcoinClient.getNetworkHashPs(totalBlock24h);
} catch (e) {
poolsStatistics['lastEstimatedHashrate'] = 0;
logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate');
}
return poolsStatistics;
}
/**
* Get all mining pool stats for a pool
*/
public async $getPoolStat(slug: string): Promise<object> {
const pool = await PoolsRepository.$getPool(slug);
if (!pool) {
throw new Error('This mining pool does not exist ' + escape(slug));
}
const blockCount: number = await BlocksRepository.$blockCount(pool.id);
const totalBlock: number = await BlocksRepository.$blockCount(null, null);
const blockCount24h: number = await BlocksRepository.$blockCount(pool.id, '24h');
const totalBlock24h: number = await BlocksRepository.$blockCount(null, '24h');
const blockCount1w: number = await BlocksRepository.$blockCount(pool.id, '1w');
const totalBlock1w: number = await BlocksRepository.$blockCount(null, '1w');
let currentEstimatedHashrate = 0;
try {
currentEstimatedHashrate = await bitcoinClient.getNetworkHashPs(totalBlock24h);
} catch (e) {
logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate');
}
return {
pool: pool,
blockCount: {
'all': blockCount,
'24h': blockCount24h,
'1w': blockCount1w,
},
blockShare: {
'all': blockCount / totalBlock,
'24h': blockCount24h / totalBlock24h,
'1w': blockCount1w / totalBlock1w,
},
estimatedHashrate: currentEstimatedHashrate * (blockCount24h / totalBlock24h),
reportedHashrate: null,
};
}
/**
* Get miner reward stats
*/
public async $getRewardStats(blockCount: number): Promise<RewardStats> {
return await BlocksRepository.$getBlockStats(blockCount);
}
/**
* [INDEXING] Generate weekly mining pool hashrate history
*/
public async $generatePoolHashrateHistory(): Promise<void> {
const now = new Date();
try {
const lastestRunDate = await HashratesRepository.$getLatestRun('last_weekly_hashrates_indexing');
// Run only if:
// * lastestRunDate is set to 0 (node backend restart, reorg)
// * we started a new week (around Monday midnight)
const runIndexing = lastestRunDate === 0 || now.getUTCDay() === 1 && lastestRunDate !== now.getUTCDate();
if (!runIndexing) {
return;
}
} catch (e) {
throw e;
}
try {
const indexedTimestamp = await HashratesRepository.$getWeeklyHashrateTimestamps();
const hashrates: any[] = [];
const genesisTimestamp = 1231006505000; // bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
const lastMonday = new Date(now.setDate(now.getDate() - (now.getDay() + 6) % 7));
const lastMondayMidnight = this.getDateMidnight(lastMonday);
let toTimestamp = lastMondayMidnight.getTime();
const totalWeekIndexed = (await BlocksRepository.$blockCount(null, null)) / 1008;
let indexedThisRun = 0;
let totalIndexed = 0;
let newlyIndexed = 0;
const startedAt = new Date().getTime() / 1000;
let timer = new Date().getTime() / 1000;
logger.debug(`Indexing weekly mining pool hashrate`);
loadingIndicators.setProgress('weekly-hashrate-indexing', 0);
while (toTimestamp > genesisTimestamp) {
const fromTimestamp = toTimestamp - 604800000;
// Skip already indexed weeks
if (indexedTimestamp.includes(toTimestamp / 1000)) {
toTimestamp -= 604800000;
++totalIndexed;
continue;
}
// Check if we have blocks for the previous week (which mean that the week
// we are currently indexing has complete data)
const blockStatsPreviousWeek: any = await BlocksRepository.$blockCountBetweenTimestamp(
null, (fromTimestamp - 604800000) / 1000, (toTimestamp - 604800000) / 1000);
if (blockStatsPreviousWeek.blockCount === 0) { // We are done indexing
break;
}
const blockStats: any = await BlocksRepository.$blockCountBetweenTimestamp(
null, fromTimestamp / 1000, toTimestamp / 1000);
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
blockStats.lastBlockHeight);
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp / 1000, toTimestamp / 1000);
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
pools = pools.map((pool: any) => {
pool.hashrate = (pool.blockCount / totalBlocks) * lastBlockHashrate;
pool.share = (pool.blockCount / totalBlocks);
return pool;
});
for (const pool of pools) {
hashrates.push({
hashrateTimestamp: toTimestamp / 1000,
avgHashrate: pool['hashrate'],
poolId: pool.poolId,
share: pool['share'],
type: 'weekly',
});
}
newlyIndexed += hashrates.length;
await HashratesRepository.$saveHashrates(hashrates);
hashrates.length = 0;
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - timer));
if (elapsedSeconds > 1) {
const runningFor = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt));
const weeksPerSeconds = Math.max(1, Math.round(indexedThisRun / elapsedSeconds));
const progress = Math.round(totalIndexed / totalWeekIndexed * 10000) / 100;
const timeLeft = Math.round((totalWeekIndexed - totalIndexed) / weeksPerSeconds);
const formattedDate = new Date(fromTimestamp).toUTCString();
logger.debug(`Getting weekly pool hashrate for ${formattedDate} | ~${weeksPerSeconds.toFixed(2)} weeks/sec | total: ~${totalIndexed}/${Math.round(totalWeekIndexed)} (${progress}%) | elapsed: ${runningFor} seconds | left: ~${timeLeft} seconds`);
timer = new Date().getTime() / 1000;
indexedThisRun = 0;
loadingIndicators.setProgress('weekly-hashrate-indexing', progress, false);
}
toTimestamp -= 604800000;
++indexedThisRun;
++totalIndexed;
}
await HashratesRepository.$setLatestRun('last_weekly_hashrates_indexing', new Date().getUTCDate());
if (newlyIndexed > 0) {
logger.info(`Indexed ${newlyIndexed} pools weekly hashrate`);
}
loadingIndicators.setProgress('weekly-hashrate-indexing', 100);
} catch (e) {
loadingIndicators.setProgress('weekly-hashrate-indexing', 100);
throw e;
}
}
/**
* [INDEXING] Generate daily hashrate data
*/
public async $generateNetworkHashrateHistory(): Promise<void> {
try {
// We only run this once a day around midnight
const latestRunDate = await HashratesRepository.$getLatestRun('last_hashrates_indexing');
const now = new Date().getUTCDate();
if (now === latestRunDate) {
return;
}
} catch (e) {
throw e;
}
try {
const indexedTimestamp = (await HashratesRepository.$getNetworkDailyHashrate(null)).map(hashrate => hashrate.timestamp);
const genesisTimestamp = 1231006505000; // bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
const lastMidnight = this.getDateMidnight(new Date());
let toTimestamp = Math.round(lastMidnight.getTime());
const hashrates: any[] = [];
const totalDayIndexed = (await BlocksRepository.$blockCount(null, null)) / 144;
let indexedThisRun = 0;
let totalIndexed = 0;
let newlyIndexed = 0;
const startedAt = new Date().getTime() / 1000;
let timer = new Date().getTime() / 1000;
logger.debug(`Indexing daily network hashrate`);
loadingIndicators.setProgress('daily-hashrate-indexing', 0);
while (toTimestamp > genesisTimestamp) {
const fromTimestamp = toTimestamp - 86400000;
// Skip already indexed weeks
if (indexedTimestamp.includes(toTimestamp / 1000)) {
toTimestamp -= 86400000;
++totalIndexed;
continue;
}
// Check if we have blocks for the previous day (which mean that the day
// we are currently indexing has complete data)
const blockStatsPreviousDay: any = await BlocksRepository.$blockCountBetweenTimestamp(
null, (fromTimestamp - 86400000) / 1000, (toTimestamp - 86400000) / 1000);
if (blockStatsPreviousDay.blockCount === 0) { // We are done indexing
break;
}
const blockStats: any = await BlocksRepository.$blockCountBetweenTimestamp(
null, fromTimestamp / 1000, toTimestamp / 1000);
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
blockStats.lastBlockHeight);
hashrates.push({
hashrateTimestamp: toTimestamp / 1000,
avgHashrate: lastBlockHashrate,
poolId: 0,
share: 1,
type: 'daily',
});
if (hashrates.length > 10) {
newlyIndexed += hashrates.length;
await HashratesRepository.$saveHashrates(hashrates);
hashrates.length = 0;
}
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - timer));
if (elapsedSeconds > 1) {
const runningFor = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt));
const daysPerSeconds = Math.max(1, Math.round(indexedThisRun / elapsedSeconds));
const progress = Math.round(totalIndexed / totalDayIndexed * 10000) / 100;
const timeLeft = Math.round((totalDayIndexed - totalIndexed) / daysPerSeconds);
const formattedDate = new Date(fromTimestamp).toUTCString();
logger.debug(`Getting network daily hashrate for ${formattedDate} | ~${daysPerSeconds.toFixed(2)} days/sec | total: ~${totalIndexed}/${Math.round(totalDayIndexed)} (${progress}%) | elapsed: ${runningFor} seconds | left: ~${timeLeft} seconds`);
timer = new Date().getTime() / 1000;
indexedThisRun = 0;
loadingIndicators.setProgress('daily-hashrate-indexing', progress);
}
toTimestamp -= 86400000;
++indexedThisRun;
++totalIndexed;
}
// Add genesis block manually
if (toTimestamp <= genesisTimestamp && !indexedTimestamp.includes(genesisTimestamp)) {
hashrates.push({
hashrateTimestamp: genesisTimestamp,
avgHashrate: await bitcoinClient.getNetworkHashPs(1, 1),
poolId: null,
type: 'daily',
});
}
newlyIndexed += hashrates.length;
await HashratesRepository.$saveHashrates(hashrates);
await HashratesRepository.$setLatestRun('last_hashrates_indexing', new Date().getUTCDate());
if (newlyIndexed > 0) {
logger.info(`Indexed ${newlyIndexed} day of network hashrate`);
}
loadingIndicators.setProgress('daily-hashrate-indexing', 100);
} catch (e) {
loadingIndicators.setProgress('daily-hashrate-indexing', 100);
throw e;
}
}
private getDateMidnight(date: Date): Date {
date.setUTCHours(0);
date.setUTCMinutes(0);
date.setUTCSeconds(0);
date.setUTCMilliseconds(0);
return date;
}
private getTimeRange(interval: string | null): number {
switch (interval) {
case '3y': return 43200; // 12h
case '2y': return 28800; // 8h
case '1y': return 28800; // 8h
case '6m': return 10800; // 3h
case '3m': return 7200; // 2h
case '1m': return 1800; // 30min
case '1w': return 300; // 5min
case '3d': return 1;
case '24h': return 1;
default: return 86400; // 24h
}
}
}
export default new Mining();

View File

@@ -0,0 +1,206 @@
import DB from '../database';
import logger from '../logger';
import config from '../config';
interface Pool {
name: string;
link: string;
regexes: string[];
addresses: string[];
slug: string;
}
class PoolsParser {
miningPools: any[] = [];
unknownPool: any = {
'name': "Unknown",
'link': "https://learnmeabitcoin.com/technical/coinbase-transaction",
'regexes': "[]",
'addresses': "[]",
'slug': 'unknown'
};
slugWarnFlag = false;
/**
* Parse the pools.json file, consolidate the data and dump it into the database
*/
public async migratePoolsJson(poolsJson: object) {
if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) {
return;
}
// First we save every entries without paying attention to pool duplication
const poolsDuplicated: Pool[] = [];
logger.debug('Parse coinbase_tags');
const coinbaseTags = Object.entries(poolsJson['coinbase_tags']);
for (let i = 0; i < coinbaseTags.length; ++i) {
poolsDuplicated.push({
'name': (<Pool>coinbaseTags[i][1]).name,
'link': (<Pool>coinbaseTags[i][1]).link,
'regexes': [coinbaseTags[i][0]],
'addresses': [],
'slug': ''
});
}
logger.debug('Parse payout_addresses');
const addressesTags = Object.entries(poolsJson['payout_addresses']);
for (let i = 0; i < addressesTags.length; ++i) {
poolsDuplicated.push({
'name': (<Pool>addressesTags[i][1]).name,
'link': (<Pool>addressesTags[i][1]).link,
'regexes': [],
'addresses': [addressesTags[i][0]],
'slug': ''
});
}
// Then, we find unique mining pool names
logger.debug('Identify unique mining pools');
const poolNames: string[] = [];
for (let i = 0; i < poolsDuplicated.length; ++i) {
if (poolNames.indexOf(poolsDuplicated[i].name) === -1) {
poolNames.push(poolsDuplicated[i].name);
}
}
logger.debug(`Found ${poolNames.length} unique mining pools`);
// Get existing pools from the db
let existingPools;
try {
if (config.DATABASE.ENABLED === true) {
[existingPools] = await DB.query({ sql: 'SELECT * FROM pools;', timeout: 120000 });
} else {
existingPools = [];
}
} catch (e) {
logger.err('Cannot get existing pools from the database, skipping pools.json import');
return;
}
this.miningPools = [];
// Finally, we generate the final consolidated pools data
const finalPoolDataAdd: Pool[] = [];
const finalPoolDataUpdate: Pool[] = [];
for (let i = 0; i < poolNames.length; ++i) {
let allAddresses: string[] = [];
let allRegexes: string[] = [];
const match = poolsDuplicated.filter((pool: Pool) => pool.name === poolNames[i]);
for (let y = 0; y < match.length; ++y) {
allAddresses = allAddresses.concat(match[y].addresses);
allRegexes = allRegexes.concat(match[y].regexes);
}
const finalPoolName = poolNames[i].replace(`'`, `''`); // To support single quote in names when doing db queries
let slug: string | undefined;
try {
slug = poolsJson['slugs'][poolNames[i]];
} catch (e) {
if (this.slugWarnFlag === false) {
logger.warn(`pools.json does not seem to contain the 'slugs' object`);
this.slugWarnFlag = true;
}
}
if (slug === undefined) {
// Only keep alphanumerical
slug = poolNames[i].replace(/[^a-z0-9]/gi, '').toLowerCase();
logger.warn(`No slug found for '${poolNames[i]}', generating it => '${slug}'`);
}
const poolObj = {
'name': finalPoolName,
'link': match[0].link,
'regexes': allRegexes,
'addresses': allAddresses,
'slug': slug
};
if (existingPools.find((pool) => pool.name === poolNames[i]) !== undefined) {
finalPoolDataUpdate.push(poolObj);
} else {
logger.debug(`Add '${finalPoolName}' mining pool`);
finalPoolDataAdd.push(poolObj);
}
this.miningPools.push({
'name': finalPoolName,
'link': match[0].link,
'regexes': JSON.stringify(allRegexes),
'addresses': JSON.stringify(allAddresses),
'slug': slug
});
}
if (config.DATABASE.ENABLED === false) { // Don't run db operations
logger.info('Mining pools.json import completed (no database)');
return;
}
logger.debug(`Update pools table now`);
// Add new mining pools into the database
let queryAdd: string = 'INSERT INTO pools(name, link, regexes, addresses, slug) VALUES ';
for (let i = 0; i < finalPoolDataAdd.length; ++i) {
queryAdd += `('${finalPoolDataAdd[i].name}', '${finalPoolDataAdd[i].link}',
'${JSON.stringify(finalPoolDataAdd[i].regexes)}', '${JSON.stringify(finalPoolDataAdd[i].addresses)}',
${JSON.stringify(finalPoolDataAdd[i].slug)}),`;
}
queryAdd = queryAdd.slice(0, -1) + ';';
// Updated existing mining pools in the database
const updateQueries: string[] = [];
for (let i = 0; i < finalPoolDataUpdate.length; ++i) {
updateQueries.push(`
UPDATE pools
SET name='${finalPoolDataUpdate[i].name}', link='${finalPoolDataUpdate[i].link}',
regexes='${JSON.stringify(finalPoolDataUpdate[i].regexes)}', addresses='${JSON.stringify(finalPoolDataUpdate[i].addresses)}',
slug='${finalPoolDataUpdate[i].slug}'
WHERE name='${finalPoolDataUpdate[i].name}'
;`);
}
try {
if (finalPoolDataAdd.length > 0) {
await DB.query({ sql: queryAdd, timeout: 120000 });
}
for (const query of updateQueries) {
await DB.query({ sql: query, timeout: 120000 });
}
await this.insertUnknownPool();
logger.info('Mining pools.json import completed');
} catch (e) {
logger.err(`Cannot import pools in the database`);
throw e;
}
}
/**
* Manually add the 'unknown pool'
*/
private async insertUnknownPool() {
try {
const [rows]: any[] = await DB.query({ sql: 'SELECT name from pools where name="Unknown"', timeout: 120000 });
if (rows.length === 0) {
await DB.query({
sql: `INSERT INTO pools(name, link, regexes, addresses, slug)
VALUES("Unknown", "https://learnmeabitcoin.com/technical/coinbase-transaction", "[]", "[]", "unknown");
`});
} else {
await DB.query(`UPDATE pools
SET name='Unknown', link='https://learnmeabitcoin.com/technical/coinbase-transaction',
regexes='[]', addresses='[]',
slug='unknown'
WHERE name='Unknown'
`);
}
} catch (e) {
logger.err('Unable to insert "Unknown" mining pool');
}
}
}
export default new PoolsParser();

View File

@@ -0,0 +1,34 @@
export interface CachedRbf {
txid: string;
expires: Date;
}
class RbfCache {
private cache: { [txid: string]: CachedRbf; } = {};
constructor() {
setInterval(this.cleanup.bind(this), 1000 * 60 * 60);
}
public add(replacedTxId: string, newTxId: string): void {
this.cache[replacedTxId] = {
expires: new Date(Date.now() + 1000 * 604800), // 1 week
txid: newTxId,
};
}
public get(txId: string): CachedRbf | undefined {
return this.cache[txId];
}
private cleanup(): void {
const currentDate = new Date();
for (const c in this.cache) {
if (this.cache[c].expires < currentDate) {
delete this.cache[c];
}
}
}
}
export default new RbfCache();

View File

@@ -1,17 +1,15 @@
import memPool from './mempool';
import { DB } from '../database';
import DB from '../database';
import logger from '../logger';
import { Statistic, TransactionExtended, OptimizedStatistic } from '../mempool.interfaces';
import config from '../config';
import { Common } from './common';
class Statistics {
protected intervalTimer: NodeJS.Timer | undefined;
protected newStatisticsEntryCallback: ((stats: OptimizedStatistic) => void) | undefined;
protected queryTimeout = 120000;
protected cache: { [date: string]: OptimizedStatistic[] } = {
'24h': [], '1w': [], '1m': [], '3m': [], '6m': [], '1y': [], '2y': [], '3y': []
};
public setNewStatisticsEntryCallback(fn: (stats: OptimizedStatistic) => void) {
this.newStatisticsEntryCallback = fn;
@@ -33,25 +31,6 @@ class Statistics {
this.runStatistics();
}, 1 * 60 * 1000);
}, difference);
this.createCache();
setInterval(this.createCache.bind(this), 600000);
}
public getCache() {
return this.cache;
}
private async createCache() {
this.cache['24h'] = await this.$list24H();
this.cache['1w'] = await this.$list1W();
this.cache['1m'] = await this.$list1M();
this.cache['3m'] = await this.$list3M();
this.cache['6m'] = await this.$list6M();
this.cache['1y'] = await this.$list1Y();
this.cache['2y'] = await this.$list2Y();
this.cache['3y'] = await this.$list3Y();
logger.debug('Statistics cache created');
}
private async runStatistics(): Promise<void> {
@@ -74,6 +53,17 @@ class Statistics {
memPoolArray = memPoolArray.filter((tx) => tx.effectiveFeePerVsize);
if (!memPoolArray.length) {
try {
const insertIdZeroed = await this.$createZeroedStatistic();
if (this.newStatisticsEntryCallback && insertIdZeroed) {
const newStats = await this.$get(insertIdZeroed);
if (newStats) {
this.newStatisticsEntryCallback(newStats);
}
}
} catch (e) {
logger.err('Unable to insert zeroed statistics. ' + e);
}
return;
}
@@ -90,9 +80,9 @@ class Statistics {
memPoolArray.forEach((transaction) => {
for (let i = 0; i < logFees.length; i++) {
if (
(config.MEMPOOL.NETWORK === 'liquid' && (i === lastItem || transaction.effectiveFeePerVsize * 10 < logFees[i + 1]))
(Common.isLiquid() && (i === lastItem || transaction.effectiveFeePerVsize * 10 < logFees[i + 1]))
||
(config.MEMPOOL.NETWORK !== 'liquid' && (i === lastItem || transaction.effectiveFeePerVsize < logFees[i + 1]))
(!Common.isLiquid() && (i === lastItem || transaction.effectiveFeePerVsize < logFees[i + 1]))
) {
if (weightVsizeFees[logFees[i]]) {
weightVsizeFees[logFees[i]] += transaction.vsize;
@@ -104,65 +94,126 @@ class Statistics {
}
});
const insertId = await this.$create({
added: 'NOW()',
unconfirmed_transactions: memPoolArray.length,
tx_per_second: txPerSecond,
vbytes_per_second: Math.round(vBytesPerSecond),
mempool_byte_weight: totalWeight,
total_fee: totalFee,
fee_data: '',
vsize_1: weightVsizeFees['1'] || 0,
vsize_2: weightVsizeFees['2'] || 0,
vsize_3: weightVsizeFees['3'] || 0,
vsize_4: weightVsizeFees['4'] || 0,
vsize_5: weightVsizeFees['5'] || 0,
vsize_6: weightVsizeFees['6'] || 0,
vsize_8: weightVsizeFees['8'] || 0,
vsize_10: weightVsizeFees['10'] || 0,
vsize_12: weightVsizeFees['12'] || 0,
vsize_15: weightVsizeFees['15'] || 0,
vsize_20: weightVsizeFees['20'] || 0,
vsize_30: weightVsizeFees['30'] || 0,
vsize_40: weightVsizeFees['40'] || 0,
vsize_50: weightVsizeFees['50'] || 0,
vsize_60: weightVsizeFees['60'] || 0,
vsize_70: weightVsizeFees['70'] || 0,
vsize_80: weightVsizeFees['80'] || 0,
vsize_90: weightVsizeFees['90'] || 0,
vsize_100: weightVsizeFees['100'] || 0,
vsize_125: weightVsizeFees['125'] || 0,
vsize_150: weightVsizeFees['150'] || 0,
vsize_175: weightVsizeFees['175'] || 0,
vsize_200: weightVsizeFees['200'] || 0,
vsize_250: weightVsizeFees['250'] || 0,
vsize_300: weightVsizeFees['300'] || 0,
vsize_350: weightVsizeFees['350'] || 0,
vsize_400: weightVsizeFees['400'] || 0,
vsize_500: weightVsizeFees['500'] || 0,
vsize_600: weightVsizeFees['600'] || 0,
vsize_700: weightVsizeFees['700'] || 0,
vsize_800: weightVsizeFees['800'] || 0,
vsize_900: weightVsizeFees['900'] || 0,
vsize_1000: weightVsizeFees['1000'] || 0,
vsize_1200: weightVsizeFees['1200'] || 0,
vsize_1400: weightVsizeFees['1400'] || 0,
vsize_1600: weightVsizeFees['1600'] || 0,
vsize_1800: weightVsizeFees['1800'] || 0,
vsize_2000: weightVsizeFees['2000'] || 0,
});
try {
const insertId = await this.$create({
added: 'NOW()',
unconfirmed_transactions: memPoolArray.length,
tx_per_second: txPerSecond,
vbytes_per_second: Math.round(vBytesPerSecond),
mempool_byte_weight: totalWeight,
total_fee: totalFee,
fee_data: '',
vsize_1: weightVsizeFees['1'] || 0,
vsize_2: weightVsizeFees['2'] || 0,
vsize_3: weightVsizeFees['3'] || 0,
vsize_4: weightVsizeFees['4'] || 0,
vsize_5: weightVsizeFees['5'] || 0,
vsize_6: weightVsizeFees['6'] || 0,
vsize_8: weightVsizeFees['8'] || 0,
vsize_10: weightVsizeFees['10'] || 0,
vsize_12: weightVsizeFees['12'] || 0,
vsize_15: weightVsizeFees['15'] || 0,
vsize_20: weightVsizeFees['20'] || 0,
vsize_30: weightVsizeFees['30'] || 0,
vsize_40: weightVsizeFees['40'] || 0,
vsize_50: weightVsizeFees['50'] || 0,
vsize_60: weightVsizeFees['60'] || 0,
vsize_70: weightVsizeFees['70'] || 0,
vsize_80: weightVsizeFees['80'] || 0,
vsize_90: weightVsizeFees['90'] || 0,
vsize_100: weightVsizeFees['100'] || 0,
vsize_125: weightVsizeFees['125'] || 0,
vsize_150: weightVsizeFees['150'] || 0,
vsize_175: weightVsizeFees['175'] || 0,
vsize_200: weightVsizeFees['200'] || 0,
vsize_250: weightVsizeFees['250'] || 0,
vsize_300: weightVsizeFees['300'] || 0,
vsize_350: weightVsizeFees['350'] || 0,
vsize_400: weightVsizeFees['400'] || 0,
vsize_500: weightVsizeFees['500'] || 0,
vsize_600: weightVsizeFees['600'] || 0,
vsize_700: weightVsizeFees['700'] || 0,
vsize_800: weightVsizeFees['800'] || 0,
vsize_900: weightVsizeFees['900'] || 0,
vsize_1000: weightVsizeFees['1000'] || 0,
vsize_1200: weightVsizeFees['1200'] || 0,
vsize_1400: weightVsizeFees['1400'] || 0,
vsize_1600: weightVsizeFees['1600'] || 0,
vsize_1800: weightVsizeFees['1800'] || 0,
vsize_2000: weightVsizeFees['2000'] || 0,
});
if (this.newStatisticsEntryCallback && insertId) {
const newStats = await this.$get(insertId);
if (newStats) {
this.newStatisticsEntryCallback(newStats);
if (this.newStatisticsEntryCallback && insertId) {
const newStats = await this.$get(insertId);
if (newStats) {
this.newStatisticsEntryCallback(newStats);
}
}
} catch (e) {
logger.err('Unable to insert statistics. ' + e);
}
}
private async $createZeroedStatistic(): Promise<number | undefined> {
try {
const query = `INSERT INTO statistics(
added,
unconfirmed_transactions,
tx_per_second,
vbytes_per_second,
mempool_byte_weight,
fee_data,
total_fee,
vsize_1,
vsize_2,
vsize_3,
vsize_4,
vsize_5,
vsize_6,
vsize_8,
vsize_10,
vsize_12,
vsize_15,
vsize_20,
vsize_30,
vsize_40,
vsize_50,
vsize_60,
vsize_70,
vsize_80,
vsize_90,
vsize_100,
vsize_125,
vsize_150,
vsize_175,
vsize_200,
vsize_250,
vsize_300,
vsize_350,
vsize_400,
vsize_500,
vsize_600,
vsize_700,
vsize_800,
vsize_900,
vsize_1000,
vsize_1200,
vsize_1400,
vsize_1600,
vsize_1800,
vsize_2000
)
VALUES (NOW(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)`;
const [result]: any = await DB.query(query);
return result.insertId;
} catch (e) {
logger.err('$create() error' + (e instanceof Error ? e.message : e));
}
}
private async $create(statistics: Statistic): Promise<number | undefined> {
try {
const connection = await DB.pool.getConnection();
const query = `INSERT INTO statistics(
added,
unconfirmed_transactions,
@@ -259,8 +310,7 @@ class Statistics {
statistics.vsize_1800,
statistics.vsize_2000,
];
const [result]: any = await connection.query(query, params);
connection.release();
const [result]: any = await DB.query(query, params);
return result.insertId;
} catch (e) {
logger.err('$create() error' + (e instanceof Error ? e.message : e));
@@ -268,58 +318,57 @@ class Statistics {
}
private getQueryForDaysAvg(div: number, interval: string) {
return `SELECT id, UNIX_TIMESTAMP(added) as added,
CAST(avg(unconfirmed_transactions) as FLOAT) as unconfirmed_transactions,
CAST(avg(tx_per_second) as FLOAT) as tx_per_second,
CAST(avg(vbytes_per_second) as FLOAT) as vbytes_per_second,
CAST(avg(vsize_1) as FLOAT) as vsize_1,
CAST(avg(vsize_2) as FLOAT) as vsize_2,
CAST(avg(vsize_3) as FLOAT) as vsize_3,
CAST(avg(vsize_4) as FLOAT) as vsize_4,
CAST(avg(vsize_5) as FLOAT) as vsize_5,
CAST(avg(vsize_6) as FLOAT) as vsize_6,
CAST(avg(vsize_8) as FLOAT) as vsize_8,
CAST(avg(vsize_10) as FLOAT) as vsize_10,
CAST(avg(vsize_12) as FLOAT) as vsize_12,
CAST(avg(vsize_15) as FLOAT) as vsize_15,
CAST(avg(vsize_20) as FLOAT) as vsize_20,
CAST(avg(vsize_30) as FLOAT) as vsize_30,
CAST(avg(vsize_40) as FLOAT) as vsize_40,
CAST(avg(vsize_50) as FLOAT) as vsize_50,
CAST(avg(vsize_60) as FLOAT) as vsize_60,
CAST(avg(vsize_70) as FLOAT) as vsize_70,
CAST(avg(vsize_80) as FLOAT) as vsize_80,
CAST(avg(vsize_90) as FLOAT) as vsize_90,
CAST(avg(vsize_100) as FLOAT) as vsize_100,
CAST(avg(vsize_125) as FLOAT) as vsize_125,
CAST(avg(vsize_150) as FLOAT) as vsize_150,
CAST(avg(vsize_175) as FLOAT) as vsize_175,
CAST(avg(vsize_200) as FLOAT) as vsize_200,
CAST(avg(vsize_250) as FLOAT) as vsize_250,
CAST(avg(vsize_300) as FLOAT) as vsize_300,
CAST(avg(vsize_350) as FLOAT) as vsize_350,
CAST(avg(vsize_400) as FLOAT) as vsize_400,
CAST(avg(vsize_500) as FLOAT) as vsize_500,
CAST(avg(vsize_600) as FLOAT) as vsize_600,
CAST(avg(vsize_700) as FLOAT) as vsize_700,
CAST(avg(vsize_800) as FLOAT) as vsize_800,
CAST(avg(vsize_900) as FLOAT) as vsize_900,
CAST(avg(vsize_1000) as FLOAT) as vsize_1000,
CAST(avg(vsize_1200) as FLOAT) as vsize_1200,
CAST(avg(vsize_1400) as FLOAT) as vsize_1400,
CAST(avg(vsize_1600) as FLOAT) as vsize_1600,
CAST(avg(vsize_1800) as FLOAT) as vsize_1800,
CAST(avg(vsize_2000) as FLOAT) as vsize_2000 \
return `SELECT
UNIX_TIMESTAMP(added) as added,
CAST(avg(vbytes_per_second) as DOUBLE) as vbytes_per_second,
CAST(avg(vsize_1) as DOUBLE) as vsize_1,
CAST(avg(vsize_2) as DOUBLE) as vsize_2,
CAST(avg(vsize_3) as DOUBLE) as vsize_3,
CAST(avg(vsize_4) as DOUBLE) as vsize_4,
CAST(avg(vsize_5) as DOUBLE) as vsize_5,
CAST(avg(vsize_6) as DOUBLE) as vsize_6,
CAST(avg(vsize_8) as DOUBLE) as vsize_8,
CAST(avg(vsize_10) as DOUBLE) as vsize_10,
CAST(avg(vsize_12) as DOUBLE) as vsize_12,
CAST(avg(vsize_15) as DOUBLE) as vsize_15,
CAST(avg(vsize_20) as DOUBLE) as vsize_20,
CAST(avg(vsize_30) as DOUBLE) as vsize_30,
CAST(avg(vsize_40) as DOUBLE) as vsize_40,
CAST(avg(vsize_50) as DOUBLE) as vsize_50,
CAST(avg(vsize_60) as DOUBLE) as vsize_60,
CAST(avg(vsize_70) as DOUBLE) as vsize_70,
CAST(avg(vsize_80) as DOUBLE) as vsize_80,
CAST(avg(vsize_90) as DOUBLE) as vsize_90,
CAST(avg(vsize_100) as DOUBLE) as vsize_100,
CAST(avg(vsize_125) as DOUBLE) as vsize_125,
CAST(avg(vsize_150) as DOUBLE) as vsize_150,
CAST(avg(vsize_175) as DOUBLE) as vsize_175,
CAST(avg(vsize_200) as DOUBLE) as vsize_200,
CAST(avg(vsize_250) as DOUBLE) as vsize_250,
CAST(avg(vsize_300) as DOUBLE) as vsize_300,
CAST(avg(vsize_350) as DOUBLE) as vsize_350,
CAST(avg(vsize_400) as DOUBLE) as vsize_400,
CAST(avg(vsize_500) as DOUBLE) as vsize_500,
CAST(avg(vsize_600) as DOUBLE) as vsize_600,
CAST(avg(vsize_700) as DOUBLE) as vsize_700,
CAST(avg(vsize_800) as DOUBLE) as vsize_800,
CAST(avg(vsize_900) as DOUBLE) as vsize_900,
CAST(avg(vsize_1000) as DOUBLE) as vsize_1000,
CAST(avg(vsize_1200) as DOUBLE) as vsize_1200,
CAST(avg(vsize_1400) as DOUBLE) as vsize_1400,
CAST(avg(vsize_1600) as DOUBLE) as vsize_1600,
CAST(avg(vsize_1800) as DOUBLE) as vsize_1800,
CAST(avg(vsize_2000) as DOUBLE) as vsize_2000 \
FROM statistics \
WHERE added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() \
GROUP BY UNIX_TIMESTAMP(added) DIV ${div} \
ORDER BY id DESC;`;
ORDER BY statistics.added DESC;`;
}
private getQueryForDays(div: number, interval: string) {
return `SELECT id, UNIX_TIMESTAMP(added) as added, unconfirmed_transactions,
tx_per_second,
vbytes_per_second,
return `SELECT
UNIX_TIMESTAMP(added) as added,
CAST(avg(vbytes_per_second) as DOUBLE) as vbytes_per_second,
vsize_1,
vsize_2,
vsize_3,
@@ -361,15 +410,13 @@ class Statistics {
FROM statistics \
WHERE added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() \
GROUP BY UNIX_TIMESTAMP(added) DIV ${div} \
ORDER BY id DESC;`;
ORDER BY statistics.added DESC;`;
}
public async $get(id: number): Promise<OptimizedStatistic | undefined> {
private async $get(id: number): Promise<OptimizedStatistic | undefined> {
try {
const connection = await DB.pool.getConnection();
const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics WHERE id = ?`;
const [rows] = await connection.query<any>(query, [id]);
connection.release();
const [rows] = await DB.query(query, [id]);
if (rows[0]) {
return this.mapStatisticToOptimizedStatistic([rows[0]])[0];
}
@@ -380,11 +427,9 @@ class Statistics {
public async $list2H(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY id DESC LIMIT 120`;
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY statistics.added DESC LIMIT 120`;
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list2H() error' + (e instanceof Error ? e.message : e));
return [];
@@ -393,11 +438,9 @@ class Statistics {
public async $list24H(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDaysAvg(120, '1 DAY'); // 2m interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = `SELECT *, UNIX_TIMESTAMP(added) as added FROM statistics ORDER BY statistics.added DESC LIMIT 1440`;
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list24h() error' + (e instanceof Error ? e.message : e));
return [];
@@ -406,11 +449,9 @@ class Statistics {
public async $list1W(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDaysAvg(600, '1 WEEK'); // 10m interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDaysAvg(300, '1 WEEK'); // 5m interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list1W() error' + (e instanceof Error ? e.message : e));
return [];
@@ -419,11 +460,9 @@ class Statistics {
public async $list1M(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDaysAvg(3600, '1 MONTH'); // 1h interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDaysAvg(1800, '1 MONTH'); // 30m interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list1M() error' + (e instanceof Error ? e.message : e));
return [];
@@ -432,11 +471,9 @@ class Statistics {
public async $list3M(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDaysAvg(14400, '3 MONTH'); // 4h interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDaysAvg(7200, '3 MONTH'); // 2h interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list3M() error' + (e instanceof Error ? e.message : e));
return [];
@@ -445,11 +482,9 @@ class Statistics {
public async $list6M(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDaysAvg(21600, '6 MONTH'); // 6h interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDaysAvg(10800, '6 MONTH'); // 3h interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list6M() error' + (e instanceof Error ? e.message : e));
return [];
@@ -458,11 +493,9 @@ class Statistics {
public async $list1Y(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDays(43200, '1 YEAR'); // 12h interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDays(28800, '1 YEAR'); // 8h interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list1Y() error' + (e instanceof Error ? e.message : e));
return [];
@@ -471,11 +504,9 @@ class Statistics {
public async $list2Y(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDays(86400, "2 YEAR"); // 1d interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDays(28800, '2 YEAR'); // 8h interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list2Y() error' + (e instanceof Error ? e.message : e));
return [];
@@ -484,11 +515,9 @@ class Statistics {
public async $list3Y(): Promise<OptimizedStatistic[]> {
try {
const connection = await DB.pool.getConnection();
const query = this.getQueryForDays(86400, "3 YEAR"); // 1d interval
const [rows] = await connection.query<any>({ sql: query, timeout: this.queryTimeout });
connection.release();
return this.mapStatisticToOptimizedStatistic(rows);
const query = this.getQueryForDays(43200, '3 YEAR'); // 12h interval
const [rows] = await DB.query({ sql: query, timeout: this.queryTimeout });
return this.mapStatisticToOptimizedStatistic(rows as Statistic[]);
} catch (e) {
logger.err('$list3Y() error' + (e instanceof Error ? e.message : e));
return [];
@@ -498,10 +527,7 @@ class Statistics {
private mapStatisticToOptimizedStatistic(statistic: Statistic[]): OptimizedStatistic[] {
return statistic.map((s) => {
return {
id: s.id || 0,
added: s.added,
unconfirmed_transactions: s.unconfirmed_transactions,
tx_per_second: s.tx_per_second,
vbytes_per_second: s.vbytes_per_second,
mempool_byte_weight: s.mempool_byte_weight,
total_fee: s.total_fee,

View File

@@ -2,6 +2,7 @@ import bitcoinApi from './bitcoin/bitcoin-api-factory';
import { TransactionExtended, TransactionMinerInfo } from '../mempool.interfaces';
import { IEsploraApi } from './bitcoin/esplora-api.interface';
import config from '../config';
import { Common } from './common';
class TransactionUtils {
constructor() { }
@@ -20,8 +21,8 @@ class TransactionUtils {
};
}
public async $getTransactionExtended(txId: string, addPrevouts = false): Promise<TransactionExtended> {
const transaction: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(txId, false, addPrevouts);
public async $getTransactionExtended(txId: string, addPrevouts = false, lazyPrevouts = false): Promise<TransactionExtended> {
const transaction: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(txId, false, addPrevouts, lazyPrevouts);
return this.extendTransaction(transaction);
}
@@ -31,7 +32,8 @@ class TransactionUtils {
// @ts-ignore
return transaction;
}
const feePerVbytes = Math.max(config.MEMPOOL.NETWORK === 'liquid' ? 0.1 : 1, (transaction.fee || 0) / (transaction.weight / 4));
const feePerVbytes = Math.max(Common.isLiquid() ? 0.1 : 1,
(transaction.fee || 0) / (transaction.weight / 4));
const transactionExtended: TransactionExtended = Object.assign({
vsize: Math.round(transaction.weight / 4),
feePerVsize: feePerVbytes,
@@ -42,6 +44,14 @@ class TransactionUtils {
}
return transactionExtended;
}
public hex2ascii(hex: string) {
let str = '';
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
}
}
export default new TransactionUtils();

View File

@@ -1,6 +1,6 @@
import logger from '../logger';
import * as WebSocket from 'ws';
import { BlockExtended, TransactionExtended, WebsocketResponse, MempoolBlock,
import { BlockExtended, TransactionExtended, WebsocketResponse, MempoolBlock, MempoolBlockDelta,
OptimizedStatistic, ILoadingIndicators, IConversionRates } from '../mempool.interfaces';
import blocks from './blocks';
import memPool from './mempool';
@@ -11,6 +11,9 @@ import { Common } from './common';
import loadingIndicators from './loading-indicators';
import config from '../config';
import transactionUtils from './transaction-utils';
import rbfCache from './rbf-cache';
import difficultyAdjustment from './difficulty-adjustment';
import feeApi from './fee-api';
class WebsocketHandler {
private wss: WebSocket.Server | undefined;
@@ -48,29 +51,38 @@ class WebsocketHandler {
if (parsedMessage && parsedMessage['track-tx']) {
if (/^[a-fA-F0-9]{64}$/.test(parsedMessage['track-tx'])) {
client['track-tx'] = parsedMessage['track-tx'];
// Client is telling the transaction wasn't found but it might have appeared before we had the time to start watching for it
// Client is telling the transaction wasn't found
if (parsedMessage['watch-mempool']) {
const tx = memPool.getMempool()[client['track-tx']];
if (tx) {
if (config.MEMPOOL.BACKEND === 'esplora') {
response['tx'] = tx;
const rbfCacheTx = rbfCache.get(client['track-tx']);
if (rbfCacheTx) {
response['txReplaced'] = {
txid: rbfCacheTx.txid,
};
client['track-tx'] = null;
} else {
// It might have appeared before we had the time to start watching for it
const tx = memPool.getMempool()[client['track-tx']];
if (tx) {
if (config.MEMPOOL.BACKEND === 'esplora') {
response['tx'] = tx;
} else {
// tx.prevout is missing from transactions when in bitcoind mode
try {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
response['tx'] = fullTx;
} catch (e) {
logger.debug('Error finding transaction: ' + (e instanceof Error ? e.message : e));
}
}
} else {
// tx.prevouts is missing from transactions when in bitcoind mode
try {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
const fullTx = await transactionUtils.$getTransactionExtended(client['track-tx'], true);
response['tx'] = fullTx;
} catch (e) {
logger.debug('Error finding transaction: ' + (e instanceof Error ? e.message : e));
logger.debug('Error finding transaction. ' + (e instanceof Error ? e.message : e));
client['track-mempool-tx'] = parsedMessage['track-tx'];
}
}
} else {
try {
const fullTx = await transactionUtils.$getTransactionExtended(client['track-tx'], true);
response['tx'] = fullTx;
} catch (e) {
logger.debug('Error finding transaction. ' + (e instanceof Error ? e.message : e));
client['track-mempool-tx'] = parsedMessage['track-tx'];
}
}
}
} else {
@@ -99,6 +111,20 @@ class WebsocketHandler {
}
}
if (parsedMessage && parsedMessage['track-mempool-block'] !== undefined) {
if (Number.isInteger(parsedMessage['track-mempool-block']) && parsedMessage['track-mempool-block'] >= 0) {
const index = parsedMessage['track-mempool-block'];
client['track-mempool-block'] = index;
const mBlocksWithTransactions = mempoolBlocks.getMempoolBlocksWithTransactions();
response['projected-block-transactions'] = {
index: index,
blockTransactions: mBlocksWithTransactions[index]?.transactions || [],
};
} else {
client['track-mempool-block'] = null;
}
}
if (parsedMessage.action === 'init') {
const _blocks = blocks.getBlocks().slice(-config.MEMPOOL.INITIAL_BLOCKS_AMOUNT);
if (!_blocks) {
@@ -181,14 +207,14 @@ class WebsocketHandler {
return {
'mempoolInfo': memPool.getMempoolInfo(),
'vBytesPerSecond': memPool.getVBytesPerSecond(),
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
'previousRetarget': blocks.getPreviousDifficultyRetarget(),
'blocks': _blocks,
'conversions': fiatConversion.getConversionRates(),
'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
'transactions': memPool.getLatestTransactions(),
'backendInfo': backendInfo.getBackendInfo(),
'loadingIndicators': loadingIndicators.getLoadingIndicators(),
'da': difficultyAdjustment.getDifficultyAdjustment(),
'fees': feeApi.getRecommendedFee(),
...this.extraInitProperties
};
}
@@ -221,14 +247,13 @@ class WebsocketHandler {
mempoolBlocks.updateMempoolBlocks(newMempool);
const mBlocks = mempoolBlocks.getMempoolBlocks();
const mempool = memPool.getMempool();
const mBlockDeltas = mempoolBlocks.getMempoolBlockDeltas();
const mempoolInfo = memPool.getMempoolInfo();
const vBytesPerSecond = memPool.getVBytesPerSecond();
const rbfTransactions = Common.findRbfTransactions(newTransactions, deletedTransactions);
for (const rbfTransaction in rbfTransactions) {
delete mempool[rbfTransaction];
}
const da = difficultyAdjustment.getDifficultyAdjustment();
memPool.handleRbfTransactions(rbfTransactions);
const recommendedFees = feeApi.getRecommendedFee();
this.wss.clients.forEach(async (client: WebSocket) => {
if (client.readyState !== WebSocket.OPEN) {
@@ -241,6 +266,8 @@ class WebsocketHandler {
response['mempoolInfo'] = mempoolInfo;
response['vBytesPerSecond'] = vBytesPerSecond;
response['transactions'] = newTransactions.slice(0, 6).map((tx) => Common.stripTransaction(tx));
response['da'] = da;
response['fees'] = recommendedFees;
}
if (client['want-mempool-blocks']) {
@@ -331,22 +358,40 @@ class WebsocketHandler {
}
}
if (client['track-tx'] && rbfTransactions[client['track-tx']]) {
for (const rbfTransaction in rbfTransactions) {
if (client['track-tx'] === rbfTransaction) {
const rbfTx = rbfTransactions[rbfTransaction];
if (config.MEMPOOL.BACKEND !== 'esplora') {
try {
const fullTx = await transactionUtils.$getTransactionExtended(rbfTransaction, true);
response['rbfTransaction'] = fullTx;
} catch (e) {
logger.debug('Error finding transaction in mempool: ' + (e instanceof Error ? e.message : e));
}
} else {
response['rbfTransaction'] = rbfTx;
}
break;
if (client['track-tx']) {
const outspends: object = {};
newTransactions.forEach((tx) => tx.vin.forEach((vin, i) => {
if (vin.txid === client['track-tx']) {
outspends[vin.vout] = {
vin: i,
txid: tx.txid,
};
}
}));
if (Object.keys(outspends).length) {
response['utxoSpent'] = outspends;
}
if (rbfTransactions[client['track-tx']]) {
for (const rbfTransaction in rbfTransactions) {
if (client['track-tx'] === rbfTransaction) {
response['rbfTransaction'] = {
txid: rbfTransactions[rbfTransaction].txid,
};
break;
}
}
}
}
if (client['track-mempool-block'] >= 0) {
const index = client['track-mempool-block'];
if (mBlockDeltas[index]) {
response['projected-block-transactions'] = {
index: index,
delta: mBlockDeltas[index],
};
}
}
@@ -362,6 +407,7 @@ class WebsocketHandler {
}
let mBlocks: undefined | MempoolBlock[];
let mBlockDeltas: undefined | MempoolBlockDelta[];
let matchRate = 0;
const _memPool = memPool.getMempool();
const _mempoolBlocks = mempoolBlocks.getMempoolBlocksWithTransactions();
@@ -378,9 +424,15 @@ class WebsocketHandler {
matchRate = Math.round((matches.length / (txIds.length - 1)) * 100);
mempoolBlocks.updateMempoolBlocks(_memPool);
mBlocks = mempoolBlocks.getMempoolBlocks();
mBlockDeltas = mempoolBlocks.getMempoolBlockDeltas();
}
block.matchRate = matchRate;
if (block.extras) {
block.extras.matchRate = matchRate;
}
const da = difficultyAdjustment.getDifficultyAdjustment();
const fees = feeApi.getRecommendedFee();
this.wss.clients.forEach((client) => {
if (client.readyState !== WebSocket.OPEN) {
@@ -394,8 +446,8 @@ class WebsocketHandler {
const response = {
'block': block,
'mempoolInfo': memPool.getMempoolInfo(),
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
'previousRetarget': blocks.getPreviousDifficultyRetarget(),
'da': da,
'fees': fees,
};
if (mBlocks && client['want-mempool-blocks']) {
@@ -403,7 +455,6 @@ class WebsocketHandler {
}
if (client['track-tx'] && txIds.indexOf(client['track-tx']) > -1) {
client['track-tx'] = null;
response['txConfirmed'] = true;
}
@@ -471,6 +522,16 @@ class WebsocketHandler {
}
}
if (client['track-mempool-block'] >= 0) {
const index = client['track-mempool-block'];
if (mBlockDeltas && mBlockDeltas[index]) {
response['projected-block-transactions'] = {
index: index,
delta: mBlockDeltas[index],
};
}
}
client.send(JSON.stringify(response));
});
}

View File

@@ -2,7 +2,7 @@ const configFile = require('../mempool-config.json');
interface IConfig {
MEMPOOL: {
NETWORK: 'mainnet' | 'testnet' | 'signet' | 'liquid';
NETWORK: 'mainnet' | 'testnet' | 'signet' | 'liquid' | 'liquidtestnet';
BACKEND: 'esplora' | 'electrum' | 'none';
HTTP_PORT: number;
SPAWN_CLUSTER_PROCS: number;
@@ -14,8 +14,14 @@ interface IConfig {
BLOCK_WEIGHT_UNITS: number;
INITIAL_BLOCKS_AMOUNT: number;
MEMPOOL_BLOCKS_AMOUNT: number;
INDEXING_BLOCKS_AMOUNT: number;
PRICE_FEED_UPDATE_INTERVAL: number;
USE_SECOND_NODE_FOR_MINFEE: boolean;
EXTERNAL_ASSETS: string[];
EXTERNAL_MAX_RETRY: number;
EXTERNAL_RETRY_INTERVAL: number;
USER_AGENT: string;
STDOUT_LOG_MIN_PRIORITY: 'emerg' | 'alert' | 'crit' | 'err' | 'warn' | 'notice' | 'info' | 'debug';
};
ESPLORA: {
REST_API_URL: string;
@@ -40,6 +46,7 @@ interface IConfig {
DATABASE: {
ENABLED: boolean;
HOST: string,
SOCKET: string,
PORT: number;
DATABASE: string;
USERNAME: string;
@@ -49,7 +56,7 @@ interface IConfig {
ENABLED: boolean;
HOST: string;
PORT: number;
MIN_PRIORITY: 'emerg' | 'alert' | 'crit' | 'err' |'warn' | 'notice' | 'info' | 'debug';
MIN_PRIORITY: 'emerg' | 'alert' | 'crit' | 'err' | 'warn' | 'notice' | 'info' | 'debug';
FACILITY: string;
};
STATISTICS: {
@@ -60,6 +67,26 @@ interface IConfig {
ENABLED: boolean;
DATA_PATH: string;
};
SOCKS5PROXY: {
ENABLED: boolean;
USE_ONION: boolean;
HOST: string;
PORT: number;
USERNAME: string;
PASSWORD: string;
};
PRICE_DATA_SERVER: {
TOR_URL: string;
CLEARNET_URL: string;
};
EXTERNAL_DATA_SERVER: {
MEMPOOL_API: string;
MEMPOOL_ONION: string;
LIQUID_API: string;
LIQUID_ONION: string;
BISQ_URL: string;
BISQ_ONION: string;
};
}
const defaults: IConfig = {
@@ -76,8 +103,14 @@ const defaults: IConfig = {
'BLOCK_WEIGHT_UNITS': 4000000,
'INITIAL_BLOCKS_AMOUNT': 8,
'MEMPOOL_BLOCKS_AMOUNT': 8,
'PRICE_FEED_UPDATE_INTERVAL': 3600,
'INDEXING_BLOCKS_AMOUNT': 11000, // 0 = disable indexing, -1 = index all blocks
'PRICE_FEED_UPDATE_INTERVAL': 600,
'USE_SECOND_NODE_FOR_MINFEE': false,
'EXTERNAL_ASSETS': [],
'EXTERNAL_MAX_RETRY': 1,
'EXTERNAL_RETRY_INTERVAL': 0,
'USER_AGENT': 'mempool',
'STDOUT_LOG_MIN_PRIORITY': 'debug',
},
'ESPLORA': {
'REST_API_URL': 'http://127.0.0.1:3000',
@@ -102,6 +135,7 @@ const defaults: IConfig = {
'DATABASE': {
'ENABLED': true,
'HOST': '127.0.0.1',
'SOCKET': '',
'PORT': 3306,
'DATABASE': 'mempool',
'USERNAME': 'mempool',
@@ -122,6 +156,26 @@ const defaults: IConfig = {
'ENABLED': false,
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db'
},
'SOCKS5PROXY': {
'ENABLED': false,
'USE_ONION': true,
'HOST': '127.0.0.1',
'PORT': 9050,
'USERNAME': '',
'PASSWORD': ''
},
"PRICE_DATA_SERVER": {
'TOR_URL': 'http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices',
'CLEARNET_URL': 'https://price.bisq.wiz.biz/getAllMarketPrices'
},
"EXTERNAL_DATA_SERVER": {
'MEMPOOL_API': 'https://mempool.space/api/v1',
'MEMPOOL_ONION': 'http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/api/v1',
'LIQUID_API': 'https://liquid.network/api/v1',
'LIQUID_ONION': 'http://liquidmom47f6s3m53ebfxn47p76a6tlnxib3wp6deux7wuzotdr6cyd.onion/api/v1',
'BISQ_URL': 'https://bisq.markets/api',
'BISQ_ONION': 'http://bisqmktse2cabavbr2xjq7xw3h6g5ottemo5rolfcwt6aly6tp5fdryd.onion/api'
}
};
class Config implements IConfig {
@@ -134,6 +188,9 @@ class Config implements IConfig {
SYSLOG: IConfig['SYSLOG'];
STATISTICS: IConfig['STATISTICS'];
BISQ: IConfig['BISQ'];
SOCKS5PROXY: IConfig['SOCKS5PROXY'];
PRICE_DATA_SERVER: IConfig['PRICE_DATA_SERVER'];
EXTERNAL_DATA_SERVER: IConfig['EXTERNAL_DATA_SERVER'];
constructor() {
const configs = this.merge(configFile, defaults);
@@ -146,6 +203,9 @@ class Config implements IConfig {
this.SYSLOG = configs.SYSLOG;
this.STATISTICS = configs.STATISTICS;
this.BISQ = configs.BISQ;
this.SOCKS5PROXY = configs.SOCKS5PROXY;
this.PRICE_DATA_SERVER = configs.PRICE_DATA_SERVER;
this.EXTERNAL_DATA_SERVER = configs.EXTERNAL_DATA_SERVER;
}
merge = (...objects: object[]): IConfig => {

View File

@@ -1,26 +1,59 @@
import config from './config';
import { createPool } from 'mysql2/promise';
import { createPool, Pool, PoolConnection } from 'mysql2/promise';
import logger from './logger';
import { PoolOptions } from 'mysql2/typings/mysql';
export class DB {
static pool = createPool({
host: config.DATABASE.HOST,
class DB {
constructor() {
if (config.DATABASE.SOCKET !== '') {
this.poolConfig.socketPath = config.DATABASE.SOCKET;
} else {
this.poolConfig.host = config.DATABASE.HOST;
}
}
private pool: Pool | null = null;
private poolConfig: PoolOptions = {
port: config.DATABASE.PORT,
database: config.DATABASE.DATABASE,
user: config.DATABASE.USERNAME,
password: config.DATABASE.PASSWORD,
connectionLimit: 10,
supportBigNumbers: true,
});
}
timezone: '+00:00',
};
export async function checkDbConnection() {
try {
const connection = await DB.pool.getConnection();
logger.info('Database connection established.');
connection.release();
} catch (e) {
logger.err('Could not connect to database: ' + (e instanceof Error ? e.message : e));
process.exit(1);
private checkDBFlag() {
if (config.DATABASE.ENABLED === false) {
logger.err('Trying to use DB feature but config.DATABASE.ENABLED is set to false, please open an issue');
}
}
public async query(query, params?) {
this.checkDBFlag();
const pool = await this.getPool();
return pool.query(query, params);
}
public async checkDbConnection() {
this.checkDBFlag();
try {
await this.query('SELECT ?', [1]);
logger.info('Database connection established.');
} catch (e) {
logger.err('Could not connect to database: ' + (e instanceof Error ? e.message : e));
process.exit(1);
}
}
private async getPool(): Promise<Pool> {
if (this.pool === null) {
this.pool = createPool(this.poolConfig);
this.pool.on('connection', function (newConnection: PoolConnection) {
newConnection.query(`SET time_zone='+00:00'`);
});
}
return this.pool;
}
}
export default new DB();

View File

@@ -5,7 +5,7 @@ import * as WebSocket from 'ws';
import * as cluster from 'cluster';
import axios from 'axios';
import { checkDbConnection } from './database';
import DB from './database';
import config from './config';
import routes from './routes';
import blocks from './api/blocks';
@@ -21,6 +21,12 @@ import backendInfo from './api/backend-info';
import loadingIndicators from './api/loading-indicators';
import mempool from './api/mempool';
import elementsParser from './api/liquid/elements-parser';
import databaseMigration from './api/database-migration';
import syncAssets from './sync-assets';
import icons from './api/liquid/icons';
import { Common } from './api/common';
import poolsUpdater from './tasks/pools-updater';
import indexer from './indexer';
class Server {
private wss: WebSocket.Server | undefined;
@@ -61,7 +67,7 @@ class Server {
}
async startServer(worker = false) {
logger.debug(`Starting Mempool Server${worker ? ' (worker)' : ''}... (${backendInfo.getShortCommitHash()})`);
logger.notice(`Starting Mempool Server${worker ? ' (worker)' : ''}... (${backendInfo.getShortCommitHash()})`);
this.app
.use((req: Request, res: Response, next: NextFunction) => {
@@ -77,16 +83,39 @@ class Server {
this.setUpWebsocketHandling();
await syncAssets.syncAssets$();
diskCache.loadMempoolCache();
if (config.DATABASE.ENABLED) {
await checkDbConnection();
await DB.checkDbConnection();
try {
if (process.env.npm_config_reindex !== undefined) { // Re-index requests
const tables = process.env.npm_config_reindex.split(',');
logger.warn(`Indexed data for "${process.env.npm_config_reindex}" tables will be erased in 5 seconds (using '--reindex')`);
await Common.sleep$(5000);
await databaseMigration.$truncateIndexedData(tables);
}
await databaseMigration.$initializeOrMigrateDatabase();
if (Common.indexingEnabled()) {
await indexer.$resetHashratesIndexingState();
}
} catch (e) {
throw new Error(e instanceof Error ? e.message : 'Error');
}
}
if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED && cluster.isMaster) {
statistics.startStatistics();
}
if (Common.isLiquid()) {
try {
icons.loadIcons();
} catch (e) {
logger.err('Cannot load liquid icons. Ignoring. Reason: ' + (e instanceof Error ? e.message : e));
}
}
fiatConversion.startService();
this.setUpHttpApiRoutes();
@@ -120,8 +149,11 @@ class Server {
logger.debug(msg);
}
}
await poolsUpdater.updatePoolsJson();
await blocks.$updateBlocks();
await memPool.$updateMempool();
indexer.$run();
setTimeout(this.runMainUpdateLoop.bind(this), config.MEMPOOL.POLL_RATE_MS);
this.currentBackendRetryInterval = 5;
} catch (e) {
@@ -143,7 +175,7 @@ class Server {
if (this.wss) {
websocketHandler.setWebsocketServer(this.wss);
}
if (config.MEMPOOL.NETWORK === 'liquid' && config.DATABASE.ENABLED) {
if (Common.isLiquid() && config.DATABASE.ENABLED) {
blocks.setNewBlockCallback(async () => {
try {
await elementsParser.$parse();
@@ -173,7 +205,7 @@ class Server {
.post(config.MEMPOOL.API_URL_PREFIX + 'tx/push', routes.$postTransactionForm)
.get(config.MEMPOOL.API_URL_PREFIX + 'donations', async (req, res) => {
try {
const response = await axios.get('https://mempool.space/api/v1/donations', { responseType: 'stream', timeout: 10000 });
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/donations`, { responseType: 'stream', timeout: 10000 });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
@@ -181,7 +213,7 @@ class Server {
})
.get(config.MEMPOOL.API_URL_PREFIX + 'donations/images/:id', async (req, res) => {
try {
const response = await axios.get('https://mempool.space/api/v1/donations/images/' + req.params.id, {
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/donations/images/${req.params.id}`, {
responseType: 'stream', timeout: 10000
});
response.data.pipe(res);
@@ -191,7 +223,7 @@ class Server {
})
.get(config.MEMPOOL.API_URL_PREFIX + 'contributors', async (req, res) => {
try {
const response = await axios.get('https://mempool.space/api/v1/contributors', { responseType: 'stream', timeout: 10000 });
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/contributors`, { responseType: 'stream', timeout: 10000 });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
@@ -199,7 +231,25 @@ class Server {
})
.get(config.MEMPOOL.API_URL_PREFIX + 'contributors/images/:id', async (req, res) => {
try {
const response = await axios.get('https://mempool.space/api/v1/contributors/images/' + req.params.id, {
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/contributors/images/${req.params.id}`, {
responseType: 'stream', timeout: 10000
});
response.data.pipe(res);
} catch (e) {
res.status(500).end();
}
})
.get(config.MEMPOOL.API_URL_PREFIX + 'translators', async (req, res) => {
try {
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/translators`, { responseType: 'stream', timeout: 10000 });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
}
})
.get(config.MEMPOOL.API_URL_PREFIX + 'translators/images/:id', async (req, res) => {
try {
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/translators/images/${req.params.id}`, {
responseType: 'stream', timeout: 10000
});
response.data.pipe(res);
@@ -211,18 +261,35 @@ class Server {
if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2h', routes.get2HStatistics)
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/24h', routes.get24HStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1w', routes.get1WHStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1m', routes.get1MStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3m', routes.get3MStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/6m', routes.get6MStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1y', routes.get1YStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2y', routes.get2YStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3y', routes.get3YStatistics.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2h', routes.$getStatisticsByTime.bind(routes, '2h'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/24h', routes.$getStatisticsByTime.bind(routes, '24h'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1w', routes.$getStatisticsByTime.bind(routes, '1w'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1m', routes.$getStatisticsByTime.bind(routes, '1m'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3m', routes.$getStatisticsByTime.bind(routes, '3m'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/6m', routes.$getStatisticsByTime.bind(routes, '6m'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/1y', routes.$getStatisticsByTime.bind(routes, '1y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/2y', routes.$getStatisticsByTime.bind(routes, '2y'))
.get(config.MEMPOOL.API_URL_PREFIX + 'statistics/3y', routes.$getStatisticsByTime.bind(routes, '3y'))
;
}
if (Common.indexingEnabled()) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pools/:interval', routes.$getPools)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pool/:slug/hashrate', routes.$getPoolHistoricalHashrate)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pool/:slug/blocks', routes.$getPoolBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pool/:slug/blocks/:height', routes.$getPoolBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/pool/:slug', routes.$getPool)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/hashrate/pools/:interval', routes.$getPoolsHistoricalHashrate)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/hashrate/:interval', routes.$getHistoricalHashrate)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/reward-stats/:blockCount', routes.$getRewardStats)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/blocks/fees/:interval', routes.$getHistoricalBlockFees)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/blocks/rewards/:interval', routes.$getHistoricalBlockRewards)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/blocks/fee-rates/:interval', routes.$getHistoricalBlockFeeRates)
.get(config.MEMPOOL.API_URL_PREFIX + 'mining/blocks/sizes-weights/:interval', routes.$getHistoricalBlockSizeAndWeight)
;
}
if (config.BISQ.ENABLED) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'bisq/stats', routes.getBisqStats)
@@ -244,6 +311,11 @@ class Server {
;
}
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks', routes.getBlocks.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks/:height', routes.getBlocks.bind(routes))
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash', routes.getBlock);
if (config.MEMPOOL.BACKEND !== 'esplora') {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'mempool', routes.getMempool)
@@ -254,10 +326,7 @@ class Server {
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/hex', routes.getRawTransaction)
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/status', routes.getTransactionStatus)
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', routes.getTransactionOutspends)
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash', routes.getBlock)
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/header', routes.getBlockHeader)
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks', routes.getBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks/:height', routes.getBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks/tip/height', routes.getBlockTipHeight)
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/txs', routes.getBlockTransactions)
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/txs/:index', routes.getBlockTransactions)
@@ -270,7 +339,16 @@ class Server {
;
}
if (config.MEMPOOL.NETWORK === 'liquid' && config.DATABASE.ENABLED) {
if (Common.isLiquid()) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'assets/icons', routes.getAllLiquidIcon)
.get(config.MEMPOOL.API_URL_PREFIX + 'assets/featured', routes.$getAllFeaturedLiquidAssets)
.get(config.MEMPOOL.API_URL_PREFIX + 'asset/:assetId/icon', routes.getLiquidIcon)
.get(config.MEMPOOL.API_URL_PREFIX + 'assets/group/:id', routes.$getAssetGroup)
;
}
if (Common.isLiquid() && config.DATABASE.ENABLED) {
this.app
.get(config.MEMPOOL.API_URL_PREFIX + 'liquid/pegs/month', routes.$getElementsPegsByMonth)
;

54
backend/src/indexer.ts Normal file
View File

@@ -0,0 +1,54 @@
import { Common } from './api/common';
import blocks from './api/blocks';
import mempool from './api/mempool';
import mining from './api/mining';
import logger from './logger';
import HashratesRepository from './repositories/HashratesRepository';
class Indexer {
runIndexer = true;
indexerRunning = false;
constructor() {
}
public reindex() {
if (Common.indexingEnabled()) {
this.runIndexer = true;
}
}
public async $run() {
if (!Common.indexingEnabled() || this.runIndexer === false ||
this.indexerRunning === true || mempool.hasPriority()
) {
return;
}
this.runIndexer = false;
this.indexerRunning = true;
try {
await blocks.$generateBlockDatabase();
await this.$resetHashratesIndexingState();
await mining.$generateNetworkHashrateHistory();
await mining.$generatePoolHashrateHistory();
} catch (e) {
this.reindex();
logger.err(`Indexer failed, trying again later. Reason: ` + (e instanceof Error ? e.message : e));
}
this.indexerRunning = false;
}
async $resetHashratesIndexingState() {
try {
await HashratesRepository.$setLatestRun('last_hashrates_indexing', 0);
await HashratesRepository.$setLatestRun('last_weekly_hashrates_indexing', 0);
} catch (e) {
logger.err(`Cannot reset hashrate indexing timestamps. Reason: ` + (e instanceof Error ? e.message : e));
}
}
}
export default new Indexer();

View File

@@ -97,6 +97,9 @@ class Logger {
syslogmsg = `<${(Logger.facilities[config.SYSLOG.FACILITY] * 8 + prionum)}> ${this.name}[${process.pid}]: ${priority.toUpperCase()}${network} ${msg}`;
this.syslog(syslogmsg);
}
if (Logger.priorities[priority] > Logger.priorities[config.MEMPOOL.STDOUT_LOG_MIN_PRIORITY]) {
return;
}
if (priority === 'warning') {
priority = 'warn';
}

View File

@@ -1,5 +1,27 @@
import { IEsploraApi } from './api/bitcoin/esplora-api.interface';
export interface PoolTag {
id: number; // mysql row id
name: string;
link: string;
regexes: string; // JSON array
addresses: string; // JSON array
slug: string;
}
export interface PoolInfo {
poolId: number; // mysql row id
name: string;
link: string;
blockCount: number;
slug: string;
}
export interface PoolStats extends PoolInfo {
rank: number;
emptyBlocks: number;
}
export interface MempoolBlock {
blockSize: number;
blockVSize: number;
@@ -11,6 +33,12 @@ export interface MempoolBlock {
export interface MempoolBlockWithTransactions extends MempoolBlock {
transactionIds: string[];
transactions: TransactionStripped[];
}
export interface MempoolBlockDelta {
added: TransactionStripped[];
removed: string[];
}
interface VinStrippedToScriptsig {
@@ -56,12 +84,26 @@ export interface TransactionStripped {
vsize: number;
value: number;
}
export interface BlockExtended extends IEsploraApi.Block {
export interface BlockExtension {
totalFees?: number;
medianFee?: number;
feeRange?: number[];
reward?: number;
coinbaseTx?: TransactionMinerInfo;
matchRate?: number;
pool?: {
id: number;
name: string;
slug: string;
};
avgFee?: number;
avgFeeRate?: number;
coinbaseRaw?: string;
}
export interface BlockExtended extends IEsploraApi.Block {
extras: BlockExtension;
}
export interface TransactionMinerInfo {
@@ -128,10 +170,7 @@ export interface Statistic {
}
export interface OptimizedStatistic {
id: number;
added: string;
unconfirmed_transactions: number;
tx_per_second: number;
vbytes_per_second: number;
total_fee: number;
mempool_byte_weight: number;
@@ -167,3 +206,21 @@ export interface IBackendInfo {
gitCommit: string;
version: string;
}
export interface IDifficultyAdjustment {
progressPercent: number;
difficultyChange: number;
estimatedRetargetDate: number;
remainingBlocks: number;
remainingTime: number;
previousRetarget: number;
nextRetargetHeight: number;
timeAvg: number;
timeOffset: number;
}
export interface RewardStats {
totalReward: number;
totalFee: number;
totalTx: number;
}

View File

@@ -0,0 +1,657 @@
import { BlockExtended } from '../mempool.interfaces';
import DB from '../database';
import logger from '../logger';
import { Common } from '../api/common';
import { prepareBlock } from '../utils/blocks-utils';
import PoolsRepository from './PoolsRepository';
import HashratesRepository from './HashratesRepository';
import { escape } from 'mysql2';
class BlocksRepository {
/**
* Save indexed block data in the database
*/
public async $saveBlockInDatabase(block: BlockExtended) {
try {
const query = `INSERT INTO blocks(
height, hash, blockTimestamp, size,
weight, tx_count, coinbase_raw, difficulty,
pool_id, fees, fee_span, median_fee,
reward, version, bits, nonce,
merkle_root, previous_block_hash, avg_fee, avg_fee_rate
) VALUE (
?, ?, FROM_UNIXTIME(?), ?,
?, ?, ?, ?,
?, ?, ?, ?,
?, ?, ?, ?,
?, ?, ?, ?
)`;
const params: any[] = [
block.height,
block.id,
block.timestamp,
block.size,
block.weight,
block.tx_count,
block.extras.coinbaseRaw,
block.difficulty,
block.extras.pool?.id, // Should always be set to something
block.extras.totalFees,
JSON.stringify(block.extras.feeRange),
block.extras.medianFee,
block.extras.reward,
block.version,
block.bits,
block.nonce,
block.merkle_root,
block.previousblockhash,
block.extras.avgFee,
block.extras.avgFeeRate,
];
await DB.query(query, params);
} catch (e: any) {
if (e.errno === 1062) { // ER_DUP_ENTRY - This scenario is possible upon node backend restart
logger.debug(`$saveBlockInDatabase() - Block ${block.height} has already been indexed, ignoring`);
} else {
logger.err('Cannot save indexed block into db. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
}
/**
* Get all block height that have not been indexed between [startHeight, endHeight]
*/
public async $getMissingBlocksBetweenHeights(startHeight: number, endHeight: number): Promise<number[]> {
if (startHeight < endHeight) {
return [];
}
try {
const [rows]: any[] = await DB.query(`
SELECT height
FROM blocks
WHERE height <= ? AND height >= ?
ORDER BY height DESC;
`, [startHeight, endHeight]);
const indexedBlockHeights: number[] = [];
rows.forEach((row: any) => { indexedBlockHeights.push(row.height); });
const seekedBlocks: number[] = Array.from(Array(startHeight - endHeight + 1).keys(), n => n + endHeight).reverse();
const missingBlocksHeights = seekedBlocks.filter(x => indexedBlockHeights.indexOf(x) === -1);
return missingBlocksHeights;
} catch (e) {
logger.err('Cannot retrieve blocks list to index. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get empty blocks for one or all pools
*/
public async $countEmptyBlocks(poolId: number | null, interval: string | null = null): Promise<any> {
interval = Common.getSqlInterval(interval);
const params: any[] = [];
let query = `SELECT count(height) as count, pools.id as poolId
FROM blocks
JOIN pools on pools.id = blocks.pool_id
WHERE tx_count = 1`;
if (poolId) {
query += ` AND pool_id = ?`;
params.push(poolId);
}
if (interval) {
query += ` AND blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP by pools.id`;
try {
const [rows] = await DB.query(query, params);
return rows;
} catch (e) {
logger.err('Cannot count empty blocks. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Return most recent block height
*/
public async $mostRecentBlockHeight(): Promise<number> {
try {
const [row] = await DB.query('SELECT MAX(height) as maxHeight from blocks');
return row[0]['maxHeight'];
} catch (e) {
logger.err(`Cannot count blocks for this pool (using offset). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get blocks count for a period
*/
public async $blockCount(poolId: number | null, interval: string | null = null): Promise<number> {
interval = Common.getSqlInterval(interval);
const params: any[] = [];
let query = `SELECT count(height) as blockCount
FROM blocks`;
if (poolId) {
query += ` WHERE pool_id = ?`;
params.push(poolId);
}
if (interval) {
if (poolId) {
query += ` AND`;
} else {
query += ` WHERE`;
}
query += ` blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
try {
const [rows] = await DB.query(query, params);
return <number>rows[0].blockCount;
} catch (e) {
logger.err(`Cannot count blocks for this pool (using offset). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get blocks count between two dates
* @param poolId
* @param from - The oldest timestamp
* @param to - The newest timestamp
* @returns
*/
public async $blockCountBetweenTimestamp(poolId: number | null, from: number, to: number): Promise<number> {
const params: any[] = [];
let query = `SELECT
count(height) as blockCount,
max(height) as lastBlockHeight
FROM blocks`;
if (poolId) {
query += ` WHERE pool_id = ?`;
params.push(poolId);
}
if (poolId) {
query += ` AND`;
} else {
query += ` WHERE`;
}
query += ` blockTimestamp BETWEEN FROM_UNIXTIME('${from}') AND FROM_UNIXTIME('${to}')`;
try {
const [rows] = await DB.query(query, params);
return <number>rows[0];
} catch (e) {
logger.err(`Cannot count blocks for this pool (using timestamps). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get blocks count for a period
*/
public async $blockCountBetweenHeight(startHeight: number, endHeight: number): Promise<number> {
const params: any[] = [];
let query = `SELECT count(height) as blockCount
FROM blocks
WHERE height <= ${startHeight} AND height >= ${endHeight}`;
try {
const [rows] = await DB.query(query, params);
return <number>rows[0].blockCount;
} catch (e) {
logger.err(`Cannot count blocks for this pool (using offset). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get the oldest indexed block
*/
public async $oldestBlockTimestamp(): Promise<number> {
const query = `SELECT UNIX_TIMESTAMP(blockTimestamp) as blockTimestamp
FROM blocks
ORDER BY height
LIMIT 1;`;
try {
const [rows]: any[] = await DB.query(query);
if (rows.length <= 0) {
return -1;
}
return <number>rows[0].blockTimestamp;
} catch (e) {
logger.err('Cannot get oldest indexed block timestamp. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get blocks mined by a specific mining pool
*/
public async $getBlocksByPool(slug: string, startHeight?: number): Promise<object[]> {
const pool = await PoolsRepository.$getPool(slug);
if (!pool) {
throw new Error('This mining pool does not exist ' + escape(slug));
}
const params: any[] = [];
let query = ` SELECT
height,
hash as id,
UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
size,
weight,
tx_count,
coinbase_raw,
difficulty,
fees,
fee_span,
median_fee,
reward,
version,
bits,
nonce,
merkle_root,
previous_block_hash as previousblockhash,
avg_fee,
avg_fee_rate
FROM blocks
WHERE pool_id = ?`;
params.push(pool.id);
if (startHeight !== undefined) {
query += ` AND height < ?`;
params.push(startHeight);
}
query += ` ORDER BY height DESC
LIMIT 10`;
try {
const [rows] = await DB.query(query, params);
const blocks: BlockExtended[] = [];
for (const block of <object[]>rows) {
blocks.push(prepareBlock(block));
}
return blocks;
} catch (e) {
logger.err('Cannot get blocks for this pool. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get one block by height
*/
public async $getBlockByHeight(height: number): Promise<object | null> {
try {
const [rows]: any[] = await DB.query(`SELECT
height,
hash,
hash as id,
UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
size,
weight,
tx_count,
coinbase_raw,
difficulty,
pools.id as pool_id,
pools.name as pool_name,
pools.link as pool_link,
pools.slug as pool_slug,
pools.addresses as pool_addresses,
pools.regexes as pool_regexes,
fees,
fee_span,
median_fee,
reward,
version,
bits,
nonce,
merkle_root,
previous_block_hash as previousblockhash,
avg_fee,
avg_fee_rate
FROM blocks
JOIN pools ON blocks.pool_id = pools.id
WHERE height = ${height};
`);
if (rows.length <= 0) {
return null;
}
rows[0].fee_span = JSON.parse(rows[0].fee_span);
return rows[0];
} catch (e) {
logger.err(`Cannot get indexed block ${height}. Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get one block by hash
*/
public async $getBlockByHash(hash: string): Promise<object | null> {
try {
const query = `
SELECT *, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp, hash as id,
pools.id as pool_id, pools.name as pool_name, pools.link as pool_link, pools.slug as pool_slug,
pools.addresses as pool_addresses, pools.regexes as pool_regexes,
previous_block_hash as previousblockhash
FROM blocks
JOIN pools ON blocks.pool_id = pools.id
WHERE hash = '${hash}';
`;
const [rows]: any[] = await DB.query(query);
if (rows.length <= 0) {
return null;
}
rows[0].fee_span = JSON.parse(rows[0].fee_span);
return rows[0];
} catch (e) {
logger.err(`Cannot get indexed block ${hash}. Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Return blocks difficulty
*/
public async $getBlocksDifficulty(interval: string | null): Promise<object[]> {
interval = Common.getSqlInterval(interval);
// :D ... Yeah don't ask me about this one https://stackoverflow.com/a/40303162
// Basically, using temporary user defined fields, we are able to extract all
// difficulty adjustments from the blocks tables.
// This allow use to avoid indexing it in another table.
let query = `
SELECT
*
FROM
(
SELECT
UNIX_TIMESTAMP(blockTimestamp) as timestamp, difficulty, height,
IF(@prevStatus = YT.difficulty, @rn := @rn + 1,
IF(@prevStatus := YT.difficulty, @rn := 1, @rn := 1)
) AS rn
FROM blocks YT
CROSS JOIN
(
SELECT @prevStatus := -1, @rn := 1
) AS var
`;
if (interval) {
query += ` WHERE blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += `
ORDER BY YT.height
) AS t
WHERE t.rn = 1
ORDER BY t.height
`;
try {
const [rows]: any[] = await DB.query(query);
for (const row of rows) {
delete row['rn'];
}
return rows;
} catch (e) {
logger.err('Cannot generate difficulty history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get general block stats
*/
public async $getBlockStats(blockCount: number): Promise<any> {
try {
// We need to use a subquery
const query = `
SELECT MIN(height) as startBlock, MAX(height) as endBlock, SUM(reward) as totalReward, SUM(fees) as totalFee, SUM(tx_count) as totalTx
FROM
(SELECT height, reward, fees, tx_count FROM blocks
ORDER by height DESC
LIMIT ?) as sub`;
const [rows]: any = await DB.query(query, [blockCount]);
return rows[0];
} catch (e) {
logger.err('Cannot generate reward stats. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/*
* Check if the last 10 blocks chain is valid
*/
public async $validateRecentBlocks(): Promise<boolean> {
try {
const [lastBlocks]: any[] = await DB.query(`SELECT height, hash, previous_block_hash FROM blocks ORDER BY height DESC LIMIT 10`);
for (let i = 0; i < lastBlocks.length - 1; ++i) {
if (lastBlocks[i].previous_block_hash !== lastBlocks[i + 1].hash) {
logger.warn(`Chain divergence detected at block ${lastBlocks[i].height}, re-indexing most recent data`);
return false;
}
}
return true;
} catch (e) {
return true; // Don't do anything if there is a db error
}
}
/**
* Check if the chain of block hash is valid and delete data from the stale branch if needed
*/
public async $validateChain(): Promise<boolean> {
try {
const start = new Date().getTime();
const [blocks]: any[] = await DB.query(`SELECT height, hash, previous_block_hash,
UNIX_TIMESTAMP(blockTimestamp) as timestamp FROM blocks ORDER BY height`);
let partialMsg = false;
let idx = 1;
while (idx < blocks.length) {
if (blocks[idx].height - 1 !== blocks[idx - 1].height) {
if (partialMsg === false) {
logger.info('Some blocks are not indexed, skipping missing blocks during chain validation');
partialMsg = true;
}
++idx;
continue;
}
if (blocks[idx].previous_block_hash !== blocks[idx - 1].hash) {
logger.warn(`Chain divergence detected at block ${blocks[idx - 1].height}, re-indexing newer blocks and hashrates`);
await this.$deleteBlocksFrom(blocks[idx - 1].height);
await HashratesRepository.$deleteHashratesFromTimestamp(blocks[idx - 1].timestamp - 604800);
return false;
}
++idx;
}
logger.info(`${idx} blocks hash validated in ${new Date().getTime() - start} ms`);
return true;
} catch (e) {
logger.err('Cannot validate chain of block hash. Reason: ' + (e instanceof Error ? e.message : e));
return true; // Don't do anything if there is a db error
}
}
/**
* Delete blocks from the database from blockHeight
*/
public async $deleteBlocksFrom(blockHeight: number) {
logger.info(`Delete newer blocks from height ${blockHeight} from the database`);
try {
await DB.query(`DELETE FROM blocks where height >= ${blockHeight}`);
} catch (e) {
logger.err('Cannot delete indexed blocks. Reason: ' + (e instanceof Error ? e.message : e));
}
}
/**
* Get the historical averaged block fees
*/
public async $getHistoricalBlockFees(div: number, interval: string | null): Promise<any> {
try {
let query = `SELECT
CAST(AVG(height) as INT) as avgHeight,
CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp,
CAST(AVG(fees) as INT) as avgFees
FROM blocks`;
if (interval !== null) {
query += ` WHERE blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP BY UNIX_TIMESTAMP(blockTimestamp) DIV ${div}`;
const [rows]: any = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot generate block fees history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get the historical averaged block rewards
*/
public async $getHistoricalBlockRewards(div: number, interval: string | null): Promise<any> {
try {
let query = `SELECT
CAST(AVG(height) as INT) as avgHeight,
CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp,
CAST(AVG(reward) as INT) as avgRewards
FROM blocks`;
if (interval !== null) {
query += ` WHERE blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP BY UNIX_TIMESTAMP(blockTimestamp) DIV ${div}`;
const [rows]: any = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot generate block rewards history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get the historical averaged block fee rate percentiles
*/
public async $getHistoricalBlockFeeRates(div: number, interval: string | null): Promise<any> {
try {
let query = `SELECT
CAST(AVG(height) as INT) as avgHeight,
CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp,
CAST(AVG(JSON_EXTRACT(fee_span, '$[0]')) as INT) as avgFee_0,
CAST(AVG(JSON_EXTRACT(fee_span, '$[1]')) as INT) as avgFee_10,
CAST(AVG(JSON_EXTRACT(fee_span, '$[2]')) as INT) as avgFee_25,
CAST(AVG(JSON_EXTRACT(fee_span, '$[3]')) as INT) as avgFee_50,
CAST(AVG(JSON_EXTRACT(fee_span, '$[4]')) as INT) as avgFee_75,
CAST(AVG(JSON_EXTRACT(fee_span, '$[5]')) as INT) as avgFee_90,
CAST(AVG(JSON_EXTRACT(fee_span, '$[6]')) as INT) as avgFee_100
FROM blocks`;
if (interval !== null) {
query += ` WHERE blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP BY UNIX_TIMESTAMP(blockTimestamp) DIV ${div}`;
const [rows]: any = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot generate block fee rates history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get the historical averaged block sizes
*/
public async $getHistoricalBlockSizes(div: number, interval: string | null): Promise<any> {
try {
let query = `SELECT
CAST(AVG(height) as INT) as avgHeight,
CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp,
CAST(AVG(size) as INT) as avgSize
FROM blocks`;
if (interval !== null) {
query += ` WHERE blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP BY UNIX_TIMESTAMP(blockTimestamp) DIV ${div}`;
const [rows]: any = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot generate block size and weight history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get the historical averaged block weights
*/
public async $getHistoricalBlockWeights(div: number, interval: string | null): Promise<any> {
try {
let query = `SELECT
CAST(AVG(height) as INT) as avgHeight,
CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp,
CAST(AVG(weight) as INT) as avgWeight
FROM blocks`;
if (interval !== null) {
query += ` WHERE blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP BY UNIX_TIMESTAMP(blockTimestamp) DIV ${div}`;
const [rows]: any = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot generate block size and weight history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
}
export default new BlocksRepository();

View File

@@ -0,0 +1,217 @@
import { escape } from 'mysql2';
import { Common } from '../api/common';
import DB from '../database';
import logger from '../logger';
import PoolsRepository from './PoolsRepository';
class HashratesRepository {
/**
* Save indexed block data in the database
*/
public async $saveHashrates(hashrates: any) {
if (hashrates.length === 0) {
return;
}
let query = `INSERT INTO
hashrates(hashrate_timestamp, avg_hashrate, pool_id, share, type) VALUES`;
for (const hashrate of hashrates) {
query += ` (FROM_UNIXTIME(${hashrate.hashrateTimestamp}), ${hashrate.avgHashrate}, ${hashrate.poolId}, ${hashrate.share}, "${hashrate.type}"),`;
}
query = query.slice(0, -1);
try {
await DB.query(query);
} catch (e: any) {
logger.err('Cannot save indexed hashrate into db. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
public async $getNetworkDailyHashrate(interval: string | null): Promise<any[]> {
interval = Common.getSqlInterval(interval);
let query = `SELECT UNIX_TIMESTAMP(hashrate_timestamp) as timestamp, avg_hashrate as avgHashrate
FROM hashrates`;
if (interval) {
query += ` WHERE hashrate_timestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()
AND hashrates.type = 'daily'`;
} else {
query += ` WHERE hashrates.type = 'daily'`;
}
query += ` ORDER by hashrate_timestamp`;
try {
const [rows]: any[] = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot fetch network hashrate history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
public async $getWeeklyHashrateTimestamps(): Promise<number[]> {
const query = `SELECT UNIX_TIMESTAMP(hashrate_timestamp) as timestamp
FROM hashrates
WHERE type = 'weekly'
GROUP BY hashrate_timestamp`;
try {
const [rows]: any[] = await DB.query(query);
return rows.map(row => row.timestamp);
} catch (e) {
logger.err('Cannot retreive indexed weekly hashrate timestamps. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Returns the current biggest pool hashrate history
*/
public async $getPoolsWeeklyHashrate(interval: string | null): Promise<any[]> {
interval = Common.getSqlInterval(interval);
const topPoolsId = (await PoolsRepository.$getPoolsInfo('1w')).map((pool) => pool.poolId);
let query = `SELECT UNIX_TIMESTAMP(hashrate_timestamp) as timestamp, avg_hashrate as avgHashrate, share, pools.name as poolName
FROM hashrates
JOIN pools on pools.id = pool_id`;
if (interval) {
query += ` WHERE hashrate_timestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()
AND hashrates.type = 'weekly'
AND pool_id IN (${topPoolsId})`;
} else {
query += ` WHERE hashrates.type = 'weekly'
AND pool_id IN (${topPoolsId})`;
}
query += ` ORDER by hashrate_timestamp, FIELD(pool_id, ${topPoolsId})`;
try {
const [rows]: any[] = await DB.query(query);
return rows;
} catch (e) {
logger.err('Cannot fetch weekly pools hashrate history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Returns a pool hashrate history
*/
public async $getPoolWeeklyHashrate(slug: string): Promise<any[]> {
const pool = await PoolsRepository.$getPool(slug);
if (!pool) {
throw new Error('This mining pool does not exist ' + escape(slug));
}
// Find hashrate boundaries
let query = `SELECT MIN(hashrate_timestamp) as firstTimestamp, MAX(hashrate_timestamp) as lastTimestamp
FROM hashrates
JOIN pools on pools.id = pool_id
WHERE hashrates.type = 'weekly' AND pool_id = ? AND avg_hashrate != 0
ORDER by hashrate_timestamp LIMIT 1`;
let boundaries = {
firstTimestamp: '1970-01-01',
lastTimestamp: '9999-01-01'
};
try {
const [rows]: any[] = await DB.query(query, [pool.id]);
boundaries = rows[0];
} catch (e) {
logger.err('Cannot fetch hashrate start/end timestamps for this pool. Reason: ' + (e instanceof Error ? e.message : e));
}
// Get hashrates entries between boundaries
query = `SELECT UNIX_TIMESTAMP(hashrate_timestamp) as timestamp, avg_hashrate as avgHashrate, share, pools.name as poolName
FROM hashrates
JOIN pools on pools.id = pool_id
WHERE hashrates.type = 'weekly' AND hashrate_timestamp BETWEEN ? AND ?
AND pool_id = ?
ORDER by hashrate_timestamp`;
try {
const [rows]: any[] = await DB.query(query, [boundaries.firstTimestamp, boundaries.lastTimestamp, pool.id]);
return rows;
} catch (e) {
logger.err('Cannot fetch pool hashrate history for this pool. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Set latest run timestamp
*/
public async $setLatestRun(key: string, val: number) {
const query = `UPDATE state SET number = ? WHERE name = ?`;
try {
await DB.query(query, [val, key]);
} catch (e) {
logger.err(`Cannot set last indexing run for ${key}. Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get latest run timestamp
*/
public async $getLatestRun(key: string): Promise<number> {
const query = `SELECT number FROM state WHERE name = ?`;
try {
const [rows]: any[] = await DB.query(query, [key]);
if (rows.length === 0) {
return 0;
}
return rows[0]['number'];
} catch (e) {
logger.err(`Cannot retrieve last indexing run for ${key}. Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Delete most recent data points for re-indexing
*/
public async $deleteLastEntries() {
logger.info(`Delete latest hashrates data points from the database`);
try {
const [rows]: any[] = await DB.query(`SELECT MAX(hashrate_timestamp) as timestamp FROM hashrates GROUP BY type`);
for (const row of rows) {
await DB.query(`DELETE FROM hashrates WHERE hashrate_timestamp = ?`, [row.timestamp]);
}
// Re-run the hashrate indexing to fill up missing data
await this.$setLatestRun('last_hashrates_indexing', 0);
await this.$setLatestRun('last_weekly_hashrates_indexing', 0);
} catch (e) {
logger.err('Cannot delete latest hashrates data points. Reason: ' + (e instanceof Error ? e.message : e));
}
}
/**
* Delete hashrates from the database from timestamp
*/
public async $deleteHashratesFromTimestamp(timestamp: number) {
logger.info(`Delete newer hashrates from timestamp ${new Date(timestamp * 1000).toUTCString()} from the database`);
try {
await DB.query(`DELETE FROM hashrates WHERE hashrate_timestamp >= FROM_UNIXTIME(?)`, [timestamp]);
// Re-run the hashrate indexing to fill up missing data
await this.$setLatestRun('last_hashrates_indexing', 0);
await this.$setLatestRun('last_weekly_hashrates_indexing', 0);
} catch (e) {
logger.err('Cannot delete latest hashrates data points. Reason: ' + (e instanceof Error ? e.message : e));
}
}
}
export default new HashratesRepository();

View File

@@ -0,0 +1,99 @@
import { Common } from '../api/common';
import config from '../config';
import DB from '../database';
import logger from '../logger';
import { PoolInfo, PoolTag } from '../mempool.interfaces';
class PoolsRepository {
/**
* Get all pools tagging info
*/
public async $getPools(): Promise<PoolTag[]> {
const [rows] = await DB.query('SELECT id, name, addresses, regexes, slug FROM pools;');
return <PoolTag[]>rows;
}
/**
* Get unknown pool tagging info
*/
public async $getUnknownPool(): Promise<PoolTag> {
const [rows] = await DB.query('SELECT id, name, slug FROM pools where name = "Unknown"');
return <PoolTag>rows[0];
}
/**
* Get basic pool info and block count
*/
public async $getPoolsInfo(interval: string | null = null): Promise<PoolInfo[]> {
interval = Common.getSqlInterval(interval);
let query = `SELECT COUNT(height) as blockCount, pool_id as poolId, pools.name as name, pools.link as link, slug
FROM blocks
JOIN pools on pools.id = pool_id`;
if (interval) {
query += ` WHERE blocks.blockTimestamp BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW()`;
}
query += ` GROUP BY pool_id
ORDER BY COUNT(height) DESC`;
try {
const [rows] = await DB.query(query);
return <PoolInfo[]>rows;
} catch (e) {
logger.err(`Cannot generate pools stats. Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get basic pool info and block count between two timestamp
*/
public async $getPoolsInfoBetween(from: number, to: number): Promise<PoolInfo[]> {
const query = `SELECT COUNT(height) as blockCount, pools.id as poolId, pools.name as poolName
FROM pools
LEFT JOIN blocks on pools.id = blocks.pool_id AND blocks.blockTimestamp BETWEEN FROM_UNIXTIME(?) AND FROM_UNIXTIME(?)
GROUP BY pools.id`;
try {
const [rows] = await DB.query(query, [from, to]);
return <PoolInfo[]>rows;
} catch (e) {
logger.err('Cannot generate pools blocks count. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get mining pool statistics for one pool
*/
public async $getPool(slug: string): Promise<PoolTag | null> {
const query = `
SELECT *
FROM pools
WHERE pools.slug = ?`;
try {
const [rows]: any[] = await DB.query(query, [slug]);
if (rows.length < 1) {
return null;
}
rows[0].regexes = JSON.parse(rows[0].regexes);
if (['testnet', 'signet'].includes(config.MEMPOOL.NETWORK)) {
rows[0].addresses = []; // pools.json only contains mainnet addresses
} else {
rows[0].addresses = JSON.parse(rows[0].addresses);
}
return rows[0];
} catch (e) {
logger.err('Cannot get pool from db. Reason: ' + (e instanceof Error ? e.message : e));
throw e;
}
}
}
export default new PoolsRepository();

View File

@@ -0,0 +1,21 @@
import DB from '../database';
import logger from '../logger';
import { IConversionRates } from '../mempool.interfaces';
class RatesRepository {
public async $saveRate(height: number, rates: IConversionRates) {
try {
await DB.query(`INSERT INTO rates(height, bisq_rates) VALUE (?, ?)`, [height, JSON.stringify(rates)]);
} catch (e: any) {
if (e.errno === 1062) { // ER_DUP_ENTRY - This scenario is possible upon node backend restart
logger.debug(`Rate already exists for block ${height}, ignoring`);
} else {
logger.err(`Cannot save exchange rate into db for block ${height} Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
}
}
export default new RatesRepository();

View File

@@ -19,45 +19,61 @@ import loadingIndicators from './api/loading-indicators';
import { Common } from './api/common';
import bitcoinClient from './api/bitcoin/bitcoin-client';
import elementsParser from './api/liquid/elements-parser';
import icons from './api/liquid/icons';
import miningStats from './api/mining';
import axios from 'axios';
import mining from './api/mining';
import BlocksRepository from './repositories/BlocksRepository';
import HashratesRepository from './repositories/HashratesRepository';
import difficultyAdjustment from './api/difficulty-adjustment';
class Routes {
constructor() {}
public async get2HStatistics(req: Request, res: Response) {
const result = await statistics.$list2H();
res.json(result);
}
public async $getStatisticsByTime(time: '2h' | '24h' | '1w' | '1m' | '3m' | '6m' | '1y' | '2y' | '3y', req: Request, res: Response) {
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
public get24HStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['24h']);
}
public get1WHStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['1w']);
}
public get1MStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['1m']);
}
public get3MStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['3m']);
}
public get6MStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['6m']);
}
public get1YStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['1y']);
}
public get2YStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['2y']);
}
public get3YStatistics(req: Request, res: Response) {
res.json(statistics.getCache()['3y']);
try {
let result;
switch (time as string) {
case '2h':
result = await statistics.$list2H();
res.setHeader('Expires', new Date(Date.now() + 1000 * 30).toUTCString());
break;
case '24h':
result = await statistics.$list24H();
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
break;
case '1w':
result = await statistics.$list1W();
break;
case '1m':
result = await statistics.$list1M();
break;
case '3m':
result = await statistics.$list3M();
break;
case '6m':
result = await statistics.$list6M();
break;
case '1y':
result = await statistics.$list1Y();
break;
case '2y':
result = await statistics.$list2Y();
break;
case '3y':
result = await statistics.$list3Y();
break;
default:
result = await statistics.$list2H();
}
res.json(result);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public getInitData(req: Request, res: Response) {
@@ -69,7 +85,7 @@ class Routes {
}
}
public async getRecommendedFees(req: Request, res: Response) {
public getRecommendedFees(req: Request, res: Response) {
if (!mempool.isInSync()) {
res.statusCode = 503;
res.send('Service Unavailable');
@@ -521,10 +537,180 @@ class Routes {
}
}
public async $getPool(req: Request, res: Response) {
try {
const stats = await mining.$getPoolStat(req.params.slug);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(stats);
} catch (e) {
if (e instanceof Error && e.message.indexOf('This mining pool does not exist') > -1) {
res.status(404).send(e.message);
} else {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
}
public async $getPoolBlocks(req: Request, res: Response) {
try {
const poolBlocks = await BlocksRepository.$getBlocksByPool(
req.params.slug,
req.params.height === undefined ? undefined : parseInt(req.params.height, 10),
);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(poolBlocks);
} catch (e) {
if (e instanceof Error && e.message.indexOf('This mining pool does not exist') > -1) {
res.status(404).send(e.message);
} else {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
}
public async $getPools(req: Request, res: Response) {
try {
const stats = await miningStats.$getPoolsStats(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(stats);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async $getPoolsHistoricalHashrate(req: Request, res: Response) {
try {
const hashrates = await HashratesRepository.$getPoolsWeeklyHashrate(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
res.json(hashrates);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async $getPoolHistoricalHashrate(req: Request, res: Response) {
try {
const hashrates = await HashratesRepository.$getPoolWeeklyHashrate(req.params.slug);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
res.json(hashrates);
} catch (e) {
if (e instanceof Error && e.message.indexOf('This mining pool does not exist') > -1) {
res.status(404).send(e.message);
} else {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
}
public async $getHistoricalHashrate(req: Request, res: Response) {
let currentHashrate = 0, currentDifficulty = 0;
try {
currentHashrate = await bitcoinClient.getNetworkHashPs();
currentDifficulty = await bitcoinClient.getDifficulty();
} catch (e) {
logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate and difficulty');
}
try {
const hashrates = await HashratesRepository.$getNetworkDailyHashrate(req.params.interval);
const difficulty = await BlocksRepository.$getBlocksDifficulty(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
res.json({
hashrates: hashrates,
difficulty: difficulty,
currentHashrate: currentHashrate,
currentDifficulty: currentDifficulty,
});
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async $getHistoricalBlockFees(req: Request, res: Response) {
try {
const blockFees = await mining.$getHistoricalBlockFees(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(blockFees);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async $getHistoricalBlockRewards(req: Request, res: Response) {
try {
const blockRewards = await mining.$getHistoricalBlockRewards(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(blockRewards);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async $getHistoricalBlockFeeRates(req: Request, res: Response) {
try {
const blockFeeRates = await mining.$getHistoricalBlockFeeRates(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(blockFeeRates);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async $getHistoricalBlockSizeAndWeight(req: Request, res: Response) {
try {
const blockSizes = await mining.$getHistoricalBlockSizes(req.params.interval);
const blockWeights = await mining.$getHistoricalBlockWeights(req.params.interval);
const blockCount = await BlocksRepository.$blockCount(null, null);
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.header('X-total-count', blockCount.toString());
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json({
sizes: blockSizes,
weights: blockWeights
});
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async getBlock(req: Request, res: Response) {
try {
const result = await bitcoinApi.$getBlock(req.params.hash);
res.json(result);
const block = await blocks.$getBlock(req.params.hash);
res.setHeader('Expires', new Date(Date.now() + 1000 * 600).toUTCString());
res.json(block);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
@@ -542,8 +728,20 @@ class Routes {
public async getBlocks(req: Request, res: Response) {
try {
loadingIndicators.setProgress('blocks', 0);
if (['mainnet', 'testnet', 'signet', 'regtest'].includes(config.MEMPOOL.NETWORK)) { // Bitcoin
const height = req.params.height === undefined ? undefined : parseInt(req.params.height, 10);
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(await blocks.$getBlocks(height, 15));
} else { // Liquid, Bisq
return await this.getLegacyBlocks(req, res);
}
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async getLegacyBlocks(req: Request, res: Response) {
try {
const returnBlocks: IEsploraApi.Block[] = [];
const fromHeight = parseInt(req.params.height, 10) || blocks.getCurrentBlockHeight();
@@ -557,7 +755,7 @@ class Routes {
}
let nextHash = startFromHash;
for (let i = 0; i < 10; i++) {
for (let i = 0; i < 10 && nextHash; i++) {
const localBlock = blocks.getBlocks().find((b) => b.id === nextHash);
if (localBlock) {
returnBlocks.push(localBlock);
@@ -567,16 +765,15 @@ class Routes {
returnBlocks.push(block);
nextHash = block.previousblockhash;
}
loadingIndicators.setProgress('blocks', i / 10 * 100);
}
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(returnBlocks);
} catch (e) {
loadingIndicators.setProgress('blocks', 100);
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public async getBlockTransactions(req: Request, res: Response) {
try {
loadingIndicators.setProgress('blocktxs-' + req.params.hash, 0);
@@ -588,9 +785,9 @@ class Routes {
const endIndex = Math.min(startingIndex + 10, txIds.length);
for (let i = startingIndex; i < endIndex; i++) {
try {
const transaction = await transactionUtils.$getTransactionExtended(txIds[i], true);
const transaction = await transactionUtils.$getTransactionExtended(txIds[i], true, true);
transactions.push(transaction);
loadingIndicators.setProgress('blocktxs-' + req.params.hash, (i + 1) / endIndex * 100);
loadingIndicators.setProgress('blocktxs-' + req.params.hash, (i - startingIndex + 1) / (endIndex - startingIndex) * 100);
} catch (e) {
logger.debug('getBlockTransactions error: ' + (e instanceof Error ? e.message : e));
}
@@ -667,7 +864,13 @@ class Routes {
}
public async getMempool(req: Request, res: Response) {
res.status(501).send('Not implemented');
const info = mempool.getMempoolInfo();
res.json({
count: info.size,
vsize: info.bytes,
total_fee: info.total_fee * 1e8,
fee_histogram: []
});
}
public async getMempoolTxIds(req: Request, res: Response) {
@@ -706,61 +909,18 @@ class Routes {
}
}
public getTransactionOutspends(req: Request, res: Response) {
res.status(501).send('Not implemented');
public async getTransactionOutspends(req: Request, res: Response) {
try {
const result = await bitcoinApi.$getOutspends(req.params.txId);
res.json(result);
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
}
public getDifficultyChange(req: Request, res: Response) {
try {
const DATime = blocks.getLastDifficultyAdjustmentTime();
const previousRetarget = blocks.getPreviousDifficultyRetarget();
const blockHeight = blocks.getCurrentBlockHeight();
const now = new Date().getTime() / 1000;
const diff = now - DATime;
const blocksInEpoch = blockHeight % 2016;
const progressPercent = (blocksInEpoch >= 0) ? blocksInEpoch / 2016 * 100 : 100;
const remainingBlocks = 2016 - blocksInEpoch;
const nextRetargetHeight = blockHeight + remainingBlocks;
let difficultyChange = 0;
if (remainingBlocks < 1870) {
if (blocksInEpoch > 0) {
difficultyChange = (600 / (diff / blocksInEpoch ) - 1) * 100;
}
if (difficultyChange > 300) {
difficultyChange = 300;
}
if (difficultyChange < -75) {
difficultyChange = -75;
}
}
const timeAvgDiff = difficultyChange * 0.1;
let timeAvgMins = 10;
if (timeAvgDiff > 0) {
timeAvgMins -= Math.abs(timeAvgDiff);
} else {
timeAvgMins += Math.abs(timeAvgDiff);
}
const timeAvg = timeAvgMins * 60;
const remainingTime = remainingBlocks * timeAvg;
const estimatedRetargetDate = remainingTime + now;
const result = {
progressPercent,
difficultyChange,
estimatedRetargetDate,
remainingBlocks,
remainingTime,
previousRetarget,
nextRetargetHeight,
timeAvg,
};
res.json(result);
res.json(difficultyAdjustment.getDifficultyAdjustment());
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}
@@ -807,6 +967,55 @@ class Routes {
: (e.message || 'Error'));
}
}
public getLiquidIcon(req: Request, res: Response) {
const result = icons.getIconByAssetId(req.params.assetId);
if (result) {
res.setHeader('content-type', 'image/png');
res.setHeader('content-length', result.length);
res.send(result);
} else {
res.status(404).send('Asset icon not found');
}
}
public getAllLiquidIcon(req: Request, res: Response) {
const result = icons.getAllIconIds();
if (result) {
res.json(result);
} else {
res.status(404).send('Asset icons not found');
}
}
public async $getAllFeaturedLiquidAssets(req: Request, res: Response) {
try {
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.LIQUID_API}/assets/featured`, { responseType: 'stream', timeout: 10000 });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
}
}
public async $getAssetGroup(req: Request, res: Response) {
try {
const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.LIQUID_API}/assets/group/${parseInt(req.params.id, 10)}`,
{ responseType: 'stream', timeout: 10000 });
response.data.pipe(res);
} catch (e) {
res.status(500).end();
}
}
public async $getRewardStats(req: Request, res: Response) {
try {
const response = await mining.$getRewardStats(parseInt(req.params.blockCount, 10));
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
res.json(response);
} catch (e) {
res.status(500).end();
}
}
}
export default new Routes();

View File

@@ -0,0 +1,92 @@
module.exports = {
addMultiSigAddress: 'addmultisigaddress',
addNode: 'addnode', // bitcoind v0.8.0+
backupWallet: 'backupwallet',
createMultiSig: 'createmultisig',
createRawTransaction: 'createrawtransaction', // bitcoind v0.7.0+
decodeRawTransaction: 'decoderawtransaction', // bitcoind v0.7.0+
decodeScript: 'decodescript',
dumpPrivKey: 'dumpprivkey',
dumpWallet: 'dumpwallet', // bitcoind v0.9.0+
encryptWallet: 'encryptwallet',
estimateFee: 'estimatefee', // bitcoind v0.10.0x
estimatePriority: 'estimatepriority', // bitcoind v0.10.0+
generate: 'generate', // bitcoind v0.11.0+
getAccount: 'getaccount',
getAccountAddress: 'getaccountaddress',
getAddedNodeInfo: 'getaddednodeinfo', // bitcoind v0.8.0+
getAddressesByAccount: 'getaddressesbyaccount',
getBalance: 'getbalance',
getBestBlockHash: 'getbestblockhash', // bitcoind v0.9.0+
getBlock: 'getblock',
getBlockStats: 'getblockstats',
getBlockFilter: 'getblockfilter',
getBlockchainInfo: 'getblockchaininfo', // bitcoind v0.9.2+
getBlockCount: 'getblockcount',
getBlockHash: 'getblockhash',
getBlockHeader: 'getblockheader',
getBlockTemplate: 'getblocktemplate', // bitcoind v0.7.0+
getChainTips: 'getchaintips', // bitcoind v0.10.0+
getChainTxStats: 'getchaintxstats',
getConnectionCount: 'getconnectioncount',
getDifficulty: 'getdifficulty',
getGenerate: 'getgenerate',
getInfo: 'getinfo',
getMempoolAncestors: 'getmempoolancestors',
getMempoolDescendants: 'getmempooldescendants',
getMempoolEntry: 'getmempoolentry',
getMempoolInfo: 'getmempoolinfo', // bitcoind v0.10+
getMiningInfo: 'getmininginfo',
getNetTotals: 'getnettotals',
getNetworkInfo: 'getnetworkinfo', // bitcoind v0.9.2+
getNetworkHashPs: 'getnetworkhashps', // bitcoind v0.9.0+
getNewAddress: 'getnewaddress',
getPeerInfo: 'getpeerinfo', // bitcoind v0.7.0+
getRawChangeAddress: 'getrawchangeaddress', // bitcoin v0.9+
getRawMemPool: 'getrawmempool', // bitcoind v0.7.0+
getRawTransaction: 'getrawtransaction', // bitcoind v0.7.0+
getReceivedByAccount: 'getreceivedbyaccount',
getReceivedByAddress: 'getreceivedbyaddress',
getTransaction: 'gettransaction',
getTxOut: 'gettxout', // bitcoind v0.7.0+
getTxOutProof: 'gettxoutproof', // bitcoind v0.11.0+
getTxOutSetInfo: 'gettxoutsetinfo', // bitcoind v0.7.0+
getUnconfirmedBalance: 'getunconfirmedbalance', // bitcoind v0.9.0+
getWalletInfo: 'getwalletinfo', // bitcoind v0.9.2+
help: 'help',
importAddress: 'importaddress', // bitcoind v0.10.0+
importPrivKey: 'importprivkey',
importWallet: 'importwallet', // bitcoind v0.9.0+
keypoolRefill: 'keypoolrefill',
keyPoolRefill: 'keypoolrefill',
listAccounts: 'listaccounts',
listAddressGroupings: 'listaddressgroupings', // bitcoind v0.7.0+
listLockUnspent: 'listlockunspent', // bitcoind v0.8.0+
listReceivedByAccount: 'listreceivedbyaccount',
listReceivedByAddress: 'listreceivedbyaddress',
listSinceBlock: 'listsinceblock',
listTransactions: 'listtransactions',
listUnspent: 'listunspent', // bitcoind v0.7.0+
lockUnspent: 'lockunspent', // bitcoind v0.8.0+
move: 'move',
ping: 'ping', // bitcoind v0.9.0+
prioritiseTransaction: 'prioritisetransaction', // bitcoind v0.10.0+
sendFrom: 'sendfrom',
sendMany: 'sendmany',
sendRawTransaction: 'sendrawtransaction', // bitcoind v0.7.0+
sendToAddress: 'sendtoaddress',
setAccount: 'setaccount',
setGenerate: 'setgenerate',
setTxFee: 'settxfee',
signMessage: 'signmessage',
signRawTransaction: 'signrawtransaction', // bitcoind v0.7.0+
stop: 'stop',
submitBlock: 'submitblock', // bitcoind v0.7.0+
validateAddress: 'validateaddress',
verifyChain: 'verifychain', // bitcoind v0.9.0+
verifyMessage: 'verifymessage',
verifyTxOutProof: 'verifytxoutproof', // bitcoind v0.11.0+
walletLock: 'walletlock',
walletPassphrase: 'walletpassphrase',
walletPassphraseChange: 'walletpassphrasechange'
}

View File

@@ -0,0 +1,61 @@
var commands = require('./commands')
var rpc = require('./jsonrpc')
// ===----------------------------------------------------------------------===//
// JsonRPC
// ===----------------------------------------------------------------------===//
function Client (opts) {
// @ts-ignore
this.rpc = new rpc.JsonRPC(opts)
}
// ===----------------------------------------------------------------------===//
// cmd
// ===----------------------------------------------------------------------===//
Client.prototype.cmd = function () {
var args = [].slice.call(arguments)
var cmd = args.shift()
callRpc(cmd, args, this.rpc)
}
// ===----------------------------------------------------------------------===//
// callRpc
// ===----------------------------------------------------------------------===//
function callRpc (cmd, args, rpc) {
var fn = args[args.length - 1]
// If the last argument is a callback, pop it from the args list
if (typeof fn === 'function') {
args.pop()
} else {
fn = function () {}
}
return rpc.call(cmd, args, function () {
var args = [].slice.call(arguments)
// @ts-ignore
args.unshift(null)
// @ts-ignore
fn.apply(this, args)
}, function (err) {
fn(err)
})
}
// ===----------------------------------------------------------------------===//
// Initialize wrappers
// ===----------------------------------------------------------------------===//
(function () {
for (var protoFn in commands) {
(function (protoFn) {
Client.prototype[protoFn] = function () {
var args = [].slice.call(arguments)
return callRpc(commands[protoFn], args, this.rpc)
}
})(protoFn)
}
})()
// Export!
module.exports.Client = Client;

View File

@@ -0,0 +1,162 @@
var http = require('http')
var https = require('https')
var JsonRPC = function (opts) {
// @ts-ignore
this.opts = opts || {}
// @ts-ignore
this.http = this.opts.ssl ? https : http
}
JsonRPC.prototype.call = function (method, params) {
return new Promise((resolve, reject) => {
var time = Date.now()
var requestJSON
if (Array.isArray(method)) {
// multiple rpc batch call
requestJSON = []
method.forEach(function (batchCall, i) {
requestJSON.push({
id: time + '-' + i,
method: batchCall.method,
params: batchCall.params
})
})
} else {
// single rpc call
requestJSON = {
id: time,
method: method,
params: params
}
}
// First we encode the request into JSON
requestJSON = JSON.stringify(requestJSON)
// prepare request options
var requestOptions = {
host: this.opts.host || 'localhost',
port: this.opts.port || 8332,
method: 'POST',
path: '/',
headers: {
'Host': this.opts.host || 'localhost',
'Content-Length': requestJSON.length
},
agent: false,
rejectUnauthorized: this.opts.ssl && this.opts.sslStrict !== false
}
if (this.opts.ssl && this.opts.sslCa) {
// @ts-ignore
requestOptions.ca = this.opts.sslCa
}
// use HTTP auth if user and password set
if (this.opts.user && this.opts.pass) {
// @ts-ignore
requestOptions.auth = this.opts.user + ':' + this.opts.pass
}
// Now we'll make a request to the server
var cbCalled = false
var request = this.http.request(requestOptions)
// start request timeout timer
var reqTimeout = setTimeout(function () {
if (cbCalled) return
cbCalled = true
request.abort()
var err = new Error('ETIMEDOUT')
// @ts-ignore
err.code = 'ETIMEDOUT'
reject(err)
}, this.opts.timeout || 30000)
// set additional timeout on socket in case of remote freeze after sending headers
request.setTimeout(this.opts.timeout || 30000, function () {
if (cbCalled) return
cbCalled = true
request.abort()
var err = new Error('ESOCKETTIMEDOUT')
// @ts-ignore
err.code = 'ESOCKETTIMEDOUT'
reject(err)
})
request.on('error', function (err) {
if (cbCalled) return
cbCalled = true
clearTimeout(reqTimeout)
reject(err)
})
request.on('response', function (response) {
clearTimeout(reqTimeout)
// We need to buffer the response chunks in a nonblocking way.
var buffer = ''
response.on('data', function (chunk) {
buffer = buffer + chunk
})
// When all the responses are finished, we decode the JSON and
// depending on whether it's got a result or an error, we call
// emitSuccess or emitError on the promise.
response.on('end', function () {
var err
if (cbCalled) return
cbCalled = true
try {
var decoded = JSON.parse(buffer)
} catch (e) {
if (response.statusCode !== 200) {
err = new Error('Invalid params, response status code: ' + response.statusCode)
err.code = -32602
reject(err)
} else {
err = new Error('Problem parsing JSON response from server')
err.code = -32603
reject(err)
}
return
}
if (!Array.isArray(decoded)) {
decoded = [decoded]
}
// iterate over each response, normally there will be just one
// unless a batch rpc call response is being processed
decoded.forEach(function (decodedResponse, i) {
if (decodedResponse.hasOwnProperty('error') && decodedResponse.error != null) {
if (reject) {
err = new Error(decodedResponse.error.message || '')
if (decodedResponse.error.code) {
err.code = decodedResponse.error.code
}
reject(err)
}
} else if (decodedResponse.hasOwnProperty('result')) {
// @ts-ignore
resolve(decodedResponse.result, response.headers)
} else {
if (reject) {
err = new Error(decodedResponse.error.message || '')
if (decodedResponse.error.code) {
err.code = decodedResponse.error.code
}
reject(err)
}
}
})
})
})
request.end(requestJSON);
});
}
module.exports.JsonRPC = JsonRPC

View File

@@ -0,0 +1,85 @@
import axios, { AxiosResponse } from 'axios';
import * as fs from 'fs';
import config from './config';
import backendInfo from './api/backend-info';
import logger from './logger';
import { SocksProxyAgent } from 'socks-proxy-agent';
const PATH = './';
class SyncAssets {
constructor() { }
public async syncAssets$() {
for (const url of config.MEMPOOL.EXTERNAL_ASSETS) {
try {
await this.downloadFile$(url);
} catch (e) {
throw new Error(`Failed to download external asset. ` + (e instanceof Error ? e.message : e));
}
}
}
private async downloadFile$(url: string) {
return new Promise((resolve, reject) => {
const fileName = url.split('/').slice(-1)[0];
try {
if (config.SOCKS5PROXY.ENABLED) {
const socksOptions: any = {
agentOptions: {
keepAlive: true,
},
hostname: config.SOCKS5PROXY.HOST,
port: config.SOCKS5PROXY.PORT
};
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
socksOptions.username = config.SOCKS5PROXY.USERNAME;
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
}
const agent = new SocksProxyAgent(socksOptions);
logger.info(`Downloading external asset ${fileName} over the Tor network...`);
return axios.get(url, {
headers: {
'User-Agent': (config.MEMPOOL.USER_AGENT === 'mempool') ? `mempool/v${backendInfo.getBackendInfo().version}` : `${config.MEMPOOL.USER_AGENT}`
},
httpAgent: agent,
httpsAgent: agent,
responseType: 'stream',
timeout: 30000
}).then(function (response) {
const writer = fs.createWriteStream(PATH + fileName);
writer.on('finish', () => {
logger.info(`External asset ${fileName} saved to ${PATH + fileName}`);
resolve(0);
});
response.data.pipe(writer);
});
} else {
logger.info(`Downloading external asset ${fileName} over clearnet...`);
return axios.get(url, {
headers: {
'User-Agent': (config.MEMPOOL.USER_AGENT === 'mempool') ? `mempool/v${backendInfo.getBackendInfo().version}` : `${config.MEMPOOL.USER_AGENT}`
},
responseType: 'stream',
timeout: 30000
}).then(function (response) {
const writer = fs.createWriteStream(PATH + fileName);
writer.on('finish', () => {
logger.info(`External asset ${fileName} saved to ${PATH + fileName}`);
resolve(0);
});
response.data.pipe(writer);
});
}
} catch (e: any) {
reject(e);
}
});
}
}
export default new SyncAssets();

View File

@@ -0,0 +1,175 @@
import axios, { AxiosResponse } from 'axios';
import poolsParser from '../api/pools-parser';
import config from '../config';
import DB from '../database';
import backendInfo from '../api/backend-info';
import logger from '../logger';
import { SocksProxyAgent } from 'socks-proxy-agent';
import * as https from 'https';
/**
* Maintain the most recent version of pools.json
*/
class PoolsUpdater {
lastRun: number = 0;
currentSha: any = undefined;
constructor() {
}
public async updatePoolsJson() {
if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) {
return;
}
const oneWeek = 604800;
const oneDay = 86400;
const now = new Date().getTime() / 1000;
if (now - this.lastRun < oneWeek) { // Execute the PoolsUpdate only once a week, or upon restart
return;
}
this.lastRun = now;
logger.info('Updating latest mining pools from Github');
if (config.SOCKS5PROXY.ENABLED) {
logger.info('List of public pools will be queried over the Tor network');
} else {
logger.info('List of public pools will be queried over clearnet');
}
try {
const githubSha = await this.fetchPoolsSha(); // Fetch pools.json sha from github
if (githubSha === undefined) {
return;
}
if (config.DATABASE.ENABLED === true) {
this.currentSha = await this.getShaFromDb();
}
logger.debug(`Pools.json sha | Current: ${this.currentSha} | Github: ${githubSha}`);
if (this.currentSha !== undefined && this.currentSha === githubSha) {
return;
}
logger.warn('Pools.json is outdated, fetch latest from github');
const poolsJson = await this.query('https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json');
if (poolsJson === undefined) {
return;
}
await poolsParser.migratePoolsJson(poolsJson);
await this.updateDBSha(githubSha);
logger.notice('PoolsUpdater completed');
} catch (e) {
this.lastRun = now - (oneWeek - oneDay); // Try again in 24h instead of waiting next week
logger.err('PoolsUpdater failed. Will try again in 24h. Reason: ' + (e instanceof Error ? e.message : e));
}
}
/**
* Fetch our latest pools.json sha from the db
*/
private async updateDBSha(githubSha: string) {
this.currentSha = githubSha;
if (config.DATABASE.ENABLED === true) {
try {
await DB.query('DELETE FROM state where name="pools_json_sha"');
await DB.query(`INSERT INTO state VALUES('pools_json_sha', NULL, '${githubSha}')`);
} catch (e) {
logger.err('Cannot save github pools.json sha into the db. Reason: ' + (e instanceof Error ? e.message : e));
}
}
}
/**
* Fetch our latest pools.json sha from the db
*/
private async getShaFromDb(): Promise<string | undefined> {
try {
const [rows]: any[] = await DB.query('SELECT string FROM state WHERE name="pools_json_sha"');
return (rows.length > 0 ? rows[0].string : undefined);
} catch (e) {
logger.err('Cannot fetch pools.json sha from db. Reason: ' + (e instanceof Error ? e.message : e));
return undefined;
}
}
/**
* Fetch our latest pools.json sha from github
*/
private async fetchPoolsSha(): Promise<string | undefined> {
const response = await this.query('https://api.github.com/repos/mempool/mining-pools/git/trees/master');
if (response !== undefined) {
for (const file of response['tree']) {
if (file['path'] === 'pools.json') {
return file['sha'];
}
}
}
logger.err('Cannot to find latest pools.json sha from github api response');
return undefined;
}
/**
* Http request wrapper
*/
private async query(path): Promise<object | undefined> {
type axiosOptions = {
headers: {
'User-Agent': string
};
timeout: number;
httpsAgent?: https.Agent;
}
const setDelay = (secs: number = 1): Promise<void> => new Promise(resolve => setTimeout(() => resolve(), secs * 1000));
const axiosOptions: axiosOptions = {
headers: {
'User-Agent': (config.MEMPOOL.USER_AGENT === 'mempool') ? `mempool/v${backendInfo.getBackendInfo().version}` : `${config.MEMPOOL.USER_AGENT}`
},
timeout: config.SOCKS5PROXY.ENABLED ? 30000 : 10000
};
let retry = 0;
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
if (config.SOCKS5PROXY.ENABLED) {
const socksOptions: any = {
agentOptions: {
keepAlive: true,
},
hostname: config.SOCKS5PROXY.HOST,
port: config.SOCKS5PROXY.PORT
};
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
socksOptions.username = config.SOCKS5PROXY.USERNAME;
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
} else {
// Retry with different tor circuits https://stackoverflow.com/a/64960234
socksOptions.username = `circuit${retry}`;
}
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
}
const data: AxiosResponse = await axios.get(path, axiosOptions);
if (data.statusText === 'error' || !data.data) {
throw new Error(`Could not fetch data from Github, Error: ${data.status}`);
}
return data.data;
} catch (e) {
logger.err('Could not connect to Github. Reason: ' + (e instanceof Error ? e.message : e));
retry++;
}
await setDelay(config.MEMPOOL.EXTERNAL_RETRY_INTERVAL);
}
return undefined;
}
}
export default new PoolsUpdater();

View File

@@ -0,0 +1,32 @@
import { BlockExtended } from '../mempool.interfaces';
export function prepareBlock(block: any): BlockExtended {
return <BlockExtended>{
id: block.id ?? block.hash, // hash for indexed block
timestamp: block.timestamp ?? block.blockTimestamp, // blockTimestamp for indexed block
height: block.height,
version: block.version,
bits: block.bits,
nonce: block.nonce,
difficulty: block.difficulty,
merkle_root: block.merkle_root,
tx_count: block.tx_count,
size: block.size,
weight: block.weight,
previousblockhash: block.previousblockhash,
extras: {
coinbaseRaw: block.coinbase_raw ?? block.extras?.coinbaseRaw,
medianFee: block.medianFee ?? block.median_fee ?? block.extras?.medianFee,
feeRange: block.feeRange ?? block.fee_span,
reward: block.reward ?? block?.extras?.reward,
totalFees: block.totalFees ?? block?.fees ?? block?.extras?.totalFees,
avgFee: block?.extras?.avgFee ?? block.avg_fee,
avgFeeRate: block?.avgFeeRate ?? block.avg_fee_rate,
pool: block?.extras?.pool ?? (block?.pool_id ? {
id: block.pool_id,
name: block.pool_name,
slug: block.pool_slug,
} : undefined),
}
};
}

View File

@@ -10,7 +10,8 @@
"moduleResolution": "node",
"typeRoots": [
"node_modules/@types"
]
],
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*.ts"

3
contributors/TechMiX.txt Normal file
View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: TechMiX

View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: antonilol

View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of May 15, 2022.
Signed: ayanamidev

3
contributors/bosch-0.txt Normal file
View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: Bosch-0

3
contributors/dsbaars.txt Normal file
View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: dsbaars

1
contributors/emzy.txt Normal file
View File

@@ -0,0 +1 @@
Mempool Space K.K. has a signed CLA or other agreement on file with @emzy as of January 25, 2022

1
contributors/hunicus.txt Normal file
View File

@@ -0,0 +1 @@
Mempool Space K.K. has a signed CLA or other agreement on file with @hunicus as of January 25, 2022

View File

@@ -0,0 +1 @@
Mempool Space K.K. has a signed CLA or other agreement on file with @knorrium as of January 25, 2022

View File

@@ -0,0 +1 @@
Mempool Space K.K. has a signed CLA or other agreement on file with @miguelmedeiros as of January 25, 2022

View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of May 31, 2022.
Signed: mononaut

View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of March 11, 2022.
Signed: naveensrinivasan

View File

@@ -0,0 +1 @@
Mempool Space K.K. has a signed CLA or other agreement on file with @nymkappa as of January 25, 2022

View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: softsimon

3
contributors/wiz.txt Normal file
View File

@@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: wiz

View File

@@ -1,101 +1,346 @@
# Docker
# Docker Installation
## Initialization
This directory contains the Dockerfiles used to build and release the official images, as well as a `docker-compose.yml` to configure environment variables and other settings.
In an empty dir create 2 sub-dirs
If you are looking to use these Docker images to deploy your own instance of Mempool, note that they only containerize Mempool's frontend and backend. You will still need to deploy and configure Bitcoin Core and an Electrum Server separately, along with any other utilities specific to your use case (e.g., a reverse proxy, etc). Such configuration is mostly beyond the scope of the Mempool project, so please only proceed if you know what you're doing.
```bash
mkdir -p data mysql/data mysql/db-scripts
Jump to a section in this doc:
- [Configure with Bitcoin Core Only](#configure-with-bitcoin-core-only)
- [Configure with Bitcoin Core + Electrum Server](#configure-with-bitcoin-core--electrum-server)
- [Further Configuration](#further-configuration)
## Configure with Bitcoin Core Only
_Note: address lookups require an Electrum Server and will not work with this configuration. [Add an Electrum Server](#configure-with-bitcoin-core--electrum-server) to your backend for full functionality._
The default Docker configuration assumes you have the following configuration in your `bitcoin.conf` file:
```
txindex=1
server=1
rpcuser=mempool
rpcpassword=mempool
```
In the `mysql/db-scripts` sub-dir add the `mariadb-structure.sql` file from the mempool repo
If you want to use different credentials, specify them in the `docker-compose.yml` file:
Your dir should now look like that:
```bash
$ls -R
.:
data mysql
./data:
./mysql:
data db-scripts
./mysql/data:
./mysql/db-scripts:
mariadb-structure.sql
```
In the main dir add the following `docker-compose.yml`
```bash
version: "3.7"
services:
web:
image: mempool/frontend:latest
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
command: "./wait-for db:3306 --timeout=720 -- nginx -g 'daemon off;'"
ports:
- 80:8080
environment:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "api"
api:
image: mempool/backend:latest
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
command: "./wait-for-it.sh db:3306 --timeout=720 --strict -- ./start.sh"
volumes:
- ./data:/backend/cache
environment:
RPC_HOST: "127.0.0.1"
RPC_PORT: "8332"
RPC_USER: "mempool"
RPC_PASS: "mempool"
ELECTRUM_HOST: "127.0.0.1"
ELECTRUM_PORT: "50002"
ELECTRUM_TLS: "false"
MYSQL_HOST: "db"
MYSQL_PORT: "3306"
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASS: "mempool"
BACKEND_MAINNET_HTTP_PORT: "8999"
CACHE_DIR: "/backend/cache"
MEMPOOL_CLEAR_PROTECTION_MINUTES: "20"
db:
image: mariadb:10.5.8
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/db-scripts:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"
MEMPOOL_BACKEND: "none"
CORE_RPC_HOST: "172.27.0.1"
CORE_RPC_PORT: "8332"
CORE_RPC_USERNAME: "customuser"
CORE_RPC_PASSWORD: "custompassword"
```
You can update all the environment variables inside the API container, especially the RPC and ELECTRUM ones
The IP address in the example above refers to Docker's default gateway IP address so that the container can hit the `bitcoind` instance running on the host machine. If your setup is different, update it accordingly.
## Run it
Make sure `bitcoind` is running and synced.
To run our docker-compose use the following cmd:
Now, run:
```bash
docker-compose up
```
If everything went okay you should see the beautiful mempool :grin:
Your Mempool instance should be running at http://localhost. The graphs will be populated as new transactions are detected.
If you get stuck on "loading blocks", this means the websocket can't connect.
Check your nginx proxy setup, firewalls, etc. and open an issue if you need help.
## Configure with Bitcoin Core + Electrum Server
First, configure `bitcoind` as specified above, and make sure your Electrum Server is running and synced. See [this FAQ](https://mempool.space/docs/faq#address-lookup-issues) if you need help picking an Electrum Server implementation.
Then, set the following variables in `docker-compose.yml` so Mempool can connect to your Electrum Server:
```
api:
environment:
MEMPOOL_BACKEND: "electrum"
ELECTRUM_HOST: "172.27.0.1"
ELECTRUM_PORT: "50002"
ELECTRUM_TLS_ENABLED: "false"
```
Eligible values for `MEMPOOL_BACKEND`:
- "electrum" if you're using [romanz/electrs](https://github.com/romanz/electrs) or [cculianu/Fulcrum](https://github.com/cculianu/Fulcrum)
- "esplora" if you're using [Blockstream/electrs](https://github.com/Blockstream/electrs)
- "none" if you're not using any Electrum Server
Of course, if your Docker host IP address is different, update accordingly.
With `bitcoind` and Electrum Server set up, run Mempool with:
```bash
docker-compose up
```
## Further Configuration
Optionally, you can override any other backend settings from `mempool-config.json`.
Below we list all settings from `mempool-config.json` and the corresponding overrides you can make in the `api` > `environment` section of `docker-compose.yml`.
<br/>
`mempool-config.json`:
```
"MEMPOOL": {
"NETWORK": "mainnet",
"BACKEND": "electrum",
"HTTP_PORT": 8999,
"SPAWN_CLUSTER_PROCS": 0,
"API_URL_PREFIX": "/api/v1/",
"POLL_RATE_MS": 2000,
"CACHE_DIR": "./cache",
"CLEAR_PROTECTION_MINUTES": 20,
"RECOMMENDED_FEE_PERCENTILE": 50,
"BLOCK_WEIGHT_UNITS": 4000000,
"INITIAL_BLOCKS_AMOUNT": 8,
"MEMPOOL_BLOCKS_AMOUNT": 8,
"PRICE_FEED_UPDATE_INTERVAL": 600,
"USE_SECOND_NODE_FOR_MINFEE": false,
"EXTERNAL_ASSETS": ["https://raw.githubusercontent.com/mempool/mining-pools/master/pools.json"],
"STDOUT_LOG_MIN_PRIORITY": "info"
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
MEMPOOL_NETWORK: ""
MEMPOOL_BACKEND: ""
MEMPOOL_HTTP_PORT: ""
MEMPOOL_SPAWN_CLUSTER_PROCS: ""
MEMPOOL_API_URL_PREFIX: ""
MEMPOOL_POLL_RATE_MS: ""
MEMPOOL_CACHE_DIR: ""
MEMPOOL_CLEAR_PROTECTION_MINUTES: ""
MEMPOOL_RECOMMENDED_FEE_PERCENTILE: ""
MEMPOOL_BLOCK_WEIGHT_UNITS: ""
MEMPOOL_INITIAL_BLOCKS_AMOUNT: ""
MEMPOOL_MEMPOOL_BLOCKS_AMOUNT: ""
MEMPOOL_PRICE_FEED_UPDATE_INTERVAL: ""
MEMPOOL_USE_SECOND_NODE_FOR_MINFEE: ""
MEMPOOL_EXTERNAL_ASSETS: ""
MEMPOOL_STDOUT_LOG_MIN_PRIORITY: ""
...
```
<br/>
`mempool-config.json`:
```
"CORE_RPC": {
"HOST": "127.0.0.1",
"PORT": 8332,
"USERNAME": "mempool",
"PASSWORD": "mempool"
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
CORE_RPC_HOST: ""
CORE_RPC_PORT: ""
CORE_RPC_USERNAME: ""
CORE_RPC_PASSWORD: ""
...
```
<br/>
`mempool-config.json`:
```
"ELECTRUM": {
"HOST": "127.0.0.1",
"PORT": 50002,
"TLS_ENABLED": true
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
ELECTRUM_HOST: ""
ELECTRUM_PORT: ""
ELECTRUM_TLS_ENABLED: ""
...
```
<br/>
`mempool-config.json`:
```
"ESPLORA": {
"REST_API_URL": "http://127.0.0.1:3000"
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
ESPLORA_REST_API_URL: ""
...
```
<br/>
`mempool-config.json`:
```
"SECOND_CORE_RPC": {
"HOST": "127.0.0.1",
"PORT": 8332,
"USERNAME": "mempool",
"PASSWORD": "mempool"
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
SECOND_CORE_RPC_HOST: ""
SECOND_CORE_RPC_PORT: ""
SECOND_CORE_RPC_USERNAME: ""
SECOND_CORE_RPC_PASSWORD: ""
...
```
<br/>
`mempool-config.json`:
```
"DATABASE": {
"ENABLED": true,
"HOST": "127.0.0.1",
"PORT": 3306,
"DATABASE": "mempool",
"USERNAME": "mempool",
"PASSWORD": "mempool"
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
DATABASE_ENABLED: ""
DATABASE_HOST: ""
DATABASE_PORT: ""
DATABASE_DATABASE: ""
DATABASE_USERAME: ""
DATABASE_PASSWORD: ""
...
```
<br/>
`mempool-config.json`:
```
"SYSLOG": {
"ENABLED": true,
"HOST": "127.0.0.1",
"PORT": 514,
"MIN_PRIORITY": "info",
"FACILITY": "local7"
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
SYSLOG_ENABLED: ""
SYSLOG_HOST: ""
SYSLOG_PORT: ""
SYSLOG_MIN_PRIORITY: ""
SYSLOG_FACILITY: ""
...
```
<br/>
`mempool-config.json`:
```
"STATISTICS": {
"ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150
},
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
STATISTICS_ENABLED: ""
STATISTICS_TX_PER_SECOND_SAMPLE_PERIOD: ""
...
```
<br/>
`mempool-config.json`:
```
"BISQ": {
"ENABLED": false,
"DATA_PATH": "/bisq/statsnode-data/btc_mainnet/db"
}
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
BISQ_ENABLED: ""
BISQ_DATA_PATH: ""
...
```
<br/>
`mempool-config.json`:
```
"SOCKS5PROXY": {
"ENABLED": false,
"HOST": "127.0.0.1",
"PORT": "9050",
"USERNAME": "",
"PASSWORD": ""
}
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
SOCKS5PROXY_ENABLED: ""
SOCKS5PROXY_HOST: ""
SOCKS5PROXY_PORT: ""
SOCKS5PROXY_USERNAME: ""
SOCKS5PROXY_PASSWORD: ""
...
```
<br/>
`mempool-config.json`:
```
"PRICE_DATA_SERVER": {
"TOR_URL": "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices",
"CLEARNET_URL": "https://price.bisq.wiz.biz/getAllMarketPrices"
}
```
Corresponding `docker-compose.yml` overrides:
```
api:
environment:
PRICE_DATA_SERVER_TOR_URL: ""
PRICE_DATA_SERVER_CLEARNET_URL: ""
...
```

View File

@@ -1,4 +1,7 @@
FROM node:16.10.0-buster-slim AS builder
FROM node:16.15.0-buster-slim AS builder
ARG commitHash
ENV DOCKER_COMMIT_HASH=${commitHash}
WORKDIR /build
COPY . .
@@ -8,7 +11,7 @@ RUN apt-get install -y build-essential python3 pkg-config
RUN npm install
RUN npm run build
FROM node:16.10.0-buster-slim
FROM node:16.15.0-buster-slim
WORKDIR /backend

View File

@@ -1,38 +1,88 @@
{
"MEMPOOL": {
"NETWORK": "mainnet",
"BACKEND": "electrum",
"HTTP_PORT": __MEMPOOL_BACKEND_MAINNET_HTTP_PORT__,
"SPAWN_CLUSTER_PROCS": 0,
"API_URL_PREFIX": "/api/v1/",
"POLL_RATE_MS": 2000,
"CACHE_DIR": "__MEMPOOL_BACKEND_MAINNET_CACHE_DIR__",
"CLEAR_PROTECTION_MINUTES": __MEMPOOL_BACKEND_CLEAR_PROTECTION_MINUTES__
"NETWORK": "__MEMPOOL_NETWORK__",
"BACKEND": "__MEMPOOL_BACKEND__",
"HTTP_PORT": __MEMPOOL_HTTP_PORT__,
"SPAWN_CLUSTER_PROCS": __MEMPOOL_SPAWN_CLUSTER_PROCS__,
"API_URL_PREFIX": "__MEMPOOL_API_URL_PREFIX__",
"POLL_RATE_MS": __MEMPOOL_POLL_RATE_MS__,
"CACHE_DIR": "__MEMPOOL_CACHE_DIR__",
"CLEAR_PROTECTION_MINUTES": __MEMPOOL_CLEAR_PROTECTION_MINUTES__,
"RECOMMENDED_FEE_PERCENTILE": __MEMPOOL_RECOMMENDED_FEE_PERCENTILE__,
"BLOCK_WEIGHT_UNITS": __MEMPOOL_BLOCK_WEIGHT_UNITS__,
"INITIAL_BLOCKS_AMOUNT": __MEMPOOL_INITIAL_BLOCKS_AMOUNT__,
"MEMPOOL_BLOCKS_AMOUNT": __MEMPOOL_MEMPOOL_BLOCKS_AMOUNT__,
"PRICE_FEED_UPDATE_INTERVAL": __MEMPOOL_PRICE_FEED_UPDATE_INTERVAL__,
"USE_SECOND_NODE_FOR_MINFEE": __MEMPOOL_USE_SECOND_NODE_FOR_MINFEE__,
"EXTERNAL_ASSETS": __MEMPOOL_EXTERNAL_ASSETS__,
"EXTERNAL_MAX_RETRY": __MEMPOOL_EXTERNAL_MAX_RETRY__,
"EXTERNAL_RETRY_INTERVAL": __MEMPOOL_EXTERNAL_RETRY_INTERVAL__,
"USER_AGENT": "__MEMPOOL_USER_AGENT__",
"STDOUT_LOG_MIN_PRIORITY": "__MEMPOOL_STDOUT_LOG_MIN_PRIORITY__",
"INDEXING_BLOCKS_AMOUNT": __MEMPOOL_INDEXING_BLOCKS_AMOUNT__
},
"CORE_RPC": {
"HOST": "__BITCOIN_MAINNET_RPC_HOST__",
"PORT": __BITCOIN_MAINNET_RPC_PORT__,
"USERNAME": "__BITCOIN_MAINNET_RPC_USER__",
"PASSWORD": "__BITCOIN_MAINNET_RPC_PASS__"
"HOST": "__CORE_RPC_HOST__",
"PORT": __CORE_RPC_PORT__,
"USERNAME": "__CORE_RPC_USERNAME__",
"PASSWORD": "__CORE_RPC_PASSWORD__"
},
"ELECTRUM": {
"HOST": "__ELECTRUM_MAINNET_HTTP_HOST__",
"PORT": __ELECTRUM_MAINNET_HTTP_PORT__,
"TLS_ENABLED": __ELECTRUM_MAINNET_TLS_ENABLED__
"HOST": "__ELECTRUM_HOST__",
"PORT": __ELECTRUM_PORT__,
"TLS_ENABLED": __ELECTRUM_TLS_ENABLED__
},
"ESPLORA": {
"REST_API_URL": "http://127.0.0.1:3000"
"REST_API_URL": "__ESPLORA_REST_API_URL__"
},
"SECOND_CORE_RPC": {
"HOST": "__SECOND_CORE_RPC_HOST__",
"PORT": __SECOND_CORE_RPC_PORT__,
"USERNAME": "__SECOND_CORE_RPC_USERNAME__",
"PASSWORD": "__SECOND_CORE_RPC_PASSWORD__"
},
"DATABASE": {
"ENABLED": true,
"HOST": "__MYSQL_HOST__",
"PORT": __MYSQL_PORT__,
"DATABASE": "__MYSQL_DATABASE__",
"USERNAME": "__MYSQL_USERNAME__",
"PASSWORD": "__MYSQL_PASSWORD__"
"ENABLED": __DATABASE_ENABLED__,
"HOST": "__DATABASE_HOST__",
"SOCKET": "__DATABASE_SOCKET__",
"PORT": __DATABASE_PORT__,
"DATABASE": "__DATABASE_DATABASE__",
"USERNAME": "__DATABASE_USERNAME__",
"PASSWORD": "__DATABASE_PASSWORD__"
},
"SYSLOG": {
"ENABLED": __SYSLOG_ENABLED__,
"HOST": "__SYSLOG_HOST__",
"PORT": __SYSLOG_PORT__,
"MIN_PRIORITY": "__SYSLOG_MIN_PRIORITY__",
"FACILITY": "__SYSLOG_FACILITY__"
},
"STATISTICS": {
"ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150
"ENABLED": __STATISTICS_ENABLED__,
"TX_PER_SECOND_SAMPLE_PERIOD": __STATISTICS_TX_PER_SECOND_SAMPLE_PERIOD__
},
"BISQ": {
"ENABLED": __BISQ_ENABLED__,
"DATA_PATH": "__BISQ_DATA_PATH__"
},
"SOCKS5PROXY": {
"ENABLED": __SOCKS5PROXY_ENABLED__,
"USE_ONION": __SOCKS5PROXY_USE_ONION__,
"HOST": "__SOCKS5PROXY_HOST__",
"PORT": "__SOCKS5PROXY_PORT__",
"USERNAME": "__SOCKS5PROXY_USERNAME__",
"PASSWORD": "__SOCKS5PROXY_PASSWORD__"
},
"PRICE_DATA_SERVER": {
"TOR_URL": "__PRICE_DATA_SERVER_TOR_URL__",
"CLEARNET_URL": "__PRICE_DATA_SERVER_CLEARNET_URL__"
},
"EXTERNAL_DATA_SERVER": {
"MEMPOOL_API": "__EXTERNAL_DATA_SERVER_MEMPOOL_API__",
"MEMPOOL_ONION": "__EXTERNAL_DATA_SERVER_MEMPOOL_ONION__",
"LIQUID_API": "__EXTERNAL_DATA_SERVER_LIQUID_API__",
"LIQUID_ONION": "__EXTERNAL_DATA_SERVER_LIQUID_ONION__",
"BISQ_URL": "__EXTERNAL_DATA_SERVER_BISQ_URL__",
"BISQ_ONION": "__EXTERNAL_DATA_SERVER_BISQ_ONION__"
}
}

View File

@@ -1,41 +1,166 @@
#!/bin/sh
#MEMPOOL
__MEMPOOL_BACKEND_MAINNET_HTTP_PORT__=${BACKEND_MAINNET_HTTP_PORT:=8999}
__MEMPOOL_BACKEND_MAINNET_CACHE_DIR__=${CACHE_DIR:=./cache}
__MEMPOOL_BACKEND_CLEAR_PROTECTION_MINUTES__=${MEMPOOL_CLEAR_PROTECTION_MINUTES:=20}
# BITCOIN
__BITCOIN_MAINNET_RPC_HOST__=${RPC_HOST:=127.0.0.1}
__BITCOIN_MAINNET_RPC_PORT__=${RPC_PORT:=8332}
__BITCOIN_MAINNET_RPC_USER__=${RPC_USER:=mempool}
__BITCOIN_MAINNET_RPC_PASS__=${RPC_PASS:=mempool}
# MEMPOOL
__MEMPOOL_NETWORK__=${MEMPOOL_NETWORK:=mainnet}
__MEMPOOL_BACKEND__=${MEMPOOL_BACKEND:=electrum}
__MEMPOOL_HTTP_PORT__=${BACKEND_HTTP_PORT:=8999}
__MEMPOOL_SPAWN_CLUSTER_PROCS__=${MEMPOOL_SPAWN_CLUSTER_PROCS:=0}
__MEMPOOL_API_URL_PREFIX__=${MEMPOOL_API_URL_PREFIX:=/api/v1/}
__MEMPOOL_POLL_RATE_MS__=${MEMPOOL_POLL_RATE_MS:=2000}
__MEMPOOL_CACHE_DIR__=${MEMPOOL_CACHE_DIR:=./cache}
__MEMPOOL_CLEAR_PROTECTION_MINUTES__=${MEMPOOL_CLEAR_PROTECTION_MINUTES:=20}
__MEMPOOL_RECOMMENDED_FEE_PERCENTILE__=${MEMPOOL_RECOMMENDED_FEE_PERCENTILE:=50}
__MEMPOOL_BLOCK_WEIGHT_UNITS__=${MEMPOOL_BLOCK_WEIGHT_UNITS:=4000000}
__MEMPOOL_INITIAL_BLOCKS_AMOUNT__=${MEMPOOL_INITIAL_BLOCKS_AMOUNT:=8}
__MEMPOOL_MEMPOOL_BLOCKS_AMOUNT__=${MEMPOOL_MEMPOOL_BLOCKS_AMOUNT:=8}
__MEMPOOL_INDEXING_BLOCKS_AMOUNT__=${MEMPOOL_INDEXING_BLOCKS_AMOUNT:=11000}
__MEMPOOL_PRICE_FEED_UPDATE_INTERVAL__=${MEMPOOL_PRICE_FEED_UPDATE_INTERVAL:=600}
__MEMPOOL_USE_SECOND_NODE_FOR_MINFEE__=${MEMPOOL_USE_SECOND_NODE_FOR_MINFEE:=false}
__MEMPOOL_EXTERNAL_ASSETS__=${MEMPOOL_EXTERNAL_ASSETS:=[]}
__MEMPOOL_EXTERNAL_MAX_RETRY__=${MEMPOOL_EXTERNAL_MAX_RETRY:=1}
__MEMPOOL_EXTERNAL_RETRY_INTERVAL__=${MEMPOOL_EXTERNAL_RETRY_INTERVAL:=0}
__MEMPOOL_USER_AGENT__=${MEMPOOL_USER_AGENT:=mempool}
__MEMPOOL_STDOUT_LOG_MIN_PRIORITY__=${MEMPOOL_STDOUT_LOG_MIN_PRIORITY:=info}
# CORE_RPC
__CORE_RPC_HOST__=${CORE_RPC_HOST:=127.0.0.1}
__CORE_RPC_PORT__=${CORE_RPC_PORT:=8332}
__CORE_RPC_USERNAME__=${CORE_RPC_USERNAME:=mempool}
__CORE_RPC_PASSWORD__=${CORE_RPC_PASSWORD:=mempool}
# ELECTRUM
__ELECTRUM_MAINNET_HTTP_HOST__=${ELECTRUM_HOST:=127.0.0.1}
__ELECTRUM_MAINNET_HTTP_PORT__=${ELECTRUM_PORT:=50002} # 50001?
__ELECTRUM_MAINNET_TLS_ENABLED__=${ELECTRUM_TLS:=false}
# MYSQL
__MYSQL_HOST__=${MYSQL_HOST:=127.0.0.1}
__MYSQL_PORT__=${MYSQL_PORT:=3306}
__MYSQL_DATABASE__=${MYSQL_DATABASE:=mempool}
__MYSQL_USERNAME__=${MYSQL_USER:=mempool}
__MYSQL_PASSWORD__=${MYSQL_PASS:=mempool}
__ELECTRUM_HOST__=${ELECTRUM_HOST:=127.0.0.1}
__ELECTRUM_PORT__=${ELECTRUM_PORT:=50002}
__ELECTRUM_TLS_ENABLED__=${ELECTRUM_TLS_ENABLED:=false}
mkdir -p "${__MEMPOOL_BACKEND_MAINNET_CACHE_DIR__}"
# ESPLORA
__ESPLORA_REST_API_URL__=${ESPLORA_REST_API_URL:=http://127.0.0.1:3000}
sed -i "s/__BITCOIN_MAINNET_RPC_HOST__/${__BITCOIN_MAINNET_RPC_HOST__}/g" mempool-config.json
sed -i "s/__BITCOIN_MAINNET_RPC_PORT__/${__BITCOIN_MAINNET_RPC_PORT__}/g" mempool-config.json
sed -i "s/__BITCOIN_MAINNET_RPC_USER__/${__BITCOIN_MAINNET_RPC_USER__}/g" mempool-config.json
sed -i "s/__BITCOIN_MAINNET_RPC_PASS__/${__BITCOIN_MAINNET_RPC_PASS__}/g" mempool-config.json
sed -i "s/__ELECTRUM_MAINNET_HTTP_HOST__/${__ELECTRUM_MAINNET_HTTP_HOST__}/g" mempool-config.json
sed -i "s/__ELECTRUM_MAINNET_HTTP_PORT__/${__ELECTRUM_MAINNET_HTTP_PORT__}/g" mempool-config.json
sed -i "s/__ELECTRUM_MAINNET_TLS_ENABLED__/${__ELECTRUM_MAINNET_TLS_ENABLED__}/g" mempool-config.json
sed -i "s/__MYSQL_HOST__/${__MYSQL_HOST__}/g" mempool-config.json
sed -i "s/__MYSQL_PORT__/${__MYSQL_PORT__}/g" mempool-config.json
sed -i "s/__MYSQL_DATABASE__/${__MYSQL_DATABASE__}/g" mempool-config.json
sed -i "s/__MYSQL_USERNAME__/${__MYSQL_USERNAME__}/g" mempool-config.json
sed -i "s/__MYSQL_PASSWORD__/${__MYSQL_PASSWORD__}/g" mempool-config.json
sed -i "s!__MEMPOOL_BACKEND_MAINNET_CACHE_DIR__!${__MEMPOOL_BACKEND_MAINNET_CACHE_DIR__}!g" mempool-config.json
sed -i "s/__MEMPOOL_BACKEND_MAINNET_HTTP_PORT__/${__MEMPOOL_BACKEND_MAINNET_HTTP_PORT__}/g" mempool-config.json
sed -i "s/__MEMPOOL_BACKEND_CLEAR_PROTECTION_MINUTES__/${__MEMPOOL_BACKEND_CLEAR_PROTECTION_MINUTES__}/g" mempool-config.json
# SECOND_CORE_RPC
__SECOND_CORE_RPC_HOST__=${SECOND_CORE_RPC_HOST:=127.0.0.1}
__SECOND_CORE_RPC_PORT__=${SECOND_CORE_RPC_PORT:=8332}
__SECOND_CORE_RPC_USERNAME__=${SECOND_CORE_RPC_USERNAME:=mempool}
__SECOND_CORE_RPC_PASSWORD__=${SECOND_CORE_RPC_PASSWORD:=mempool}
# DATABASE
__DATABASE_ENABLED__=${DATABASE_ENABLED:=true}
__DATABASE_HOST__=${DATABASE_HOST:=127.0.0.1}
__DATABASE_SOCKET__=${DATABASE_SOCKET:=""}
__DATABASE_PORT__=${DATABASE_PORT:=3306}
__DATABASE_DATABASE__=${DATABASE_DATABASE:=mempool}
__DATABASE_USERNAME__=${DATABASE_USERNAME:=mempool}
__DATABASE_PASSWORD__=${DATABASE_PASSWORD:=mempool}
# SYSLOG
__SYSLOG_ENABLED__=${SYSLOG_ENABLED:=false}
__SYSLOG_HOST__=${SYSLOG_HOST:=127.0.0.1}
__SYSLOG_PORT__=${SYSLOG_PORT:=514}
__SYSLOG_MIN_PRIORITY__=${SYSLOG_MIN_PRIORITY:=info}
__SYSLOG_FACILITY__=${SYSLOG_FACILITY:=local7}
# STATISTICS
__STATISTICS_ENABLED__=${STATISTICS_ENABLED:=true}
__STATISTICS_TX_PER_SECOND_SAMPLE_PERIOD__=${STATISTICS_TX_PER_SECOND_SAMPLE_PERIOD:=150}
# BISQ
__BISQ_ENABLED__=${BISQ_ENABLED:=false}
__BISQ_DATA_PATH__=${BISQ_DATA_PATH:=/bisq/statsnode-data/btc_mainnet/db}
# SOCKS5PROXY
__SOCKS5PROXY_ENABLED__=${SOCKS5PROXY_ENABLED:=false}
__SOCKS5PROXY_USE_ONION__=${SOCKS5PROXY_USE_ONION:=true}
__SOCKS5PROXY_HOST__=${SOCKS5PROXY_HOST:=localhost}
__SOCKS5PROXY_PORT__=${SOCKS5PROXY_PORT:=9050}
__SOCKS5PROXY_USERNAME__=${SOCKS5PROXY_USERNAME:=""}
__SOCKS5PROXY_PASSWORD__=${SOCKS5PROXY_PASSWORD:=""}
# PRICE_DATA_SERVER
__PRICE_DATA_SERVER_TOR_URL__=${PRICE_DATA_SERVER_TOR_URL:=http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices}
__PRICE_DATA_SERVER_CLEARNET_URL__=${PRICE_DATA_SERVER_CLEARNET_URL:=https://price.bisq.wiz.biz/getAllMarketPrices}
# EXTERNAL_DATA_SERVER
__EXTERNAL_DATA_SERVER_MEMPOOL_API__=${EXTERNAL_DATA_SERVER_MEMPOOL_API:=https://mempool.space/api/v1}
__EXTERNAL_DATA_SERVER_MEMPOOL_ONION__=${EXTERNAL_DATA_SERVER_MEMPOOL_ONION:=http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/api/v1}
__EXTERNAL_DATA_SERVER_LIQUID_API__=${EXTERNAL_DATA_SERVER_LIQUID_API:=https://liquid.network/api/v1}
__EXTERNAL_DATA_SERVER_LIQUID_ONION__=${EXTERNAL_DATA_SERVER_LIQUID_ONION:=http://liquidmom47f6s3m53ebfxn47p76a6tlnxib3wp6deux7wuzotdr6cyd.onion/api/v1}
__EXTERNAL_DATA_SERVER_BISQ_URL__=${EXTERNAL_DATA_SERVER_BISQ_URL:=https://bisq.markets/api}
__EXTERNAL_DATA_SERVER_BISQ_ONION__=${EXTERNAL_DATA_SERVER_BISQ_ONION:=http://bisqmktse2cabavbr2xjq7xw3h6g5ottemo5rolfcwt6aly6tp5fdryd.onion/api}
mkdir -p "${__MEMPOOL_CACHE_DIR__}"
sed -i "s/__MEMPOOL_NETWORK__/${__MEMPOOL_NETWORK__}/g" mempool-config.json
sed -i "s/__MEMPOOL_BACKEND__/${__MEMPOOL_BACKEND__}/g" mempool-config.json
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_API_URL_PREFIX__!${__MEMPOOL_API_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_CACHE_DIR__!${__MEMPOOL_CACHE_DIR__}!g" mempool-config.json
sed -i "s/__MEMPOOL_CLEAR_PROTECTION_MINUTES__/${__MEMPOOL_CLEAR_PROTECTION_MINUTES__}/g" mempool-config.json
sed -i "s/__MEMPOOL_RECOMMENDED_FEE_PERCENTILE__/${__MEMPOOL_RECOMMENDED_FEE_PERCENTILE__}/g" mempool-config.json
sed -i "s/__MEMPOOL_BLOCK_WEIGHT_UNITS__/${__MEMPOOL_BLOCK_WEIGHT_UNITS__}/g" mempool-config.json
sed -i "s/__MEMPOOL_INITIAL_BLOCKS_AMOUNT__/${__MEMPOOL_INITIAL_BLOCKS_AMOUNT__}/g" mempool-config.json
sed -i "s/__MEMPOOL_MEMPOOL_BLOCKS_AMOUNT__/${__MEMPOOL_MEMPOOL_BLOCKS_AMOUNT__}/g" mempool-config.json
sed -i "s/__MEMPOOL_INDEXING_BLOCKS_AMOUNT__/${__MEMPOOL_INDEXING_BLOCKS_AMOUNT__}/g" mempool-config.json
sed -i "s/__MEMPOOL_PRICE_FEED_UPDATE_INTERVAL__/${__MEMPOOL_PRICE_FEED_UPDATE_INTERVAL__}/g" mempool-config.json
sed -i "s/__MEMPOOL_USE_SECOND_NODE_FOR_MINFEE__/${__MEMPOOL_USE_SECOND_NODE_FOR_MINFEE__}/g" mempool-config.json
sed -i "s!__MEMPOOL_EXTERNAL_ASSETS__!${__MEMPOOL_EXTERNAL_ASSETS__}!g" mempool-config.json
sed -i "s!__MEMPOOL_EXTERNAL_MAX_RETRY__!${__MEMPOOL_EXTERNAL_MAX_RETRY__}!g" mempool-config.json
sed -i "s!__MEMPOOL_EXTERNAL_RETRY_INTERVAL__!${__MEMPOOL_EXTERNAL_RETRY_INTERVAL__}!g" mempool-config.json
sed -i "s!__MEMPOOL_USER_AGENT__!${__MEMPOOL_USER_AGENT__}!g" mempool-config.json
sed -i "s/__MEMPOOL_STDOUT_LOG_MIN_PRIORITY__/${__MEMPOOL_STDOUT_LOG_MIN_PRIORITY__}/g" mempool-config.json
sed -i "s/__CORE_RPC_HOST__/${__CORE_RPC_HOST__}/g" mempool-config.json
sed -i "s/__CORE_RPC_PORT__/${__CORE_RPC_PORT__}/g" mempool-config.json
sed -i "s/__CORE_RPC_USERNAME__/${__CORE_RPC_USERNAME__}/g" mempool-config.json
sed -i "s/__CORE_RPC_PASSWORD__/${__CORE_RPC_PASSWORD__}/g" mempool-config.json
sed -i "s/__ELECTRUM_HOST__/${__ELECTRUM_HOST__}/g" mempool-config.json
sed -i "s/__ELECTRUM_PORT__/${__ELECTRUM_PORT__}/g" mempool-config.json
sed -i "s/__ELECTRUM_TLS_ENABLED__/${__ELECTRUM_TLS_ENABLED__}/g" mempool-config.json
sed -i "s!__ESPLORA_REST_API_URL__!${__ESPLORA_REST_API_URL__}!g" mempool-config.json
sed -i "s/__SECOND_CORE_RPC_HOST__/${__SECOND_CORE_RPC_HOST__}/g" mempool-config.json
sed -i "s/__SECOND_CORE_RPC_PORT__/${__SECOND_CORE_RPC_PORT__}/g" mempool-config.json
sed -i "s/__SECOND_CORE_RPC_USERNAME__/${__SECOND_CORE_RPC_USERNAME__}/g" mempool-config.json
sed -i "s/__SECOND_CORE_RPC_PASSWORD__/${__SECOND_CORE_RPC_PASSWORD__}/g" mempool-config.json
sed -i "s/__DATABASE_ENABLED__/${__DATABASE_ENABLED__}/g" mempool-config.json
sed -i "s/__DATABASE_HOST__/${__DATABASE_HOST__}/g" mempool-config.json
sed -i "s!__DATABASE_SOCKET__!${__DATABASE_SOCKET__}!g" mempool-config.json
sed -i "s/__DATABASE_PORT__/${__DATABASE_PORT__}/g" mempool-config.json
sed -i "s/__DATABASE_DATABASE__/${__DATABASE_DATABASE__}/g" mempool-config.json
sed -i "s/__DATABASE_USERNAME__/${__DATABASE_USERNAME__}/g" mempool-config.json
sed -i "s/__DATABASE_PASSWORD__/${__DATABASE_PASSWORD__}/g" mempool-config.json
sed -i "s/__SYSLOG_ENABLED__/${__SYSLOG_ENABLED__}/g" mempool-config.json
sed -i "s/__SYSLOG_HOST__/${__SYSLOG_HOST__}/g" mempool-config.json
sed -i "s/__SYSLOG_PORT__/${__SYSLOG_PORT__}/g" mempool-config.json
sed -i "s/__SYSLOG_MIN_PRIORITY__/${__SYSLOG_MIN_PRIORITY__}/g" mempool-config.json
sed -i "s/__SYSLOG_FACILITY__/${__SYSLOG_FACILITY__}/g" mempool-config.json
sed -i "s/__STATISTICS_ENABLED__/${__STATISTICS_ENABLED__}/g" mempool-config.json
sed -i "s/__STATISTICS_TX_PER_SECOND_SAMPLE_PERIOD__/${__STATISTICS_TX_PER_SECOND_SAMPLE_PERIOD__}/g" mempool-config.json
sed -i "s/__BISQ_ENABLED__/${__BISQ_ENABLED__}/g" mempool-config.json
sed -i "s!__BISQ_DATA_PATH__!${__BISQ_DATA_PATH__}!g" mempool-config.json
sed -i "s/__SOCKS5PROXY_ENABLED__/${__SOCKS5PROXY_ENABLED__}/g" mempool-config.json
sed -i "s/__SOCKS5PROXY_USE_ONION__/${__SOCKS5PROXY_USE_ONION__}/g" mempool-config.json
sed -i "s/__SOCKS5PROXY_HOST__/${__SOCKS5PROXY_HOST__}/g" mempool-config.json
sed -i "s/__SOCKS5PROXY_PORT__/${__SOCKS5PROXY_PORT__}/g" mempool-config.json
sed -i "s/__SOCKS5PROXY_USERNAME__/${__SOCKS5PROXY_USERNAME__}/g" mempool-config.json
sed -i "s/__SOCKS5PROXY_PASSWORD__/${__SOCKS5PROXY_PASSWORD__}/g" mempool-config.json
sed -i "s!__PRICE_DATA_SERVER_TOR_URL__!${__PRICE_DATA_SERVER_TOR_URL__}!g" mempool-config.json
sed -i "s!__PRICE_DATA_SERVER_CLEARNET_URL__!${__PRICE_DATA_SERVER_CLEARNET_URL__}!g" mempool-config.json
sed -i "s!__EXTERNAL_DATA_SERVER_MEMPOOL_API__!${__EXTERNAL_DATA_SERVER_MEMPOOL_API__}!g" mempool-config.json
sed -i "s!__EXTERNAL_DATA_SERVER_MEMPOOL_ONION__!${__EXTERNAL_DATA_SERVER_MEMPOOL_ONION__}!g" mempool-config.json
sed -i "s!__EXTERNAL_DATA_SERVER_LIQUID_API__!${__EXTERNAL_DATA_SERVER_LIQUID_API__}!g" mempool-config.json
sed -i "s!__EXTERNAL_DATA_SERVER_LIQUID_ONION__!${__EXTERNAL_DATA_SERVER_LIQUID_ONION__}!g" mempool-config.json
sed -i "s!__EXTERNAL_DATA_SERVER_BISQ_URL__!${__EXTERNAL_DATA_SERVER_BISQ_URL__}!g" mempool-config.json
sed -i "s!__EXTERNAL_DATA_SERVER_BISQ_ONION__!${__EXTERNAL_DATA_SERVER_BISQ_ONION__}!g" mempool-config.json
node /backend/dist/index.js

0
docker/data/.gitkeep Normal file
View File

View File

@@ -1,23 +1,10 @@
version: "3.7"
services:
electrum:
build:
context: .
dockerfile: docker/electrum/Dockerfile
user: "1000:1000"
restart: on-failure
command: ""
ports:
- 50001:50001
- 50002:50002
- 4224:4224
- 8332:8332
environment:
ELECTRUM: "electrum"
# add electrs configs
web:
environment:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "api"
image: mempool/frontend:latest
user: "1000:1000"
restart: on-failure
@@ -25,10 +12,19 @@ services:
command: "./wait-for db:3306 --timeout=720 -- nginx -g 'daemon off;'"
ports:
- 80:8080
environment:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "api"
api:
environment:
MEMPOOL_BACKEND: "none"
CORE_RPC_HOST: "172.27.0.1"
CORE_RPC_PORT: "8332"
CORE_RPC_USERNAME: "mempool"
CORE_RPC_PASSWORD: "mempool"
DATABASE_ENABLED: "true"
DATABASE_HOST: "db"
DATABASE_DATABASE: "mempool"
DATABASE_USERNAME: "mempool"
DATABASE_PASSWORD: "mempool"
STATISTICS_ENABLED: "true"
image: mempool/backend:latest
user: "1000:1000"
restart: on-failure
@@ -36,32 +32,15 @@ services:
command: "./wait-for-it.sh db:3306 --timeout=720 --strict -- ./start.sh"
volumes:
- ./data:/backend/cache
db:
environment:
RPC_HOST: "127.0.0.1"
RPC_PORT: "8332"
RPC_USER: "mempool"
RPC_PASS: "mempool"
ELECTRUM_HOST: "127.0.0.1"
ELECTRUM_PORT: "50002"
ELECTRUM_TLS: "false"
MYSQL_HOST: "db"
MYSQL_PORT: "3306"
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASS: "mempool"
BACKEND_MAINNET_HTTP_PORT: "8999"
CACHE_DIR: "/backend/cache"
MEMPOOL_CLEAR_PROTECTION_MINUTES: "20"
db:
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"
image: mariadb:10.5.8
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/db-scripts:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"

View File

@@ -1,4 +1,4 @@
FROM node:16.10.0-buster-slim AS builder
FROM node:16.15.0-buster-slim AS builder
ARG commitHash
ENV DOCKER_COMMIT_HASH=${commitHash}

View File

@@ -2,7 +2,7 @@
#backend
gitMaster="\.\.\/\.git\/refs\/heads\/master"
git ls-remote https://github.com/mempool/mempool.git $1 | awk '{ print $1}' > ./backend/master
git ls-remote https://github.com/mempool/mempool.git "$1^{}" | awk '{ print $1}' > ./backend/master
cp ./docker/backend/* ./backend/
sed -i "s/${gitMaster}/master/g" ./backend/src/api/backend-info.ts

View File

3
frontend/.gitignore vendored
View File

@@ -50,7 +50,10 @@ Thumbs.db
src/resources/assets.json
src/resources/assets.minimal.json
src/resources/assets-testnet.json
src/resources/assets-testnet.minimal.json
src/resources/pools.json
src/resources/mining-pools/*
# environment config
mempool-frontend-config.json

View File

@@ -1,8 +1,30 @@
# mempool-frontend
# Mempool Frontend
## Contributing
You can build and run the Mempool frontend and proxy to the production Mempool backend (for easier frontend development), or you can connect it to your own backend for a full Mempool development instance, custom deployment, etc.
This package is used for the https://mempool.space, https://liquid.network and https://bisq.markets websites - there are npm scripts to setup all three, which effectively change how BASE_MODULE is configured:
Jump to a section in this doc:
- [Quick Setup for Frontend Development](#quick-setup-for-frontend-development)
- [Manual Frontend Setup](#manual-setup)
- [Translations](#translations-transifex-project)
## Quick Setup for Frontend Development
If you want to quickly improve the UI, fix typos, or make other updates that don't require any backend changes, you don't need to set up an entire backend—you can simply run the Mempool frontend locally and proxy to the mempool.space backend.
### 1. Clone Mempool Repository
Get the latest Mempool code:
```
git clone https://github.com/mempool/mempool
cd mempool
```
### 2. Specify Website
The same frontend codebase is used for https://mempool.space, https://liquid.network and https://bisq.markets.
Configure the frontend for the site you want by running the corresponding command:
```
$ npm run config:defaults:mempool
@@ -10,18 +32,22 @@ $ npm run config:defaults:liquid
$ npm run config:defaults:bisq
```
Changes that affect the frontend codebase only can be done using the production backend so you don't need to spin up the entire Mempool infrastructure. This is very convenient in case you want to quickly improve the UI, fix typos or implement new features that don't require any backend changes.
### 3. Run the Frontend
Make your changes, install the project dependencies and run the frontend server as follows:
_Make sure to use Node.js 16.15 and npm 7._
Install project dependencies and run the frontend server:
```
$ npm install
$ npm run serve:local-prod
```
The frontend will be available at http://localhost:4200/ and all API requests will be proxied to the production server at https://mempool.space
The frontend will be available at http://localhost:4200/ and all API requests will be proxied to the production server at https://mempool.space.
After making your changes, you can run our end-to-end automation suite and check for possible regressions:
### 4. Test
After making your changes, you can run our end-to-end automation suite and check for possible regressions.
Headless:
@@ -37,11 +63,43 @@ $ npm run config:defaults:mempool && npm run cypress:open
This will open the Cypress test runner, where you can select any of the test files to run.
If all tests are green, submit your PR and it will be reviewed by someone on the team as soon as possible.
If all tests are green, submit your PR, and it will be reviewed by someone on the team as soon as possible.
## Manual Setup
Set up the [Mempool backend](../backend/) first, if you haven't already.
### 1. Build the Frontend
_Node.js 16 and npm 7 are recommended._
Build the frontend:
```
cd frontend
npm install # add --prod for production
npm run build
```
### 2. Run the Frontend
#### Development
To run your local Mempool frontend with your local Mempool backend:
```
npm run serve
```
#### Production
The `npm run build` command from step 1 above should have generated a `dist` directory. Put the contents of `dist/` onto your web server.
You will probably want to set up a reverse proxy, TLS, etc. There are sample nginx configuration files in the top level of the repository for reference, but note that support for such tasks is outside the scope of this project.
## Translations: Transifex Project
The mempool frontend strings are localized into 20+ locales:
The Mempool frontend strings are localized into 20+ locales:
https://www.transifex.com/mempool/mempool/dashboard/
### Translators

View File

@@ -218,6 +218,10 @@
"proxyConfig": "proxy.conf.local.js",
"verbose": true
},
"mixed": {
"proxyConfig": "proxy.conf.mixed.js",
"verbose": true
},
"staging": {
"proxyConfig": "proxy.conf.js",
"disableHostCheck": true,
@@ -229,6 +233,12 @@
"disableHostCheck": true,
"host": "0.0.0.0",
"verbose": false
},
"local-staging": {
"proxyConfig": "proxy.conf.staging.js",
"disableHostCheck": true,
"host": "0.0.0.0",
"verbose": false
}
}
},

View File

@@ -0,0 +1,23 @@
import { defineConfig } from 'cypress'
export default defineConfig({
projectId: 'ry4br7',
videosFolder: 'cypress/videos',
screenshotsFolder: 'cypress/screenshots',
fixturesFolder: 'cypress/fixtures',
video: false,
retries: {
runMode: 3,
openMode: 0,
},
chromeWebSecurity: false,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:4200',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
},
})

View File

@@ -1,16 +0,0 @@
{
"projectId": "ry4br7",
"integrationFolder": "cypress/integration",
"supportFile": "cypress/support/index.ts",
"videosFolder": "cypress/videos",
"screenshotsFolder": "cypress/screenshots",
"pluginsFile": "cypress/plugins/index.js",
"fixturesFolder": "cypress/fixtures",
"baseUrl": "http://localhost:4200",
"video": false,
"retries": {
"runMode": 3,
"openMode": 0
},
"chromeWebSecurity": false
}

View File

@@ -0,0 +1,164 @@
describe('Bisq', () => {
const baseModule = Cypress.env("BASE_MODULE");
const basePath = '';
beforeEach(() => {
cy.intercept('/sockjs-node/info*').as('socket');
cy.intercept('/bisq/api/markets/hloc?market=btc_usd&interval=day').as('hloc');
cy.intercept('/bisq/api/markets/ticker').as('ticker');
cy.intercept('/bisq/api/markets/markets').as('markets');
cy.intercept('/bisq/api/markets/volumes/7d').as('7d');
cy.intercept('/bisq/api/markets/trades?market=all').as('trades');
cy.intercept('/bisq/api/txs/*/*').as('txs');
cy.intercept('/bisq/api/blocks/*/*').as('blocks');
cy.intercept('/bisq/api/stats').as('stats');
});
if (baseModule === 'bisq') {
it('loads the dashboard', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
});
describe("transactions", () => {
it('loads the transactions screen', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#btn-transactions').click().then(() => {
cy.get('.table > tr').should('have.length', 50);
});
});
const filters = [
"Asset listing fee", "Blind vote", "Compensation request",
"Genesis", "Irregular", "Lockup", "Pay trade fee", "Proof of burn",
"Proposal", "Reimbursement request", "Transfer BSQ", "Unlock", "Vote reveal"
];
filters.forEach((filter) => {
it.only(`filters the transaction screen by ${filter}`, () => {
cy.visit(`${basePath}/transactions`);
cy.wait('@txs');
cy.waitForSkeletonGone();
cy.get('#filter').click();
cy.contains(filter).find('input').click();
cy.wait('@txs');
cy.wait(500);
cy.get('td:nth-of-type(2)').each(($td) => {
expect($td.text().trim()).to.eq(filter);
});
});
});
it("filters using multiple criteria", () => {
const filters = ['Proposal', 'Lockup', 'Unlock'];
cy.visit(`${basePath}/transactions`);
cy.waitForSkeletonGone();
cy.get('#filter').click();
filters.forEach((filter) => {
cy.contains(filter).find('input').click();
//TODO: change this waiter
cy.wait(1500);
});
cy.get('td:nth-of-type(2)').each(($td) => {
const regex = new RegExp(`${filters.join('|')}`, 'g');
expect($td.text().trim()).to.match(regex);
});
});
const transactions = [
{ type: 'Asset listing fee', txid: '3548aa0c002b015ea700072b7d7d76d45d4f10a3573804d0d2f624c0bb255b6b' },
{ type: 'Blind vote', txid: 'f8fabb95efa1bb81325e4c961b9fc7e3508a9b9ecd4eddf1400e58867eff8d92' },
{ type: 'Compensation request', txid: 'a8cdc65fe6bb8730f5f89f99f779d0469b0a493e1ae570e20eb7afda696a18a9' },
{ type: 'Genesis', txid: '4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5' },
{ type: 'Irregular', txid: '90b06684a517388fec2237e2362a29810dc82f0e13e019c84747ec27051e6c53' },
{ type: 'Lockup', txid: '365425b3b7487229e2ba598fb8f2a9e359e3351620383e5018548649a28b78c4' },
{ type: 'Pay trade fee', txid: 'a66b30e9777e16572ab36723539df8f45bd5d8130d810b2c3d75b8c02a191eaf' },
{ type: 'Proof of burn', txid: '8325ccb87065fb9243ed9ff1cbb431fc2ac5060a60433bcde474ccbd97b76dcb' },
{ type: 'Proposal', txid: '34e2a20f045c82fbcf7cb191b42dea6fba45641777e1751ffb29d3981c4bf413' },
{ type: 'Reimbursement request', txid: '04c16c79ca6b9ec9978880024b0d0ad3100020f33286b63c85ca7b1a319421ae' },
{ type: 'Transfer BSQ', txid: '64500bd9220675ad30d5ace27de95a341a498d7eda08162ee0ce7feb8c56cb14' },
{ type: 'Unlock', txid: '5a756841bbb11137d15b0082a3fcadbe102791f41a95d661d3bd0c5ad0b3b1a3' },
{ type: 'Vote reveal', txid: 'bd7daae1d4af8837db5e47d7bd9d8b9f83dcfd35d112f85e90728b9be45191f7' }
];
transactions.forEach((transaction) => {
it(`loads a "${transaction.type}" transaction`, () => {
cy.visit(`${basePath}/tx/${transaction.txid}`);
cy.waitForSkeletonGone();
});
});
});
describe('blocks', () => {
it('loads the blocks screen', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#btn-blocks').click().then(() => {
cy.wait('@blocks');
cy.get('tbody tr').should('have.length', 10);
});
});
it('loads a specific block', () => {
cy.visit(`${basePath}/block/0000000000000000000137ef33faa63bc6e809ab30932cf77d454fb36d2bd83a`);
cy.waitForSkeletonGone();
});
});
describe('markets', () => {
it('loads the markets screen', () => {
cy.visit(`${basePath}/markets`);
cy.waitForSkeletonGone();
});
it('loads a specific market', () => {
cy.visit(`${basePath}/market/btc_eur`);
cy.waitForSkeletonGone();
//Buy Offers
cy.get('.row > :nth-child(1) td').should('have.length.at.least', 1);
//Sell offers
cy.get('.row > :nth-child(1) td').should('have.length.at.least', 1);
//Trades
cy.get('app-bisq-trades > .table-container td').should('have.length.at.least', 1);
});
});
it('loads the stats screen', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#btn-stats').click().then(() => {
cy.wait('@stats');
});
});
it('loads the api screen', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#btn-docs').click().then(() => {
cy.get('.section-header').should('have.length.at.least', 1);
cy.get('.endpoint-container').should('have.length.at.least', 1);
});
});
it('shows blocks pagination with 5 pages (desktop)', () => {
cy.viewport(760, 800);
cy.visit(`${basePath}/blocks`);
cy.waitForSkeletonGone();
cy.get('tbody tr').should('have.length', 10);
// 5 pages + 4 buttons = 9 buttons
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 9);
});
it('shows blocks pagination with 3 pages (mobile)', () => {
cy.viewport(669, 800);
cy.visit(`${basePath}/blocks`);
cy.waitForSkeletonGone();
cy.get('tbody tr').should('have.length', 10);
// 3 pages + 4 buttons = 7 buttons
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 7);
});
} else {
it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`);
}
});

View File

@@ -0,0 +1,213 @@
describe('Liquid', () => {
const baseModule = Cypress.env("BASE_MODULE");
const basePath = '';
beforeEach(() => {
cy.intercept('/liquid/api/block/**').as('block');
cy.intercept('/liquid/api/blocks/').as('blocks');
cy.intercept('/liquid/api/tx/**/outspends').as('outspends');
cy.intercept('/liquid/api/block/**/txs/**').as('block-txs');
cy.intercept('/resources/pools.json').as('pools');
Cypress.Commands.add('waitForBlockData', () => {
cy.wait('@socket');
cy.wait('@block');
cy.wait('@outspends');
});
});
if (baseModule === 'liquid') {
it('check first mempool block after skeleton loads', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#mempool-block-0 > .blockLink').should('exist');
});
it('loads the dashboard', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
});
it('loads the blocks page', () => {
cy.visit(`${basePath}`);
cy.get('#btn-blocks').click().then(() => {
cy.wait(1000);
});
cy.waitForSkeletonGone();
});
it('loads a specific block page', () => {
cy.visit(`${basePath}/block/7e1369a23a5ab861e7bdede2aadcccae4ea873ffd9caf11c7c5541eb5bcdff54`);
cy.waitForSkeletonGone();
});
it('loads the graphs page', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#btn-graphs').click().then(() => {
cy.wait(1000);
});
});
it('loads the tv page - desktop', () => {
cy.visit(`${basePath}/tv`);
cy.waitForSkeletonGone();
});
it('loads the graphs page - mobile', () => {
cy.visit(`${basePath}`)
cy.waitForSkeletonGone();
cy.get('#btn-graphs').click().then(() => {
cy.viewport('iphone-6');
cy.wait(1000);
cy.get('.tv-only').should('not.exist');
});
});
it('renders unconfidential addresses correctly on mobile', () => {
cy.viewport('iphone-6');
cy.visit(`${basePath}/address/ex1qqmmjdwrlg59c8q4l75sj6wedjx57tj5grt8pat`);
cy.waitForSkeletonGone();
//TODO: Add proper IDs for these selectors
const firstRowSelector = '.container-xl > :nth-child(3) > div > :nth-child(1) > .table > tbody';
const thirdRowSelector = '.container-xl > :nth-child(3) > div > :nth-child(3)';
cy.get(firstRowSelector).invoke('css', 'width').then(firstRowWidth => {
cy.get(thirdRowSelector).invoke('css', 'width').then(thirdRowWidth => {
expect(parseInt(firstRowWidth)).to.be.lessThan(parseInt(thirdRowWidth));
});
});
});
describe('peg in/peg out', () => {
it('loads peg in addresses', () => {
cy.visit(`${basePath}/tx/fe764f7bedfc2a37b29d9c8aef67d64a57d253a6b11c5a55555cfd5826483a58`);
cy.waitForSkeletonGone();
//TODO: Change to an element id so we don't assert on a string
cy.get('.table-tx-vin').should('contain', 'Peg-in');
cy.get('.table-tx-vin a').click().then(() => {
cy.waitForSkeletonGone();
if (baseModule === 'liquid') {
cy.url().should('eq', 'https://mempool.space/tx/f148c0d854db4174ea420655235f910543f0ec3680566dcfdf84fb0a1697b592');
} else {
//TODO: Use an environment variable to get the hostname
cy.url().should('eq', 'http://localhost:4200/tx/f148c0d854db4174ea420655235f910543f0ec3680566dcfdf84fb0a1697b592');
}
});
});
it('loads peg out addresses', () => {
cy.visit(`${basePath}/tx/ecf6eba04ffb3946faa172343c87162df76f1a57b07b0d6dc6ad956b13376dc8`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vout a').first().click().then(() => {
cy.waitForSkeletonGone();
if (baseModule === 'liquid') {
cy.url().should('eq', 'https://mempool.space/address/1BxoGcMg14oaH3CwHD2hF4gU9VcfgX5yoR');
} else {
//TODO: Use an environment variable to get the hostname
cy.url().should('eq', 'http://localhost:4200/address/1BxoGcMg14oaH3CwHD2hF4gU9VcfgX5yoR');
}
//TODO: Add a custom class so we don't assert on a string
cy.get('.badge').should('contain', 'Liquid Peg Out');
});
});
});
describe('assets', () => {
it('shows the assets screen', () => {
cy.visit(`${basePath}/assets`);
cy.waitForSkeletonGone();
cy.get('.featuredBox .card').should('have.length.at.least', 5);
});
it('allows searching assets', () => {
cy.visit(`${basePath}/assets`);
cy.waitForSkeletonGone();
cy.get('.container-xl input').click().type('Liquid Bitcoin').then(() => {
cy.get('ngb-typeahead-window', { timeout: 30000 }).should('have.length', 1);
});
});
it('shows a specific asset ID', () => {
cy.visit(`${basePath}/assets`);
cy.waitForSkeletonGone();
cy.get('.container-xl input').click().type('Liquid AUD').then(() => {
cy.get('ngb-typeahead-window:nth-of-type(1) button', { timeout: 30000 }).click();
});
});
});
describe('unblinded TX', () => {
it('should not show an unblinding error message for regular txs', () => {
cy.visit(`${basePath}/tx/82a479043ec3841e0d3f829afc8df4f0e2bbd675a13f013ea611b2fde0027d45`);
cy.waitForSkeletonGone();
cy.get('.error-unblinded').should('not.exist');
});
it('show unblinded TX', () => {
cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc,2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3a`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr:nth-child(1) .amount').should('contain.text', '0.02465000 L-BTC');
cy.get('.table-tx-vin tr').should('have.class', 'assetBox');
cy.get('.table-tx-vout tr:nth-child(1) .amount').should('contain.text', '0.00100000 L-BTC');
cy.get('.table-tx-vout tr:nth-child(2) .amount').should('contain.text', '0.02364760 L-BTC');
cy.get('.table-tx-vout tr').should('have.class', 'assetBox');
});
it('show empty unblinded TX', () => {
cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr:nth-child(1)').should('have.class', '');
cy.get('.table-tx-vin tr:nth-child(1) .amount').should('contain.text', 'Confidential');
cy.get('.table-tx-vout tr:nth-child(1)').should('have.class', '');
cy.get('.table-tx-vout tr:nth-child(2)').should('have.class', '');
cy.get('.table-tx-vout tr:nth-child(1) .amount').should('contain.text', 'Confidential');
cy.get('.table-tx-vout tr:nth-child(2) .amount').should('contain.text', 'Confidential');
});
it('show invalid unblinded TX hex', () => {
cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=123`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr').should('have.class', '');
cy.get('.table-tx-vout tr').should('have.class', '');
cy.get('.error-unblinded').contains('Error: Invalid blinding data (invalid hex)');
});
it('show first unblinded vout', () => {
cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vout tr:nth-child(1)').should('have.class', 'assetBox');
cy.get('.table-tx-vout tr:nth-child(1) .amount').should('contain.text', '0.00100000 L-BTC');
});
it('show second unblinded vout', () => {
cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3a`);
cy.get('.table-tx-vout tr:nth-child(2').should('have.class', 'assetBox');
cy.get('.table-tx-vout tr:nth-child(2) .amount').should('contain.text', '0.02364760 L-BTC');
});
it('show invalid error unblinded TX', () => {
cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc,2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3c`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vout tr').should('have.class', 'assetBox');
cy.get('.error-unblinded').contains('Error: Invalid blinding data.');
});
it('shows asset peg in/out and burn transactions', () => {
cy.visit(`${basePath}/assets/asset/6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vout tr').not('.assetBox');
cy.get('.table-tx-vin tr').not('.assetBox');
});
it('prevents regressing issue #644', () => {
cy.visit(`${basePath}/tx/393b890966f305e7c440fcfb12a13f51a7a9011cc59ff5f14f6f93214261bd82`);
cy.waitForSkeletonGone();
});
});
} else {
it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`);
}
});

View File

@@ -0,0 +1,169 @@
describe('Liquid Testnet', () => {
const baseModule = Cypress.env("BASE_MODULE");
const basePath = '/testnet';
beforeEach(() => {
cy.intercept('/liquidtestnet/api/block/**').as('block');
cy.intercept('/liquidtestnet/api/blocks/').as('blocks');
cy.intercept('/liquidtestnet/api/tx/**/outspends').as('outspends');
cy.intercept('/liquidtestnet/api/block/**/txs/**').as('block-txs');
cy.intercept('/resources/pools.json').as('pools');
Cypress.Commands.add('waitForBlockData', () => {
cy.wait('@socket');
cy.wait('@block');
cy.wait('@outspends');
});
});
if (baseModule === 'liquid') {
it('check first mempool block after skeleton loads', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
cy.get('#mempool-block-0 > .blockLink').should('exist');
});
it('loads the dashboard', () => {
cy.visit(`${basePath}`);
cy.waitForSkeletonGone();
});
it('loads the blocks page', () => {
cy.visit(`${basePath}`)
cy.get('#btn-blocks');
cy.waitForSkeletonGone();
});
it('loads a specific block page', () => {
cy.visit(`${basePath}/block/7e1369a23a5ab861e7bdede2aadcccae4ea873ffd9caf11c7c5541eb5bcdff54`);
cy.waitForSkeletonGone();
});
it('loads the graphs page', () => {
cy.visit(`${basePath}`);
cy.get('#btn-graphs');
cy.waitForSkeletonGone();
});
it('loads the tv page - desktop', () => {
cy.visit(`${basePath}/tv`);
cy.waitForSkeletonGone();
});
it('loads the graphs page - mobile', () => {
cy.visit(`${basePath}`)
cy.waitForSkeletonGone();
cy.viewport('iphone-6');
cy.get('.tv-only').should('not.exist');
});
it.skip('renders unconfidential addresses correctly on mobile', () => {
cy.viewport('iphone-6');
cy.visit(`${basePath}/address/__TODO__`);
cy.waitForSkeletonGone();
//TODO: Add proper IDs for these selectors
const firstRowSelector = '.container-xl > :nth-child(3) > div > :nth-child(1) > .table > tbody';
const thirdRowSelector = '.container-xl > :nth-child(3) > div > :nth-child(3)';
cy.get(firstRowSelector).invoke('css', 'width').then(firstRowWidth => {
cy.get(thirdRowSelector).invoke('css', 'width').then(thirdRowWidth => {
expect(parseInt(firstRowWidth)).to.be.lessThan(parseInt(thirdRowWidth));
});
});
});
describe('assets', () => {
it('allows searching assets', () => {
cy.visit(`${basePath}/assets`);
cy.waitForSkeletonGone();
cy.get('.container-xl input').click().type('Liquid Bitcoin').then(() => {
cy.get('ngb-typeahead-window').should('have.length', 1);
});
});
it('shows a specific asset ID', () => {
cy.visit(`${basePath}/assets`);
cy.waitForSkeletonGone();
cy.get('.container-xl input').click().type('Liquid CAD').then(() => {
cy.get('ngb-typeahead-window:nth-of-type(1) button').click();
});
});
});
describe('unblinded TX', () => {
it('should not show an unblinding error message for regular txs', () => {
cy.visit(`${basePath}/tx/82a479043ec3841e0d3f829afc8df4f0e2bbd675a13f013ea611b2fde0027d45`);
cy.waitForSkeletonGone();
cy.get('.error-unblinded').should('not.exist');
});
it('show unblinded TX', () => {
cy.visit(`${basePath}/tx/c3d908ab77891e4c569b0df71aae90f4720b157019ebb20db176f4f9c4d626b8#blinded=100000,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,df290ead654d7d110ebc5aaf0bcf11d5b5d360431a467f1cde0a856fde986893,33cb3a2fd2e76643843691cf44a78c5cd28ec652a414da752160ad63fbd37bc9,49741,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,edb0713bcbfcb3daabf601cb50978439667d208e15fed8a5ebbfea5696cda1d5,4de70115501e8c7d6bd763e229bf42781edeacf6e75e1d7bdfa4c63104bc508a`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr:nth-child(1) .amount').should('contain.text', '0.00100000 tL-BTC');
cy.get('.table-tx-vin tr').should('have.class', 'assetBox');
cy.get('.table-tx-vout tr:nth-child(1) .amount').should('contain.text', '0.00050000 tL-BTC');
cy.get('.table-tx-vout tr:nth-child(2) .amount').should('contain.text', '0.00049741 tL-BTC');
cy.get('.table-tx-vout tr').should('have.class', 'assetBox');
});
it('show empty unblinded TX', () => {
cy.visit(`${basePath}/tx/c3d908ab77891e4c569b0df71aae90f4720b157019ebb20db176f4f9c4d626b8#blinded=`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr:nth-child(1)').should('have.class', '');
cy.get('.table-tx-vin tr:nth-child(1) .amount').should('contain.text', 'Confidential');
cy.get('.table-tx-vout tr:nth-child(1)').should('have.class', '');
cy.get('.table-tx-vout tr:nth-child(2)').should('have.class', '');
cy.get('.table-tx-vout tr:nth-child(1) .amount').should('contain.text', 'Confidential');
cy.get('.table-tx-vout tr:nth-child(2) .amount').should('contain.text', 'Confidential');
});
it('show invalid unblinded TX hex', () => {
cy.visit(`${basePath}/tx/2477f220eef1d03f8ffa4a2861c275d155c3562adf0d79523aeeb0c59ee611ba#blinded=5000`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr').should('have.class', '');
cy.get('.table-tx-vout tr').should('have.class', '');
cy.get('.error-unblinded').contains('Error: Invalid blinding data (invalid hex)');
});
it('show first unblinded vout', () => {
cy.visit(`${basePath}/tx/0877bc0c7aa5c2b8d0e4b15450425879b8783c40e341806037a605ef836fb886#blinded=5000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,328de54e90e867a9154b4f1eb7fcab86267e880fa2ee9e53b41a91e61dab86e6,8885831e6b089eaf06889d53a24843f0da533d300a7b1527b136883a6819f3ae,5000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,aca78b953615d69ae0ae68c4c5c3c0ee077c10bc20ad3f0c5960706004e6cb56,d2ec175afe5f761e2dbd443faf46abbb7091f341deb3387e5787d812bdb2df9f,100000,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,4b54a4ca809b3844f34dd88b68617c4c866d92a02211f02ba355755bac20a1c6,eddd02e92b0cfbad8cab89828570a50f2c643bb2a54d886c86e25ce47e818685,99729,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,8b86d565c9549eb0352bb81ee576d01d064435b64fddcc045decebeb1d9913ce,b082ce3448d40d47b5b39f15d72b285f4a1046b636b56c25f32f498ece29d062,10000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,62b04ee86198d6b41681cdd0acb450ab366af727a010aaee8ba0b9e69ff43896,3f98429bca9b538dc943c22111f25d9c4448d45a63ff0f4e58b22fd434c0365e`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vout tr:nth-child(1)').should('have.class', 'assetBox');
cy.get('.table-tx-vout tr:nth-child(1) .amount').should('contain.text', '0.00099729 tL-BTC');
});
it('show second unblinded vout (asset)', () => {
cy.visit(`${basePath}/tx/0877bc0c7aa5c2b8d0e4b15450425879b8783c40e341806037a605ef836fb886#blinded=5000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,328de54e90e867a9154b4f1eb7fcab86267e880fa2ee9e53b41a91e61dab86e6,8885831e6b089eaf06889d53a24843f0da533d300a7b1527b136883a6819f3ae,5000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,aca78b953615d69ae0ae68c4c5c3c0ee077c10bc20ad3f0c5960706004e6cb56,d2ec175afe5f761e2dbd443faf46abbb7091f341deb3387e5787d812bdb2df9f,100000,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,4b54a4ca809b3844f34dd88b68617c4c866d92a02211f02ba355755bac20a1c6,eddd02e92b0cfbad8cab89828570a50f2c643bb2a54d886c86e25ce47e818685,99729,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,8b86d565c9549eb0352bb81ee576d01d064435b64fddcc045decebeb1d9913ce,b082ce3448d40d47b5b39f15d72b285f4a1046b636b56c25f32f498ece29d062,10000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,62b04ee86198d6b41681cdd0acb450ab366af727a010aaee8ba0b9e69ff43896,3f98429bca9b538dc943c22111f25d9c4448d45a63ff0f4e58b22fd434c0365e`);
cy.get('.table-tx-vout tr:nth-child(2)').should('have.class', 'assetBox');
//TODO Update after the precision bug fix is merged
cy.get('.table-tx-vout tr:nth-child(2) .amount').should('contain.text', '0 TEST');
});
it('should link to the asset page from the unblinded tx', () => {
cy.visit(`${basePath}/tx/0877bc0c7aa5c2b8d0e4b15450425879b8783c40e341806037a605ef836fb886#blinded=5000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,328de54e90e867a9154b4f1eb7fcab86267e880fa2ee9e53b41a91e61dab86e6,8885831e6b089eaf06889d53a24843f0da533d300a7b1527b136883a6819f3ae,5000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,aca78b953615d69ae0ae68c4c5c3c0ee077c10bc20ad3f0c5960706004e6cb56,d2ec175afe5f761e2dbd443faf46abbb7091f341deb3387e5787d812bdb2df9f,100000,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,4b54a4ca809b3844f34dd88b68617c4c866d92a02211f02ba355755bac20a1c6,eddd02e92b0cfbad8cab89828570a50f2c643bb2a54d886c86e25ce47e818685,99729,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,8b86d565c9549eb0352bb81ee576d01d064435b64fddcc045decebeb1d9913ce,b082ce3448d40d47b5b39f15d72b285f4a1046b636b56c25f32f498ece29d062,10000,38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5,62b04ee86198d6b41681cdd0acb450ab366af727a010aaee8ba0b9e69ff43896,3f98429bca9b538dc943c22111f25d9c4448d45a63ff0f4e58b22fd434c0365e`);
cy.get('.table-tx-vout tr:nth-child(2) .amount a').click().then(() => {
cy.waitForSkeletonGone();
cy.url().should('contain', '/assets/asset/38fca2d939696061a8f76d4e6b5eecd54e3b4221c846f24a6b279e79952850a5');
});
});
it('show invalid error unblinded TX', () => {
cy.visit(`${basePath}/tx/c3d908ab77891e4c569b0df71aae90f4720b157019ebb20db176f4f9c4d626b8#blinded=100000,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,df290ead654d7d110ebc5aaf0bcf11d5b5d360431a467f1cde0a856fde986893,33cb3a2fd2e76643843691cf44a78c5cd28ec652a414da752160ad63fbd37bc9,49741,144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49,edb0713bcbfcb3daabf601cb50978439667d208e15fed8a5ebbfea5696cda1d5,4de70115501e8c7d6bd763e229bf42781edeacf6e75e1d7bdfa4c63104bc508c`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vin tr').should('have.class', 'assetBox');
cy.get('.error-unblinded').contains('Error: Invalid blinding data.');
});
it('shows asset peg in/out and burn transactions', () => {
cy.visit(`${basePath}/assets/asset/ac3e0ff248c5051ffd61e00155b7122e5ebc04fd397a0ecbdd4f4e4a56232926`);
cy.waitForSkeletonGone();
cy.get('.table-tx-vout tr').not('.assetBox');
cy.get('.table-tx-vin tr').not('.assetBox');
});
});
} else {
it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`);
}
});

View File

@@ -0,0 +1,578 @@
import { emitMempoolInfo, dropWebSocket } from "../../support/websocket";
const baseModule = Cypress.env("BASE_MODULE");
//Credit: https://github.com/bahmutov/cypress-examples/blob/6cedb17f83a3bb03ded13cf1d6a3f0656ca2cdf5/docs/recipes/overlapping-elements.md
/**
* Returns true if two DOM rectangles are overlapping
* @param {DOMRect} rect1 the bounding client rectangle of the first element
* @param {DOMRect} rect2 the bounding client rectangle of the second element
* @returns {boolean}
*/
const areOverlapping = (rect1, rect2) => {
// if one rectangle is on the left side of the other
if (rect1.right < rect2.left || rect2.right < rect1.left) {
return false
}
// if one rectangle is above the other
if (rect1.bottom < rect2.top || rect2.bottom < rect1.top) {
return false
}
// the rectangles must overlap
return true
}
/**
* Returns the bounding rectangle of the first DOM
* element in the given jQuery object.
*/
const getRectangle = ($el) => $el[0].getBoundingClientRect();
describe('Mainnet', () => {
beforeEach(() => {
//cy.intercept('/sockjs-node/info*').as('socket');
cy.intercept('/api/block-height/*').as('block-height');
cy.intercept('/api/block/*').as('block');
cy.intercept('/api/block/*/txs/0').as('block-txs');
cy.intercept('/api/tx/*/outspends').as('tx-outspends');
cy.intercept('/resources/pools.json').as('pools');
// Search Auto Complete
cy.intercept('/api/address-prefix/1wiz').as('search-1wiz');
cy.intercept('/api/address-prefix/1wizS').as('search-1wizS');
cy.intercept('/api/address-prefix/1wizSA').as('search-1wizSA');
Cypress.Commands.add('waitForBlockData', () => {
cy.wait('@tx-outspends');
cy.wait('@pools');
});
});
if (baseModule === 'mempool') {
it('check first mempool block after skeleton loads', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#mempool-block-0 > .blockLink').should('exist');
});
it('loads the status screen', () => {
cy.visit('/status');
cy.get('#mempool-block-0').should('be.visible');
cy.get('[id^="bitcoin-block-"]').should('have.length', 8);
cy.get('.footer').should('be.visible');
cy.get('.row > :nth-child(1)').invoke('text').then((text) => {
expect(text).to.match(/Incoming transactions.* vB\/s/);
});
cy.get('.row > :nth-child(2)').invoke('text').then((text) => {
expect(text).to.match(/Unconfirmed:(.*)/);
});
cy.get('.row > :nth-child(3)').invoke('text').then((text) => {
expect(text).to.match(/Mempool size:(.*) (kB|MB) \((\d+) (block|blocks)\)/);
});
});
//TODO: This test is flaky, refactor later
it.skip('loads dashboard, drop websocket and reconnect', () => {
cy.viewport('macbook-16');
cy.mockMempoolSocket();
cy.visit('/');
cy.get('.badge').should('not.exist');
dropWebSocket();
cy.get('.badge').should('be.visible');
cy.get('.badge', { timeout: 25000 }).should('not.exist');
emitMempoolInfo({
'params': {
command: 'init'
}
});
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
});
it('loads the dashboard', () => {
cy.visit('/');
cy.waitForSkeletonGone();
});
it('check op_return tx tooltip', () => {
cy.visit('/block/00000000000000000003c5f542bed265319c6cf64238cf1f1bb9bca3ebf686d2');
cy.waitForSkeletonGone();
cy.get('tbody > :nth-child(2) > :nth-child(1) > a').first().trigger('onmouseover');
cy.get('tbody > :nth-child(2) > :nth-child(1) > a').first().trigger('mouseenter');
cy.get('.tooltip-inner').should('be.visible');
});
it('check op_return coinbase tooltip', () => {
cy.visit('/block/00000000000000000003c5f542bed265319c6cf64238cf1f1bb9bca3ebf686d2');
cy.waitForSkeletonGone();
cy.get('div > a > .badge').first().trigger('onmouseover');
cy.get('div > a > .badge').first().trigger('mouseenter');
cy.get('.tooltip-inner').should('be.visible');
});
describe('search', () => {
it('allows searching for partial Bitcoin addresses', () => {
cy.visit('/');
cy.get('.search-box-container > .form-control').type('1wiz').then(() => {
cy.wait('@search-1wiz');
cy.get('ngb-typeahead-window button.dropdown-item').should('have.length', 10);
});
cy.get('.search-box-container > .form-control').type('S').then(() => {
cy.wait('@search-1wizS');
cy.get('ngb-typeahead-window button.dropdown-item').should('have.length', 5);
});
cy.get('.search-box-container > .form-control').type('A').then(() => {
cy.wait('@search-1wizSA');
cy.get('ngb-typeahead-window button.dropdown-item').should('have.length', 1)
});
cy.get('ngb-typeahead-window button.dropdown-item.active').click().then(() => {
cy.url().should('include', '/address/1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC');
cy.waitForSkeletonGone();
cy.get('.text-center').should('not.have.text', 'Invalid Bitcoin address');
});
});
['BC1PQYQSZQ', 'bc1PqYqSzQ'].forEach((searchTerm) => {
it(`allows searching for partial case insensitive bech32m addresses: ${searchTerm}`, () => {
cy.visit('/');
cy.get('.search-box-container > .form-control').type(searchTerm).then(() => {
cy.get('ngb-typeahead-window button.dropdown-item').should('have.length', 1);
cy.get('ngb-typeahead-window button.dropdown-item.active').click().then(() => {
cy.url().should('include', '/address/bc1pqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqsyjer9e');
cy.waitForSkeletonGone();
cy.get('.text-center').should('not.have.text', 'Invalid Bitcoin address');
});
});
});
});
['BC1Q000375VXCU', 'bC1q000375vXcU'].forEach((searchTerm) => {
it(`allows searching for partial case insensitive bech32 addresses: ${searchTerm}`, () => {
cy.visit('/');
cy.get('.search-box-container > .form-control').type(searchTerm).then(() => {
cy.get('ngb-typeahead-window button.dropdown-item').should('have.length', 1);
cy.get('ngb-typeahead-window button.dropdown-item.active').click().then(() => {
cy.url().should('include', '/address/bc1q000375vxcuf5v04lmwy22vy2thvhqkxghgq7dy');
cy.waitForSkeletonGone();
cy.get('.text-center').should('not.have.text', 'Invalid Bitcoin address');
});
});
});
});
});
describe('address highlighting', () => {
it('highlights single input addresses', () => {
const address = '1wiz32gbHZwMzJCRHMGehJuBgsMTPdaCa';
cy.visit(`/address/${address}`);
cy.waitForSkeletonGone();
cy.get('[data-cy="tx-0"] .table-tx-vin .highlight').should('exist');
cy.get('[data-cy="tx-0"] .table-tx-vin .highlight').invoke('text').should('contain', `${address}`);
});
it('highlights multiple input addresses', () => {
const address = '1wiz1rtKFBA58qjb582WF5KAFg9mWCuZV';
cy.visit(`/address/${address}`);
cy.waitForSkeletonGone();
cy.get('[data-cy="tx-2"] .table-tx-vin .highlight').should('exist');
cy.get('[data-cy="tx-2"] .table-tx-vin .highlight').its('length').should('equal', 2);
cy.get('[data-cy="tx-2"] .table-tx-vin .highlight').invoke('text').should('contain', `${address}`);
});
it('highlights both input and output addresses in the same transaction', () => {
const address = 'bc1q03u63r6hm7a3v6em58zdqtp446w2pw30nm63mv';
cy.visit(`/address/${address}`);
cy.waitForSkeletonGone();
cy.get('[data-cy="tx-1"] .table-tx-vin .highlight').should('exist');
cy.get('[data-cy="tx-1"] .table-tx-vout .highlight').should('exist');
});
it('highlights single output addresses', () => {
const address = '1wiz32gbHZwMzJCRHMGehJuBgsMTPdaCa';
cy.visit(`/address/${address}`);
cy.waitForSkeletonGone();
cy.get('[data-cy="tx-1"] .table-tx-vout .highlight').should('exist');
cy.get('[data-cy="tx-1"] .table-tx-vout .highlight').invoke('text').should('contain', `${address}`);
});
it('highlights multiple output addresses', () => {
const address = '1F3Q3sQmiGsWSqK5K6T9tYnX8yqzYRgQbe';
cy.visit(`/address/${address}`);
cy.waitForSkeletonGone();
cy.get('[data-cy="tx-1"] .table-tx-vout .highlight').should('exist');
cy.get('[data-cy="tx-1"] .table-tx-vout .highlight').its('length').should('equal', 2);
cy.get('[data-cy="tx-1"] .table-tx-vout .highlight').invoke('text').should('contain', `${address}`);
});
});
describe('blocks navigation', () => {
describe('keyboard events', () => {
it('loads first blockchain blocks visible and keypress arrow right', () => {
cy.viewport('macbook-16');
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('.blockchain-blocks-0 > a').click().then(() => {
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('not.exist');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.waitForPageIdle();
cy.document().right();
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
});
});
it('loads first blockchain blocks visible and keypress arrow left', () => {
cy.viewport('macbook-16');
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('.blockchain-blocks-0 > a').click().then(() => {
cy.waitForPageIdle();
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('not.exist');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.document().left();
cy.get('.title-block h1').invoke('text').should('equal', 'Next Block');
});
});
it('loads last blockchain blocks and keypress arrow right', () => {
cy.viewport('macbook-16');
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('.blockchain-blocks-4 > a').click().then(() => {
cy.waitForPageIdle();
// block 6
cy.document().right();
cy.wait(5000);
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
// block 7
cy.document().right();
cy.wait(5000);
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
// block 8 - last visible block
cy.document().right();
cy.wait(5000);
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
// block 9 - not visible at the blochchain blocks visible block
cy.document().right();
cy.wait(5000);
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
});
});
it('loads genesis block and keypress arrow right', () => {
cy.viewport('macbook-16');
cy.visit('/block/0');
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.document().right();
cy.wait(5000);
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('not.exist');
});
it('loads genesis block and keypress arrow left', () => {
cy.viewport('macbook-16');
cy.visit('/block/0');
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.document().left();
cy.wait(5000);
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
});
});
describe('mouse events', () => {
it('loads first blockchain blocks visible and click on the arrow right', () => {
cy.viewport('macbook-16');
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('.blockchain-blocks-0 > a').click().then(() => {
cy.waitForPageIdle();
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('not.exist');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').click().then(() => {
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
});
});
});
it('loads genesis block and click on the arrow left', () => {
cy.viewport('macbook-16');
cy.visit('/block/0');
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('not.exist');
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').click().then(() => {
cy.get('[ngbtooltip="Next Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
cy.get('[ngbtooltip="Previous Block"] > .ng-fa-icon > .svg-inline--fa').should('be.visible');
});
});
});
});
it('loads skeleton when changes between networks', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.changeNetwork("testnet");
cy.changeNetwork("signet");
cy.changeNetwork("mainnet");
});
it.skip('loads the dashboard with the skeleton blocks', () => {
cy.mockMempoolSocket();
cy.visit("/");
cy.get(':nth-child(1) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(2) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(3) > #bitcoin-block-0').should('be.visible');
cy.get('#mempool-block-0').should('be.visible');
cy.get('#mempool-block-1').should('be.visible');
cy.get('#mempool-block-2').should('be.visible');
emitMempoolInfo({
'params': {
command: 'init'
}
});
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
});
it('loads the pools screen', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#btn-pools').click().then(() => {
cy.wait(1000);
});
});
it('loads the graphs screen', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#btn-graphs').click().then(() => {
cy.wait(1000);
});
});
describe('graphs page', () => {
it('check buttons - mobile', () => {
cy.viewport('iphone-6');
cy.visit('/graphs');
cy.waitForSkeletonGone();
cy.get('.small-buttons > :nth-child(2)').should('be.visible');
cy.get('#dropdownFees').should('be.visible');
cy.get('.btn-group').should('be.visible');
});
it('check buttons - tablet', () => {
cy.viewport('ipad-2');
cy.visit('/graphs');
cy.waitForSkeletonGone();
cy.get('.small-buttons > :nth-child(2)').should('be.visible');
cy.get('#dropdownFees').should('be.visible');
cy.get('.btn-group').should('be.visible');
});
it('check buttons - desktop', () => {
cy.viewport('macbook-16');
cy.visit('/graphs');
cy.waitForSkeletonGone();
cy.get('.small-buttons > :nth-child(2)').should('be.visible');
cy.get('#dropdownFees').should('be.visible');
cy.get('.btn-group').should('be.visible');
});
});
it('loads the tv screen - desktop', () => {
cy.viewport('macbook-16');
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#btn-tv').click().then(() => {
cy.viewport('macbook-16');
cy.get('.chart-holder');
cy.get('.blockchain-wrapper').should('be.visible');
cy.get('#mempool-block-0').should('be.visible');
});
});
it('loads the tv screen - mobile', () => {
cy.viewport('iphone-6');
cy.visit('/tv');
cy.waitForSkeletonGone();
cy.get('.chart-holder');
cy.get('.blockchain-wrapper').should('not.visible');
});
it('loads the api screen', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#btn-docs').click().then(() => {
cy.wait(1000);
});
});
describe('blocks', () => {
it('shows empty blocks properly', () => {
cy.visit('/block/0000000000000000000bd14f744ef2e006e61c32214670de7eb891a5732ee775');
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.get('h2').invoke('text').should('equal', '1 transaction');
});
it('expands and collapses the block details', () => {
cy.visit('/block/0');
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('be.visible');
});
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('not.be.visible');
});
});
it('shows blocks with no pagination', () => {
cy.visit('/block/00000000000000000001ba40caf1ad4cec0ceb77692662315c151953bfd7c4c4');
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.get('.block-tx-title h2').invoke('text').should('equal', '19 transactions');
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 5);
});
it('supports pagination on the block screen', () => {
// 41 txs
cy.visit('/block/00000000000000000009f9b7b0f63ad50053ad12ec3b7f5ca951332f134f83d8');
cy.waitForSkeletonGone();
cy.get('.pagination-container a').invoke('text').then((text1) => {
cy.get('.active + li').first().click().then(() => {
cy.waitForSkeletonGone();
cy.waitForPageIdle();
cy.get('.header-bg.box > a').invoke('text').then((text2) => {
expect(text1).not.to.eq(text2);
});
});
});
});
it('shows blocks pagination with 5 pages (desktop)', () => {
cy.viewport(760, 800);
cy.visit('/block/000000000000000000049281946d26fcba7d99fdabc1feac524bc3a7003d69b3').then(() => {
cy.waitForSkeletonGone();
cy.waitForPageIdle();
});
// 5 pages + 4 buttons = 9 buttons
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 9);
});
it('shows blocks pagination with 3 pages (mobile)', () => {
cy.viewport(669, 800);
cy.visit('/block/000000000000000000049281946d26fcba7d99fdabc1feac524bc3a7003d69b3').then(() => {
cy.waitForSkeletonGone();
cy.waitForPageIdle();
});
// 3 pages + 4 buttons = 7 buttons
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 7);
});
});
describe('RBF transactions', () => {
it('shows RBF transactions properly (mobile)', () => {
cy.viewport('iphone-xr');
cy.mockMempoolSocket();
cy.visit('/tx/f81a08699b62b2070ad8fe0f2a076f8bea0386a2fdcd8124caee42cbc564a0d5');
cy.waitForSkeletonGone();
emitMempoolInfo({
'params': {
command: 'init'
}
});
cy.get('#mempool-block-0');
emitMempoolInfo({
'params': {
command: 'rbfTransaction'
}
});
cy.get('.alert-mempool').should('be.visible');
cy.get('.alert-mempool').invoke('css', 'width').then((alertWidth) => {
cy.get('.container-xl > :nth-child(3)').invoke('css', 'width').should('equal', alertWidth);
});
cy.get('.btn-success').then(getRectangle).then((rectA) => {
cy.get('.alert-mempool').then(getRectangle).then((rectB) => {
expect(areOverlapping(rectA, rectB), 'Confirmations box and RBF alert are overlapping').to.be.false;
});
});
});
it('shows RBF transactions properly (desktop)', () => {
cy.viewport('macbook-16');
cy.mockMempoolSocket();
cy.visit('/tx/f81a08699b62b2070ad8fe0f2a076f8bea0386a2fdcd8124caee42cbc564a0d5');
cy.waitForSkeletonGone();
emitMempoolInfo({
'params': {
command: 'init'
}
});
cy.get('#mempool-block-0');
emitMempoolInfo({
'params': {
command: 'rbfTransaction'
}
});
cy.get('.alert-mempool').should('be.visible');
const alertLocator = '.alert-mempool';
const tableLocator = '.container-xl > :nth-child(3)';
cy.get(tableLocator).invoke('css', 'width').then((firstWidth) => {
cy.get(alertLocator).invoke('css', 'width').should('equal', firstWidth);
});
cy.get('.btn-success').then(getRectangle).then((rectA) => {
cy.get('.alert-mempool').then(getRectangle).then((rectB) => {
expect(areOverlapping(rectA, rectB), 'Confirmations box and RBF alert are overlapping').to.be.false;
});
});
});
});
} else {
it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`);
}
});

View File

@@ -0,0 +1,139 @@
import { emitMempoolInfo } from "../../support/websocket";
const baseModule = Cypress.env("BASE_MODULE");
describe('Signet', () => {
beforeEach(() => {
cy.intercept('/api/block-height/*').as('block-height');
cy.intercept('/api/block/*').as('block');
cy.intercept('/api/block/*/txs/0').as('block-txs');
cy.intercept('/api/tx/*/outspends').as('tx-outspends');
});
if (baseModule === 'mempool') {
it('loads the dashboard', () => {
cy.visit('/signet');
cy.waitForSkeletonGone();
});
it('check first mempool block after skeleton loads', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#mempool-block-0 > .blockLink').should('exist');
});
it.skip('loads the dashboard with the skeleton blocks', () => {
cy.mockMempoolSocket();
cy.visit("/signet");
cy.get(':nth-child(1) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(2) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(3) > #bitcoin-block-0').should('be.visible');
cy.get('#mempool-block-0').should('be.visible');
cy.get('#mempool-block-1').should('be.visible');
cy.get('#mempool-block-2').should('be.visible');
emitMempoolInfo({
'params': {
"network": "signet"
}
});
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
});
it('loads the pools screen', () => {
cy.visit('/signet');
cy.waitForSkeletonGone();
cy.get('#btn-pools').click().then(() => {
cy.wait(1000);
});
});
it('loads the graphs screen', () => {
cy.visit('/signet');
cy.waitForSkeletonGone();
cy.get('#btn-graphs').click().then(() => {
cy.wait(1000);
});
});
describe('tv mode', () => {
it('loads the tv screen - desktop', () => {
cy.viewport('macbook-16');
cy.visit('/signet');
cy.waitForSkeletonGone();
cy.get('#btn-tv').click().then(() => {
cy.get('.chart-holder').should('be.visible');
cy.get('#mempool-block-0').should('be.visible');
cy.get('.tv-only').should('not.exist');
});
});
it('loads the tv screen - mobile', () => {
cy.visit('/signet');
cy.waitForSkeletonGone();
cy.get('#btn-tv').click().then(() => {
cy.viewport('iphone-8');
cy.get('.chart-holder').should('be.visible');
cy.get('.tv-only').should('not.exist');
//TODO: Remove comment when the bug is fixed
//cy.get('#mempool-block-0').should('be.visible');
});
});
});
it('loads the api screen', () => {
cy.visit('/signet');
cy.waitForSkeletonGone();
cy.get('#btn-docs').click().then(() => {
cy.wait(1000);
});
});
describe('blocks', () => {
it('shows empty blocks properly', () => {
cy.visit('/signet/block/00000133d54e4589f6436703b067ec23209e0a21b8a9b12f57d0592fd85f7a42');
cy.waitForSkeletonGone();
cy.get('h2').invoke('text').should('equal', '1 transaction');
});
it('expands and collapses the block details', () => {
cy.visit('/signet/block/0');
cy.waitForSkeletonGone();
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('be.visible');
});
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('not.be.visible');
});
});
it('shows blocks with no pagination', () => {
cy.visit('/signet/block/00000078f920a96a69089877b934ce7fd009ab55e3170920a021262cb258e7cc');
cy.waitForSkeletonGone();
cy.get('h2').invoke('text').should('equal', '13 transactions');
cy.get('ul.pagination').first().children().should('have.length', 5);
});
it('supports pagination on the block screen', () => {
// 43 txs
cy.visit('/signet/block/00000094bd52f73bdbfc4bece3a94c21fec2dc968cd54210496e69e4059d66a6');
cy.waitForSkeletonGone();
cy.get('.header-bg.box > a').invoke('text').then((text1) => {
cy.get('.active + li').first().click().then(() => {
cy.get('.header-bg.box > a').invoke('text').then((text2) => {
expect(text1).not.to.eq(text2);
});
});
});
});
});
} else {
it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`);
}
});

View File

@@ -0,0 +1,138 @@
import { confirmAddress, emitMempoolInfo, sendWsMock, showNewTx, startTrackingAddress } from "../../support/websocket";
const baseModule = Cypress.env("BASE_MODULE");
describe('Testnet', () => {
beforeEach(() => {
cy.intercept('/api/block-height/*').as('block-height');
cy.intercept('/api/block/*').as('block');
cy.intercept('/api/block/*/txs/0').as('block-txs');
cy.intercept('/api/tx/*/outspends').as('tx-outspends');
});
if (baseModule === 'mempool') {
it('loads the dashboard', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
});
it('check first mempool block after skeleton loads', () => {
cy.visit('/');
cy.waitForSkeletonGone();
cy.get('#mempool-block-0 > .blockLink').should('exist');
});
it.skip('loads the dashboard with the skeleton blocks', () => {
cy.mockMempoolSocket();
cy.visit("/testnet");
cy.get(':nth-child(1) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(2) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(3) > #bitcoin-block-0').should('be.visible');
cy.get('#mempool-block-0').should('be.visible');
cy.get('#mempool-block-1').should('be.visible');
cy.get('#mempool-block-2').should('be.visible');
emitMempoolInfo({
'params': {
loaded: true
}
});
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
});
it('loads the pools screen', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('#btn-pools').click().then(() => {
cy.wait(1000);
});
});
it('loads the graphs screen', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('#btn-graphs').click().then(() => {
cy.wait(1000);
});
});
describe('tv mode', () => {
it('loads the tv screen - desktop', () => {
cy.viewport('macbook-16');
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('#btn-tv').click().then(() => {
cy.wait(1000);
cy.get('.tv-only').should('not.exist');
//TODO: Remove comment when the bug is fixed
//cy.get('#mempool-block-0').should('be.visible');
});
});
it('loads the tv screen - mobile', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('#btn-tv').click().then(() => {
cy.viewport('iphone-6');
cy.wait(1000);
cy.get('.tv-only').should('not.exist');
});
});
});
it('loads the api screen', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('#btn-docs').click().then(() => {
cy.wait(1000);
});
});
describe('blocks', () => {
it('shows empty blocks properly', () => {
cy.visit('/testnet/block/0');
cy.waitForSkeletonGone();
cy.get('h2').invoke('text').should('equal', '1 transaction');
});
it('expands and collapses the block details', () => {
cy.visit('/testnet/block/0');
cy.waitForSkeletonGone();
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('be.visible');
});
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('not.be.visible');
});
});
it('shows blocks with no pagination', () => {
cy.visit('/testnet/block/000000000000002f8ce27716e74ecc7ad9f7b5101fed12d09e28bb721b9460ea');
cy.waitForSkeletonGone();
cy.get('h2').invoke('text').should('equal', '11 transactions');
cy.get('ul.pagination').first().children().should('have.length', 5);
});
it('supports pagination on the block screen', () => {
// 48 txs
cy.visit('/testnet/block/000000000000002ca3878ebd98b313a1c2d531f2e70a6575d232ca7564dea7a9');
cy.waitForSkeletonGone();
cy.get('.header-bg.box > a').invoke('text').then((text1) => {
cy.get('.active + li').first().click().then(() => {
cy.get('.header-bg.box > a').invoke('text').then((text2) => {
expect(text1).not.to.eq(text2);
});
});
});
});
});
} else {
it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`);
}
});

Some files were not shown because too many files have changed in this diff Show More