Compare commits

..

No commits in common. "main" and "v2.2.3" have entirely different histories.
main ... v2.2.3

83 changed files with 9216 additions and 9459 deletions

150
README-bisq.md Normal file
View File

@ -0,0 +1,150 @@
# mempool**JS** - Bisq API
Interface to access the Bisq API.
[Back to home](./README.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,6 +1,6 @@
# mempool**JS** - Bitcoin API
Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `signet` APIs.
Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs.
[Back to home](./README.md)
@ -8,80 +8,53 @@ Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `signet` APIs.
## **Features**
- Addresses
- [Get Address](#get-address)
- [Get Address Txs](#get-address-txs)
- [Get Address Txs Chain](#get-address-txs-chain)
- [Get Address Txs Mempool](#get-address-txs-mempool)
- [Get Address Txs Utxo](#get-address-txs-utxo)
- Assets
- [Get Asset](#get-asset)
- [Get Asset Txs](#get-asset-txs)
- [Get Asset Supply](#get-asset-supply)
- Blocks
- [Get Block](#get-block)
- [Get Block Status](#get-block-status)
- [Get Block Txs](#get-block-txs)
- [Get Block Txids](#get-block-txids)
- [Get Block Txid](#get-block-txid)
- [Get Block Raw](#get-block-raw)
- [Get Blocks Header](#get-blocks-header)
- [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Difficulty
- [Get Difficulty Adjustment](#get-difficulty-adjustment)
- Fees
- [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- Lightning
- [Get Network Stats](#get-network-stats)
- [Get Nodes In Country](#get-nodes-in-country)
- [Get Nodes Stats Per Country](#get-nodes-stats-per-country)
- [Get Nodes Hosted by ISP](#get-nodes-hosted-by-isp)
- [Get ISP Ranking](#get-isp-ranking)
- [Get Liquidity Ranking](#get-liquidity-ranking)
- [Get Connectivity Ranking](#get-connectivity-ranking)
- [Get Oldest Nodes](#get-oldest-nodes)
- [Get Node Stats](#get-node-stats)
- [Get Historical Node Stats](#get-historical-node-stats)
- [Get Channel](#get-channel)
- [Get Channels From Transaction IDs](#get-channels-from-transaction-ids)
- [Get Channels From Node Public Key](#get-channels-from-node-public-key)
- [Get Channels Geodata](#get-channels-geodata)
- [Get Channels Geodata By Public Key](#get-channels-geodata-by-public-key)
- 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)
- Bitcoin
- Addresses
- [Get Address](#get-address)
- [Get Address Txs](#get-address-txs)
- [Get Address Txs Chain](#get-address-txs-chain)
- [Get Address Txs Mempool](#get-address-txs-mempool)
- [Get Address Txs Utxo](#get-address-txs-utxo)
- Assets
- [Get Asset](#get-asset)
- [Get Asset Txs](#get-asset-txs)
- [Get Asset Supply](#get-asset-supply)
- Blocks
- [Get Block](#get-block)
- [Get Block Status](#get-block-status)
- [Get Block Txs](#get-block-txs)
- [Get Block Txids](#get-block-txids)
- [Get Block Txid](#get-block-txid)
- [Get Block Raw](#get-block-raw)
- [Get Blocks Header](#get-blocks-header)
- [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Difficulty
- [Get Difficulty Adjustment](#get-difficulty-adjustment)
- Fees
- [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- 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 Outspends]($post-tx-outspends)
- Websocket
- [Websocket Client](#websocket-client)
- [Websocket Server](#websocket-server)
- [Bisq](./README-bisq.md)
- [Liquid](./README-liquid.md)
---
@ -450,267 +423,6 @@ const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
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.
@ -944,13 +656,13 @@ const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
```
### **Post Tx **
### **Post Tx Outspends**
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:**
- {string} txhex
- {string} txid
[ [NodeJS Example](examples/nodejs/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
@ -959,163 +671,81 @@ const {
bitcoin: { transactions },
} = mempoolJS();
const txhex = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const postTx = await transactions.postTx({ txhex });
const postTx = await transactions.postTx({ txid });
console.log(postTx);
```
### **Init Websocket**
### **Websocket**
Initializes a websocket connection.
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats.
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) ]
#### **Websocket Server**
Only use on server side apps.
```js
const { bitcoin: { websocket } } = mempoolJS();
const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
const init = async () => {
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);
}
});
}
init();
```
### **Want Data**
#### **Websocket Client**
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) ]
Only use on browser apps.
```js
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
```
### **Stop Want Data**
Unsubscribe from `want` data.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
websocket.wsStopData(ws); // for in-browser websocket, use websocket.wsStopDataBrowser
```
### **Track Address**
Subscribe to address updates.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
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
const init = async () => {
const {
bitcoin: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.addEventListener('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);
}
});
};
init();
```

View File

@ -1,6 +1,6 @@
# mempool**JS** - Liquid API
# mempool**JS** - Bitcoin API
Interface to access Liquid APIs.
Interface to access the Bitcoin `mainet`, `testnet`, `signet` APIs.
[Back to home](./README.md)
@ -8,57 +8,50 @@ Interface to access Liquid APIs.
## **Features**
- Addresses
- [Get Address](#get-address)
- [Get Address Txs](#get-address-txs)
- [Get Address Txs Chain](#get-address-txs-chain)
- [Get Address Txs Mempool](#get-address-txs-mempool)
- [Get Address Txs Utxo](#get-address-txs-utxo)
- Assets
- [Get Asset](#get-asset)
- [Get Asset Icon](#get-asset-icon)
- [Get Asset Txs](#get-asset-txs)
- [Get Asset Supply](#get-asset-supply)
- [Get Assets Icons](#get-assets-icons)
- Blocks
- [Get Block](#get-block)
- [Get Block Status](#get-block-status)
- [Get Block Txs](#get-block-txs)
- [Get Block Txids](#get-block-txids)
- [Get Block Txid](#get-block-txid)
- [Get Block Raw](#get-block-raw)
- [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Fees
- [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- 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 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 Mempool Block](#track-mempool-block)
- [Stop Track Mempool Block](#stop-track-mempool-block)
- [Bitcoin](./README-bitcoin.md)
- [Bisq](./README-bisq.md)
- Liquid
- Addresses
- [Get Address](#get-address)
- [Get Address Txs](#get-address-txs)
- [Get Address Txs Chain](#get-address-txs-chain)
- [Get Address Txs Mempool](#get-address-txs-mempool)
- [Get Address Txs Utxo](#get-address-txs-utxo)
- Assets
- [Get Asset](#get-asset)
- [Get Asset Txs](#get-asset-txs)
- [Get Asset Supply](#get-asset-supply)
- Blocks
- [Get Block](#get-block)
- [Get Block Status](#get-block-status)
- [Get Block Txs](#get-block-txs)
- [Get Block Txids](#get-block-txids)
- [Get Block Txid](#get-block-txid)
- [Get Block Raw](#get-block-raw)
- [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Fees
- [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- 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 Outspends]($post-tx-outspends)
- Websocket
- [Websocket Client](#websocket-client)
- [Websocket Server](#websocket-server)
---
@ -77,7 +70,7 @@ const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
@ -98,7 +91,7 @@ const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs);
@ -119,7 +112,7 @@ const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain);
@ -140,7 +133,7 @@ const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
console.log(addressTxsMempool);
@ -171,7 +164,7 @@ Returns information about a Liquid asset.
- {string} asset_id
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -194,7 +187,7 @@ Returns transactions associated with the specified Liquid asset. For the network
- {string} asset_id
- {boolean} is_mempool
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -217,7 +210,7 @@ Get the current total supply of the specified asset. For the native asset (L-BTC
- {string} asset_id
- {boolean} decimal
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -590,6 +583,27 @@ const txRaw = await transactions.getTxRaw({ txid });
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**
Returns a merkle inclusion proof for the transaction using Electrum's blockchain.transaction.get_merkle format.
@ -657,13 +671,13 @@ const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
```
### **Post Tx **
### **Post Tx Outspends**
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:**
- {string} txhex
- {string} txid
[ [NodeJS Example](examples/nodejs/liquid/transactions.ts) ] [ [HTML Example](examples/html/liquid/transactions.html) ] [ [Top](#features) ]
@ -672,123 +686,81 @@ const {
liquid: { transactions },
} = mempoolJS();
const txhex = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const postTx = await transactions.postTx({ txhex });
const postTx = await transactions.postTx({ txid });
console.log(postTx);
```
### **Init Websocket**
### **Websocket**
Initializes a websocket connection.
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats.
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) ]
```js
const { liquid: { websocket } } = mempoolJS( {hostname: 'liquid.network'} );
const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
```
#### **Websocket Server**
### **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) ]
Only use on server side apps.
```js
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
const { liquid: { websocket } } = mempoolJS();
const init = async () => {
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);
}
});
}
init();
```
### **Stop Want Data**
#### **Websocket Client**
Unsubscribe from `want` data.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
Only use on browser apps.
```js
websocket.wsStopData(ws); // for in-browser websocket, use websocket.wsStopDataBrowser
```
const init = async () => {
const {
liquid: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
### **Track Address**
Subscribe to address updates.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
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
```
ws.addEventListener('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);
}
});
};
init();
```

View File

@ -32,25 +32,13 @@ Import the module.
```js
import mempoolJS from '@mempool/mempool.js';
// default mempool.space endpointsconst { bitcoin, liquid } = mempoolJS();
// default mempool.space endpoints
const { bitcoin, bisq, liquid } = mempoolJS();
// (optional) your custom endpoints
const { bitcoin } = mempoolJS({
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'
const { bitcoin, bisq, liquid } = mempoolJS({
hostname: 'mempool.space',
network: 'testnet' // 'signet' | 'testnet' | 'mainnet'
});
```
@ -66,20 +54,12 @@ Call `mempoolJS()` function to access the API methods.
```js
// default mempool.space endpoints
const { bitcoin } = mempoolJS();
const { bitcoin, bisq, liquid } = mempoolJS();
// (optional) your custom endpoints
const { bitcoin } = mempoolJS({
protocol: 'https', // optional, defaults to http for localhost, otherwise https
const { bitcoin, bisq, liquid } = mempoolJS({
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'
network: 'testnet' // 'signet' | 'testnet' | 'mainnet'
});
```
@ -92,10 +72,15 @@ const { liquid } = mempoolJS({
- [Blocks](./README-bitcoin.md#get-blocks)
- [Difficulty Adjustment](./README-bitcoin.md#get-difficulty-adjustment)
- [Fees](./README-bitcoin.md#get-fees)
- [Lightning](./README-bitcoin.md#get-network-stats)
- [Mempool](./README-bitcoin.md#get-mempool)
- [Transactions](./README-bitcoin.md#get-transactions)
- [Websocket](./README-bitcoin.md#init-websocket)
- [Websocket Client](./README-bitcoin.md#Websocket-Client)
- [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)
- [Addresses](./README-liquid.md#get-address)
- [Assets](./README-liquid.md#get-address)
@ -103,7 +88,8 @@ const { liquid } = mempoolJS({
- [Fees](./README-liquid.md#get-address)
- [Mempool](./README-liquid.md#get-address)
- [Transactions](./README-liquid.md#get-address)
- [Websocket](./README-liquid.md#init-websocket)
- [Websocket Client](./README-liquid.md#Websocket-Client)
- [Websocket Server](./README-liquid.md#Websocket-Server)
---

View File

@ -0,0 +1,21 @@
<!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

@ -0,0 +1,31 @@
<!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

@ -0,0 +1,19 @@
<!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

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

View File

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

View File

@ -2,19 +2,16 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script src="https://mempool.space/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);
}
const {
bitcoin: { difficulty },
} = mempoolJS();
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
console.log(difficultyAdjustment);
};
init();
</script>

View File

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

View File

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

View File

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

View File

@ -2,49 +2,32 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
try {
const {
bitcoin: { websocket },
} = mempoolJS();
const {
bitcoin: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
const ws = websocket.wsInitBrowser();
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
websocket.wsWantDataBrowser(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
websocket.wsTrackAddressBrowser(ws, "1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC");
websocket.wsTrackAddressesBrowser(ws, [
"1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC",
]);
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);
}
ws.addEventListener('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);
}
});
};
init();
</script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,43 +2,32 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { websocket },
} = mempoolJS( { hostname: 'liquid.network' } );
const {
liquid: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
const ws = websocket.wsInitBrowser();
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
websocket.wsWantDataBrowser(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
websocket.wsTrackAddressBrowser(ws, "GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon");
websocket.wsTrackAddressesBrowser(ws, [
"GsDhxpV4Voi3XJA22bnAH4q8117hjZrQMF",
]);
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);
}
ws.addEventListener('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);
}
});
};
init();
</script>

View File

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

View File

@ -0,0 +1,23 @@
import mempoolJS from "@mempool/mempool.js";
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

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,59 +0,0 @@
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,21 +1,17 @@
import mempoolJS from "./../../../src/index";
import mempoolJS from "@mempool/mempool.js";
const init = async () => {
try {
const {
bitcoin: { mempool },
} = mempoolJS();
const getMempool = await mempool.getMempool();
console.log(getMempool);
const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent);
const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids);
} catch (error) {
console.log(error);
}
const {
bitcoin: { mempool },
} = mempoolJS();
const getMempool = await mempool.getMempool();
console.log(getMempool);
const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent);
const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids);
};
init();

View File

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

View File

@ -1,45 +1,27 @@
import mempoolJS from "./../../../src/index";
import mempoolJS from "@mempool/mempool.js";
const { bitcoin: { websocket } } = mempoolJS();
const init = async () => {
try {
const {
bitcoin: { websocket },
} = mempoolJS();
const ws = websocket.wsInit();
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
websocket.wsTrackAddress(ws, "1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC");
websocket.wsTrackAddresses(ws, [
"1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC",
]);
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);
}
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);
}
});
}
init();

19
examples/nodejs/index.ts Normal file
View File

@ -0,0 +1,19 @@
import mempoolJS from "@mempool/mempool.js";
const init = async () => {
const { bitcoin } = mempoolJS({
hostname:'localhost:4200'
});
const feesRecommended = await bitcoin.fees.getFeesRecommended();
console.log(feesRecommended);
const hash = "0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2";
const block = await bitcoin.blocks.getBlockHeader({hash});
console.log(block);
const difficultyAdjustment = await bitcoin.difficulty.getDifficultyAdjustment();
console.log(difficultyAdjustment);
};
init();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,38 +1,27 @@
import mempoolJS from "./../../../src/index";
import mempoolJS from "@mempool/mempool.js";
const { liquid: { websocket } } = mempoolJS();
const init = async () => {
try {
const { liquid: { websocket } } = mempoolJS( { hostname: 'liquid.network' } );
const ws = websocket.wsInit();
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
websocket.wsTrackAddress(ws, "GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon");
websocket.wsTrackAddresses(ws, [
"GsDhxpV4Voi3XJA22bnAH4q8117hjZrQMF",
]);
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);
}
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);
}
});
}
init();

View File

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

8246
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
{
"name": "@mempool/mempool.js",
"version": "3.0.0",
"version": "2.2.3",
"description": "NPM package module for Mempool APIs.",
"main": "lib/index.js",
"keywords": [
"axios",
"bitcoin",
"bisq",
"liquid",
"mainet",
"testnet",
"testnet4",
"signet",
"blockchain",
"html",
@ -31,8 +31,9 @@
"scripts": {
"start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts",
"examples-nodemon": "nodemon --watch 'examples/nodejs/**' --ext 'ts,json' --ignore 'src/**/*.spec.ts' --exec 'ts-node examples/nodejs/index.ts'",
"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",
"export-js": "tsc | browserify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify lib/index.js --standalone mempoolJS > dist/mempool.min.js",
"prepare": "npm run build",
"postversion": "git push && git push --tags"
},
@ -40,26 +41,21 @@
"lib/**/*"
],
"dependencies": {
"axios": "1.13.2",
"ws": "^8.18.3"
"axios": "^0.21.1",
"ws": "^7.4.3"
},
"devDependencies": {
"@types/node": "^24.10.1",
"@types/websocket": "^1.0.10",
"@types/ws": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^8.46.4",
"@typescript-eslint/parser": "^8.46.4",
"browserify": "^17.0.1",
"eslint": "^9.39.1",
"esmify": "^2.1.1",
"nodemon": "^3.1.11",
"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"
"@types/node": "^14.14.25",
"@types/websocket": "^1.0.2",
"@types/ws": "^7.4.1",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"browserify": "^17.0.0",
"eslint": "^7.19.0",
"nodemon": "^2.0.7",
"tinyify": "^3.0.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},
"license": "MIT"
}

13
src/app/bisq/addresses.ts Normal file
View File

@ -0,0 +1,13 @@
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>(`/address/${params.address}`);
return data;
};
return {
getAddress,
};
};

27
src/app/bisq/blocks.ts Normal file
View File

@ -0,0 +1,27 @@
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

@ -0,0 +1,13 @@
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

@ -0,0 +1,21 @@
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,11 +12,7 @@ export const useAddresses = (api: AxiosInstance): AddressInstance => {
return data;
};
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 getAddressTxs = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
return data;
};

View File

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

View File

@ -2,22 +2,15 @@ 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`);
const { data } = await api.get<Adjustment>(`/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

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

View File

@ -1,86 +1,14 @@
import { WsInstance } from '../../interfaces/bitcoin/websockets';
import {
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';
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets';
import wsClient from '../../services/ws/client';
import wsServer from '../../services/ws/server';
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`
const wsEndpoint = `wss://${hostname}/api/v1/ws`;
return {
wsInit: () => wsInit(wsEndpoint),
wsInitBrowser: () => wsInitBrowser(wsEndpoint),
wsWantData: (ws: WebSocketServer, options: string[]) => wsWantData(ws, options),
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),
initClient: ({ options }: WsInterface) =>
wsClient(options, wsEndpoint),
initServer: ({ options }: WsInterface) =>
wsServer(options, wsEndpoint),
};
};

View File

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

View File

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

View File

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

View File

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

View File

@ -1,69 +1,14 @@
import { WsLiquidInstance } from '../../interfaces/liquid/websockets';
import {
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';
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets';
import wsClient from '../../services/ws/client';
import wsServer from '../../services/ws/server';
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`
const wsEndpoint = `wss://${hostname}/liquid/api/v1/ws`;
return {
wsInit: () => wsInit(wsEndpoint),
wsInitBrowser: () => wsInitBrowser(wsEndpoint),
wsWantData: (ws: WebSocketServer, options: string[]) => wsWantData(ws, options),
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), };
initClient: ({ options }: WsInterface) =>
wsClient(options, wsEndpoint),
initServer: ({ options }: WsInterface) =>
wsServer(options, wsEndpoint),
};
};

View File

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

View File

@ -0,0 +1,13 @@
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

@ -0,0 +1,18 @@
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

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

View File

@ -0,0 +1,46 @@
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 {
getAddress: (params: { address: string }) => Promise<Address>;
getAddressTxs: (params: { address: string, after_txid?: string }) => Promise<Tx[]>;
getAddressTxs: (params: { address: string }) => Promise<Tx[]>;
getAddressTxsChain: (params: { address: string }) => Promise<Tx[]>;
getAddressTxsMempool: (params: { address: string }) => Promise<Tx[]>;
getAddressTxsUtxo: (params: { address: string }) => Promise<AddressTxsUtxo[]>;

View File

@ -14,7 +14,6 @@ export interface Block {
nonce: number;
bits: number;
difficulty: number;
extras: any;
}
export interface BlockStatus {
@ -25,7 +24,7 @@ export interface BlockStatus {
export interface BlockInstance {
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>;
getBlockTxs: (params: { hash: string; start_index?: number }) => Promise<Tx>;
getBlockTxids: (params: { hash: string }) => Promise<string[]>;

View File

@ -6,32 +6,8 @@ export interface Adjustment {
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

@ -1,98 +0,0 @@
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>;
getTxRaw: (params: { txid: string }) => Promise<string>;
getTxMerkleBlockProof: (params: { txid: string }) => Promise<string>;
getTxMerkleProof: (params: { txid: string }) => Promise<TxMerkleProof>;
getTxMerkleProof: (params: { txid: string }) => Promise<Array<TxMerkleProof>>;
getTxOutspend: (params: {
txid: string;
vout: number;
}) => Promise<TxOutspend>;
getTxOutspends: (params: { txid: string }) => Promise<Array<TxOutspend>>;
postTx: (params: { txhex: string }) => Promise<unknown>;
postTx: (params: { txid: string }) => Promise<unknown>;
}

View File

@ -1,34 +1,10 @@
export interface WsInterface {
options: string[];
}
import WebSocketServer from 'ws';
export interface WsInstance {
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;
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;
initClient: ({ options }: WsInterface) => WebSocket;
initServer: ({ options }: WsInterface) => WebSocketServer;
}

View File

@ -2,21 +2,20 @@ import { AddressInstance } from './bitcoin/addresses';
import { BlockInstance } from './bitcoin/blocks';
import { DifficultyInstance } from './bitcoin/difficulty';
import { FeeInstance } from './bitcoin/fees';
import { LightningInstance } from './bitcoin/lightning';
import { MempoolInstance } from './bitcoin/mempool';
import { TxInstance } from './bitcoin/transactions';
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 { BlockLiquidInstance } from './liquid/blocks';
import { TxLiquidInstance } from './liquid/transactions';
import { WsLiquidInstance } from './liquid/websockets';
import { AxiosRequestConfig } from 'axios';
import { BlockLiquidInstance } from './liquid/block';
export interface MempoolConfig {
protocol?: 'http' | 'https';
hostname?: string;
network?: string;
config?: AxiosRequestConfig;
}
export interface MempoolReturn {
@ -25,18 +24,23 @@ export interface MempoolReturn {
blocks: BlockInstance;
difficulty: DifficultyInstance;
fees: FeeInstance;
lightning: LightningInstance
mempool: MempoolInstance;
transactions: TxInstance;
websocket: WsInstance;
};
bisq: {
addresses: AddressesInstance;
blocks: BlocksInstance;
statistics: StatsInstance;
transactions: TransactionsInstance;
};
liquid: {
assets: AssetsInstance;
addresses: AddressInstance;
blocks: BlockLiquidInstance;
fees: FeeInstance;
mempool: MempoolInstance;
transactions: TxLiquidInstance;
websocket: WsLiquidInstance;
transactions: TxInstance;
websocket: WsInstance;
};
}

View File

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

View File

@ -14,7 +14,6 @@ export interface Block {
nonce: number;
bits: number;
difficulty: number;
extras: any;
}
export interface BlockStatus {
@ -25,7 +24,7 @@ export interface BlockStatus {
export interface BlockLiquidInstance {
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>;
getBlockTxs: (params: { hash: string; start_index?: number }) => Promise<Tx>;
getBlockTxids: (params: { hash: string }) => Promise<string[]>;

View File

@ -1,61 +0,0 @@
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

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

25
src/services/ws/client.ts Normal file
View File

@ -0,0 +1,25 @@
const serverWS = (
options: string[],
endpoint: string,
): WebSocket => {
const ws = new WebSocket(endpoint);
ws.addEventListener("open", function open() {
ws.send(JSON.stringify({ action: "want", data: options }));
});
ws.addEventListener("close", async function close() {
await sleep(60000);
serverWS(options, endpoint);
});
return ws;
}
const sleep = (ms: number) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
export default serverWS;

31
src/services/ws/server.ts Normal file
View File

@ -0,0 +1,31 @@
import WebSocket from 'ws';
const serverWS = (
options: string[],
endpoint: string,
): WebSocket => {
const ws = new WebSocket(endpoint);
const interval = setInterval(function ping() {
ws.ping();
}, 30000);
ws.on("open", function open() {
ws.send(JSON.stringify({ action: "want", data: options }));
});
ws.on("close", async function close() {
clearInterval(interval);
ws.terminate();
await sleep(60000);
serverWS(options, endpoint);
});
return ws;
}
const sleep = (ms: number) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
export default serverWS;

View File

@ -1,88 +0,0 @@
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

@ -1,90 +0,0 @@
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 });
}

6463
yarn.lock

File diff suppressed because it is too large Load Diff