Compare commits

...

80 Commits

Author SHA1 Message Date
mononaut
a27b4a61e8
Merge pull request #206 from mempool/mononaut/testnet4
add testnet4 support
2025-11-14 15:54:54 +08:00
mononaut
188225ee9b
Merge pull request #205 from mempool/mononaut/upgrade-dependencies
upgrade dependencies
2025-11-14 15:54:43 +08:00
Mononaut
cd518abb75
Add testnet4 2025-11-13 12:44:18 +00:00
Mononaut
b82210f9b2
upgrade dependencies 2025-11-13 12:31:12 +00:00
softsimon
e2668703b3
Merge pull request #202 from mempool/mononaut/v3-prerelease
v3.0.0
2024-12-02 11:21:48 +07:00
Mononaut
1d512794db
v3.0.0 2024-12-01 20:47:38 +00:00
Mononaut
42b8e3fb35
update dependencies 2024-12-01 20:47:12 +00:00
softsimon
d875bc250d
Merge pull request #180 from mempool/natsoni/fix-get-address-txs-endpoint
Add optional after_txid param to getAddressTxs method
2024-03-06 21:58:52 +07:00
softsimon
8bd8634993
Merge pull request #179 from mempool/natsoni/bump-axios
Bump axios dependency version 0.24 -> 1.6.7
2024-03-06 21:58:14 +07:00
natsoni
9d9057c689
Add optional after_txid param to getAddressTxs method 2024-03-05 12:27:40 +01:00
natsoni
676a496524
Fix bundle build by adding esmify devDep 2024-03-05 11:58:32 +01:00
natsoni
157de89446
Bump axios dependency version 2024-03-05 11:28:58 +01:00
natsoni
4faf304445
Fix hostname in websocket example 2024-03-05 11:11:22 +01:00
softsimon
14ddd97e83
Merge pull request #174 from mempool/natsoni/websocket-re-implementation
Rewrite Websocket api
2024-03-05 15:45:20 +07:00
natsoni
4d9425ade3
Rewrite websocket api 2024-02-22 13:00:15 +01:00
natsoni
3b99ee2643
Fix Liquid API constructor 2024-02-21 16:05:03 +01:00
natsoni
fe36609d4f
Remove liquid merkle block proof endpoint 2024-02-20 17:10:52 +01:00
natsoni
3a05b7cd62
Merge pull request #170 from mempool/fix-http-req-opts
Add support for more http options (from @0xFlicker)
2024-02-20 16:12:43 +01:00
natsoni
944c5a81f3
Fix protocol detection 2024-02-20 15:43:07 +01:00
natsoni
bfb4a6dcc1
Merge branch 'main' into fix-http-req-opts and resolve conflicts 2024-02-20 15:28:52 +01:00
softsimon
3c7f94dbf7
Merge pull request #169 from mempool/natsoni/spring-cleaning
Mempool.js clean up
2024-02-20 21:01:11 +07:00
natsoni
241910e230
Fix paths in README files 2024-02-20 14:43:30 +01:00
natsoni
f04fbc1b0e
Fix random bugs and examples 2024-02-20 12:00:32 +01:00
natsoni
9ccd0ed416
Fix examples paths 2024-02-20 11:24:18 +01:00
natsoni
c12771a74c
Remove bisq support and include liquid api in main package 2024-02-20 11:20:00 +01:00
softsimon
cf2cd542c8
Merge pull request #166 from mempool/natsoni/add-endpoints
Add Lightning API endpoints and difficulty
2024-02-20 16:58:27 +07:00
flick
80373ba7fb
feat: adds support for more http options 2024-02-19 17:49:08 -07:00
natsoni
dd90188c68
Add Lightning api to doc 2024-02-18 19:28:50 +01:00
natsoni
d05e7e76e1
Merge pull request #167 from mempool/natsoni/blocks-endpoint-upgrade
Fix block type declaration and upgrade endpoint to v1
2024-02-18 18:23:06 +01:00
natsoni
ed9420c2ee
Fix block type declaration and upgrade endpoint to v1 2024-02-18 18:21:43 +01:00
natsoni
a55db5211a
Add types to hashrate endpoint 2024-02-18 17:48:28 +01:00
natsoni
11ce59a63b
Add lightning API endpoints 2024-02-18 17:40:23 +01:00
natsoni
167b8ace79
Add hashrate endpoint to bitcoin api 2024-02-18 13:22:48 +01:00
natsoni
e0cc5fd0a1
Merge pull request #165 from learntheropes/tx-push
fix bug on transaction push body
2024-02-18 12:48:59 +01:00
natsoni
9b01825d70
Fix postTx request in Liquid api 2024-02-18 12:47:28 +01:00
softsimon
6977129e5a
Merge pull request #164 from mempool/natsoni/fix-package-version
Fix package version to 2.3.0
2024-02-17 23:38:46 +08:00
natsoni
de07484358
Merge pull request #100 from bennyhodl/merkle-proof-interface
fix: return type of txMerkleProof
2024-02-16 17:34:09 +01:00
natsoni
76788dabc0
Fix bisq hostname typo 2024-02-16 15:36:14 +01:00
natsoni
81d870fc56
Fix package version to 2.3.0 2024-02-16 15:08:39 +01:00
bennyhodl
5087157a31 Return type of txMerkleProof - remove array 2023-06-28 18:38:43 -04:00
giovannilaperna
6efe22bb44
fix bug on transaction push body 2023-04-06 23:56:24 +02:00
softsimon
3f0ab7307a
Bumping version to 2.3.0 2022-01-10 15:53:10 +04:00
softsimon
7e8d5547fd
Bumping to 2.3.0-dev1 2021-12-22 19:31:25 +04:00
softsimon
029cd8ad48
Bumping package version to v2.2.6 2021-12-20 23:36:19 +04:00
softsimon
f2a8ac7087
Updating endpoint addresses for Liquid and Bisq backend 2021-12-20 23:34:52 +04:00
softsimon
721ed60ba5
Fixing type for image response 2021-12-20 23:34:36 +04:00
softsimon
4893ff1d81
Adding support for Asset Icon API endpoints 2021-12-20 23:25:44 +04:00
softsimon
d238b1a779
Correcting "blocks" typo 2021-12-20 23:14:11 +04:00
softsimon
a9b2f31ae5
Merge pull request #32 from mikeriss/patch-2
Typo fixed
2021-12-20 23:13:32 +04:00
Dmitry Martynenko
ce56c1b03b
websocket testnet url fix 2021-12-20 23:08:13 +04:00
softsimon
b5a8a5dc24
Merge pull request #35 from mempool/simon/version-bump-2.2.4
Bumping dependency versions and package version to 2.2.4
2021-12-20 22:26:57 +04:00
softsimon
06f23c5f37
Bumping dependency versions and package version to 2.2.4 2021-12-20 22:25:12 +04:00
softsimon
870bae5180
Merge pull request #30 from Draichi/patch-1
Update README-bitcoin.md
2021-12-08 21:36:58 +04:00
mikeriss
a614ad4119
Typo fixed 2021-11-02 17:15:01 +01:00
mikeriss
3a42e20cf1
Typo (#31)
changed res.blocks to res.block
2021-10-25 09:21:01 -03:00
Lucas
905ef5ed19
Update README-bitcoin.md
Fix 404 on page links
2021-09-06 13:36:58 -03:00
Miguel Medeiros
9fe77e49a2 Change liquid address doc example. 2021-08-10 13:09:38 -03:00
Miguel Medeiros
62902ba8c7 Add liquid.js documentation. 2021-08-10 13:03:23 -03:00
Miguel Medeiros
1873eb41c6 Change version to 2.2.1 for bisq / liquid modules. 2021-08-10 12:39:11 -03:00
Miguel Medeiros
efd0436851 Add bisq.js readme. 2021-08-10 12:38:33 -03:00
Miguel Medeiros
edab1ad3d5 Fix post tx documentation. 2021-08-10 01:44:50 -03:00
Miguel Medeiros
4efc927303 Add bisqJS and liquidJS npm modules. 2021-08-10 01:30:13 -03:00
Miguel Medeiros
acc0c80953 2.2.4 2021-08-04 08:11:27 -03:00
Miguel Medeiros
334ed2b173 Fix difficulty adjustment endpoint. 2021-08-04 08:09:29 -03:00
Miguel Medeiros
24f0ab8f84 2.2.3 2021-07-23 18:08:43 -03:00
Miguel Medeiros
c1f41d6e1c Add difficulty adjustment documentation link. 2021-07-23 18:02:14 -03:00
Miguel Medeiros
aed4bc5fc9 Add difficulty adjustment examples. 2021-07-23 17:58:54 -03:00
Miguel Medeiros
caf8d956b5 Add difficulty adjustment endpoints methods. 2021-07-23 17:37:28 -03:00
Miguel Medeiros
1c32b05abe Add localhost support. 2021-07-23 17:36:40 -03:00
Miguel Medeiros
7dec92a1bf Change documentation link to official mempool.space. 2021-07-22 02:22:03 -03:00
Miguel Medeiros
4cd7665e8c Add blockHeader instructions and examples. 2021-07-22 02:18:15 -03:00
Miguel Medeiros
47fa100786 Add getBlockHeader method. 2021-07-22 02:14:11 -03:00
Miguel Medeiros
f244ad191e Change command build. 2021-07-22 00:55:29 -03:00
Miguel Medeiros
92bf87821a 2.2.2 2021-05-31 21:03:20 -03:00
Miguel Medeiros
920622137b Fix readme instructions. 2021-05-31 20:36:00 -03:00
Miguel Medeiros
b3606e46c1 Fix getAddress endpoint url. 2021-05-31 20:02:16 -03:00
Miguel Medeiros
112e54ae57
2.2.1 (#22) 2021-05-20 12:25:11 -03:00
Miguel Medeiros
e3068c2d8d
Bugfix Websocket hostname. (#21)
* Add yarn-error.log to gitignore.

* Add ts-node to devDependencies.
Add script to only build tsc.
Add websocket to keywords.

* Update yarn.lock libs.

* FIX websocket endpoint hostname.
FIX corrent import for all examples.
FIX websocket instrucions on readme.
2021-05-20 12:03:40 -03:00
Miguel Medeiros
0aa3757217 FIX rename package. 2021-04-17 00:34:47 -03:00
Miguel Medeiros
f26adbd982
FIX rename package name. (#19) (#20) 2021-04-17 00:20:32 -03:00
83 changed files with 14582 additions and 3345 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
/lib /lib
/dist/* /dist/*
!.gitkeep !.gitkeep
yarn-error.log

View File

@ -1,150 +0,0 @@
# mempool**JS** - Bisq API
Interface to access the Bisq API.
[Back to home](./README-bitcoin.md)
---
## **Features**
- [Bitcoin](./README-bitcoin.md)
- Bisq
- Addresses
- [Get Address](#get-address)
- Blocks
- [Get Block](#get-block)
- [Get Blocks](#get-blocks)
- [Get Block Tip Height](#get-block-tip-height)
- Statistics
- Transactions
- [Get Transaction](#get-transaction)
- [Get Transactions](#get-transactions)
- [Liquid](./README-liquid.md)
---
### **Get Address**
Returns statistics about all Bisq transactions.
[ [NodeJS Example](examples/nodejs/bisq/addresses.ts) ] [ [HTML Example](examples/html/bisq/addresses.html) ] [ [Top](#features) ]
```js
const {
bisq: { addresses },
} = mempoolJS();
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
```
### **Get Block**
Returns all Bisq transactions that exist in a Bitcoin block.
**Parameters:**
- {string} hash
[ [NodeJS Example](examples/nodejs/bisq/blocks.ts) ] [ [HTML Example](examples/html/bisq/blocks.html) ] [ [Top](#features) ]
```js
const {
bisq: { blocks },
} = mempoolJS();
const hash = '000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
const block = await blocks.getBlock({ hash });
console.log(block);
```
### **Get Blocks**
Returns `:length` Bitcoin blocks that contain Bisq transactions, starting from `:index`.
**Parameters:**
- {number} index
- {number} length
[ [NodeJS Example](examples/nodejs/bisq/blocks.ts) ] [ [HTML Example](examples/html/bisq/blocks.html) ] [ [Top](#features) ]
```js
const {
bisq: { blocks },
} = mempoolJS();
const hash = '000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
console.log(myBlocks);
```
### **Get Blocks Tip Height**
Returns the most recently processed Bitcoin block height processed by Bisq.
[ [NodeJS Example](examples/nodejs/bisq/blocks.ts) ] [ [HTML Example](examples/html/bisq/blocks.html) ] [ [Top](#features) ]
```js
const {
bisq: { blocks },
} = mempoolJS();
const myBlocksHeight = await blocks.getBlocksTipHeight({
index: 0,
length: 1,
});
console.log(myBlocksHeight);
```
### **Get Stats**
Returns statistics about all Bisq transactions.
[ [NodeJS Example](examples/nodejs/bisq/statistics.ts) ] [ [HTML Example](examples/html/bisq/statistics.html) ] [ [Top](#features) ]
```js
const {
bisq: { statistics },
} = mempoolJS();
const stats = await statistics.getStats();
console.log(stats);
```
### **Get Transaction**
Returns details about a Bisq transaction.
[ [NodeJS Example](examples/nodejs/bisq/transactions.ts) ] [ [HTML Example](examples/html/bisq/transactions.html) ] [ [Top](#features) ]
```js
const {
bisq: { transactions },
} = mempoolJS();
const txid = '4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
const tx = await transactions.getTx({ txid });
console.log(tx);
```
### **Get Transactions**
Returns details about a Bisq transactions.
[ [NodeJS Example](examples/nodejs/bisq/transactions.ts) ] [ [HTML Example](examples/html/bisq/transactions.html) ] [ [Top](#features) ]
```js
const {
bisq: { transactions },
} = mempoolJS();
const txs = await transactions.getTxs({ index: 0, length: 1 });
console.log(txs);
```

View File

@ -1,57 +1,87 @@
# mempool**JS** - Bitcoin API # mempool**JS** - Bitcoin API
Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs. Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `signet` APIs.
[Back to home](#) [Back to home](./README.md)
--- ---
## **Features** ## **Features**
- Bitcoin - Addresses
- Addresses - [Get Address](#get-address)
- [Get Address](#get-address) - [Get Address Txs](#get-address-txs)
- [Get Address Txs](#get-address-txs) - [Get Address Txs Chain](#get-address-txs-chain)
- [Get Address Txs Chain](#get-address-txs-chain) - [Get Address Txs Mempool](#get-address-txs-mempool)
- [Get Address Txs Mempool](#get-address-txs-mempool) - [Get Address Txs Utxo](#get-address-txs-utxo)
- [Get Address Txs Utxo](#get-address-txs-utxo) - Assets
- Assets - [Get Asset](#get-asset)
- [Get Asset](#get-asset) - [Get Asset Txs](#get-asset-txs)
- [Get Asset Txs](#get-asset-txs) - [Get Asset Supply](#get-asset-supply)
- [Get Asset Supply](#get-asset-supply) - Blocks
- Blocks - [Get Block](#get-block)
- [Get Block](#get-block) - [Get Block Status](#get-block-status)
- [Get Block Status](#get-block-status) - [Get Block Txs](#get-block-txs)
- [Get Block Txs](#get-block-txs) - [Get Block Txids](#get-block-txids)
- [Get Block Txids](#get-block-txids) - [Get Block Txid](#get-block-txid)
- [Get Block Txid](#get-block-txid) - [Get Block Raw](#get-block-raw)
- [Get Block Raw](#get-block-raw) - [Get Blocks Header](#get-blocks-header)
- [Get Blocks Height](#get-blocks-height) - [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks) - [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height) - [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash) - [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Fees - Difficulty
- [Get Fees Recommended](#get-fees-recommended) - [Get Difficulty Adjustment](#get-difficulty-adjustment)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks) - Fees
- Mempool - [Get Fees Recommended](#get-fees-recommended)
- [Get Mempool](#get-mempool) - [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- [Get Mempool Recent](#get-mempool-recent) - Lightning
- [Get Mempool Txids](#get-mempool-txids) - [Get Network Stats](#get-network-stats)
- Transactions - [Get Nodes In Country](#get-nodes-in-country)
- [Get Tx](#get-tx) - [Get Nodes Stats Per Country](#get-nodes-stats-per-country)
- [Get Tx Status](#get-tx-status) - [Get Nodes Hosted by ISP](#get-nodes-hosted-by-isp)
- [Get Tx Hex](#get-tx-hex) - [Get ISP Ranking](#get-isp-ranking)
- [Get Tx Raw](#get-tx-raw) - [Get Liquidity Ranking](#get-liquidity-ranking)
- [Get Tx Merkle Block Proof](#get-tx-merkle-block-proof) - [Get Connectivity Ranking](#get-connectivity-ranking)
- [Get Tx Merkle Proof](#get-tx-merkle-proof) - [Get Oldest Nodes](#get-oldest-nodes)
- [Get Tx Outspend](#get-tx-outspend) - [Get Node Stats](#get-node-stats)
- [Get Tx Outspends](#get-tx-outspends) - [Get Historical Node Stats](#get-historical-node-stats)
- [Post Tx Outspends]($post-tx-outspends) - [Get Channel](#get-channel)
- Websocket - [Get Channels From Transaction IDs](#get-channels-from-transaction-ids)
- [Websocket Client](#websocket-client) - [Get Channels From Node Public Key](#get-channels-from-node-public-key)
- [Websocket Server](#websocket-server) - [Get Channels Geodata](#get-channels-geodata)
- [Bisq](./README-bisq.md) - [Get Channels Geodata By Public Key](#get-channels-geodata-by-public-key)
- [Liquid](./README-liquid.md) - Mempool
- [Get Mempool](#get-mempool)
- [Get Mempool Recent](#get-mempool-recent)
- [Get Mempool Txids](#get-mempool-txids)
- Transactions
- [Get Tx](#get-tx)
- [Get Tx Status](#get-tx-status)
- [Get Tx Hex](#get-tx-hex)
- [Get Tx Raw](#get-tx-raw)
- [Get Tx Merkle Block Proof](#get-tx-merkle-block-proof)
- [Get Tx Merkle Proof](#get-tx-merkle-proof)
- [Get Tx Outspend](#get-tx-outspend)
- [Get Tx Outspends](#get-tx-outspends)
- [Post Tx](#post-tx)
- Websocket
- [Init Websocket](#init-websocket)
- [Want Data](#want-data)
- [Stop Want Data](#stop-want-data)
- [Track Address](#track-address)
- [Stop Track Address](#stop-track-address)
- [Track Addresses](#track-addresses)
- [Stop Track Addresses](#stop-track-addresses)
- [Track Transaction](#track-transaction)
- [Stop Track Transaction](#stop-track-transaction)
- [Track Rbf Summary](#track-rbf-summary)
- [Stop Track Rbf Summary](#stop-track-rbf-summary)
- [Track Rbf](#track-rbf)
- [Stop Track Rbf](#stop-track-rbf)
- [Track Mempool Block](#track-mempool-block)
- [Stop Track Mempool Block](#stop-track-mempool-block)
--- ---
@ -284,6 +314,25 @@ const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw); console.log(blockRaw);
``` ```
### **Get Blocks Header**
Returns the hex-encoded block header.
**Parameters:**
- {string} hash
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { blocks },
} = mempoolJS();
const blockHeader = await blocks.getBlockHeader({ hash: '0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2' });
console.log(blockHeader);
```
### **Get Blocks Height** ### **Get Blocks Height**
Returns the hash of the block currently at `:height`. Returns the hash of the block currently at `:height`.
@ -356,6 +405,21 @@ const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash); console.log(blocksTipHash);
``` ```
### **Get Difficulty Adjustment**
Returns the hash of the last block.
[ [NodeJS Example](examples/nodejs/bitcoin/difficulty.ts) ] [ [HTML Example](examples/html/bitcoin/difficulty.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { difficulty },
} = mempoolJS();
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
console.log(difficultyAdjustment);
```
### **Get Fees Recommended** ### **Get Fees Recommended**
Returns our currently suggested fees for new transactions. Returns our currently suggested fees for new transactions.
@ -386,6 +450,283 @@ const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks); console.log(feesMempoolBlocks);
``` ```
### **Get Network Stats**
Returns network-wide stats such as total number of channels and nodes, total capacity, and average/median fee figures.
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const networkStats = await lightning.getNetworkStats();
console.log(networkStats);
```
### **Get Nodes In Country**
Returns a list of Lightning nodes running on clearnet in the requested `:country`, where `:country` is an ISO Alpha-2 country code.
**Parameters:**
- {string} country
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const nodesInCountry = await lightning.getNodesInCountry({ country: 'US' });
console.log(nodesInCountry);
```
### **Get Nodes Stats Per Country**
Returns aggregate capacity and number of clearnet nodes per country. Capacity figures are in satoshis.
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const nodesStatsPerCountry = await lightning.getNodesStatsPerCountry();
console.log(nodesStatsPerCountry);
```
### **Get Nodes Hosted by ISP**
Returns a list of nodes hosted by a specified `:isp`, where `:isp` is an ISP's ASN.
**Parameters:**
- {number} isp
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const nodesHostedByISP = await lightning.getNodesHostedByISP({ isp: 16509 });
console.log(nodesHostedByISP);
```
### **Get ISP Ranking**
Returns aggregate capacity, number of nodes, and number of channels per ISP. Capacity figures are in satoshis.
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const ispRanking = await lightning.getISPRanking();
console.log(ispRanking);
```
### **Get Liquidity Ranking**
Returns a list of the top 100 nodes by liquidity (aggregate channel capacity).
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const liquidityRanking = await lightning.getLiquidityRanking();
console.log(liquidityRanking);
```
### **Get Connectivity Ranking**
Returns a list of the top 100 nodes by connectivity (number of open channels).
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const connectivityRanking = await lightning.getConnectivityRanking();
console.log(connectivityRanking);
```
### **Get Oldest Nodes**
Returns a list of the top 100 oldest nodes.
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const oldestNodes = await lightning.getOldestNodes();
console.log(oldestNodes);
```
### **Get Node Stats**
Returns details about a node with the given `:public_key`.
**Parameters:**
- {string} public_key
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const nodeStats = await lightning.getNodeStats({ public_key });
console.log(nodeStats);
```
### **Get Historical Node Stats**
Returns historical stats for a node with the given `:public_key`.
**Parameters:**
- {string} public_key
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const historicalNodeStats = await lightning.getHistoricalNodeStats({ public_key });
console.log(historicalNodeStats);
```
### **Get Channel**
Returns details about a channel with the given `:id`.
**Parameters:**
- {string} id
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const channel = await lightning.getChannel({ id });
console.log(channel);
```
### **Get Channels From Transaction IDs**
Returns channels that correspond to the given `:txId` (multiple transaction IDs can be specified).
**Parameters:**
- {[]string} txId
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const channelsFromTransactionIDs = await lightning.getChannelsFromTransactionIDs({ txId });
console.log(channelsFromTransactionIDs);
```
### **Get Channels From Node Public Key**
Returns a list of a node's channels given its `:public_key`. Ten channels are returned at a time. Use `:index` for paging. `:status` can be `open`, `active`, or `closed`.
**Parameters:**
- {string} public_key
- {string} status
- {number} index
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const channelsFromNodePublicKey = await lightning.getChannelsFromNodePublicKey({ public_key, status, index });
console.log(channelsFromNodePublicKey);
```
### **Get Channels Geodata**
Returns a list of channels with corresponding node geodata.
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const channelsGeodata = await lightning.getChannelsGeodata();
console.log(channelsGeodata);
```
### **Get Channels Geodata By Public Key**
Returns a list of channels with corresponding geodata for a node with the given `:public_key`.
**Parameters:**
- {string} public_key
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { lightning },
} = mempoolJS();
const channelsGeodataByPublicKey = await lightning.getChannelsGeodataByPublicKey({ public_key });
console.log(channelsGeodataByPublicKey);
```
### **Get Children Pay for Parent**
Returns current mempool as projected blocks.
[ [NodeJS Example](examples/nodejs/bitcoin/fees.ts) ] [ [HTML Example](examples/html/bitcoin/fees.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { fees },
} = mempoolJS();
const txid = 'txid';
const feesCPFP = await fees.getCPFP({ txid });
console.log(feesCPFP);
```
### **Get Mempool** ### **Get Mempool**
Returns current mempool backlog statistics. Returns current mempool backlog statistics.
@ -603,13 +944,13 @@ const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends); console.log(txOutspends);
``` ```
### **Post Tx Outspends** ### **Post Tx **
Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success. Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success.
**Parameters:** **Parameters:**
- {string} txid - {string} txhex
[ [NodeJS Example](examples/nodejs/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ] [ [NodeJS Example](examples/nodejs/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
@ -618,72 +959,163 @@ const {
bitcoin: { transactions }, bitcoin: { transactions },
} = mempoolJS(); } = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521'; const txhex = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const postTx = await transactions.postTx({ txid }); const postTx = await transactions.postTx({ txhex });
console.log(postTx); console.log(postTx);
``` ```
### **Websocket** ### **Init Websocket**
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats. Initializes a websocket connection.
Push transactions related to address: `{ 'track-address': '3PbJ...bF9B' }` to receive all new transactions containing that address as input or output. Returns an array of transactions. address-transactions for new mempool transactions, and block-transactions for new block confirmed transactions. [ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
#### **Websocket Server**
```js ```js
const { const { bitcoin: { websocket } } = mempoolJS();
bitcoin: { websocket }, const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
} = mempoolJS(); ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
const ws = websocket.initServer({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.on('message', function incoming(data) {
const res = JSON.parse(data.toString());
if (res.blocks) {
console.log(res.blocks);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
}); });
``` ```
#### **Websocket Client** ### **Want Data**
Subscribe to `want` data. Available: `blocks`, `mempool-block`, `live-2h-chart`, and `stats`.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js ```js
const { websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
bitcoin: { websocket }, ```
} = mempoolJS();
### **Stop Want Data**
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'], Unsubscribe from `want` data.
});
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
ws.on('message', function incoming(data) {
const res = JSON.parse(data.toString()); ```js
if (res.blocks) { websocket.wsStopData(ws); // for in-browser websocket, use websocket.wsStopDataBrowser
console.log(res.blocks); ```
}
if (res.mempoolInfo) { ### **Track Address**
console.log(res.mempoolInfo);
} Subscribe to address updates.
if (res.transactions) {
console.log(res.transactions); [ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
}
if (res.mempoolBlocks) { ```js
console.log(res.mempoolBlocks); websocket.wsTrackAddress(ws, '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'); // for in-browser websocket, use websocket.wsTrackAddressBrowser
} ```
});
### **Stop Track Address**
Unsubscribe from address updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingAddress(ws, '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'); // for in-browser websocket, use websocket.wsStopTrackingAddressBrowser
```
### **Track Addresses**
Subscribe to multiple address updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackAddresses(ws, ['1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC']); // for in-browser websocket, use websocket.wsTrackAddressesBrowser
```
### **Stop Track Addresses**
Unsubscribe from multiple address updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingAddresses(ws); // for in-browser websocket, use websocket.wsStopTrackingAddressesBrowser
```
### **Track Transaction**
Subscribe to transaction updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackTransaction(ws, '01313ca0148a1bbe5676e5dd6a84e76f8b39038658bd8c333d3b2d3f7ea6dd08'); // for in-browser websocket, use websocket.wsTrackTransactionBrowser
```
### **Stop Track Transaction**
Unsubscribe from transaction updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingTransaction(ws); // for in-browser websocket, use websocket.wsStopTrackingTransactionBrowser
```
### **Track Rbf Summary**
Subscribe to RBF summary updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackRbfSummary(ws); // for in-browser websocket, use websocket.wsTrackRbfSummaryBrowser
```
### **Stop Track Rbf Summary**
Unsubscribe from RBF summary updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingRbfSummary(ws); // for in-browser websocket, use websocket.wsStopTrackingRbfSummaryBrowser
```
### **Track Rbf**
Subscribe to RBF updates. Set the second parameter to `true` to track Full RBF.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackRbf(ws, true); // for in-browser websocket, use websocket.wsTrackRbfBrowser
```
### **Stop Track Rbf**
Unsubscribe from RBF updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingRbf(ws); // for in-browser websocket, use websocket.wsStopTrackingRbfBrowser
```
### **Track Mempool Block**
Subscribe to mempool blocks.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackMempoolBlock(ws, 1); // for in-browser websocket, use websocket.wsTrackMempoolBlockBrowser
```
### **Stop Track Mempool Block**
Unsubscribe from mempool blocks.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingMempoolBlock(ws); // for in-browser websocket, use websocket.wsStopTrackingMempoolBlockBrowser
``` ```

View File

@ -1,6 +1,6 @@
# mempool**JS** - Bitcoin API # mempool**JS** - Liquid API
Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs. Interface to access Liquid APIs.
[Back to home](./README.md) [Back to home](./README.md)
@ -8,50 +8,57 @@ Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs.
## **Features** ## **Features**
- [Bitcoin](./README-bitcoin.md) - Addresses
- [Bisq](./README-bisq.md) - [Get Address](#get-address)
- Liquid - [Get Address Txs](#get-address-txs)
- Addresses - [Get Address Txs Chain](#get-address-txs-chain)
- [Get Address](#get-address) - [Get Address Txs Mempool](#get-address-txs-mempool)
- [Get Address Txs](#get-address-txs) - [Get Address Txs Utxo](#get-address-txs-utxo)
- [Get Address Txs Chain](#get-address-txs-chain) - Assets
- [Get Address Txs Mempool](#get-address-txs-mempool) - [Get Asset](#get-asset)
- [Get Address Txs Utxo](#get-address-txs-utxo) - [Get Asset Icon](#get-asset-icon)
- Assets - [Get Asset Txs](#get-asset-txs)
- [Get Asset](#get-asset) - [Get Asset Supply](#get-asset-supply)
- [Get Asset Txs](#get-asset-txs) - [Get Assets Icons](#get-assets-icons)
- [Get Asset Supply](#get-asset-supply) - Blocks
- Blocks - [Get Block](#get-block)
- [Get Block](#get-block) - [Get Block Status](#get-block-status)
- [Get Block Status](#get-block-status) - [Get Block Txs](#get-block-txs)
- [Get Block Txs](#get-block-txs) - [Get Block Txids](#get-block-txids)
- [Get Block Txids](#get-block-txids) - [Get Block Txid](#get-block-txid)
- [Get Block Txid](#get-block-txid) - [Get Block Raw](#get-block-raw)
- [Get Block Raw](#get-block-raw) - [Get Blocks Height](#get-blocks-height)
- [Get Blocks Height](#get-blocks-height) - [Get Blocks](#get-blocks)
- [Get Blocks](#get-blocks) - [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Height](#get-blocks-tip-height) - [Get Blocks Tip Hash](#get-blocks-tip-hash)
- [Get Blocks Tip Hash](#get-blocks-tip-hash) - Fees
- Fees - [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Recommended](#get-fees-recommended) - [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks) - Mempool
- Mempool - [Get Mempool](#get-mempool)
- [Get Mempool](#get-mempool) - [Get Mempool Recent](#get-mempool-recent)
- [Get Mempool Recent](#get-mempool-recent) - [Get Mempool Txids](#get-mempool-txids)
- [Get Mempool Txids](#get-mempool-txids) - Transactions
- Transactions - [Get Tx](#get-tx)
- [Get Tx](#get-tx) - [Get Tx Status](#get-tx-status)
- [Get Tx Status](#get-tx-status) - [Get Tx Hex](#get-tx-hex)
- [Get Tx Hex](#get-tx-hex) - [Get Tx Raw](#get-tx-raw)
- [Get Tx Raw](#get-tx-raw) - [Get Tx Merkle Proof](#get-tx-merkle-proof)
- [Get Tx Merkle Block Proof](#get-tx-merkle-block-proof) - [Get Tx Outspend](#get-tx-outspend)
- [Get Tx Merkle Proof](#get-tx-merkle-proof) - [Get Tx Outspends](#get-tx-outspends)
- [Get Tx Outspend](#get-tx-outspend) - [Post Tx](#post-tx)
- [Get Tx Outspends](#get-tx-outspends) - Websocket
- [Post Tx Outspends]($post-tx-outspends) - [Init Websocket](#init-websocket)
- Websocket - [Want Data](#want-data)
- [Websocket Client](#websocket-client) - [Stop Want Data](#stop-want-data)
- [Websocket Server](#websocket-server) - [Track Address](#track-address)
- [Stop Track Address](#stop-track-address)
- [Track Addresses](#track-addresses)
- [Stop Track Addresses](#stop-track-addresses)
- [Track Transaction](#track-transaction)
- [Stop Track Transaction](#stop-track-transaction)
- [Track Mempool Block](#track-mempool-block)
- [Stop Track Mempool Block](#stop-track-mempool-block)
--- ---
@ -70,7 +77,7 @@ const {
liquid: { addresses }, liquid: { addresses },
} = mempoolJS(); } = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const myAddress = await addresses.getAddress({ address }); const myAddress = await addresses.getAddress({ address });
console.log(myAddress); console.log(myAddress);
@ -91,7 +98,7 @@ const {
liquid: { addresses }, liquid: { addresses },
} = mempoolJS(); } = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const addressTxs = await addresses.getAddressTxs({ address }); const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs); console.log(addressTxs);
@ -112,7 +119,7 @@ const {
liquid: { addresses }, liquid: { addresses },
} = mempoolJS(); } = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const addressTxsChain = await addresses.getAddressTxsChain({ address }); const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain); console.log(addressTxsChain);
@ -133,7 +140,7 @@ const {
liquid: { addresses }, liquid: { addresses },
} = mempoolJS(); } = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const addressTxsMempool = await addresses.getAddressTxsMempool({ address }); const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
console.log(addressTxsMempool); console.log(addressTxsMempool);
@ -164,7 +171,7 @@ Returns information about a Liquid asset.
- {string} asset_id - {string} asset_id
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ] [ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
```js ```js
const { const {
@ -187,7 +194,7 @@ Returns transactions associated with the specified Liquid asset. For the network
- {string} asset_id - {string} asset_id
- {boolean} is_mempool - {boolean} is_mempool
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ] [ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
```js ```js
const { const {
@ -210,7 +217,7 @@ Get the current total supply of the specified asset. For the native asset (L-BTC
- {string} asset_id - {string} asset_id
- {boolean} decimal - {boolean} decimal
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ] [ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
```js ```js
const { const {
@ -583,27 +590,6 @@ const txRaw = await transactions.getTxRaw({ txid });
console.log(txRaw); console.log(txRaw);
``` ```
### **Get Tx Merkle Block Proof**
Returns a merkle inclusion proof for the transaction using bitcoind's merkleblock format.
**Parameters:**
- {string} txid
[ [NodeJS Example](examples/nodejs/liquid/transactions.ts) ] [ [HTML Example](examples/html/liquid/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid });
console.log(txMerkleBlockProof);
```
### **Get Tx Merkle Proof** ### **Get Tx Merkle Proof**
Returns a merkle inclusion proof for the transaction using Electrum's blockchain.transaction.get_merkle format. Returns a merkle inclusion proof for the transaction using Electrum's blockchain.transaction.get_merkle format.
@ -671,13 +657,13 @@ const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends); console.log(txOutspends);
``` ```
### **Post Tx Outspends** ### **Post Tx **
Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success. Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success.
**Parameters:** **Parameters:**
- {string} txid - {string} txhex
[ [NodeJS Example](examples/nodejs/liquid/transactions.ts) ] [ [HTML Example](examples/html/liquid/transactions.html) ] [ [Top](#features) ] [ [NodeJS Example](examples/nodejs/liquid/transactions.ts) ] [ [HTML Example](examples/html/liquid/transactions.html) ] [ [Top](#features) ]
@ -686,72 +672,123 @@ const {
liquid: { transactions }, liquid: { transactions },
} = mempoolJS(); } = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521'; const txhex = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const postTx = await transactions.postTx({ txid }); const postTx = await transactions.postTx({ txhex });
console.log(postTx); console.log(postTx);
``` ```
### **Websocket** ### **Init Websocket**
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats. Initializes a websocket connection.
Push transactions related to address: `{ 'track-address': '3PbJ...bF9B' }` to receive all new transactions containing that address as input or output. Returns an array of transactions. address-transactions for new mempool transactions, and block-transactions for new block confirmed transactions. [ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
#### **Websocket Server**
```js ```js
const { const { liquid: { websocket } } = mempoolJS( {hostname: 'liquid.network'} );
liquid: { websocket }, const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
} = mempoolJS(); ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
const ws = websocket.initServer({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.on('message', function incoming(data) {
const res = JSON.parse(data.toString());
if (res.blocks) {
console.log(res.blocks);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
}); });
``` ```
#### **Websocket Client** ### **Want Data**
Subscribe to `want` data. Available: `blocks`, `mempool-block`, `live-2h-chart`, and `stats`.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js ```js
const { websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
liquid: { websocket }, ```
} = mempoolJS();
### **Stop Want Data**
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'], Unsubscribe from `want` data.
});
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
ws.on('message', function incoming(data) {
const res = JSON.parse(data.toString()); ```js
if (res.blocks) { websocket.wsStopData(ws); // for in-browser websocket, use websocket.wsStopDataBrowser
console.log(res.blocks); ```
}
if (res.mempoolInfo) { ### **Track Address**
console.log(res.mempoolInfo);
} Subscribe to address updates.
if (res.transactions) {
console.log(res.transactions); [ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
}
if (res.mempoolBlocks) { ```js
console.log(res.mempoolBlocks); websocket.wsTrackAddress(ws, 'GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon'); // for in-browser websocket, use websocket.wsTrackAddressBrowser
} ```
});
### **Stop Track Address**
Unsubscribe from address updates.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingAddress(ws); // for in-browser websocket, use websocket.wsStopTrackingAddressBrowser
```
### **Track Addresses**
Subscribe to multiple addresses updates.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackAddresses(ws, ['GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon']); // for in-browser websocket, use websocket.wsTrackAddressesBrowser
```
### **Stop Track Addresses**
Unsubscribe from multiple addresses updates.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingAddresses(ws); // for in-browser websocket, use websocket.wsStopTrackingAddressesBrowser
```
### **Track Transaction**
Subscribe to a transaction updates.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackTransaction(ws, '23195d459a70875c3b1f9fb9082acc9f0594f1c63dac71b40f2ff7298630a421'); // for in-browser websocket, use websocket.wsTrackTransactionBrowser()
```
### **Stop Track Transaction**
Unsubscribe from a transaction updates.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingTransaction(ws); // for in-browser websocket, use websocket.wsStopTrackingTransactionBrowser
```
### **Track Mempool Block**
Subscribe to mempool blocks.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsTrackMempoolBlock(ws, 1); // for in-browser websocket, use websocket.wsTrackMempoolBlockBrowser
```
### **Stop Track Mempool Block**
Unsubscribe from mempool blocks.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopTrackingMempoolBlock(ws); // for in-browser websocket, use websocket.wsStopTrackingMempoolBlockBrowser
``` ```

View File

@ -1,13 +1,15 @@
# Mempool JS API # Mempool JS API
[![npm version](https://img.shields.io/npm/v/@mempool/mempool-js.svg?style=flat-square)](https://www.npmjs.org/package/@mempool/mempool-js) [![npm version](https://img.shields.io/npm/v/@mempool/mempool.js.svg?style=flat-square)](https://www.npmjs.org/package/@mempool/mempool.js)
[![NPM](https://img.shields.io/david/mempool/mempool-js.svg?style=flat-square)](https://david-dm.org/mempool/mempool-js#info=dependencies) [![NPM](https://img.shields.io/david/mempool/mempool.js.svg?style=flat-square)](https://david-dm.org/mempool/mempool.js#info=dependencies)
[![Known Vulnerabilities](https://snyk.io/test/github/mempool/mempool-js/badge.svg?style=flat-square)](https://snyk.io/test/github/mempool/mempool-js) [![Known Vulnerabilities](https://snyk.io/test/github/mempool/mempool.js/badge.svg?style=flat-square)](https://snyk.io/test/github/mempool/mempool.js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
NPM package module for Mempool APIs. NPM package module for Mempool APIs.
## [https://mempool.tools/mempool-js](https://mempool.tools/mempool-js) Documentation: [https://mempool.space/api](https://mempool.space/api)
---
## **Installation** ## **Installation**
@ -17,25 +19,38 @@ Install the npm module.
```bash ```bash
# npm # npm
$ npm install @mempool/mempool-js --save $ npm install @mempool/mempool.js --save
# yarn # yarn
$ yarn add @mempool/mempool-js $ yarn add @mempool/mempool.js
``` ```
Or if you're not into package management, just [download a ZIP](https://github.com/mempool/mempool-js/archive/refs/heads/main.zip) file. Or if you're not into package management, just [download a ZIP](https://github.com/mempool/mempool.js/archive/refs/heads/main.zip) file.
Import the module. Import the module.
```js ```js
import mempoolJS from '@mempool/mempool-js'; import mempoolJS from '@mempool/mempool.js';
// default mempool.space endpoints // default mempool.space endpointsconst { bitcoin, liquid } = mempoolJS();
const { bitcoin, bisq, liquid } = mempoolJS();
// (alternative) your custom endpoints // (optional) your custom endpoints
const { bitcoin, bisq, liquid } = mempoolJS({ const { bitcoin } = mempoolJS({
homespace: 'mempool.space', protocol: 'https', // optional, defaults to http for localhost, otherwise https
hostname: 'mempool.space',
network: 'testnet4' // 'signet' | 'testnet' | 'testnet4' | 'mainnet',
config: { // optional axios request config to add to requests
headers: {
authorization: 'Basic auth'
}
}
});
// Liquid API
const { liquid } = mempoolJS({
protocol: 'https', // optional, defaults to http for localhost, otherwise https
hostname: 'liquid.network',
network: 'liquid' // 'liquid' | 'liquidtestnet'
}); });
``` ```
@ -47,15 +62,24 @@ Include the line below in the `head` tag of your html file.
<script type="text/javascript" src="https://mempool.space/mempool.js"></script> <script type="text/javascript" src="https://mempool.space/mempool.js"></script>
``` ```
Call `mempoolJS` function to access the API methods. Call `mempoolJS()` function to access the API methods.
```js ```js
// default mempool.space endpoints // default mempool.space endpoints
const { bitcoin, bisq, liquid } = mempoolJS(); const { bitcoin } = mempoolJS();
// (alternative) your custom endpoints // (optional) your custom endpoints
const { bitcoin, bisq, liquid } = mempoolJS({ const { bitcoin } = mempoolJS({
homespace: 'mempool.space', protocol: 'https', // optional, defaults to http for localhost, otherwise https
hostname: 'mempool.space',
network: 'testnet4', // 'signet' | 'testnet' | 'testnet4' | 'mainnet'
});
// Liquid API
const { liquid } = mempoolJS({
protocol: 'https', // optional, defaults to http for localhost, otherwise https
hostname: 'liquid.network',
network: 'liquid' // 'liquid' | 'liquidtestnet'
}); });
``` ```
@ -66,16 +90,12 @@ const { bitcoin, bisq, liquid } = mempoolJS({
- [Bitcoin](./README-bitcoin.md) - [Bitcoin](./README-bitcoin.md)
- [Addresses](./README-bitcoin.md#get-address) - [Addresses](./README-bitcoin.md#get-address)
- [Blocks](./README-bitcoin.md#get-blocks) - [Blocks](./README-bitcoin.md#get-blocks)
- [Difficulty Adjustment](./README-bitcoin.md#get-difficulty-adjustment)
- [Fees](./README-bitcoin.md#get-fees) - [Fees](./README-bitcoin.md#get-fees)
- [Lightning](./README-bitcoin.md#get-network-stats)
- [Mempool](./README-bitcoin.md#get-mempool) - [Mempool](./README-bitcoin.md#get-mempool)
- [Transactions](./README-bitcoin.md#get-transactions) - [Transactions](./README-bitcoin.md#get-transactions)
- [Websocket Client](./README-bitcoin.md#Websocket-Client) - [Websocket](./README-bitcoin.md#init-websocket)
- [Websocket Server](./README-bitcoin.md#Websocket-Server)
- [Bisq](./README-bisq.md#get-address)
- [Addresses](./README-bisq.md#get-address)
- [Blocks](./README-bisq.md#get-blocks)
- [Statistics](./README-bisq.md#get-statistics)
- [Transactions](./README-bisq.md#get-transactions)
- [Liquid](./README-liquid.md#get-address) - [Liquid](./README-liquid.md#get-address)
- [Addresses](./README-liquid.md#get-address) - [Addresses](./README-liquid.md#get-address)
- [Assets](./README-liquid.md#get-address) - [Assets](./README-liquid.md#get-address)
@ -83,8 +103,7 @@ const { bitcoin, bisq, liquid } = mempoolJS({
- [Fees](./README-liquid.md#get-address) - [Fees](./README-liquid.md#get-address)
- [Mempool](./README-liquid.md#get-address) - [Mempool](./README-liquid.md#get-address)
- [Transactions](./README-liquid.md#get-address) - [Transactions](./README-liquid.md#get-address)
- [Websocket Client](./README-liquid.md#Websocket-Client) - [Websocket](./README-liquid.md#init-websocket)
- [Websocket Server](./README-liquid.md#Websocket-Server)
--- ---

View File

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
const {
bisq: { addresses },
} = mempoolJS();
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,31 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
const {
bisq: { blocks },
} = mempoolJS();
const hash =
'000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
const block = await blocks.getBlock({ hash });
console.log(block);
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
console.log(myBlocks);
const myBlocksHeight = await blocks.getBlocksTipHeight({
index: 0,
length: 1,
});
console.log(myBlocksHeight);
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
const {
bisq: { statistics },
} = mempoolJS();
const stats = await statistics.getStats();
console.log(stats);
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,24 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
const {
bisq: { transactions },
} = mempoolJS();
const txid = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
const tx = await transactions.getTx({ txid });
console.log(tx);
const txs = await transactions.getTxs({ index: 0, length: 1 });
console.log(txs);
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -2,31 +2,35 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
bitcoin: { addresses }, const {
} = mempoolJS(); bitcoin: { addresses },
} = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
const myAddress = await addresses.getAddress({ address }); const myAddress = await addresses.getAddress({ address });
console.log(myAddress); console.log(myAddress);
const addressTxs = await addresses.getAddressTxs({ address }); const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs); console.log(addressTxs);
const addressTxsChain = await addresses.getAddressTxsChain({ address }); const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain); console.log(addressTxsChain);
const addressTxsMempool = await addresses.getAddressTxsMempool({ const addressTxsMempool = await addresses.getAddressTxsMempool({
address, address,
}); });
console.log(addressTxsMempool); console.log(addressTxsMempool);
const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address }); const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address });
console.log(addressTxsUtxo); console.log(addressTxsUtxo);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,48 +2,55 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
bitcoin: { blocks }, const {
} = mempoolJS(); bitcoin: { blocks },
} = mempoolJS();
const hash = const hash =
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce'; '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const block = await blocks.getBlock({ hash }); const block = await blocks.getBlock({ hash });
console.log(block); console.log(block);
const blockStatus = await blocks.getBlockStatus({ hash }); const blockStatus = await blocks.getBlockStatus({ hash });
console.log(blockStatus); console.log(blockStatus);
const blockTxs = await blocks.getBlockTxs({ hash }); const blockTxs = await blocks.getBlockTxs({ hash });
console.log(blockTxs); console.log(blockTxs);
const blockTxids = await blocks.getBlockTxids({ hash }); const blockTxids = await blocks.getBlockTxids({ hash });
console.log(blockTxids); console.log(blockTxids);
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 }); const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
console.log(blockTxid); console.log(blockTxid);
const blockRaw = await blocks.getBlockRaw({ hash }); const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw); console.log(blockRaw);
const blockHeight = await blocks.getBlockHeight({ height: 0 }); const blockHeader = await blocks.getBlockHeader({ hash });
console.log(blockHeight); console.log(blockHeader);
const getBlocks = await blocks.getBlocks({ start_height: 9999 }); const blockHeight = await blocks.getBlockHeight({ height: 0 });
console.log(getBlocks); console.log(blockHeight);
const blocksTipHeight = await blocks.getBlocksTipHeight(); const getBlocks = await blocks.getBlocks({ start_height: 9999 });
console.log(blocksTipHeight); console.log(getBlocks);
const blocksTipHash = await blocks.getBlocksTipHash(); const blocksTipHeight = await blocks.getBlocksTipHeight();
console.log(blocksTipHash); console.log(blocksTipHeight);
const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>
</head> </head>
<body></body> <body></body>
</html> </html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
bitcoin: { difficulty },
} = mempoolJS();
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
console.log(difficultyAdjustment);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -2,18 +2,22 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
bitcoin: { fees }, const {
} = mempoolJS(); bitcoin: { fees },
} = mempoolJS();
const feesRecommended = await fees.getFeesRecommended(); const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended); console.log(feesRecommended);
const feesMempoolBlocks = await fees.getFeesMempoolBlocks(); const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks); console.log(feesMempoolBlocks);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const { bitcoin: { lightning } } = mempoolJS();
const node = '03d607f3e69fd032524a867b288216bfab263b6eaee4e07783799a6fe69bb84fac';
const channel = '768457472831193088';
const networkStats = await lightning.getNetworkStats();
console.log(networkStats);
const nodesInCountry = await lightning.getNodesInCountry({ country: 'fr' });
console.log(nodesInCountry);
const nodesStatsPerCountry = await lightning.getNodesStatsPerCountry();
console.log(nodesStatsPerCountry);
const nodesHostedByISP = await lightning.getNodesHostedByISP({ isp: 16509 });
console.log(nodesHostedByISP);
const ispRanking = await lightning.getISPRanking();
console.log(ispRanking);
const liquidityRanking = await lightning.getLiquidityRanking();
console.log(liquidityRanking);
const connectivityRanking = await lightning.getConnectivityRanking();
console.log(connectivityRanking);
const oldestNodes = await lightning.getOldestNodes();
console.log(oldestNodes);
const nodeStats = await lightning.getNodeStats({ public_key: node });
console.log(nodeStats);
const historicalNodeStats = await lightning.getHistoricalNodeStats({ public_key: node });
console.log(historicalNodeStats);
const channelData = await lightning.getChannel({ id: channel });
console.log(channelData);
const channelsFromTxIds = await lightning.getChannelsFromTxIds({ txId: ['c3173549f502ede6440d5c48ea74af5607d88484c7a912bbef73d430049f8af4', 'd78f0b41a263af3df91fa4171cc2f60c40196aaf8f4bde5d1c8ff4474cfe753b'] });
console.log(channelsFromTxIds);
const channelsFromNodePublicKey = await lightning.getChannelsFromNodePublicKey({ public_key: node, status: 'active'});
console.log(channelsFromNodePublicKey);
const channelsGeodata = await lightning.getChannelsGeodata();
console.log(channelsGeodata);
const channelsGeodataByPublicKey = await lightning.getChannelsGeodataByPublicKey({ public_key: node });
console.log(channelsGeodataByPublicKey);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -2,21 +2,25 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
bitcoin: { mempool }, const {
} = mempoolJS(); bitcoin: { mempool },
} = mempoolJS();
const getMempool = await mempool.getMempool(); const getMempool = await mempool.getMempool();
console.log(getMempool); console.log(getMempool);
const getMempoolRecent = await mempool.getMempoolRecent(); const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent); console.log(getMempoolRecent);
const getMempoolTxids = await mempool.getMempoolTxids(); const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids); console.log(getMempoolTxids);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,50 +2,55 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
bitcoin: { transactions }, const {
} = mempoolJS(); bitcoin: { transactions },
} = mempoolJS();
const txid = const txid =
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521'; '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const tx = await transactions.getTx({ txid }); const tx = await transactions.getTx({ txid });
console.log(tx); console.log(tx);
const txStatus = await transactions.getTxStatus({ txid }); const txStatus = await transactions.getTxStatus({ txid });
console.log(txStatus); console.log(txStatus);
const txHex = await transactions.getTxHex({ txid }); const txHex = await transactions.getTxHex({ txid });
console.log(txHex); console.log(txHex);
const txRaw = await transactions.getTxRaw({ txid }); const txRaw = await transactions.getTxRaw({ txid });
console.log(txRaw); console.log(txRaw);
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({
txid, txid,
}); });
console.log(txMerkleBlockProof); console.log(txMerkleBlockProof);
const txMerkleProof = await transactions.getTxMerkleProof({ txid }); const txMerkleProof = await transactions.getTxMerkleProof({ txid });
console.log(txMerkleProof); console.log(txMerkleProof);
const txOutspend = await transactions.getTxOutspend({ const txOutspend = await transactions.getTxOutspend({
txid, txid,
vout: 3, vout: 3,
}); });
console.log(txOutspend); console.log(txOutspend);
const txOutspends = await transactions.getTxOutspends({ txid }); const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends); console.log(txOutspends);
// const postTx = await transactions.postTx({ txid }); const postTx = await transactions.postTx({ txhex: txHex });
// console.log(postTx); console.log(postTx);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>
</head> </head>
<body></body> <body></body>
</html> </html>

View File

@ -2,32 +2,49 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
bitcoin: { websocket }, const {
} = mempoolJS(); bitcoin: { websocket },
// console.log(mempoolJS()); } = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.on('message', function incoming(data) { const ws = websocket.wsInitBrowser();
const res = JSON.parse(data.toString());
if (res.blocks) { ws.addEventListener('message', function incoming({data}) {
console.log(res.blocks); console.log(JSON.parse(data.toString()));
} });
if (res.mempoolInfo) {
console.log(res.mempoolInfo); websocket.wsWantDataBrowser(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
}
if (res.transactions) { websocket.wsTrackAddressBrowser(ws, "1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC");
console.log(res.transactions);
} websocket.wsTrackAddressesBrowser(ws, [
if (res.mempoolBlocks) { "1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC",
console.log(res.mempoolBlocks); ]);
}
}); websocket.wsTrackTransactionBrowser(ws, "01313ca0148a1bbe5676e5dd6a84e76f8b39038658bd8c333d3b2d3f7ea6dd08");
websocket.wsTrackRbfSummaryBrowser(ws);
websocket.wsTrackRbfBrowser(ws, true);
websocket.wsTrackMempoolBlockBrowser(ws, 1);
setTimeout(() => {
websocket.wsStopDataBrowser(ws);
websocket.wsStopTrackingAddressBrowser(ws);
websocket.wsStopTrackingAddressesBrowser(ws);
websocket.wsStopTrackingTransactionBrowser(ws);
websocket.wsStopTrackingRbfSummaryBrowser(ws);
websocket.wsStopTrackingRbfBrowser(ws);
websocket.wsStopTrackingMempoolBlockBrowser(ws);
}, 60000);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,31 +2,35 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { addresses }, const {
} = mempoolJS(); liquid: { addresses },
} = mempoolJS( { hostname: 'liquid.network' } );
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const myAddress = await addresses.getAddress({ address }); const myAddress = await addresses.getAddress({ address });
console.log(myAddress); console.log(myAddress);
const addressTxs = await addresses.getAddressTxs({ address }); const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs); console.log(addressTxs);
const addressTxsChain = await addresses.getAddressTxsChain({ address }); const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain); console.log(addressTxsChain);
const addressTxsMempool = await addresses.getAddressTxsMempool({ const addressTxsMempool = await addresses.getAddressTxsMempool({
address, address,
}); });
console.log(addressTxsMempool); console.log(addressTxsMempool);
const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address }); const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address });
console.log(addressTxsUtxo); console.log(addressTxsUtxo);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,29 +2,33 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { assets }, const {
} = mempoolJS(); liquid: { assets },
} = mempoolJS( { hostname: 'liquid.network' } );
const asset_id = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const asset_id = 'a0c358a0f6947864af3a06f3f6a2aeb304df7fd95c922f2f22d7412399ce7691';
const asset = await assets.getAsset({ asset_id }); const asset = await assets.getAsset({ asset_id });
console.log(asset); console.log(asset);
const assetTxs = await assets.getAssetTxs({ const assetTxs = await assets.getAssetTxs({
asset_id, asset_id,
is_mempool: false, is_mempool: false,
}); });
console.log(assetTxs); console.log(assetTxs);
const assetSupply = await assets.getAssetSupply({ const assetSupply = await assets.getAssetSupply({
asset_id, asset_id,
decimal: false, decimal: false,
}); });
console.log(assetSupply); console.log(assetSupply);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,45 +2,49 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { blocks }, const {
} = mempoolJS(); liquid: { blocks },
} = mempoolJS( { hostname: 'liquid.network' } );
const hash = const hash =
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce'; '54f02bdec5509ea769c8be82aed51f689969b653d92a2812d5a36266cbfbc55e';
const block = await blocks.getBlock({ hash }); const block = await blocks.getBlock({ hash });
console.log(block); console.log(block);
const blockStatus = await blocks.getBlockStatus({ hash }); const blockStatus = await blocks.getBlockStatus({ hash });
console.log(blockStatus); console.log(blockStatus);
const blockTxs = await blocks.getBlockTxs({ hash }); const blockTxs = await blocks.getBlockTxs({ hash });
console.log(blockTxs); console.log(blockTxs);
const blockTxids = await blocks.getBlockTxids({ hash }); const blockTxids = await blocks.getBlockTxids({ hash });
console.log(blockTxids); console.log(blockTxids);
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 }); const blockTxid = await blocks.getBlockTxid({ hash, index: 0 });
console.log(blockTxid); console.log(blockTxid);
const blockRaw = await blocks.getBlockRaw({ hash }); const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw); console.log(blockRaw);
const blockHeight = await blocks.getBlockHeight({ height: 0 }); const blockHeight = await blocks.getBlockHeight({ height: 0 });
console.log(blockHeight); console.log(blockHeight);
const getBlocks = await blocks.getBlocks({ start_height: 9999 }); const getBlocks = await blocks.getBlocks({ start_height: 9999 });
console.log(getBlocks); console.log(getBlocks);
const blocksTipHeight = await blocks.getBlocksTipHeight(); const blocksTipHeight = await blocks.getBlocksTipHeight();
console.log(blocksTipHeight); console.log(blocksTipHeight);
const blocksTipHash = await blocks.getBlocksTipHash(); const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash); console.log(blocksTipHash);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,18 +2,22 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { fees }, const {
} = mempoolJS(); liquid: { fees },
} = mempoolJS( { hostname: 'liquid.network' } );
const feesRecommended = await fees.getFeesRecommended(); const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended); console.log(feesRecommended);
const feesMempoolBlocks = await fees.getFeesMempoolBlocks(); const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks); console.log(feesMempoolBlocks);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,21 +2,25 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { mempool }, const {
} = mempoolJS(); liquid: { mempool },
} = mempoolJS( { hostname: 'liquid.network' } );
const getMempool = await mempool.getMempool(); const getMempool = await mempool.getMempool();
console.log(getMempool); console.log(getMempool);
const getMempoolRecent = await mempool.getMempoolRecent(); const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent); console.log(getMempoolRecent);
const getMempoolTxids = await mempool.getMempoolTxids(); const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids); console.log(getMempoolTxids);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -2,47 +2,46 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { transactions }, const {
} = mempoolJS(); liquid: { transactions },
} = mempoolJS( { hostname: 'liquid.network' } );
const txid = const txid =
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521'; '064d1dff90cbb6fce81311f9804a737df9e3873bc4717ff6aae068fffab423ab';
const tx = await transactions.getTx({ txid }); const tx = await transactions.getTx({ txid });
console.log(tx); console.log(tx);
const txStatus = await transactions.getTxStatus({ txid }); const txStatus = await transactions.getTxStatus({ txid });
console.log(txStatus); console.log(txStatus);
const txHex = await transactions.getTxHex({ txid }); const txHex = await transactions.getTxHex({ txid });
console.log(txHex); console.log(txHex);
const txRaw = await transactions.getTxRaw({ txid }); const txRaw = await transactions.getTxRaw({ txid });
console.log(txRaw); console.log(txRaw);
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ const txMerkleProof = await transactions.getTxMerkleProof({ txid });
txid, console.log(txMerkleProof);
});
console.log(txMerkleBlockProof);
const txMerkleProof = await transactions.getTxMerkleProof({ txid }); const txOutspend = await transactions.getTxOutspend({
console.log(txMerkleProof); txid,
vout: 3,
});
console.log(txOutspend);
const txOutspend = await transactions.getTxOutspend({ const txOutspends = await transactions.getTxOutspends({ txid });
txid, console.log(txOutspends);
vout: 3,
});
console.log(txOutspend);
const txOutspends = await transactions.getTxOutspends({ txid }); const postTx = await transactions.postTx({ txhex: txHex });
console.log(txOutspends); console.log(postTx);
} catch (error) {
// const postTx = await transactions.postTx({ txid }); console.log(error);
// console.log(postTx); }
}; };
init(); init();
</script> </script>

View File

@ -2,32 +2,43 @@
<html> <html>
<head> <head>
<title>Page Title</title> <title>Page Title</title>
<script src="https://mempool.space/mempool.js"></script> <script src="./../../../dist/mempool.js"></script>
<script> <script>
const init = async () => { const init = async () => {
const { try {
liquid: { websocket }, const {
} = mempoolJS(); liquid: { websocket },
} = mempoolJS( { hostname: 'liquid.network' } );
const ws = websocket.initServer({ const ws = websocket.wsInitBrowser();
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.on('message', function incoming(data) { ws.addEventListener('message', function incoming({data}) {
const res = JSON.parse(data.toString()); console.log(JSON.parse(data.toString()));
if (res.blocks) { });
console.log(res.blocks);
} websocket.wsWantDataBrowser(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
if (res.mempoolInfo) {
console.log(res.mempoolInfo); websocket.wsTrackAddressBrowser(ws, "GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon");
}
if (res.transactions) { websocket.wsTrackAddressesBrowser(ws, [
console.log(res.transactions); "GsDhxpV4Voi3XJA22bnAH4q8117hjZrQMF",
} ]);
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks); websocket.wsTrackTransactionBrowser(ws, "23195d459a70875c3b1f9fb9082acc9f0594f1c63dac71b40f2ff7298630a421");
}
}); websocket.wsTrackMempoolBlockBrowser(ws, 1);
setTimeout(() => {
websocket.wsStopDataBrowser(ws);
websocket.wsStopTrackingAddressBrowser(ws);
websocket.wsStopTrackingAddressesBrowser(ws);
websocket.wsStopTrackingTransactionBrowser(ws);
websocket.wsStopTrackingMempoolBlockBrowser(ws);
}, 60000);
} catch (error) {
console.log(error);
}
}; };
init(); init();
</script> </script>

View File

@ -1,13 +0,0 @@
import mempoolJS from '../../../src/index';
const init = async () => {
const {
bisq: { addresses },
} = mempoolJS();
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
};
init();

View File

@ -1,23 +0,0 @@
import mempoolJS from '../../../src/index';
const init = async () => {
const {
bisq: { blocks },
} = mempoolJS();
const hash =
'000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
const block = await blocks.getBlock({ hash });
console.log(block);
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
console.log(myBlocks);
const myBlocksHeight = await blocks.getBlocksTipHeight({
index: 0,
length: 1,
});
console.log(myBlocksHeight);
};
init();

View File

@ -1,11 +0,0 @@
import mempoolJS from '../../../src/index';
const init = async () => {
const {
bisq: { statistics },
} = mempoolJS();
const stats = await statistics.getStats();
console.log(stats);
};
init();

View File

@ -1,17 +0,0 @@
import mempoolJS from '../../../src/index';
const init = async () => {
const {
bisq: { transactions },
} = mempoolJS();
const txid =
'4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
const tx = await transactions.getTx({ txid });
console.log(tx);
const txs = await transactions.getTxs({ index: 0, length: 1 });
console.log(txs);
};
init();

View File

@ -1,25 +1,27 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
bitcoin: { addresses }, const { bitcoin: { addresses } } = mempoolJS();
} = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
const myAddress = await addresses.getAddress({ address }); const myAddress = await addresses.getAddress({ address });
console.log(myAddress); console.log(myAddress);
const addressTxs = await addresses.getAddressTxs({ address }); const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs); console.log(addressTxs);
const addressTxsChain = await addresses.getAddressTxsChain({ address }); const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain); console.log(addressTxsChain);
const addressTxsMempool = await addresses.getAddressTxsMempool({ address }); const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
console.log(addressTxsMempool); console.log(addressTxsMempool);
const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address }); const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address });
console.log(addressTxsUtxo); console.log(addressTxsUtxo);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,41 +1,49 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
bitcoin: { blocks }, const {
} = mempoolJS(); bitcoin: { blocks },
} = mempoolJS();
const hash = const hash =
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce'; '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const block = await blocks.getBlock({ hash }); const block = await blocks.getBlock({ hash });
console.log(block); console.log(block);
const blockStatus = await blocks.getBlockStatus({ hash }); const blockStatus = await blocks.getBlockStatus({ hash });
console.log(blockStatus); console.log(blockStatus);
const blockTxs = await blocks.getBlockTxs({ hash }); const blockTxs = await blocks.getBlockTxs({ hash });
console.log(blockTxs); console.log(blockTxs);
const blockTxids = await blocks.getBlockTxids({ hash }); const blockTxids = await blocks.getBlockTxids({ hash });
console.log(blockTxids); console.log(blockTxids);
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 }); const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
console.log(blockTxid); console.log(blockTxid);
const blockRaw = await blocks.getBlockRaw({ hash }); const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw); console.log(blockRaw);
const blockHeight = await blocks.getBlockHeight({ height: 0 }); const blockHeader = await blocks.getBlockHeader({ hash });
console.log(blockHeight); console.log(blockHeader);
const getBlocks = await blocks.getBlocks({ start_height: 9999 }); const blockHeight = await blocks.getBlockHeight({ height: 0 });
console.log(getBlocks); console.log(blockHeight);
const blocksTipHeight = await blocks.getBlocksTipHeight(); const getBlocks = await blocks.getBlocks({ start_height: 9999 });
console.log(blocksTipHeight); console.log(getBlocks);
const blocksTipHash = await blocks.getBlocksTipHash(); const blocksTipHeight = await blocks.getBlocksTipHeight();
console.log(blocksTipHash); console.log(blocksTipHeight);
const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -0,0 +1,18 @@
import mempoolJS from "./../../../src/index";
const init = async () => {
try {
const {
bitcoin: { difficulty },
} = mempoolJS();
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
console.log(difficultyAdjustment);
const hashrate = await difficulty.getHashrate({ interval: "1m" });
console.log(hashrate);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,19 +1,23 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
bitcoin: { fees }, const {
} = mempoolJS(); bitcoin: { fees },
} = mempoolJS();
const feesRecommended = await fees.getFeesRecommended(); const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended); console.log(feesRecommended);
const feesMempoolBlocks = await fees.getFeesMempoolBlocks(); const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks); console.log(feesMempoolBlocks);
const txid = 'txid'; const txid = '94bb221746f0626caf63c8dd279e07963bfe514fabe596019c95a41c5f5af97c';
const feesCPFP = await fees.getCPFP({ txid }); const feesCPFP = await fees.getCPFP({ txid });
console.log(feesCPFP); console.log(feesCPFP);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -0,0 +1,59 @@
import mempoolJS from "./../../../src/index";
const init = async () => {
try {
const { bitcoin: { lightning } } = mempoolJS();
const node = '03d607f3e69fd032524a867b288216bfab263b6eaee4e07783799a6fe69bb84fac';
const channel = '768457472831193088';
const networkStats = await lightning.getNetworkStats();
console.log(networkStats);
const nodesInCountry = await lightning.getNodesInCountry({ country: 'fr' });
console.log(nodesInCountry);
const nodesStatsPerCountry = await lightning.getNodesStatsPerCountry();
console.log(nodesStatsPerCountry);
const nodesHostedByISP = await lightning.getNodesHostedByISP({ isp: 16509 });
console.log(nodesHostedByISP);
const ispRanking = await lightning.getISPRanking();
console.log(ispRanking);
const liquidityRanking = await lightning.getLiquidityRanking();
console.log(liquidityRanking);
const connectivityRanking = await lightning.getConnectivityRanking();
console.log(connectivityRanking);
const oldestNodes = await lightning.getOldestNodes();
console.log(oldestNodes);
const nodeStats = await lightning.getNodeStats({ public_key: node });
console.log(nodeStats);
const historicalNodeStats = await lightning.getHistoricalNodeStats({ public_key: node });
console.log(historicalNodeStats);
const channelData = await lightning.getChannel({ id: channel });
console.log(channelData);
const channelsFromTxIds = await lightning.getChannelsFromTxIds({ txId: ['c3173549f502ede6440d5c48ea74af5607d88484c7a912bbef73d430049f8af4', 'd78f0b41a263af3df91fa4171cc2f60c40196aaf8f4bde5d1c8ff4474cfe753b'] });
console.log(channelsFromTxIds);
const channelsFromNodePublicKey = await lightning.getChannelsFromNodePublicKey({ public_key: node, status: 'active'});
console.log(channelsFromNodePublicKey);
const channelsGeodata = await lightning.getChannelsGeodata();
console.log(channelsGeodata);
const channelsGeodataByPublicKey = await lightning.getChannelsGeodataByPublicKey({ public_key: node });
console.log(channelsGeodataByPublicKey);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,17 +1,21 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
bitcoin: { mempool }, const {
} = mempoolJS(); bitcoin: { mempool },
} = mempoolJS();
const getMempool = await mempool.getMempool(); const getMempool = await mempool.getMempool();
console.log(getMempool); console.log(getMempool);
const getMempoolRecent = await mempool.getMempoolRecent(); const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent); console.log(getMempoolRecent);
const getMempoolTxids = await mempool.getMempoolTxids(); const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids); console.log(getMempoolTxids);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,41 +1,45 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
bitcoin: { transactions }, const {
} = mempoolJS(); bitcoin: { transactions },
} = mempoolJS();
const txid = const txid =
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521'; '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const tx = await transactions.getTx({ txid }); const tx = await transactions.getTx({ txid });
console.log(tx); console.log(tx);
const txStatus = await transactions.getTxStatus({ txid }); const txStatus = await transactions.getTxStatus({ txid });
console.log(txStatus); console.log(txStatus);
const txHex = await transactions.getTxHex({ txid }); const txHex = await transactions.getTxHex({ txid });
console.log(txHex); console.log(txHex);
const txRaw = await transactions.getTxRaw({ txid }); const txRaw = await transactions.getTxRaw({ txid });
console.log(txRaw); console.log(txRaw);
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid }); const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid });
console.log(txMerkleBlockProof); console.log(txMerkleBlockProof);
const txMerkleProof = await transactions.getTxMerkleProof({ txid }); const txMerkleProof = await transactions.getTxMerkleProof({ txid });
console.log(txMerkleProof); console.log(txMerkleProof);
const txOutspend = await transactions.getTxOutspend({ const txOutspend = await transactions.getTxOutspend({
txid, txid,
vout: 3, vout: 3,
}); });
console.log(txOutspend); console.log(txOutspend);
const txOutspends = await transactions.getTxOutspends({ txid }); const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends); console.log(txOutspends);
// const postTx = await transactions.postTx({ txid }); // const postTx = await transactions.postTx({ txhex });
// console.log(postTx); // console.log(postTx);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,28 +1,45 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
bitcoin: { websocket }, const {
} = mempoolJS(); bitcoin: { websocket },
} = mempoolJS();
const ws = websocket.initServer({ const ws = websocket.wsInit();
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.on('message', function incoming(data) { ws.addEventListener('message', function incoming({data}) {
const res = JSON.parse(data.toString()); console.log(JSON.parse(data.toString()));
if (res.blocks) { });
console.log(res.blocks);
} websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
if (res.mempoolInfo) {
console.log(res.mempoolInfo); websocket.wsTrackAddress(ws, "1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC");
}
if (res.transactions) { websocket.wsTrackAddresses(ws, [
console.log(res.transactions); "1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC",
} ]);
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks); websocket.wsTrackTransaction(ws, "01313ca0148a1bbe5676e5dd6a84e76f8b39038658bd8c333d3b2d3f7ea6dd08");
}
}); websocket.wsTrackRbfSummary(ws);
};
websocket.wsTrackRbf(ws, true);
websocket.wsTrackMempoolBlock(ws, 1);
setTimeout(() => {
websocket.wsStopData(ws);
websocket.wsStopTrackingAddress(ws);
websocket.wsStopTrackingAddresses(ws);
websocket.wsStopTrackingTransaction(ws);
websocket.wsStopTrackingRbfSummary(ws);
websocket.wsStopTrackingRbf(ws);
websocket.wsStopTrackingMempoolBlock(ws);
}, 60000);
} catch (error) {
console.log(error);
}
}
init(); init();

View File

@ -1,25 +1,29 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { addresses }, const {
} = mempoolJS(); liquid: { addresses },
} = mempoolJS( { hostname: 'liquid.network' } );
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'; const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const myAddress = await addresses.getAddress({ address }); const myAddress = await addresses.getAddress({ address });
console.log(myAddress); console.log(myAddress);
const addressTxs = await addresses.getAddressTxs({ address }); const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs); console.log(addressTxs);
const addressTxsChain = await addresses.getAddressTxsChain({ address }); const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain); console.log(addressTxsChain);
const addressTxsMempool = await addresses.getAddressTxsMempool({ address }); const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
console.log(addressTxsMempool); console.log(addressTxsMempool);
const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address }); const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address });
console.log(addressTxsUtxo); console.log(addressTxsUtxo);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,20 +1,24 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { assets }, const {
} = mempoolJS(); liquid: { assets },
} = mempoolJS( { hostname: 'liquid.network' } );
const asset_id = const asset_id =
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d'; '6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
const asset = await assets.getAsset({ asset_id }); const asset = await assets.getAsset({ asset_id });
console.log(asset); console.log(asset);
const assetTxs = await assets.getAssetTxs({ asset_id, is_mempool: false }); const assetTxs = await assets.getAssetTxs({ asset_id, is_mempool: false });
console.log(assetTxs); console.log(assetTxs);
const assetSupply = await assets.getAssetSupply({ asset_id, decimal: false }); const assetSupply = await assets.getAssetSupply({ asset_id, decimal: false });
console.log(assetSupply); console.log(assetSupply);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,41 +1,45 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { blocks }, const {
} = mempoolJS(); liquid: { blocks },
} = mempoolJS( { hostname: 'liquid.network' } );
const hash = const hash =
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce'; '5ec96b63f95aad27391a8a41f1dce2161d48c4f26aeb1f72695a12c98a005e1f';
const block = await blocks.getBlock({ hash }); const block = await blocks.getBlock({ hash });
console.log(block); console.log(block);
const blockStatus = await blocks.getBlockStatus({ hash }); const blockStatus = await blocks.getBlockStatus({ hash });
console.log(blockStatus); console.log(blockStatus);
const blockTxs = await blocks.getBlockTxs({ hash }); const blockTxs = await blocks.getBlockTxs({ hash });
console.log(blockTxs); console.log(blockTxs);
const blockTxids = await blocks.getBlockTxids({ hash }); const blockTxids = await blocks.getBlockTxids({ hash });
console.log(blockTxids); console.log(blockTxids);
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 }); const blockTxid = await blocks.getBlockTxid({ hash, index: 1 });
console.log(blockTxid); console.log(blockTxid);
const blockRaw = await blocks.getBlockRaw({ hash }); const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw); console.log(blockRaw);
const blockHeight = await blocks.getBlockHeight({ height: 0 }); const blockHeight = await blocks.getBlockHeight({ height: 0 });
console.log(blockHeight); console.log(blockHeight);
const getBlocks = await blocks.getBlocks({ start_height: 9999 }); const getBlocks = await blocks.getBlocks({ start_height: 9999 });
console.log(getBlocks); console.log(getBlocks);
const blocksTipHeight = await blocks.getBlocksTipHeight(); const blocksTipHeight = await blocks.getBlocksTipHeight();
console.log(blocksTipHeight); console.log(blocksTipHeight);
const blocksTipHash = await blocks.getBlocksTipHash(); const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash); console.log(blocksTipHash);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,14 +1,18 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { fees }, const {
} = mempoolJS(); liquid: { fees },
} = mempoolJS( { hostname: 'liquid.network' } );
const feesRecommended = await fees.getFeesRecommended(); const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended); console.log(feesRecommended);
const feesMempoolBlocks = await fees.getFeesMempoolBlocks(); const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks); console.log(feesMempoolBlocks);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,17 +1,21 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { mempool }, const {
} = mempoolJS(); liquid: { mempool },
} = mempoolJS( { hostname: 'liquid.network' } );
const getMempool = await mempool.getMempool(); const getMempool = await mempool.getMempool();
console.log(getMempool); console.log(getMempool);
const getMempoolRecent = await mempool.getMempoolRecent(); const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent); console.log(getMempoolRecent);
const getMempoolTxids = await mempool.getMempoolTxids(); const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids); console.log(getMempoolTxids);
} catch (error) {
console.log(error);
}
}; };
init(); init();

View File

@ -1,41 +1,42 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { transactions }, const {
} = mempoolJS(); liquid: { transactions },
} = mempoolJS( { hostname: 'liquid.network' } );
const txid = const txid =
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521'; '555fbc3ca784903b238fdadc92515577dfa9124185259c5d9a773508bbc365e5';
const tx = await transactions.getTx({ txid }); const tx = await transactions.getTx({ txid });
console.log(tx); console.log(tx);
const txStatus = await transactions.getTxStatus({ txid }); const txStatus = await transactions.getTxStatus({ txid });
console.log(txStatus); console.log(txStatus);
const txHex = await transactions.getTxHex({ txid }); const txHex = await transactions.getTxHex({ txid });
console.log(txHex); console.log(txHex);
const txRaw = await transactions.getTxRaw({ txid }); const txRaw = await transactions.getTxRaw({ txid });
console.log(txRaw); console.log(txRaw);
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid }); const txMerkleProof = await transactions.getTxMerkleProof({ txid });
console.log(txMerkleBlockProof); console.log(txMerkleProof);
const txMerkleProof = await transactions.getTxMerkleProof({ txid }); const txOutspend = await transactions.getTxOutspend({
console.log(txMerkleProof); txid,
vout: 3,
});
console.log(txOutspend);
const txOutspend = await transactions.getTxOutspend({ const txOutspends = await transactions.getTxOutspends({ txid });
txid, console.log(txOutspends);
vout: 3,
});
console.log(txOutspend);
const txOutspends = await transactions.getTxOutspends({ txid }); const postTx = await transactions.postTx({ txhex: txHex });
console.log(txOutspends); console.log(postTx);
} catch (error) {
// const postTx = await transactions.postTx({ txid }); console.log(error);
// console.log(postTx); }
}; };
init(); init();

View File

@ -1,28 +1,38 @@
import mempoolJS from '../../../src/index'; import mempoolJS from "./../../../src/index";
const init = async () => { const init = async () => {
const { try {
liquid: { websocket },
} = mempoolJS();
const ws = websocket.initServer({ const { liquid: { websocket } } = mempoolJS( { hostname: 'liquid.network' } );
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.on('message', function incoming(data) { const ws = websocket.wsInit();
const res = JSON.parse(data.toString());
if (res.blocks) { ws.addEventListener('message', function incoming({data}) {
console.log(res.blocks); console.log(JSON.parse(data.toString()));
} });
if (res.mempoolInfo) {
console.log(res.mempoolInfo); websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
}
if (res.transactions) { websocket.wsTrackAddress(ws, "GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon");
console.log(res.transactions);
} websocket.wsTrackAddresses(ws, [
if (res.mempoolBlocks) { "GsDhxpV4Voi3XJA22bnAH4q8117hjZrQMF",
console.log(res.mempoolBlocks); ]);
}
}); websocket.wsTrackTransaction(ws, "23195d459a70875c3b1f9fb9082acc9f0594f1c63dac71b40f2ff7298630a421");
};
websocket.wsTrackMempoolBlock(ws, 1);
setTimeout(() => {
websocket.wsStopData(ws);
websocket.wsStopTrackingAddress(ws);
websocket.wsStopTrackingAddresses(ws);
websocket.wsStopTrackingTransaction(ws);
websocket.wsStopTrackingMempoolBlock(ws);
}, 60000);
} catch (error) {
console.log(error);
}
}
init(); init();

View File

@ -1,5 +1,5 @@
{ {
"watch": ["src"], "watch": ["src", "examples"],
"ext": "ts,json", "ext": "ts,json",
"ignore": ["src/**/*.spec.ts"], "ignore": ["src/**/*.spec.ts"],
"exec": "ts-node ./src/index.ts" "exec": "ts-node ./src/index.ts"

10234
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,22 @@
{ {
"name": "@mempool/mempool-js", "name": "@mempool/mempool.js",
"version": "2.2.0", "version": "3.0.0",
"description": "NPM package module for Mempool APIs.", "description": "NPM package module for Mempool APIs.",
"main": "lib/index.js", "main": "lib/index.js",
"keywords": [ "keywords": [
"axios", "axios",
"bitcoin", "bitcoin",
"bisq",
"liquid", "liquid",
"mainet", "mainet",
"testnet", "testnet",
"testnet4",
"signet", "signet",
"blockchain", "blockchain",
"html", "html",
"mempool-space", "mempool.space",
"mempool-js", "mempool.js",
"mempool", "mempool",
"websocket",
"nodejs", "nodejs",
"typescript" "typescript"
], ],
@ -24,13 +25,14 @@
"private": false, "private": false,
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/mempool/mempool-js.git" "url": "git://github.com/mempool/mempool.js.git"
}, },
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
"scripts": { "scripts": {
"start": "ts-node src/index.ts", "start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts", "dev": "nodemon src/index.ts",
"build": "tsc | browserify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify lib/index.js --standalone mempoolJS > dist/mempool.min.js", "build": "tsc",
"export-mempool-js": "tsc | browserify -p esmify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify -p esmify lib/index.js --standalone mempoolJS > dist/mempool.min.js",
"prepare": "npm run build", "prepare": "npm run build",
"postversion": "git push && git push --tags" "postversion": "git push && git push --tags"
}, },
@ -38,20 +40,26 @@
"lib/**/*" "lib/**/*"
], ],
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "1.13.2",
"ws": "^7.4.3" "ws": "^8.18.3"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^14.14.25", "@types/node": "^24.10.1",
"@types/websocket": "^1.0.2", "@types/websocket": "^1.0.10",
"@types/ws": "^7.4.1", "@types/ws": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^4.14.2", "@typescript-eslint/eslint-plugin": "^8.46.4",
"@typescript-eslint/parser": "^4.14.2", "@typescript-eslint/parser": "^8.46.4",
"browserify": "^17.0.0", "browserify": "^17.0.1",
"eslint": "^7.19.0", "eslint": "^9.39.1",
"nodemon": "^2.0.7", "esmify": "^2.1.1",
"tinyify": "^3.0.0", "nodemon": "^3.1.11",
"typescript": "^4.1.3" "tinyify": "^4.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
},
"overrides": {
"terser": "^5.14.2",
"babel-traverse": "npm:@babel/traverse@^7.23.2"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -1,13 +0,0 @@
import { AxiosInstance } from 'axios';
import { Address, AddressesInstance } from '../../interfaces/bisq/addresses';
export const useAddresses = (api: AxiosInstance): AddressesInstance => {
const getAddress = async (params: { address: string }) => {
const { data } = await api.get<Address>(`/block/${params.address}`);
return data;
};
return {
getAddress,
};
};

View File

@ -1,27 +0,0 @@
import { AxiosInstance } from 'axios';
import { Block, BlocksInstance } from '../../interfaces/bisq/blocks';
export const useBlocks = (api: AxiosInstance): BlocksInstance => {
const getBlock = async (params: { hash: string }) => {
const { data } = await api.get<Block>(`/block/${params.hash}`);
return data;
};
const getBlocks = async (params: { index: number; length: number }) => {
const { data } = await api.get<Block>(
`/blocks/${params.index}/${params.length}`
);
return data;
};
const getBlocksTipHeight = async () => {
const { data } = await api.get<number>(`/blocks/tip/height`);
return data;
};
return {
getBlock,
getBlocks,
getBlocksTipHeight,
};
};

View File

@ -1,13 +0,0 @@
import { AxiosInstance } from 'axios';
import { Stats, StatsInstance } from '../../interfaces/bisq/statistics';
export const useStatistics = (api: AxiosInstance): StatsInstance => {
const getStats = async () => {
const { data } = await api.get<Stats>(`/stats`);
return data;
};
return {
getStats,
};
};

View File

@ -1,21 +0,0 @@
import { AxiosInstance } from 'axios';
import { Tx, TransactionsInstance } from '../../interfaces/bisq/transactions';
export const useTransactions = (api: AxiosInstance): TransactionsInstance => {
const getTx = async (params: { txid: string }) => {
const { data } = await api.get<Tx>(`/tx/${params.txid}`);
return data;
};
const getTxs = async (params: { index: number; length: number }) => {
const { data } = await api.get<Tx[]>(
`/txs/${params.index}/${params.length}`
);
return data;
};
return {
getTx,
getTxs,
};
};

View File

@ -12,7 +12,11 @@ export const useAddresses = (api: AxiosInstance): AddressInstance => {
return data; return data;
}; };
const getAddressTxs = async (params: { address: string }) => { const getAddressTxs = async (params: { address: string, after_txid?: string }) => {
if (params.after_txid) {
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs?after_txid=${params.after_txid}`);
return data;
}
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`); const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
return data; return data;
}; };

View File

@ -8,7 +8,7 @@ import { Tx } from '../../interfaces/bitcoin/transactions';
export const useBlocks = (api: AxiosInstance): BlockInstance => { export const useBlocks = (api: AxiosInstance): BlockInstance => {
const getBlock = async (params: { hash: string }) => { const getBlock = async (params: { hash: string }) => {
const { data } = await api.get<Block>(`/block/${params.hash}`); const { data } = await api.get<Block>(`/v1/block/${params.hash}`);
return data; return data;
}; };
@ -44,13 +44,18 @@ export const useBlocks = (api: AxiosInstance): BlockInstance => {
return data; return data;
}; };
const getBlockHeader = async (params: { hash: string }) => {
const { data } = await api.get<string>(`/block/${params.hash}/header`);
return data;
};
const getBlockHeight = async (params: { height: number }) => { const getBlockHeight = async (params: { height: number }) => {
const { data } = await api.get<string>(`/block-height/${params.height}`); const { data } = await api.get<string>(`/block-height/${params.height}`);
return data; return data;
}; };
const getBlocks = async (params: { start_height?: number }) => { const getBlocks = async (params: { start_height?: number }) => {
const { data } = await api.get<Block>(`/blocks/${params.start_height}`); const { data } = await api.get<Block[]>(`/v1/blocks/${params.start_height}`);
return data; return data;
}; };
@ -72,6 +77,7 @@ export const useBlocks = (api: AxiosInstance): BlockInstance => {
getBlockTxid, getBlockTxid,
getBlockTxids, getBlockTxids,
getBlockRaw, getBlockRaw,
getBlockHeader,
getBlockHeight, getBlockHeight,
getBlocksTipHash, getBlocksTipHash,
getBlocksTipHeight, getBlocksTipHeight,

View File

@ -0,0 +1,23 @@
import { AxiosInstance } from 'axios';
import {
Adjustment,
DifficultyInstance,
Hashrate,
} from '../../interfaces/bitcoin/difficulty';
export const useDifficulty = (api: AxiosInstance): DifficultyInstance => {
const getDifficultyAdjustment = async () => {
const { data } = await api.get<Adjustment>(`/v1/difficulty-adjustment`);
return data;
};
const getHashrate = async (params: { interval: string }): Promise<Hashrate> => {
const { data } = await api.get<Hashrate>(`/v1/mining/hashrate/${params.interval}`);
return data;
}
return {
getDifficultyAdjustment,
getHashrate,
};
};

View File

@ -0,0 +1,97 @@
import { AxiosInstance } from 'axios';
import { Channel, LightningInstance, NetworkStats, Node, NodeStats } from '../../interfaces/bitcoin/lightning';
export const useLightning = (api: AxiosInstance): LightningInstance => {
const getNetworkStats = async () => {
const { data } = await api.get<NetworkStats>(`/v1/lightning/statistics/latest`);
return data;
}
const getNodesInCountry = async (params: { country: string }) => {
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/country/${params.country}`);
return data;
}
const getNodesStatsPerCountry = async () => {
const { data } = await api.get<any>(`/v1/lightning/nodes/countries`);
return data;
}
const getNodesHostedByISP = async (params: { isp: number }) => {
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/isp/${params.isp}`);
return data;
}
const getISPRanking = async () => {
const { data } = await api.get<any>(`/v1/lightning/nodes/isp-ranking`);
return data;
}
const getLiquidityRanking = async () => {
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/rankings/liquidity`);
return data;
}
const getConnectivityRanking = async () => {
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/rankings/connectivity`);
return data;
}
const getOldestNodes = async () => {
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/rankings/age`);
return data;
}
const getNodeStats = async (params: { public_key: string }) => {
const { data } = await api.get<Node>(`/v1/lightning/nodes/${params.public_key}`);
return data;
}
const getHistoricalNodeStats = async (params: { public_key: string }) => {
const { data } = await api.get<NodeStats[]>(`/v1/lightning/nodes/${params.public_key}/statistics`);
return data;
}
const getChannel = async (params: { id: string }) => {
const { data } = await api.get<Channel>(`/v1/lightning/channels/${params.id}`);
return data;
}
const getChannelsFromTxIds = async (params: { txId: string[] }) => {
const { data } = await api.get<any[]>(`/v1/lightning/channels/txids?txId[]=${params.txId.join('&txId[]=')}`);
return data;
}
const getChannelsFromNodePublicKey = async (params: { public_key: string, status: string, index?: number }) => {
const { data } = await api.get<Channel[]>(`/v1/lightning/channels?public_key=${params.public_key}&status=${params.status}&index=${params?.index}`);
return data;
}
const getChannelsGeodata = async () => {
const { data } = await api.get<any[]>(`/v1/lightning/channels-geo`);
return data;
}
const getChannelsGeodataByPublicKey = async (params: { public_key: string }) => {
const { data } = await api.get<any[]>(`/v1/lightning/channels-geo/${params.public_key}`);
return data;
}
return {
getNetworkStats,
getNodesInCountry,
getNodesStatsPerCountry,
getNodesHostedByISP,
getISPRanking,
getLiquidityRanking,
getConnectivityRanking,
getOldestNodes,
getNodeStats,
getHistoricalNodeStats,
getChannel,
getChannelsFromTxIds,
getChannelsFromNodePublicKey,
getChannelsGeodata,
getChannelsGeodataByPublicKey,
};
};

View File

@ -36,7 +36,7 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
}; };
const getTxMerkleProof = async (params: { txid: string }) => { const getTxMerkleProof = async (params: { txid: string }) => {
const { data } = await api.get<Array<TxMerkleProof>>( const { data } = await api.get<TxMerkleProof>(
`/tx/${params.txid}/merkle-proof` `/tx/${params.txid}/merkle-proof`
); );
return data; return data;
@ -56,8 +56,8 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
return data; return data;
}; };
const postTx = async (params: { txid: string }) => { const postTx = async (params: { txhex: string }) => {
const { data } = await api.post<string>(`/tx`, { txid: params.txid }); const { data } = await api.post<string>(`/tx`, params.txhex );
return data; return data;
}; };

View File

@ -1,14 +1,86 @@
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets'; import { WsInstance } from '../../interfaces/bitcoin/websockets';
import wsClient from '../../services/ws/client'; import {
import wsServer from '../../services/ws/server'; wsInit as wsInitBrowser,
wsWantData as wsWantDataBrowser,
wsStopData as wsStopDataBrowser,
wsTrackAddress as wsTrackAddressBrowser,
wsStopTrackingAddress as wsStopTrackingAddressBrowser,
wsTrackAddresses as wsTrackAddressesBrowser,
wsStopTrackingAddresses as wsStopTrackingAddressesBrowser,
wsTrackTransaction as wsTrackTransactionBrowser,
wsStopTrackingTransaction as wsStopTrackingTransactionBrowser,
wsTrackRbfSummary as wsTrackRbfSummaryBrowser,
wsStopTrackingRbfSummary as wsStopTrackingRbfSummaryBrowser,
wsTrackRbf as wsTrackRbfBrowser,
wsStopTrackingRbf as wsStopTrackingRbfBrowser,
wsTrackMempoolBlock as wsTrackMempoolBlockBrowser,
wsStopTrackingMempoolBlock as wsStopTrackingMempoolBlockBrowser,
} from '../../services/ws/ws-client-browser';
import {
wsInit,
wsWantData,
wsStopData,
wsTrackAddress,
wsStopTrackingAddress,
wsTrackAddresses,
wsStopTrackingAddresses,
wsTrackTransaction,
wsStopTrackingTransaction,
wsTrackRbfSummary,
wsStopTrackingRbfSummary,
wsTrackRbf,
wsStopTrackingRbf,
wsTrackMempoolBlock,
wsStopTrackingMempoolBlock
} from '../../services/ws/ws-client-node';
import WebSocketServer from 'ws';
const defaultWs = 'wss://mempool.space/api/v1/ws'; export const useWebsocket = (hostname: string, network: string, protocol: string | undefined): WsInstance => {
export const useWebsocket = (hostname?: string): WsInstance => { if (!protocol) {
hostname?.includes('localhost') ? protocol = 'ws' : protocol = 'wss';
} else if (protocol === 'http' || protocol === 'ws') {
protocol = 'ws';
} else {
protocol = 'wss';
}
if (network && ['testnet', 'testnet4', 'signet'].includes(network)) {
network = `/${network}`;
} else {
network = '';
}
const wsEndpoint = `${protocol}://${hostname}${network}/api/v1/ws`
return { return {
initClient: ({ options }: WsInterface) => wsInit: () => wsInit(wsEndpoint),
wsClient(options, defaultWs, hostname), wsInitBrowser: () => wsInitBrowser(wsEndpoint),
initServer: ({ options }: WsInterface) => wsWantData: (ws: WebSocketServer, options: string[]) => wsWantData(ws, options),
wsServer(options, defaultWs, hostname), wsWantDataBrowser: (ws: WebSocket, options: string[]) => wsWantDataBrowser(ws, options),
wsStopData: (ws: WebSocketServer) => wsStopData(ws),
wsStopDataBrowser: (ws: WebSocket) => wsStopDataBrowser(ws),
wsTrackAddress: (ws: WebSocketServer, address: string) => wsTrackAddress(ws, address),
wsTrackAddressBrowser: (ws: WebSocket, address: string) => wsTrackAddressBrowser(ws, address),
wsStopTrackingAddress: (ws: WebSocketServer) => wsStopTrackingAddress(ws),
wsStopTrackingAddressBrowser: (ws: WebSocket) => wsStopTrackingAddressBrowser(ws),
wsTrackAddresses: (ws: WebSocketServer, addresses: string[]) => wsTrackAddresses(ws, addresses),
wsTrackAddressesBrowser: (ws: WebSocket, addresses: string[]) => wsTrackAddressesBrowser(ws, addresses),
wsStopTrackingAddresses: (ws: WebSocketServer) => wsStopTrackingAddresses(ws),
wsStopTrackingAddressesBrowser: (ws: WebSocket) => wsStopTrackingAddressesBrowser(ws),
wsTrackTransaction: (ws: WebSocketServer, txid: string) => wsTrackTransaction(ws, txid),
wsTrackTransactionBrowser: (ws: WebSocket, txid: string) => wsTrackTransactionBrowser(ws, txid),
wsStopTrackingTransaction: (ws: WebSocketServer) => wsStopTrackingTransaction(ws),
wsStopTrackingTransactionBrowser: (ws: WebSocket) => wsStopTrackingTransactionBrowser(ws),
wsTrackRbfSummary: (ws: WebSocketServer) => wsTrackRbfSummary(ws),
wsTrackRbfSummaryBrowser: (ws: WebSocket) => wsTrackRbfSummaryBrowser(ws),
wsStopTrackingRbfSummary: (ws: WebSocketServer) => wsStopTrackingRbfSummary(ws),
wsStopTrackingRbfSummaryBrowser: (ws: WebSocket) => wsStopTrackingRbfSummaryBrowser(ws),
wsTrackRbf: (ws: WebSocketServer, fullRbf: boolean) => wsTrackRbf(ws, fullRbf),
wsTrackRbfBrowser: (ws: WebSocket, fullRbf: boolean) => wsTrackRbfBrowser(ws, fullRbf),
wsStopTrackingRbf: (ws: WebSocketServer) => wsStopTrackingRbf(ws),
wsStopTrackingRbfBrowser: (ws: WebSocket) => wsStopTrackingRbfBrowser(ws),
wsTrackMempoolBlock: (ws: WebSocketServer, index: number) => wsTrackMempoolBlock(ws, index),
wsTrackMempoolBlockBrowser: (ws: WebSocket, index: number) => wsTrackMempoolBlockBrowser(ws, index),
wsStopTrackingMempoolBlock: (ws: WebSocketServer) => wsStopTrackingMempoolBlock(ws),
wsStopTrackingMempoolBlockBrowser: (ws: WebSocket) => wsStopTrackingMempoolBlockBrowser(ws),
}; };
}; };

View File

@ -12,7 +12,11 @@ export const useAddresses = (api: AxiosInstance): AddressInstance => {
return data; return data;
}; };
const getAddressTxs = async (params: { address: string }) => { const getAddressTxs = async (params: { address: string, after_txid?: string }) => {
if (params.after_txid) {
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs?after_txid=${params.after_txid}`);
return data;
}
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`); const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
return data; return data;
}; };

View File

@ -7,6 +7,11 @@ export const useAssets = (api: AxiosInstance): AssetsInstance => {
return data; return data;
}; };
const getAssetIcon = async (params: { asset_id: string }) => {
const { data } = await api.get(`/v1/asset/${params.asset_id}/icon`);
return data;
};
const getAssetTxs = async (params: { const getAssetTxs = async (params: {
asset_id: string; asset_id: string;
is_mempool: boolean; is_mempool: boolean;
@ -29,9 +34,16 @@ export const useAssets = (api: AxiosInstance): AssetsInstance => {
return data; return data;
}; };
const getAssetsIcons = async () => {
const { data } = await api.get<string[]>(`/v1/assets/icons`);
return data;
};
return { return {
getAsset, getAsset,
getAssetIcon,
getAssetTxs, getAssetTxs,
getAssetSupply, getAssetSupply,
getAssetsIcons,
}; };
}; };

View File

@ -2,13 +2,13 @@ import { AxiosInstance } from 'axios';
import { import {
Block, Block,
BlockStatus, BlockStatus,
BlockInstance, BlockLiquidInstance,
} from '../../interfaces/bitcoin/blocks'; } from '../../interfaces/liquid/blocks';
import { Tx } from '../../interfaces/bitcoin/transactions'; import { Tx } from '../../interfaces/bitcoin/transactions';
export const useBlocks = (api: AxiosInstance): BlockInstance => { export const useBlocks = (api: AxiosInstance): BlockLiquidInstance => {
const getBlock = async (params: { hash: string }) => { const getBlock = async (params: { hash: string }) => {
const { data } = await api.get<Block>(`/block/${params.hash}`); const { data } = await api.get<Block>(`/v1/block/${params.hash}`);
return data; return data;
}; };
@ -50,7 +50,7 @@ export const useBlocks = (api: AxiosInstance): BlockInstance => {
}; };
const getBlocks = async (params: { start_height?: number }) => { const getBlocks = async (params: { start_height?: number }) => {
const { data } = await api.get<Block>(`/blocks/${params.start_height}`); const { data } = await api.get<Block[]>(`/v1/blocks/${params.start_height}`);
return data; return data;
}; };

View File

@ -4,10 +4,10 @@ import {
TxStatus, TxStatus,
TxMerkleProof, TxMerkleProof,
TxOutspend, TxOutspend,
TxInstance, TxLiquidInstance,
} from '../../interfaces/bitcoin/transactions'; } from '../../interfaces/liquid/transactions';
export const useTransactions = (api: AxiosInstance): TxInstance => { export const useTransactions = (api: AxiosInstance): TxLiquidInstance => {
const getTx = async (params: { txid: string }) => { const getTx = async (params: { txid: string }) => {
const { data } = await api.get<Tx>(`/tx/${params.txid}`); const { data } = await api.get<Tx>(`/tx/${params.txid}`);
return data; return data;
@ -28,15 +28,8 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
return data; return data;
}; };
const getTxMerkleBlockProof = async (params: { txid: string }) => {
const { data } = await api.get<string>(
`/tx/${params.txid}/merkleblock-proof`
);
return data;
};
const getTxMerkleProof = async (params: { txid: string }) => { const getTxMerkleProof = async (params: { txid: string }) => {
const { data } = await api.get<Array<TxMerkleProof>>( const { data } = await api.get<TxMerkleProof>(
`/tx/${params.txid}/merkle-proof` `/tx/${params.txid}/merkle-proof`
); );
return data; return data;
@ -56,8 +49,8 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
return data; return data;
}; };
const postTx = async (params: { txid: string }) => { const postTx = async (params: { txhex: string }) => {
const { data } = await api.post<string>(`/tx`, { txid: params.txid }); const { data } = await api.post<string>(`/tx`, params.txhex );
return data; return data;
}; };
@ -66,7 +59,6 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
getTxStatus, getTxStatus,
getTxHex, getTxHex,
getTxRaw, getTxRaw,
getTxMerkleBlockProof,
getTxMerkleProof, getTxMerkleProof,
getTxOutspend, getTxOutspend,
getTxOutspends, getTxOutspends,

View File

@ -1,14 +1,69 @@
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets'; import { WsLiquidInstance } from '../../interfaces/liquid/websockets';
import wsClient from '../../services/ws/client'; import {
import wsServer from '../../services/ws/server'; wsInit as wsInitBrowser,
wsWantData as wsWantDataBrowser,
wsStopData as wsStopDataBrowser,
wsTrackAddress as wsTrackAddressBrowser,
wsStopTrackingAddress as wsStopTrackingAddressBrowser,
wsTrackAddresses as wsTrackAddressesBrowser,
wsStopTrackingAddresses as wsStopTrackingAddressesBrowser,
wsTrackTransaction as wsTrackTransactionBrowser,
wsStopTrackingTransaction as wsStopTrackingTransactionBrowser,
wsTrackMempoolBlock as wsTrackMempoolBlockBrowser,
wsStopTrackingMempoolBlock as wsStopTrackingMempoolBlockBrowser,
} from '../../services/ws/ws-client-browser';
import {
wsInit,
wsWantData,
wsStopData,
wsTrackAddress,
wsStopTrackingAddress,
wsTrackAddresses,
wsStopTrackingAddresses,
wsTrackTransaction,
wsStopTrackingTransaction,
wsTrackMempoolBlock,
wsStopTrackingMempoolBlock
} from '../../services/ws/ws-client-node';
import WebSocketServer from 'ws';
const defaultWs = 'wss://mempool.space/liquid/api/v1/ws'; export const useWebsocket = (hostname: string, network: string, protocol: string | undefined): WsLiquidInstance => {
export const useWebsocket = (hostname?: string): WsInstance => { if (!protocol) {
hostname?.includes('localhost') ? protocol = 'ws' : protocol = 'wss';
} else if (protocol === 'http' || protocol === 'ws') {
protocol = 'ws';
} else {
protocol = 'wss';
}
if (network && ['testnet', 'liquidtestnet'].includes(network)) {
network = `/liquidtestnet`;
} else {
network = '/liquid';
}
const wsEndpoint = `${protocol}://${hostname}${network}/api/v1/ws`
return { return {
initClient: ({ options }: WsInterface) => wsInit: () => wsInit(wsEndpoint),
wsClient(options, defaultWs, hostname), wsInitBrowser: () => wsInitBrowser(wsEndpoint),
initServer: ({ options }: WsInterface) => wsWantData: (ws: WebSocketServer, options: string[]) => wsWantData(ws, options),
wsServer(options, defaultWs, hostname), wsWantDataBrowser: (ws: WebSocket, options: string[]) => wsWantDataBrowser(ws, options),
}; wsStopData: (ws: WebSocketServer) => wsStopData(ws),
wsStopDataBrowser: (ws: WebSocket) => wsStopDataBrowser(ws),
wsTrackAddress: (ws: WebSocketServer, address: string) => wsTrackAddress(ws, address),
wsTrackAddressBrowser: (ws: WebSocket, address: string) => wsTrackAddressBrowser(ws, address),
wsStopTrackingAddress: (ws: WebSocketServer) => wsStopTrackingAddress(ws),
wsStopTrackingAddressBrowser: (ws: WebSocket) => wsStopTrackingAddressBrowser(ws),
wsTrackAddresses: (ws: WebSocketServer, addresses: string[]) => wsTrackAddresses(ws, addresses),
wsTrackAddressesBrowser: (ws: WebSocket, addresses: string[]) => wsTrackAddressesBrowser(ws, addresses),
wsStopTrackingAddresses: (ws: WebSocketServer) => wsStopTrackingAddresses(ws),
wsStopTrackingAddressesBrowser: (ws: WebSocket) => wsStopTrackingAddressesBrowser(ws),
wsTrackTransaction: (ws: WebSocketServer, txid: string) => wsTrackTransaction(ws, txid),
wsTrackTransactionBrowser: (ws: WebSocket, txid: string) => wsTrackTransactionBrowser(ws, txid),
wsStopTrackingTransaction: (ws: WebSocketServer) => wsStopTrackingTransaction(ws),
wsStopTrackingTransactionBrowser: (ws: WebSocket) => wsStopTrackingTransactionBrowser(ws),
wsTrackMempoolBlock: (ws: WebSocketServer, index: number) => wsTrackMempoolBlock(ws, index),
wsTrackMempoolBlockBrowser: (ws: WebSocket, index: number) => wsTrackMempoolBlockBrowser(ws, index),
wsStopTrackingMempoolBlock: (ws: WebSocketServer) => wsStopTrackingMempoolBlock(ws),
wsStopTrackingMempoolBlockBrowser: (ws: WebSocket) => wsStopTrackingMempoolBlockBrowser(ws), };
}; };

View File

@ -1,22 +1,15 @@
import { MempoolConfig, MempoolReturn } from './interfaces/index'; import { MempoolConfig, MempoolReturn } from './interfaces/index';
import { import { makeBitcoinAPI, makeLiquidAPI } from './services/api/index';
makeBitcoinAPI,
makeBisqAPI,
makeLiquidAPI,
} from './services/api/index';
import { useAddresses } from './app/bitcoin/addresses'; import { useAddresses } from './app/bitcoin/addresses';
import { useBlocks } from './app/bitcoin/blocks'; import { useBlocks } from './app/bitcoin/blocks';
import { useDifficulty } from './app/bitcoin/difficulty';
import { useFees } from './app/bitcoin/fees'; import { useFees } from './app/bitcoin/fees';
import { useLightning } from './app/bitcoin/lightning';
import { useMempool } from './app/bitcoin/mempool'; import { useMempool } from './app/bitcoin/mempool';
import { useTransactions } from './app/bitcoin/transactions'; import { useTransactions } from './app/bitcoin/transactions';
import { useWebsocket } from './app/bitcoin/websocket'; import { useWebsocket } from './app/bitcoin/websocket';
import { useAddresses as useAddressesBisq } from './app/bisq/addresses';
import { useBlocks as useBlocksBisq } from './app/bisq/blocks';
import { useStatistics as useStatisticsBisq } from './app/bisq/statistics';
import { useTransactions as useTransactionsBisq } from './app/bisq/transactions';
import { useAssets as useAssetsLiquid } from './app/liquid/assets'; import { useAssets as useAssetsLiquid } from './app/liquid/assets';
import { useAddresses as useAddressesLiquid } from './app/liquid/addresses'; import { useAddresses as useAddressesLiquid } from './app/liquid/addresses';
import { useBlocks as useBlocksLiquid } from './app/liquid/blocks'; import { useBlocks as useBlocksLiquid } from './app/liquid/blocks';
@ -29,7 +22,7 @@ const hostnameEndpointDefault = 'mempool.space';
const networkEndpointDefault = 'main'; const networkEndpointDefault = 'main';
const mempool = ( const mempool = (
{ hostname, network }: MempoolConfig = { { hostname, network, protocol, config }: MempoolConfig = {
hostname: hostnameEndpointDefault, hostname: hostnameEndpointDefault,
network: networkEndpointDefault, network: networkEndpointDefault,
} }
@ -37,24 +30,28 @@ const mempool = (
if (!hostname) hostname = hostnameEndpointDefault; if (!hostname) hostname = hostnameEndpointDefault;
if (!network) network = networkEndpointDefault; if (!network) network = networkEndpointDefault;
const { api: apiBitcoin } = makeBitcoinAPI({ hostname, network }); const { api: apiBitcoin } = makeBitcoinAPI({
const { api: apiBisq } = makeBisqAPI(hostname); hostname,
const { api: apiLiquid } = makeLiquidAPI(hostname); network,
protocol,
config,
});
const { api: apiLiquid } = makeLiquidAPI({
hostname,
network,
protocol,
config,
});
return { return {
bitcoin: { bitcoin: {
addresses: useAddresses(apiBitcoin), addresses: useAddresses(apiBitcoin),
blocks: useBlocks(apiBitcoin), blocks: useBlocks(apiBitcoin),
difficulty: useDifficulty(apiBitcoin),
fees: useFees(apiBitcoin), fees: useFees(apiBitcoin),
lightning: useLightning(apiBitcoin),
mempool: useMempool(apiBitcoin), mempool: useMempool(apiBitcoin),
transactions: useTransactions(apiBitcoin), transactions: useTransactions(apiBitcoin),
websocket: useWebsocket(hostname), websocket: useWebsocket(hostname, network, protocol),
},
bisq: {
statistics: useStatisticsBisq(apiBisq),
addresses: useAddressesBisq(apiBisq),
blocks: useBlocksBisq(apiBisq),
transactions: useTransactionsBisq(apiBisq),
}, },
liquid: { liquid: {
addresses: useAddressesLiquid(apiLiquid), addresses: useAddressesLiquid(apiLiquid),
@ -63,7 +60,7 @@ const mempool = (
fees: useFeesLiquid(apiLiquid), fees: useFeesLiquid(apiLiquid),
mempool: useMempoolLiquid(apiLiquid), mempool: useMempoolLiquid(apiLiquid),
transactions: useTransactionsLiquid(apiLiquid), transactions: useTransactionsLiquid(apiLiquid),
websocket: useWebsocketLiquid(hostname), websocket: useWebsocketLiquid(hostname, network, protocol),
}, },
}; };
}; };

View File

@ -1,13 +0,0 @@
import { Tx } from './transactions';
export interface Address {
height: number;
time: number;
hash: string;
previousBlockHash: string;
txs: Tx[];
}
export interface AddressesInstance {
getAddress: (params: { address: string }) => Promise<Address>;
}

View File

@ -1,18 +0,0 @@
import { Tx } from './transactions';
export interface Block {
height: number;
time: number;
hash: string;
previousBlockHash: string;
txs: Tx[];
}
export interface BlocksInstance {
getBlock: (params: { hash: string }) => Promise<Block>;
getBlocks: (params: { index: number; length: number }) => Promise<Block>;
getBlocksTipHeight: (params: {
index: number;
length: number;
}) => Promise<number>;
}

View File

@ -1,11 +0,0 @@
export interface Stats {
address: number;
minted: number;
burnt: number;
spent_txos: number;
unspent_txos: number;
}
export interface StatsInstance {
getStats: () => Promise<Stats>;
}

View File

@ -1,46 +0,0 @@
export interface Tx {
txVersion: string;
id: string;
blockHeight: number;
blockHash: string;
time: number;
inputs: [];
outputs: [
{
txVersion: string;
txId: string;
index: number;
bsqAmount: number;
btcAmount: number;
height: number;
isVerified: true;
burntFee: number;
invalidatedBsq: number;
address: string;
scriptPubKey: {
addresses: [string];
asm: string;
hex: string;
reqSigs: number;
type: string;
};
time: number;
txType: string;
txTypeDisplayString: string;
txOutputType: string;
txOutputTypeDisplayString: string;
lockTime: number;
isUnspent: true;
}
];
txType: string;
txTypeDisplayString: string;
burntFee: number;
invalidatedBsq: number;
unlockBlockHeight: number;
}
export interface TransactionsInstance {
getTx: (params: { txid: string }) => Promise<Tx>;
getTxs: (params: { index: number; length: number }) => Promise<Tx[]>;
}

View File

@ -23,7 +23,7 @@ export interface AddressTxsUtxo {
export interface AddressInstance { export interface AddressInstance {
getAddress: (params: { address: string }) => Promise<Address>; getAddress: (params: { address: string }) => Promise<Address>;
getAddressTxs: (params: { address: string }) => Promise<Tx[]>; getAddressTxs: (params: { address: string, after_txid?: string }) => Promise<Tx[]>;
getAddressTxsChain: (params: { address: string }) => Promise<Tx[]>; getAddressTxsChain: (params: { address: string }) => Promise<Tx[]>;
getAddressTxsMempool: (params: { address: string }) => Promise<Tx[]>; getAddressTxsMempool: (params: { address: string }) => Promise<Tx[]>;
getAddressTxsUtxo: (params: { address: string }) => Promise<AddressTxsUtxo[]>; getAddressTxsUtxo: (params: { address: string }) => Promise<AddressTxsUtxo[]>;

View File

@ -14,6 +14,7 @@ export interface Block {
nonce: number; nonce: number;
bits: number; bits: number;
difficulty: number; difficulty: number;
extras: any;
} }
export interface BlockStatus { export interface BlockStatus {
@ -24,12 +25,13 @@ export interface BlockStatus {
export interface BlockInstance { export interface BlockInstance {
getBlock: (params: { hash: string }) => Promise<Block>; getBlock: (params: { hash: string }) => Promise<Block>;
getBlocks: (params: { start_height?: number }) => Promise<Block>; getBlocks: (params: { start_height?: number }) => Promise<Block[]>;
getBlockStatus: (params: { hash: string }) => Promise<BlockStatus>; getBlockStatus: (params: { hash: string }) => Promise<BlockStatus>;
getBlockTxs: (params: { hash: string; start_index?: number }) => Promise<Tx>; getBlockTxs: (params: { hash: string; start_index?: number }) => Promise<Tx>;
getBlockTxids: (params: { hash: string }) => Promise<string[]>; getBlockTxids: (params: { hash: string }) => Promise<string[]>;
getBlockTxid: (params: { hash: string; index: number }) => Promise<string>; getBlockTxid: (params: { hash: string; index: number }) => Promise<string>;
getBlockRaw: (params: { hash: string }) => Promise<string>; getBlockRaw: (params: { hash: string }) => Promise<string>;
getBlockHeader: (params: { hash: string }) => Promise<string>;
getBlockHeight: (params: { height: number }) => Promise<string>; getBlockHeight: (params: { height: number }) => Promise<string>;
getBlocksTipHeight: () => Promise<number>; getBlocksTipHeight: () => Promise<number>;
getBlocksTipHash: () => Promise<string>; getBlocksTipHash: () => Promise<string>;

View File

@ -0,0 +1,37 @@
export interface Adjustment {
progressPercent: number,
difficultyChange: number,
estimatedRetargetDate: number,
remainingBlocks: number,
remainingTime: number,
previousRetarget: number,
nextRetargetHeight: number,
timeAvg: number,
timeOffset: number,
expectedBlocks: number,
}
export interface Hashrate {
hashrates: HashRateData[],
difficulty: DifficultyData[],
currentHashrate: number,
currentDifficulty: number,
}
export interface HashRateData {
timestamp: number,
avgHashrate: number
}
export interface DifficultyData {
time: number,
height: number,
difficulty: number,
adjustment: number
}
export interface DifficultyInstance {
getDifficultyAdjustment: () => Promise<Adjustment>;
getHashrate: (params: { interval: string }) => Promise<Hashrate>;
}

View File

@ -0,0 +1,98 @@
import { Tx, TxStatus } from './transactions';
export interface NetworkStatsEntry {
added: string;
avg_base_fee_mtokens: number;
avg_capacity: number;
avg_fee_rate: number;
channel_count: number;
clearnet_nodes: number;
clearnet_tor_nodes: number;
id: number;
med_base_fee_mtokens: number;
med_capacity: number;
med_fee_rate: number;
node_count: number;
tor_nodes: number;
total_capacity: number;
unannounced_nodes: number;
}
export interface NetworkStats {
latest: NetworkStatsEntry;
previous: NetworkStatsEntry;
}
export interface Node {
alias: string;
public_key: string;
channels: number;
capacity: number;
updatedAt: string;
base_fee_mtokens?: number;
cltv_delta?: number;
fee_rate?: number;
is_disabled?: boolean;
max_htlc_mtokens?: number;
min_htlc_mtokens?: number;
longitude?: number;
latitude?: number;
funding_balance?: number;
closing_balance?: number;
city?: any;
country?: any;
iso_code?: any;
subdivision?: any;
first_seen?: number;
isp?: string;
features?: any[];
featuresBit?: string;
active_channel_count?: number;
opened_channel_count?: number;
closed_channel_count?: number;
}
export interface NodeStats {
added: number;
capacity: number;
channels: number;
}
export interface Channel {
id: number;
short_id: string;
capacity: number;
transaction_id: string;
transaction_vout: number;
closing_transaction_id: string;
closing_reason: number;
closing_fee: number;
updated_at: string;
closing_date?: string;
created: string;
status: number;
funding_ratio?: number;
closed_by?: string;
single_funded?: boolean;
node_left: Node,
node_right: Node,
}
export interface LightningInstance {
getNetworkStats: () => Promise<NetworkStats>;
getNodesInCountry: (params: { country: string }) => Promise<Node[]>;
getNodesStatsPerCountry: () => Promise<any>;
getNodesHostedByISP: (params: { isp: number }) => Promise<Node[]>;
getISPRanking: () => Promise<any>;
getLiquidityRanking: () => Promise<Node[]>;
getConnectivityRanking: () => Promise<Node[]>;
getOldestNodes: () => Promise<Node[]>;
getNodeStats: (params: { public_key: string }) => Promise<Node>;
getHistoricalNodeStats: (params: { public_key: string }) => Promise<NodeStats[]>;
getChannel: (params: { id: string }) => Promise<Channel>;
getChannelsFromTxIds: (params: { txId: string[] }) => Promise<any[]>;
getChannelsFromNodePublicKey: (params: { public_key: string, status: string, index?: number }) => Promise<Channel[]>;
getChannelsGeodata: () => Promise<any>;
getChannelsGeodataByPublicKey: (params: { public_key: string }) => Promise<any[]>;
}

View File

@ -52,11 +52,11 @@ export interface TxInstance {
getTxHex: (params: { txid: string }) => Promise<string>; getTxHex: (params: { txid: string }) => Promise<string>;
getTxRaw: (params: { txid: string }) => Promise<string>; getTxRaw: (params: { txid: string }) => Promise<string>;
getTxMerkleBlockProof: (params: { txid: string }) => Promise<string>; getTxMerkleBlockProof: (params: { txid: string }) => Promise<string>;
getTxMerkleProof: (params: { txid: string }) => Promise<Array<TxMerkleProof>>; getTxMerkleProof: (params: { txid: string }) => Promise<TxMerkleProof>;
getTxOutspend: (params: { getTxOutspend: (params: {
txid: string; txid: string;
vout: number; vout: number;
}) => Promise<TxOutspend>; }) => Promise<TxOutspend>;
getTxOutspends: (params: { txid: string }) => Promise<Array<TxOutspend>>; getTxOutspends: (params: { txid: string }) => Promise<Array<TxOutspend>>;
postTx: (params: { txid: string }) => Promise<unknown>; postTx: (params: { txhex: string }) => Promise<unknown>;
} }

View File

@ -1,10 +1,34 @@
export interface WsInterface {
options: string[];
}
import WebSocketServer from 'ws'; import WebSocketServer from 'ws';
export interface WsInstance { export interface WsInstance {
initClient: ({ options }: WsInterface) => WebSocket; wsInit: () => WebSocketServer;
initServer: ({ options }: WsInterface) => WebSocketServer; wsInitBrowser: () => WebSocket;
wsWantData: (ws: WebSocketServer, options: string[]) => void;
wsWantDataBrowser: (ws: WebSocket, options: string[]) => void;
wsStopData: (ws: WebSocketServer) => void;
wsStopDataBrowser: (ws: WebSocket) => void;
wsTrackAddress: (ws: WebSocketServer, address: string) => void;
wsTrackAddressBrowser: (ws: WebSocket, address: string) => void;
wsStopTrackingAddress: (ws: WebSocketServer) => void;
wsStopTrackingAddressBrowser: (ws: WebSocket) => void;
wsTrackAddresses: (ws: WebSocketServer, addresses: string[]) => void;
wsTrackAddressesBrowser: (ws: WebSocket, addresses: string[]) => void;
wsStopTrackingAddresses: (ws: WebSocketServer) => void;
wsStopTrackingAddressesBrowser: (ws: WebSocket) => void;
wsTrackTransaction: (ws: WebSocketServer, txid: string) => void;
wsTrackTransactionBrowser: (ws: WebSocket, txid: string) => void;
wsStopTrackingTransaction: (ws: WebSocketServer) => void;
wsStopTrackingTransactionBrowser: (ws: WebSocket) => void;
wsTrackRbfSummary: (ws: WebSocketServer) => void;
wsTrackRbfSummaryBrowser: (ws: WebSocket) => void;
wsStopTrackingRbfSummary: (ws: WebSocketServer) => void;
wsStopTrackingRbfSummaryBrowser: (ws: WebSocket) => void;
wsTrackRbf: (ws: WebSocketServer, fullRbf: boolean) => void;
wsTrackRbfBrowser: (ws: WebSocket, fullRbf: boolean) => void;
wsStopTrackingRbf: (ws: WebSocketServer) => void;
wsStopTrackingRbfBrowser: (ws: WebSocket) => void;
wsTrackMempoolBlock: (ws: WebSocketServer, index: number) => void;
wsTrackMempoolBlockBrowser: (ws: WebSocket, index: number) => void;
wsStopTrackingMempoolBlock: (ws: WebSocketServer) => void;
wsStopTrackingMempoolBlockBrowser: (ws: WebSocket) => void;
} }

View File

@ -1,44 +1,42 @@
import { AddressInstance } from './bitcoin/addresses'; import { AddressInstance } from './bitcoin/addresses';
import { BlockInstance } from './bitcoin/blocks'; import { BlockInstance } from './bitcoin/blocks';
import { DifficultyInstance } from './bitcoin/difficulty';
import { FeeInstance } from './bitcoin/fees'; import { FeeInstance } from './bitcoin/fees';
import { LightningInstance } from './bitcoin/lightning';
import { MempoolInstance } from './bitcoin/mempool'; import { MempoolInstance } from './bitcoin/mempool';
import { TxInstance } from './bitcoin/transactions'; import { TxInstance } from './bitcoin/transactions';
import { WsInstance } from './bitcoin/websockets'; import { WsInstance } from './bitcoin/websockets';
import { AddressesInstance } from './bisq/addresses';
import { BlocksInstance } from './bisq/blocks';
import { StatsInstance } from './bisq/statistics';
import { TransactionsInstance } from './bisq/transactions';
import { AssetsInstance } from './liquid/assets'; import { AssetsInstance } from './liquid/assets';
import { BlockLiquidInstance } from './liquid/blocks';
import { TxLiquidInstance } from './liquid/transactions';
import { WsLiquidInstance } from './liquid/websockets';
import { AxiosRequestConfig } from 'axios';
export interface MempoolConfig { export interface MempoolConfig {
protocol?: 'http' | 'https';
hostname?: string; hostname?: string;
network?: string; network?: string;
config?: AxiosRequestConfig;
} }
export interface MempoolReturn { export interface MempoolReturn {
bitcoin: { bitcoin: {
addresses: AddressInstance; addresses: AddressInstance;
blocks: BlockInstance; blocks: BlockInstance;
difficulty: DifficultyInstance;
fees: FeeInstance; fees: FeeInstance;
lightning: LightningInstance
mempool: MempoolInstance; mempool: MempoolInstance;
transactions: TxInstance; transactions: TxInstance;
websocket: WsInstance; websocket: WsInstance;
}; };
bisq: {
addresses: AddressesInstance;
blocks: BlocksInstance;
statistics: StatsInstance;
transactions: TransactionsInstance;
};
liquid: { liquid: {
assets: AssetsInstance; assets: AssetsInstance;
addresses: AddressInstance; addresses: AddressInstance;
blocks: BlockInstance; blocks: BlockLiquidInstance;
fees: FeeInstance; fees: FeeInstance;
mempool: MempoolInstance; mempool: MempoolInstance;
transactions: TxInstance; transactions: TxLiquidInstance;
websocket: WsInstance; websocket: WsLiquidInstance;
}; };
} }

View File

@ -16,6 +16,7 @@ interface AssetStats {
export interface AssetsInstance { export interface AssetsInstance {
getAsset: (params: { asset_id: string }) => Promise<Asset>; getAsset: (params: { asset_id: string }) => Promise<Asset>;
getAssetIcon: (params: { asset_id: string }) => Promise<unknown>;
getAssetTxs: (params: { getAssetTxs: (params: {
asset_id: string; asset_id: string;
is_mempool: boolean; is_mempool: boolean;
@ -24,4 +25,5 @@ export interface AssetsInstance {
asset_id: string; asset_id: string;
decimal: boolean; decimal: boolean;
}) => Promise<Asset>; }) => Promise<Asset>;
getAssetsIcons: () => Promise<string[]>
} }

View File

@ -0,0 +1,37 @@
import { Tx } from '../bitcoin/transactions';
export interface Block {
id: string;
height: number;
version: number;
timestamp: number;
tx_count: number;
size: number;
weight: number;
merkle_root: string;
previousblockhash: string;
mediantime: number;
nonce: number;
bits: number;
difficulty: number;
extras: any;
}
export interface BlockStatus {
in_best_chain: boolean;
height: number;
next_best: string;
}
export interface BlockLiquidInstance {
getBlock: (params: { hash: string }) => Promise<Block>;
getBlocks: (params: { start_height?: number }) => Promise<Block[]>;
getBlockStatus: (params: { hash: string }) => Promise<BlockStatus>;
getBlockTxs: (params: { hash: string; start_index?: number }) => Promise<Tx>;
getBlockTxids: (params: { hash: string }) => Promise<string[]>;
getBlockTxid: (params: { hash: string; index: number }) => Promise<string>;
getBlockRaw: (params: { hash: string }) => Promise<string>;
getBlockHeight: (params: { height: number }) => Promise<string>;
getBlocksTipHeight: () => Promise<number>;
getBlocksTipHash: () => Promise<string>;
}

View File

@ -0,0 +1,61 @@
export interface Tx {
txid: string;
version: number;
locktime: number;
vin: {
txid: string;
vout: number;
prevout: Vout;
scriptsig: string;
scriptsig_asm: string;
is_coinbase: boolean;
sequence: string;
}[];
vout: Vout[];
size: number;
weight: number;
fee: number;
status: TxStatus;
}
export interface Vout {
scriptpubkey: string;
scriptpubkey_asm: string;
scriptpubkey_type: string;
scriptpubkey_address: string;
value: number;
}
export interface TxStatus {
confirmed: boolean;
block_height: number;
block_hash: string;
block_time: number;
}
export interface TxMerkleProof {
block_height: number;
merkle: string[];
pos: number;
}
export interface TxOutspend {
spent: boolean;
txid: string;
vin: number;
status: TxStatus;
}
export interface TxLiquidInstance {
getTx: (params: { txid: string }) => Promise<Tx>;
getTxStatus: (params: { txid: string }) => Promise<TxStatus>;
getTxHex: (params: { txid: string }) => Promise<string>;
getTxRaw: (params: { txid: string }) => Promise<string>;
getTxMerkleProof: (params: { txid: string }) => Promise<TxMerkleProof>;
getTxOutspend: (params: {
txid: string;
vout: number;
}) => Promise<TxOutspend>;
getTxOutspends: (params: { txid: string }) => Promise<Array<TxOutspend>>;
postTx: (params: { txhex: string }) => Promise<unknown>;
}

View File

@ -0,0 +1,26 @@
import WebSocketServer from 'ws';
export interface WsLiquidInstance {
wsInit: () => WebSocketServer;
wsInitBrowser: () => WebSocket;
wsWantData: (ws: WebSocketServer, options: string[]) => void;
wsWantDataBrowser: (ws: WebSocket, options: string[]) => void;
wsStopData: (ws: WebSocketServer) => void;
wsStopDataBrowser: (ws: WebSocket) => void;
wsTrackAddress: (ws: WebSocketServer, address: string) => void;
wsTrackAddressBrowser: (ws: WebSocket, address: string) => void;
wsStopTrackingAddress: (ws: WebSocketServer) => void;
wsStopTrackingAddressBrowser: (ws: WebSocket) => void;
wsTrackAddresses: (ws: WebSocketServer, addresses: string[]) => void;
wsTrackAddressesBrowser: (ws: WebSocket, addresses: string[]) => void;
wsStopTrackingAddresses: (ws: WebSocketServer) => void;
wsStopTrackingAddressesBrowser: (ws: WebSocket) => void;
wsTrackTransaction: (ws: WebSocketServer, txid: string) => void;
wsTrackTransactionBrowser: (ws: WebSocket, txid: string) => void;
wsStopTrackingTransaction: (ws: WebSocketServer) => void;
wsStopTrackingTransactionBrowser: (ws: WebSocket) => void;
wsTrackMempoolBlock: (ws: WebSocketServer, index: number) => void;
wsTrackMempoolBlockBrowser: (ws: WebSocket, index: number) => void;
wsStopTrackingMempoolBlock: (ws: WebSocketServer) => void;
wsStopTrackingMempoolBlockBrowser: (ws: WebSocket) => void;
}

View File

@ -1,35 +1,46 @@
import axios, { AxiosInstance } from 'axios'; import axios, { AxiosInstance } from 'axios';
import { MempoolConfig } from './../../interfaces/index'; import { MempoolConfig } from '../../interfaces';
export const makeBitcoinAPI = ({ export const makeBitcoinAPI = ({
hostname, hostname,
network, network,
protocol,
config,
}: MempoolConfig): { api: AxiosInstance } => { }: MempoolConfig): { api: AxiosInstance } => {
if (network && ['testnet', 'signet'].includes(network)) { if (!protocol) {
hostname?.includes('localhost') ? protocol = 'http' : protocol = 'https';
}
if (network && ['testnet', 'testnet4', 'signet'].includes(network)) {
network = `/${network}`; network = `/${network}`;
} else { } else {
network = ''; network = '';
} }
const api = axios.create({ const api = axios.create({
baseURL: `https://${hostname}${network}/api/`, baseURL: `${protocol}://${hostname}${network}/api/`,
...config,
}); });
return { return {
api, api,
}; };
}; };
export const makeBisqAPI = (hostname?: string): { api: AxiosInstance } => { export const makeLiquidAPI = ({
hostname,
network,
protocol,
config,
}: MempoolConfig): { api: AxiosInstance } => {
if (!protocol) {
hostname?.includes('localhost') ? protocol = 'http' : protocol = 'https';
}
if (network && ['testnet', 'liquidtestnet'].includes(network)) {
network = `/liquidtestnet`;
} else {
network = '/liquid';
}
const api = axios.create({ const api = axios.create({
baseURL: `https://${hostname}/bisq/api/`, baseURL: `${protocol}://${hostname}${network}/api/`,
}); ...config,
return {
api,
};
};
export const makeLiquidAPI = (hostname?: string): { api: AxiosInstance } => {
const api = axios.create({
baseURL: `https://${hostname}/liquid/api/`,
}); });
return { return {
api, api,
@ -38,6 +49,5 @@ export const makeLiquidAPI = (hostname?: string): { api: AxiosInstance } => {
export default { export default {
makeBitcoinAPI, makeBitcoinAPI,
makeBisqAPI,
makeLiquidAPI, makeLiquidAPI,
}; };

View File

@ -1,23 +0,0 @@
const browserWS = (
options: string[],
defaultWs: string,
websocketEndpoint?: string
): WebSocket => {
const ws = new WebSocket(websocketEndpoint || defaultWs);
ws.addEventListener('open', function open() {
handleMessage(ws, options);
});
return ws;
};
const handleMessage = (ws: WebSocket, options: string[]) => {
ws.send(JSON.stringify({ action: 'init' }));
ws.send(
JSON.stringify({
action: 'want',
data: options,
})
);
};
export default browserWS;

View File

@ -1,24 +0,0 @@
import WebSocket from 'ws';
const serverWS = (
options: string[],
defaultWs: string,
websocketEndpoint?: string
): WebSocket => {
const ws = new WebSocket(websocketEndpoint || defaultWs);
ws.on('open', function open() {
handleMessage(ws, options);
});
return ws;
};
const handleMessage = (ws: WebSocket, options: string[]) => {
ws.send(JSON.stringify({ action: 'init' }));
ws.send(
JSON.stringify({
action: 'want',
data: options,
})
);
};
export default serverWS;

View File

@ -0,0 +1,88 @@
const TIMEOUT_DURATION = 5000;
const MAX_RETRY_COUNT = 3;
const wsActionWrapper = (ws: WebSocket, action: any): void => {
let retryCount = 0;
const sendData = () => {
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(action));
} else if (retryCount < MAX_RETRY_COUNT) {
retryCount++;
console.log("WebSocket connection is not open. Retrying...");
setTimeout(sendData, TIMEOUT_DURATION);
} else {
console.log("WebSocket connection is not open. Max retry count reached.");
}
};
sendData();
}
export const wsInit = (endpoint: string): WebSocket => {
const ws = new WebSocket(endpoint);
ws.addEventListener("open", function open() {
ws.send(JSON.stringify({ action: "init" }));
});
return ws;
}
export const wsWantData = (ws: WebSocket, options: string[]): void => {
wsActionWrapper(ws, { action: "want", data: options });
}
export const wsStopData = (ws: WebSocket): void => {
wsActionWrapper(ws, { action: "want", data: [] });
}
export const wsTrackAddress = (ws: WebSocket, address: string): void => {
wsActionWrapper(ws, { 'track-address': address });
}
export const wsStopTrackingAddress = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-address': 'stop' });
}
export const wsTrackAddresses = (ws: WebSocket, addresses: string[]): void => {
wsActionWrapper(ws, { 'track-addresses': addresses });
}
export const wsStopTrackingAddresses = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-addresses': [] });
}
export const wsTrackTransaction = (ws: WebSocket, txid: string): void => {
wsActionWrapper(ws, { 'track-tx': txid });
}
export const wsStopTrackingTransaction = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-tx': 'stop' });
}
export const wsTrackRbfSummary = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-rbf-summary': true });
}
export const wsStopTrackingRbfSummary = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-rbf-summary': false });
}
export const wsTrackRbf = (ws: WebSocket, fullRbf: boolean): void => {
if (!fullRbf) {
wsActionWrapper(ws, { 'track-rbf': 'all' });
} else {
wsActionWrapper(ws, { 'track-rbf': 'fullRbf' });
}
}
export const wsStopTrackingRbf = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-rbf': 'stop' });
}
export const wsTrackMempoolBlock = (ws: WebSocket, index: number): void => {
wsActionWrapper(ws, { 'track-mempool-block': index });
}
export const wsStopTrackingMempoolBlock = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-mempool-block': -1 });
}

View File

@ -0,0 +1,90 @@
import WebSocket from "ws";
const TIMEOUT_DURATION = 5000;
const MAX_RETRY_COUNT = 3;
const wsActionWrapper = (ws: WebSocket, action: any): void => {
let retryCount = 0;
const sendData = () => {
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(action));
} else if (retryCount < MAX_RETRY_COUNT) {
retryCount++;
console.log("WebSocket connection is not open. Retrying...");
setTimeout(sendData, TIMEOUT_DURATION);
} else {
console.log("WebSocket connection is not open. Max retry count reached.");
}
};
sendData();
}
export const wsInit = (endpoint: string): WebSocket => {
const ws = new WebSocket(endpoint);
ws.addEventListener("open", function open() {
ws.send(JSON.stringify({ action: "init" }));
});
return ws;
}
export const wsWantData = (ws: WebSocket, options: string[]): void => {
wsActionWrapper(ws, { action: "want", data: options });
}
export const wsStopData = (ws: WebSocket): void => {
wsActionWrapper(ws, { action: "want", data: [] });
}
export const wsTrackAddress = (ws: WebSocket, address: string): void => {
wsActionWrapper(ws, { 'track-address': address });
}
export const wsStopTrackingAddress = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-address': 'stop' });
}
export const wsTrackAddresses = (ws: WebSocket, addresses: string[]): void => {
wsActionWrapper(ws, { 'track-addresses': addresses });
}
export const wsStopTrackingAddresses = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-addresses': [] });
}
export const wsTrackTransaction = (ws: WebSocket, txid: string): void => {
wsActionWrapper(ws, { 'track-tx': txid });
}
export const wsStopTrackingTransaction = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-tx': 'stop' });
}
export const wsTrackRbfSummary = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-rbf-summary': true });
}
export const wsStopTrackingRbfSummary = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-rbf-summary': false });
}
export const wsTrackRbf = (ws: WebSocket, fullRbf: boolean): void => {
if (!fullRbf) {
wsActionWrapper(ws, { 'track-rbf': 'all' });
} else {
wsActionWrapper(ws, { 'track-rbf': 'fullRbf' });
}
}
export const wsStopTrackingRbf = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-rbf': 'stop' });
}
export const wsTrackMempoolBlock = (ws: WebSocket, index: number): void => {
wsActionWrapper(ws, { 'track-mempool-block': index });
}
export const wsStopTrackingMempoolBlock = (ws: WebSocket): void => {
wsActionWrapper(ws, { 'track-mempool-block': -1 });
}

3634
yarn.lock

File diff suppressed because it is too large Load Diff