Compare commits

...

41 Commits

Author SHA1 Message Date
mononaut
a27b4a61e8
Merge pull request #206 from mempool/mononaut/testnet4
add testnet4 support
2025-11-14 15:54:54 +08:00
mononaut
188225ee9b
Merge pull request #205 from mempool/mononaut/upgrade-dependencies
upgrade dependencies
2025-11-14 15:54:43 +08:00
Mononaut
cd518abb75
Add testnet4 2025-11-13 12:44:18 +00:00
Mononaut
b82210f9b2
upgrade dependencies 2025-11-13 12:31:12 +00:00
softsimon
e2668703b3
Merge pull request #202 from mempool/mononaut/v3-prerelease
v3.0.0
2024-12-02 11:21:48 +07:00
Mononaut
1d512794db
v3.0.0 2024-12-01 20:47:38 +00:00
Mononaut
42b8e3fb35
update dependencies 2024-12-01 20:47:12 +00:00
softsimon
d875bc250d
Merge pull request #180 from mempool/natsoni/fix-get-address-txs-endpoint
Add optional after_txid param to getAddressTxs method
2024-03-06 21:58:52 +07:00
softsimon
8bd8634993
Merge pull request #179 from mempool/natsoni/bump-axios
Bump axios dependency version 0.24 -> 1.6.7
2024-03-06 21:58:14 +07:00
natsoni
9d9057c689
Add optional after_txid param to getAddressTxs method 2024-03-05 12:27:40 +01:00
natsoni
676a496524
Fix bundle build by adding esmify devDep 2024-03-05 11:58:32 +01:00
natsoni
157de89446
Bump axios dependency version 2024-03-05 11:28:58 +01:00
natsoni
4faf304445
Fix hostname in websocket example 2024-03-05 11:11:22 +01:00
softsimon
14ddd97e83
Merge pull request #174 from mempool/natsoni/websocket-re-implementation
Rewrite Websocket api
2024-03-05 15:45:20 +07:00
natsoni
4d9425ade3
Rewrite websocket api 2024-02-22 13:00:15 +01:00
natsoni
3b99ee2643
Fix Liquid API constructor 2024-02-21 16:05:03 +01:00
natsoni
fe36609d4f
Remove liquid merkle block proof endpoint 2024-02-20 17:10:52 +01:00
natsoni
3a05b7cd62
Merge pull request #170 from mempool/fix-http-req-opts
Add support for more http options (from @0xFlicker)
2024-02-20 16:12:43 +01:00
natsoni
944c5a81f3
Fix protocol detection 2024-02-20 15:43:07 +01:00
natsoni
bfb4a6dcc1
Merge branch 'main' into fix-http-req-opts and resolve conflicts 2024-02-20 15:28:52 +01:00
softsimon
3c7f94dbf7
Merge pull request #169 from mempool/natsoni/spring-cleaning
Mempool.js clean up
2024-02-20 21:01:11 +07:00
natsoni
241910e230
Fix paths in README files 2024-02-20 14:43:30 +01:00
natsoni
f04fbc1b0e
Fix random bugs and examples 2024-02-20 12:00:32 +01:00
natsoni
9ccd0ed416
Fix examples paths 2024-02-20 11:24:18 +01:00
natsoni
c12771a74c
Remove bisq support and include liquid api in main package 2024-02-20 11:20:00 +01:00
softsimon
cf2cd542c8
Merge pull request #166 from mempool/natsoni/add-endpoints
Add Lightning API endpoints and difficulty
2024-02-20 16:58:27 +07:00
flick
80373ba7fb
feat: adds support for more http options 2024-02-19 17:49:08 -07:00
natsoni
dd90188c68
Add Lightning api to doc 2024-02-18 19:28:50 +01:00
natsoni
d05e7e76e1
Merge pull request #167 from mempool/natsoni/blocks-endpoint-upgrade
Fix block type declaration and upgrade endpoint to v1
2024-02-18 18:23:06 +01:00
natsoni
ed9420c2ee
Fix block type declaration and upgrade endpoint to v1 2024-02-18 18:21:43 +01:00
natsoni
a55db5211a
Add types to hashrate endpoint 2024-02-18 17:48:28 +01:00
natsoni
11ce59a63b
Add lightning API endpoints 2024-02-18 17:40:23 +01:00
natsoni
167b8ace79
Add hashrate endpoint to bitcoin api 2024-02-18 13:22:48 +01:00
natsoni
e0cc5fd0a1
Merge pull request #165 from learntheropes/tx-push
fix bug on transaction push body
2024-02-18 12:48:59 +01:00
natsoni
9b01825d70
Fix postTx request in Liquid api 2024-02-18 12:47:28 +01:00
softsimon
6977129e5a
Merge pull request #164 from mempool/natsoni/fix-package-version
Fix package version to 2.3.0
2024-02-17 23:38:46 +08:00
natsoni
de07484358
Merge pull request #100 from bennyhodl/merkle-proof-interface
fix: return type of txMerkleProof
2024-02-16 17:34:09 +01:00
natsoni
76788dabc0
Fix bisq hostname typo 2024-02-16 15:36:14 +01:00
natsoni
81d870fc56
Fix package version to 2.3.0 2024-02-16 15:08:39 +01:00
bennyhodl
5087157a31 Return type of txMerkleProof - remove array 2023-06-28 18:38:43 -04:00
giovannilaperna
6efe22bb44
fix bug on transaction push body 2023-04-06 23:56:24 +02:00
120 changed files with 8770 additions and 10921 deletions

View File

@ -1,147 +0,0 @@
# mempool**JS** - Bisq API
Interface to access Bisq API.
[Back to home](./README.md)
---
## **Features**
- 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)
---
### **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`, `signet` APIs.
Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `signet` APIs.
[Back to home](./README.md)
@ -35,6 +35,22 @@ Interface to access Bitcoin `mainet`, `testnet`, `signet` APIs.
- 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)
@ -48,10 +64,24 @@ Interface to access Bitcoin `mainet`, `testnet`, `signet` APIs.
- [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)
- [Post Tx](#post-tx)
- Websocket
- [Websocket Client](#websocket-client)
- [Websocket Server](#websocket-server)
- [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)
---
@ -63,7 +93,7 @@ Returns details about an address. Available fields: `address`, `chain_stats`, an
- {string} address
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -84,7 +114,7 @@ Get transaction history for the specified address/scripthash, sorted with newest
- {string} address
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -105,7 +135,7 @@ Get confirmed transaction history for the specified address/scripthash, sorted w
- {string} address
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -126,7 +156,7 @@ Get unconfirmed transaction history for the specified `address/scripthash`. Retu
- {string} address
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
@ -147,7 +177,7 @@ Get the list of unspent transaction outputs associated with the `address/scripth
- {string} address
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const { addresses } = mempoolJS();
@ -420,6 +450,267 @@ 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.
@ -653,7 +944,7 @@ const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
```
### **Post Tx Outspends**
### **Post Tx **
Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success.
@ -674,75 +965,157 @@ const postTx = await transactions.postTx({ txhex });
console.log(postTx);
```
### **Websocket**
### **Init Websocket**
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats.
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.
Initializes a websocket connection.
[ [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 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.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
}
init();
const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
ws.addEventListener('message', function incoming({data}) {
console.log(JSON.parse(data.toString()));
});
```
#### **Websocket Client**
### **Want Data**
Only use on browser apps.
Subscribe to `want` data. Available: `blocks`, `mempool-block`, `live-2h-chart`, and `stats`.
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
```js
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.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
};
init();
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
```

View File

@ -43,14 +43,22 @@ Interface to access Liquid APIs.
- [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)
- [Post Tx](#post-tx)
- Websocket
- [Websocket Client](#websocket-client)
- [Websocket Server](#websocket-server)
- [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)
---
@ -163,7 +171,7 @@ Returns information about a Liquid asset.
- {string} asset_id
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
```js
const {
@ -186,7 +194,7 @@ Returns transactions associated with the specified Liquid asset. For the network
- {string} asset_id
- {boolean} is_mempool
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
```js
const {
@ -209,7 +217,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/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
```js
const {
@ -582,27 +590,6 @@ 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.
@ -670,7 +657,7 @@ const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
```
### **Post Tx Outspends**
### **Post Tx **
Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success.
@ -691,75 +678,117 @@ const postTx = await transactions.postTx({ txhex });
console.log(postTx);
```
### **Websocket**
### **Init Websocket**
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats.
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.
Initializes a websocket connection.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
#### **Websocket Server**
Only use on server side apps.
```js
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();
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 Client**
### **Want Data**
Only use on browser apps.
Subscribe to `want` data. Available: `blocks`, `mempool-block`, `live-2h-chart`, and `stats`.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
```js
const init = async () => {
const {
liquid: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
```
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();
```
### **Stop Want Data**
Unsubscribe from `want` data.
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/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/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
```

View File

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

View File

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/bisq.js"></script>
<script>
const init = async () => {
try {
const { addresses } = bisqJS();
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/bisq.js"></script>
<script>
const init = async () => {
try {
const { blocks } = bisqJS();
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);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,46 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/bisq.js"></script>
<script>
const init = async () => {
try {
const { markets } = bisqJS();
const market = "BTC_USD";
const basecurrency = "BTC";
const allMarkets = await markets.getMarkets();
console.log(allMarkets);
const currencies = await markets.getCurrencies();
console.log(currencies);
const depth = await markets.getDepth({ market });
console.log(depth)
const hloc = await markets.getHloc({ market });
console.log(hloc);
const offers = await markets.getOffers({ market });
console.log(offers);
const ticker = await markets.getTicker({ market });
console.log(ticker);
const trades = await markets.getTrades({ market });
console.log(trades);
const volumes = await markets.getVolumes({ basecurrency, market });
console.log(volumes);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/bisq.js"></script>
<script>
const init = async () => {
try {
const { statistics } = bisqJS();
const stats = await statistics.getStats();
console.log(stats);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,28 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/bisq.js"></script>
<script>
const init = async () => {
try {
const { transactions } = bisqJS();
const txid =
'4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
const tx = await transactions.getTx({ txid });
console.log(tx);
const txs = await transactions.getTxs({ index: 0, length: 1 });
console.log(txs);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {

View File

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

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
@ -42,7 +42,7 @@
const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
const postTx = await transactions.postTx({ txhex });
const postTx = await transactions.postTx({ txhex: txHex });
console.log(postTx);
} catch (error) {
console.log(error);

View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
bitcoin: { websocket },
} = mempoolJS();
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);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,37 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { addresses } = liquidJS();
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);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { assets } = liquidJS();
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);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,51 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { blocks } = liquidJS();
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);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,24 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { fees } = liquidJS();
const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended);
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { mempool } = liquidJS();
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);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,48 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { transactions } = liquidJS();
const txid =
'f4e0cae35f8eb239c1eee9177884582aa6e4ce41e919f276617e9c7557168b53';
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 txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid });
console.log(txMerkleBlockProof);
// const postTx = await transactions.postTx({ txhex });
// console.log(postTx);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,38 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/liquid.js"></script>
<script>
const init = async () => {
try {
const { websocket } = liquidJS();
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);
}
});
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -2,13 +2,13 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { addresses },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';

View File

@ -8,7 +8,7 @@
try {
const {
liquid: { assets },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const asset_id = 'a0c358a0f6947864af3a06f3f6a2aeb304df7fd95c922f2f22d7412399ce7691';

View File

@ -2,13 +2,13 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { blocks },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const hash =
'54f02bdec5509ea769c8be82aed51f689969b653d92a2812d5a36266cbfbc55e';

View File

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

View File

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

View File

@ -2,16 +2,16 @@
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { transactions },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const txid =
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
'064d1dff90cbb6fce81311f9804a737df9e3873bc4717ff6aae068fffab423ab';
const tx = await transactions.getTx({ txid });
console.log(tx);
@ -25,11 +25,6 @@
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);
@ -42,8 +37,8 @@
const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
// const postTx = await transactions.postTx({ txhex });
// console.log(postTx);
const postTx = await transactions.postTx({ txhex: txHex });
console.log(postTx);
} catch (error) {
console.log(error);
}

View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { websocket },
} = mempoolJS( { hostname: 'liquid.network' } );
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);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

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

View File

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
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);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

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

View File

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

View File

@ -1,40 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
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.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

@ -1,40 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { 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);
}
});
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

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

View File

@ -1,24 +0,0 @@
import bisqJS from "./../../../src/index-bisq";
const init = async () => {
try {
const { blocks } = bisqJS();
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);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,38 +0,0 @@
import bisqJS from "./../../../src/index-bisq";
const init = async () => {
try {
const { markets } = bisqJS();
const market = "BTC_USD";
const basecurrency = "BTC";
const allMarkets = await markets.getMarkets();
console.log(allMarkets);
const currencies = await markets.getCurrencies();
console.log(currencies);
const depth = await markets.getDepth({ market });
console.log(depth)
const hloc = await markets.getHloc({ market });
console.log(hloc);
const offers = await markets.getOffers({ market });
console.log(offers);
const ticker = await markets.getTicker({ market });
console.log(ticker);
const trades = await markets.getTrades({ market });
console.log(trades);
const volumes = await markets.getVolumes({ basecurrency, market });
console.log(volumes);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,13 +0,0 @@
import bisqJS from "./../../../src/index-bisq";
const init = async () => {
try {
const { statistics } = bisqJS();
const stats = await statistics.getStats();
console.log(stats);
} catch (error) {
console.log(error);
}
};
init();

View File

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

View File

@ -1,4 +1,4 @@
import mempoolJS from "./../../../../src/index";
import mempoolJS from "./../../../src/index";
const init = async () => {
try {

View File

@ -1,4 +1,4 @@
import mempoolJS from "./../../../../src/index";
import mempoolJS from "./../../../src/index";
const init = async () => {
try {

View File

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

View File

@ -1,4 +1,4 @@
import mempoolJS from "./../../../../src/index";
import mempoolJS from "./../../../src/index";
const init = async () => {
try {
@ -12,7 +12,7 @@ const init = async () => {
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks);
const txid = 'txid';
const txid = '94bb221746f0626caf63c8dd279e07963bfe514fabe596019c95a41c5f5af97c';
const feesCPFP = await fees.getCPFP({ txid });
console.log(feesCPFP);

View File

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

View File

@ -3,7 +3,7 @@ import mempoolJS from "./../../../src/index";
const init = async () => {
try {
const {
liquid: { mempool },
bitcoin: { mempool },
} = mempoolJS();
const getMempool = await mempool.getMempool();

View File

@ -3,7 +3,7 @@ import mempoolJS from "./../../../src/index";
const init = async () => {
try {
const {
liquid: { transactions },
bitcoin: { transactions },
} = mempoolJS();
const txid =

View File

@ -0,0 +1,45 @@
import mempoolJS from "./../../../src/index";
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);
}
}
init();

View File

@ -1,45 +0,0 @@
import mempoolJS from "./../../../src/index";
const init = async () => {
try {
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);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,30 +0,0 @@
import mempoolJS from "./../../../src/index";
const { liquid: { websocket } } = mempoolJS();
const init = async () => {
try {
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);
}
});
} catch (error) {
console.log(error);
}
}
init();

View File

@ -4,7 +4,7 @@ const init = async () => {
try {
const {
liquid: { addresses },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';

View File

@ -4,7 +4,7 @@ const init = async () => {
try {
const {
liquid: { assets },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const asset_id =
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';

View File

@ -1,13 +1,13 @@
import mempoolJS from "./../../../../src/index";
import mempoolJS from "./../../../src/index";
const init = async () => {
try {
const {
liquid: { blocks },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const hash =
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
'5ec96b63f95aad27391a8a41f1dce2161d48c4f26aeb1f72695a12c98a005e1f';
const block = await blocks.getBlock({ hash });
console.log(block);
@ -21,7 +21,7 @@ const init = async () => {
const blockTxids = await blocks.getBlockTxids({ hash });
console.log(blockTxids);
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
const blockTxid = await blocks.getBlockTxid({ hash, index: 1 });
console.log(blockTxid);
const blockRaw = await blocks.getBlockRaw({ hash });

View File

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

View File

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

View File

@ -1,13 +1,13 @@
import mempoolJS from "./../../../../src/index";
import mempoolJS from "./../../../src/index";
const init = async () => {
try {
const {
liquid: { transactions },
} = mempoolJS();
} = mempoolJS( { hostname: 'liquid.network' } );
const txid =
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
'555fbc3ca784903b238fdadc92515577dfa9124185259c5d9a773508bbc365e5';
const tx = await transactions.getTx({ txid });
console.log(tx);
@ -20,10 +20,7 @@ const init = async () => {
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);
@ -36,8 +33,8 @@ const init = async () => {
const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
// const postTx = await transactions.postTx({ txhex });
// console.log(postTx);
const postTx = await transactions.postTx({ txhex: txHex });
console.log(postTx);
} catch (error) {
console.log(error);
}

View File

@ -0,0 +1,38 @@
import mempoolJS from "./../../../src/index";
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);
}
}
init();

View File

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

View File

@ -1,27 +0,0 @@
import mempoolJS from "./../../../../src/index";
const init = async () => {
try {
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);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,40 +0,0 @@
import mempoolJS from "./../../../../src/index";
const init = async () => {
try {
const {
bisq: { markets },
} = mempoolJS();
const market = "BTC_USD";
const basecurrency = "BTC";
const allMarkets = await markets.getMarkets();
console.log(allMarkets);
const currencies = await markets.getCurrencies();
console.log(currencies);
const depth = await markets.getDepth({ market });
console.log(depth)
const hloc = await markets.getHloc({ market });
console.log(hloc);
const offers = await markets.getOffers({ market });
console.log(offers);
const ticker = await markets.getTicker({ market });
console.log(ticker);
const trades = await markets.getTrades({ market });
console.log(trades);
const volumes = await markets.getVolumes({ basecurrency, market });
console.log(volumes);
} catch (error) {
console.log(error);
}
};
init();

View File

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

View File

@ -1,21 +0,0 @@
import mempoolJS from "./../../../../src/index";
const init = async () => {
try {
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);
} catch (error) {
console.log(error);
}
};
init();

View File

@ -1,21 +0,0 @@
import mempoolJS from "./../../../../src/index";
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);
}
};
init();

View File

@ -1,45 +0,0 @@
import mempoolJS from "./../../../../src/index";
const init = async () => {
try {
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);
}
};
init();

View File

@ -1,30 +0,0 @@
import mempoolJS from "./../../../../src/index";
const { bitcoin: { websocket } } = mempoolJS();
const init = async () => {
try {
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);
}
});
} catch (error) {
console.log(error);
}
}
init();

View File

@ -1,29 +0,0 @@
import mempoolJS from "./../../../../src/index";
const init = async () => {
try {
const {
liquid: { addresses },
} = mempoolJS();
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);
}
};
init();

View File

@ -1,24 +0,0 @@
import mempoolJS from "./../../../../src/index";
const init = async () => {
try {
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);
}
};
init();

View File

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

View File

@ -1,30 +0,0 @@
import mempoolJS from "./../../../../src/index";
const { liquid: { websocket } } = mempoolJS();
const init = async () => {
try {
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);
}
});
} catch (error) {
console.log(error);
}
}
init();

View File

@ -1,6 +0,0 @@
/node_modules
/lib
/dist/*
!.gitkeep
yarn-error.log

View File

@ -1,265 +0,0 @@
# Bisq**JS** - Features
Interface to access the Bisq API.
[Back to home](./README.md)
---
## **Features**
- Addresses
- [Get Address](#get-address)
- Blocks
- [Get Block](#get-block)
- [Get Blocks](#get-blocks)
- [Get Block Tip Height](#get-block-tip-height)
- Markets
- [Get Currencies](#get-currencies)
- [Get Depth](#get-depth)
- [Get HLOC](#get-hloc)
- [Get Markets](#get-markets)
- [Get Offers](#get-offers)
- [Get Ticker](#get-ticker)
- [Get Trades](#get-trades)
- [Get Volumes](#get-volumes)
- Statistics
- [Get Statistics](#get-statistics)
- Transactions
- [Get Transaction](#get-transaction)
- [Get Transactions](#get-transactions)
---
### **Get Address**
Returns statistics about all Bisq transactions.
[ [NodeJS Example](../examples/nodejs/bisq-js/addresses.ts) ] [ [HTML Example](../examples/html/bisq-js/addresses.html) ] [ [Top](#features) ]
```js
const { addresses } = bisqJS();
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-js/blocks.ts) ] [ [HTML Example](../examples/html/bisq-js/blocks.html) ] [ [Top](#features) ]
```js
const { blocks } = bisqJS();
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-js/blocks.ts) ] [ [HTML Example](../examples/html/bisq-js/blocks.html) ] [ [Top](#features) ]
```js
const { blocks } = bisqJS();
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-js/blocks.ts) ] [ [HTML Example](../examples/html/bisq-js/blocks.html) ] [ [Top](#features) ]
```js
const { blocks } = bisqJS();
const myBlocksHeight = await blocks.getBlocksTipHeight({
index: 0,
length: 1,
});
console.log(myBlocksHeight);
```
### **Get Market Currencies**
Returns the Bisq market currencies.
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const currencies = await markets.getCurrencies();
console.log(currencies);
```
### **Get Market Depth**
Returns the Bisq market depth.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const depth = await markets.getDepth({ market });
console.log(depth)
```
### **Get Market HLOC**
Returns the Bisq market Hloc.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const hloc = await markets.getHloc({ market });
console.log(hloc);
```
### **Get Market Offers**
Returns the Bisq market Offers.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const offers = await markets.getOffers({ market });
console.log(offers);
```
### **Get Market Ticker**
Returns the Bisq market Ticker.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const ticker = await markets.getTicker({ market });
console.log(ticker);
```
### **Get Market Trades**
Returns the Bisq market Trades.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const trades = await markets.getTrades({ market });
console.log(trades);
```
### **Get Market Volumes**
Returns the Bisq market Volumes.
**Parameters:**
- {string} market
[ [NodeJS Example](../examples/nodejs/bisq-js/markets.ts) ] [ [HTML Example](../examples/html/bisq-js/markets.html) ] [ [Top](#features) ]
```js
const { markets } = bisqJS();
const market = "BTC_USD";
const basecurrency = "BTC";
const volumes = await markets.getVolumes({ basecurrency, market });
console.log(volumes);
```
### **Get Stats**
Returns statistics about all Bisq transactions.
[ [NodeJS Example](../examples/nodejs/bisq-js/statistics.ts) ] [ [HTML Example](../examples/html/bisq-js/statistics.html) ] [ [Top](#features) ]
```js
const { statistics } = bisqJS();
const stats = await statistics.getStats();
console.log(stats);
```
### **Get Transaction**
Returns details about a Bisq transaction.
[ [NodeJS Example](../examples/nodejs/bisq-js/transactions.ts) ] [ [HTML Example](../examples/html/bisq-js/transactions.html) ] [ [Top](#features) ]
```js
const { transactions } = bisqJS();
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-js/transactions.ts) ] [ [HTML Example](../examples/html/bisq-js/transactions.html) ] [ [Top](#features) ]
```js
const { transactions } = bisqJS();
const txs = await transactions.getTxs({ index: 0, length: 1 });
console.log(txs);
```

View File

@ -1,67 +0,0 @@
# Bisq**JS** API
[![npm version](https://img.shields.io/npm/v/@mempool/bisq.js.svg?style=flat-square)](https://www.npmjs.org/package/@mempool/bisq.js)
[![NPM](https://img.shields.io/david/mempool/bisq.js.svg?style=flat-square)](https://david-dm.org/mempool/bisq.js#info=dependencies)
[![Known Vulnerabilities](https://snyk.io/test/github/mempool/bisq.js/badge.svg?style=flat-square)](https://snyk.io/test/github/mempool/bisq.js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
NPM package module for Bisq APIs.
Documentation: [https://bisq.markets/api](https://bisq.markets/api)
## **Installation**
### **ES Modules**
Install the npm module.
```bash
# npm
$ npm install @mempool/bisq.js --save
# yarn
$ yarn add @mempool/bisq.js
```
Or if you're not into package management, just [download a ZIP](https://github.com/mempool/mempool.js/archive/refs/heads/main.zip) file.
Import the module.
```js
import bisqJS from '@mempool/bisq.js';
const bisq = bisqJS();
```
### **CommonJS**
Include the line below in the `head` tag of your html file.
```html
<script type="text/javascript" src="https://bisq.markets/bisq.js"></script>
```
Call `bisqJS()` function to access the API methods.
```js
const bisq = bisqJS();
```
---
## **Features**
- [Addresses](./README-bisq.md#get-address)
- [Blocks](./README-bisq.md#get-blocks)
- [Markets](./README-bisq.md#get-markets)
- [Statistics](./README-bisq.md#get-statistics)
- [Transactions](./README-bisq.md#get-transactions)
---
## **Contributing**
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
---
## **License** [MIT](https://choosealicense.com/licenses/mit/)

View File

@ -1,57 +0,0 @@
{
"name": "@mempool/bisq.js",
"version": "2.2.1",
"description": "NPM package module for Bisq APIs.",
"main": "../lib/index-bisq.js",
"keywords": [
"axios",
"bitcoin",
"bisq",
"blockchain",
"html",
"bisq.js",
"mempool.space",
"mempool.js",
"mempool",
"websocket",
"nodejs",
"typescript"
],
"author": "Miguel Medeiros <contact@miguelmedeiros.com.br> (miguelmedeiros.com.br)",
"url": "https://bisq.markets/",
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/mempool/mempool.js.git"
},
"types": "../lib/index-bisq.d.ts",
"scripts": {
"start": "ts-node ../src/index-bisq.ts",
"dev": "nodemon ../src/index-bisq.ts",
"build": "tsc",
"export-js": "tsc | browserify ../lib/index-bisq.js --standalone bisqJS > ../dist/bisq.js | browserify -p tinyify ../lib/index-bisq.js --standalone bisqJS > ../dist/bisq.min.js",
"prepare": "npm run build",
"postversion": "git push && git push --tags"
},
"files": [
"../lib/**/*"
],
"dependencies": {
"axios": "^0.21.1",
"ws": "^7.4.3"
},
"devDependencies": {
"@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"
}

View File

@ -1,6 +0,0 @@
/node_modules
/lib
/dist/*
!.gitkeep
yarn-error.log

View File

@ -1,763 +0,0 @@
# Liquid**JS** - Liquid API
Interface to access Liquid APIs.
[Back to home](./README.md)
---
## **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 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)
---
### **Get Address**
Returns details about an address. Available fields: `address`, `chain_stats`, and `mempool_stats`. `{chain,mempool}\_stats` each contain an object with `tx_count`, `funded_txo_count`, `funded_txo_sum`, `spent_txo_count`, and `spent_txo_sum`.
**Parameters:**
- {string} address
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const myAddress = await addresses.getAddress({ address });
console.log(myAddress);
```
### **Get Address Txs**
Get transaction history for the specified address/scripthash, sorted with newest first. Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using `:last_seen_txid`.
**Parameters:**
- {string} address
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const addressTxs = await addresses.getAddressTxs({ address });
console.log(addressTxs);
```
### **Get Address Txs Chain**
Get confirmed transaction history for the specified address/scripthash, sorted with newest first. Returns 25 transactions per page. More can be requested by specifying the last txid seen by the previous query.
**Parameters:**
- {string} address
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const addressTxsChain = await addresses.getAddressTxsChain({ address });
console.log(addressTxsChain);
```
### **Get Address Txs Mempool**
Get unconfirmed transaction history for the specified `address/scripthash`. Returns up to 50 transactions (no paging).
**Parameters:**
- {string} address
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { addresses },
} = mempoolJS();
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
console.log(addressTxsMempool);
```
### **Get Address Txs Utxo**
Get the list of unspent transaction outputs associated with the `address/scripthash`. Available fields: `txid`, `vout`, `value`, and `status` (with the status of the funding tx).
**Parameters:**
- {string} address
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const { addresses } = mempoolJS();
const addressTxsUtxo = await addresses.getAddressTxsUtxo('15e10745f15593a...');
console.log(addressTxsUtxo);
```
### **Get Asset**
Returns information about a Liquid asset.
**Parameters:**
- {string} asset_id
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { assets },
} = mempoolJS();
const asset_id =
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
const asset = await assets.getAsset({ asset_id });
console.log(asset);
```
### **Get Asset Txs**
Returns transactions associated with the specified Liquid asset. For the network's native asset, returns a list of peg in, peg out, and burn transactions. For user-issued assets, returns a list of issuance, reissuance, and burn transactions. Does not include regular transactions transferring this asset.
**Parameters:**
- {string} asset_id
- {boolean} is_mempool
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { assets },
} = mempoolJS();
const asset_id =
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
const assetTxs = await assets.getAssetTxs({ asset_id, is_mempool: false });
console.log(assetTxs);
```
### **Get Asset Supply**
Get the current total supply of the specified asset. For the native asset (L-BTC), this is calculated as `[chain,mempool]\_stats.peg_in_amount` - `[chain,mempool]\_stats.peg_out_amount` - `[chain,mempool]\_stats.burned_amount`. For issued assets, this is calculated as `[chain,mempool]\_stats.issued_amount` - `[chain,mempool]\_stats.burned_amount`. Not available for assets with blinded issuances. If `/decimal` is specified, returns the supply as a decimal according to the asset's divisibility. Otherwise, returned in base units.
**Parameters:**
- {string} asset_id
- {boolean} decimal
[ [NodeJS Example](../examples/nodejs/liquid-js/addresses.ts) ] [ [HTML Example](../examples/html/liquid-js/addresses.html) ] [ [Top](#features) ]
```js
const {
liquid: { assets },
} = mempoolJS();
const asset_id =
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
const assetSupply = await assets.getAssetSupply({ asset_id, decimal: false });
console.log(assetSupply);
```
### **Get Block**
Returns details about a block. Available fields: `id`, `height`, `version`, `timestamp`, `bits`, `nonce`, `merkle_root`, `tx_count`, `size`, `weight`, and `previousblockhash`.
**Parameters:**
- {string} hash
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const block = await blocks.getBlock({ hash });
console.log(block);
```
### **Get Block Status**
Returns the confirmation status of a block. Available fields: `in_best_chain` (boolean, false for orphaned blocks), `next_best` (the hash of the next block, only available for blocks in the best chain).
**Parameters:**
- {string} hash
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const blockStatus = await blocks.getBlockStatus({ hash });
console.log(blockStatus);
```
### **Get Block Txs**
Returns a list of transactions in the block (up to 25 transactions beginning at start_index). Transactions returned here do not have the status field, since all the transactions share the same block and confirmation status.
**Parameters:**
- {string} hash
- {number} start_index
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const blockTxs = await blocks.getBlockTxs({ hash });
console.log(blockTxs);
```
### **Get Block Txids**
Returns a list of all txids in the block.
**Parameters:**
- {string} hash
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const blockTxids = await blocks.getBlockTxids({ hash });
console.log(blockTxids);
```
### **Get Block Txid**
Returns the transaction at index :index within the specified block.
**Parameters:**
- {string} hash
- {number} index
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
console.log(blockTxid);
```
### **Get Block Raw**
Returns the raw block representation in binary.
**Parameters:**
- {string} hash
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw);
```
### **Get Blocks Height**
Returns the hash of the block currently at `:height`.
**Parameters:**
- {number} height
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const blockHeight = await blocks.getBlockHeight({ height: 0 });
console.log(blockHeight);
```
### **Get Blocks**
Returns the 10 newest blocks starting at the tip or at `:start_height` if specified.
**Parameters:**
- {number} start_height
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
console.log(getBlocks);
```
### **Get Blocks Tip Height**
Returns the 10 newest blocks starting at the tip or at `:start_height` if specified.
**Parameters:**
- {number} start_height
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const blocksTipHeight = await blocks.getBlocksTipHeight();
console.log(blocksTipHeight);
```
### **Get Blocks Tip Hash**
Returns the hash of the last block.
[ [NodeJS Example](../examples/nodejs/liquid-js/blocks.ts) ] [ [HTML Example](../examples/html/liquid-js/blocks.html) ] [ [Top](#features) ]
```js
const {
liquid: { blocks },
} = mempoolJS();
const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash);
```
### **Get Fees Recommended**
Returns our currently suggested fees for new transactions.
[ [NodeJS Example](../examples/nodejs/liquid-js/fees.ts) ] [ [HTML Example](../examples/html/liquid-js/fees.html) ] [ [Top](#features) ]
```js
const {
liquid: { fees },
} = mempoolJS();
const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended);
```
### **Get Fees Mempool Blocks**
Returns current mempool as projected blocks.
[ [NodeJS Example](../examples/nodejs/liquid-js/fees.ts) ] [ [HTML Example](../examples/html/liquid-js/fees.html) ] [ [Top](#features) ]
```js
const {
liquid: { fees },
} = mempoolJS();
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks);
```
### **Get Mempool**
Returns current mempool backlog statistics.
[ [NodeJS Example](../examples/nodejs/liquid-js/mempool.ts) ] [ [HTML Example](../examples/html/liquid-js/mempool.html) ] [ [Top](#features) ]
```js
const {
liquid: { mempool },
} = mempoolJS();
const getMempool = await mempool.getMempool();
console.log(getMempool);
```
### **Get Mempool Recent**
Get a list of the last 10 transactions to enter the mempool. Each transaction object contains simplified overview data, with the following fields: `txid`, `fee`, `vsize`, and `value`.
[ [NodeJS Example](../examples/nodejs/liquid-js/mempool.ts) ] [ [HTML Example](../examples/html/liquid-js/mempool.html) ] [ [Top](#features) ]
```js
const {
liquid: { mempool },
} = mempoolJS();
const getMempoolRecent = await mempool.getMempoolRecent();
console.log(getMempoolRecent);
```
### **Get Mempool Txids**
Get the full list of txids in the mempool as an array. The order of the `txids` is arbitrary and does not match bitcoind.
[ [NodeJS Example](../examples/nodejs/liquid-js/mempool.ts) ] [ [HTML Example](../examples/html/liquid-js/mempool.html) ] [ [Top](#features) ]
```js
const {
liquid: { mempool },
} = mempoolJS();
const getMempoolTxids = await mempool.getMempoolTxids();
console.log(getMempoolTxids);
```
### **Get Tx**
Returns details about a transaction. Available fields: `txid`, `version`, `locktime`, `size`, `weight`, `fee`, `vin`, `vout`, and `status`.
**Parameters:**
- {string} txid
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const tx = await transactions.getTx({ txid });
console.log(tx);
```
### **Get Tx Status**
Returns the confirmation status of a transaction. Available fields: `confirmed` (boolean), `block_height` (optional), and `block_hash` (optional).
**Parameters:**
- {string} txid
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txStatus = await transactions.getTxStatus({ txid });
console.log(txStatus);
```
### **Get Tx Hex**
Returns a transaction serialized as hex.
**Parameters:**
- {string} txid
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txHex = await transactions.getTxHex({ txid });
console.log(txHex);
```
### **Get Tx Raw**
Returns a transaction as binary data.
**Parameters:**
- {string} txid
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
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-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/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.
**Parameters:**
- {string} txid
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txMerkleProof = await transactions.getTxMerkleProof({ txid });
console.log(txMerkleProof);
```
### **Get Tx Outspend**
Returns the spending status of a transaction output. Available fields: `spent` (boolean), `txid` (optional), `vin` (optional), and `status` (optional, the status of the spending tx).
**Parameters:**
- {string} txid
- {number} vout
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txOutspend = await transactions.getTxOutspend({
txid,
vout: 3,
});
console.log(txOutspend);
```
### **Get Tx Outspends**
Returns the spending status of all transaction outputs.
**Parameters:**
- {string} txid
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const txOutspends = await transactions.getTxOutspends({ txid });
console.log(txOutspends);
```
### **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
[ [NodeJS Example](../examples/nodejs/liquid-js/transactions.ts) ] [ [HTML Example](../examples/html/liquid-js/transactions.html) ] [ [Top](#features) ]
```js
const {
liquid: { transactions },
} = mempoolJS();
const txhex = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
const postTx = await transactions.postTx({ txhex });
console.log(postTx);
```
### **Websocket**
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-js/websocket.ts) ] [ [HTML Example](../examples/html/liquid-js/websocket.html) ] [ [Top](#features) ]
#### **Websocket Server**
Only use on server side apps.
```js
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();
```
#### **Websocket Client**
Only use on browser apps.
```js
const init = async () => {
const {
liquid: { 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,70 +0,0 @@
# Liquid**JS** API
[![npm version](https://img.shields.io/npm/v/@mempool/liquid.js.svg?style=flat-square)](https://www.npmjs.org/package/@mempool/liquid.js)
[![NPM](https://img.shields.io/david/mempool/liquid.js.svg?style=flat-square)](https://david-dm.org/mempool/liquid.js#info=dependencies)
[![Known Vulnerabilities](https://snyk.io/test/github/mempool/liquid.js/badge.svg?style=flat-square)](https://snyk.io/test/github/mempool/liquid.js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
NPM package module for Liquid Network APIs.
Documentation: [https://liquid.network/api](https://liquid.network/api)
## **Installation**
### **ES Modules**
Install the npm module.
```bash
# npm
$ npm install @mempool/liquid.js --save
# yarn
$ yarn add @mempool/liquid.js
```
Or if you're not into package management, just [download a ZIP](https://github.com/mempool/mempool.js/archive/refs/heads/main.zip) file.
Import the module.
```js
import liquidJS from '@mempool/liquid.js';
const liquid = liquidJS();
```
### **CommonJS**
Include the line below in the `head` tag of your html file.
```html
<script type="text/javascript" src="https://liquid.network/liquid.js"></script>
```
Call `liquidJS()` function to access the API methods.
```js
const liquid = liquidJS();
```
---
## **Features**
- [Addresses](./README-liquid.md#get-address)
- [Assets](./README-liquid.md#get-address)
- [Blocks](./README-liquid.md#get-address)
- [Fees](./README-liquid.md#get-address)
- [Mempool](./README-liquid.md#get-address)
- [Transactions](./README-liquid.md#get-address)
- [Websocket Client](./README-liquid.md#Websocket-Client)
- [Websocket Server](./README-liquid.md#Websocket-Server)
---
## **Contributing**
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
---
## **License** [MIT](https://choosealicense.com/licenses/mit/)

View File

@ -1,56 +0,0 @@
{
"name": "@mempool/liquid.js",
"version": "2.2.1",
"description": "NPM package module for Liquid APIs.",
"main": "../lib/index-liquid.js",
"keywords": [
"axios",
"bitcoin",
"liquid",
"blockchain",
"html",
"mempool.space",
"mempool.js",
"mempool",
"websocket",
"nodejs",
"typescript"
],
"author": "Miguel Medeiros <contact@miguelmedeiros.com.br> (miguelmedeiros.com.br)",
"url": "https://liquid.network/",
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/mempool/mempool.js.git"
},
"types": "../lib/index-liquid.d.ts",
"scripts": {
"start": "ts-node ../src/index-liquid.ts",
"dev": "nodemon ../src/index-liquid.ts",
"build": "tsc",
"export-js": "tsc | browserify ../lib/index-liquid.js --standalone liquidJS > ../dist/liquid.js | browserify -p tinyify ../lib/index-liquid.js --standalone liquidJS > ../dist/liquid.min.js",
"prepare": "npm run build",
"postversion": "git push && git push --tags"
},
"files": [
"../lib/**/*"
],
"dependencies": {
"axios": "^0.21.1",
"ws": "^7.4.3"
},
"devDependencies": {
"@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"
}

7989
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": "2.3.0",
"version": "3.0.0",
"description": "NPM package module for Mempool APIs.",
"main": "lib/index.js",
"keywords": [
"axios",
"bitcoin",
"bisq",
"liquid",
"mainet",
"testnet",
"testnet4",
"signet",
"blockchain",
"html",
@ -32,9 +32,7 @@
"start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts",
"build": "tsc",
"export-mempool-js": "tsc | browserify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify lib/index.js --standalone mempoolJS > dist/mempool.min.js",
"export-bisq-js": "tsc | browserify lib/index-bisq.js --standalone bisqJS > dist/bisq.js | browserify -p tinyify lib/index-bisq.js --standalone bisqJS > dist/bisq.min.js",
"export-liquid-js": "tsc | browserify lib/index-liquid.js --standalone liquidJS > dist/liquid.js | browserify -p tinyify lib/index-liquid.js --standalone liquidJS > dist/liquid.min.js",
"export-mempool-js": "tsc | browserify -p esmify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify -p esmify lib/index.js --standalone mempoolJS > dist/mempool.min.js",
"prepare": "npm run build",
"postversion": "git push && git push --tags"
},
@ -42,21 +40,26 @@
"lib/**/*"
],
"dependencies": {
"axios": "0.24.0",
"ws": "8.3.0"
"axios": "1.13.2",
"ws": "^8.18.3"
},
"devDependencies": {
"@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"
"@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"
},
"license": "MIT"
}

View File

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

View File

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

View File

@ -1,137 +0,0 @@
import { AxiosInstance } from 'axios';
import { Currencies, Depth, Markets, Hloc, MarketsInstance, Offers, Trades, Volumes } from '../../interfaces/bisq/markets';
export const useMarkets = (api: AxiosInstance): MarketsInstance => {
const getCurrencies = async (
params: {
basecurrency?: string;
type?: string;
format?: string;
} = {
basecurrency: 'BTC',
type: 'all',
format: 'jsonpretty',
}
) => {
const { data } = await api.get<Currencies>('/currencies', { params });
return data;
};
const getDepth = async (
params: {
market: string;
format?: string;
} = {
market: 'xmr_btc',
format: 'jsonpretty',
}
) => {
const { data } = await api.get<Depth>('/depth', { params });
return data;
};
const getHloc = async (params: {
market: string;
interval?: string;
timestamp_from?: string;
timestamp_to?: string;
format?: string;
}) => {
const { data } = await api.get<Hloc[]>('/hloc', { params });
return data;
};
const getMarkets = async (
params: {
format?: string;
} = {
format: 'jsonpretty',
}
) => {
const { data } = await api.get<Markets>('/markets', { params });
return data;
};
const getOffers = async (
params: {
market: string;
direction?: string;
format?: string;
} = {
market: 'xmr_btc',
format: 'jsonpretty',
}
) => {
const { data } = await api.get<Offers>('/offers', { params });
return data;
};
const getTicker = async (
params: {
market?: string;
format?: string;
} = {
format: 'jsonpretty',
}
) => {
const { data } = await api.get('/ticker', { params });
return data;
};
const getTrades = async (
params: {
market: string;
format?: string;
timestamp_from?: string;
timestamp_to?: string;
trade_id_from?: string;
trade_id_to?: string;
limit?: number;
sort?: string;
} = {
market: 'all',
format: 'jsonpretty',
timestamp_from: '2016-01-01',
timestamp_to: 'now',
limit: 100,
sort: 'desc',
}
) => {
const { data } = await api.get<Trades[]>('/trades', { params });
return data;
};
const getVolumes = async (
params: {
basecurrency: string;
market: string;
interval?: string;
timestamp_from?: string;
timestamp_to?: string;
format?: string;
} = {
basecurrency: '',
market: '',
interval: 'auto',
timestamp_from: '2016-01-01',
timestamp_to: 'now',
format: 'jsonpretty',
}
) => {
const { data } = await api.get<Volumes[]>('/trades', { params });
return data;
};
return {
getCurrencies,
getDepth,
getHloc,
getMarkets,
getOffers,
getTicker,
getTrades,
getVolumes,
};
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,86 @@
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets';
import wsClient from '../../services/ws/client';
import wsServer from '../../services/ws/server';
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';
export const useWebsocket = (hostname: string, network: string): WsInstance => {
export const useWebsocket = (hostname: string, network: string, protocol: string | undefined): WsInstance => {
const wsEndpoint = `wss://${hostname}${network === 'main' ? '' : `/${network}`}/api/v1/ws`;
if (!protocol) {
hostname?.includes('localhost') ? protocol = 'ws' : protocol = 'wss';
} else if (protocol === 'http' || protocol === 'ws') {
protocol = 'ws';
} else {
protocol = 'wss';
}
if (network && ['testnet', 'testnet4', 'signet'].includes(network)) {
network = `/${network}`;
} else {
network = '';
}
const wsEndpoint = `${protocol}://${hostname}${network}/api/v1/ws`
return {
initClient: ({ options }: WsInterface) =>
wsClient(options, wsEndpoint),
initServer: ({ options }: WsInterface) =>
wsServer(options, wsEndpoint),
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),
};
};

View File

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

View File

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

View File

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

View File

@ -1,14 +1,69 @@
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets';
import wsClient from '../../services/ws/client';
import wsServer from '../../services/ws/server';
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';
export const useWebsocket = (hostname: string): WsInstance => {
export const useWebsocket = (hostname: string, network: string, protocol: string | undefined): WsLiquidInstance => {
const wsEndpoint = `wss://${hostname}/liquid/api/v1/ws`;
if (!protocol) {
hostname?.includes('localhost') ? protocol = 'ws' : protocol = 'wss';
} else if (protocol === 'http' || protocol === 'ws') {
protocol = 'ws';
} else {
protocol = 'wss';
}
if (network && ['testnet', 'liquidtestnet'].includes(network)) {
network = `/liquidtestnet`;
} else {
network = '/liquid';
}
const wsEndpoint = `${protocol}://${hostname}${network}/api/v1/ws`
return {
initClient: ({ options }: WsInterface) =>
wsClient(options, wsEndpoint),
initServer: ({ options }: WsInterface) =>
wsServer(options, wsEndpoint),
};
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), };
};

View File

@ -1,33 +0,0 @@
import { MempoolConfig, BisqMarketsReturn } from './interfaces/index';
import { makeBisqAPI, makeBisqMarketsAPI } from './services/api/index';
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 { useMarkets as useMarkets } from './app/bisq/markets';
const hostnameEndpointDefault = 'bisq.market';
const networkEndpointDefault = 'bisq';
const mempool = ({ hostname, network }: MempoolConfig = {
hostname: hostnameEndpointDefault,
network: networkEndpointDefault,
}): BisqMarketsReturn => {
if (!hostname) hostname = hostnameEndpointDefault;
if (!network) network = networkEndpointDefault;
const { api: apiBisq } = makeBisqAPI(hostname);
const { api: apiBisqMarkets } = makeBisqMarketsAPI();
return {
statistics: useStatisticsBisq(apiBisq),
addresses: useAddressesBisq(apiBisq),
blocks: useBlocksBisq(apiBisq),
transactions: useTransactionsBisq(apiBisq),
markets: useMarkets(apiBisqMarkets),
};
};
mempool.default = mempool;
export = mempool;

View File

@ -1,41 +0,0 @@
import { MempoolConfig, LiquidNetworkReturn } from './interfaces/index';
import {
makeLiquidAPI,
} from './services/api/index';
import { useAssets as useAssetsLiquid } from './app/liquid/assets';
import { useAddresses as useAddressesLiquid } from './app/liquid/addresses';
import { useBlocks as useBlocksLiquid } from './app/liquid/blocks';
import { useFees as useFeesLiquid } from './app/liquid/fees';
import { useMempool as useMempoolLiquid } from './app/liquid/mempool';
import { useTransactions as useTransactionsLiquid } from './app/liquid/transactions';
import { useWebsocket as useWebsocketLiquid } from './app/liquid/websocket';
const hostnameEndpointDefault = 'liquid.network';
const networkEndpointDefault = 'liquid';
const mempool = (
{
hostname, network }: MempoolConfig = {
hostname: hostnameEndpointDefault,
network: networkEndpointDefault,
}
): LiquidNetworkReturn => {
if (!hostname) hostname = hostnameEndpointDefault;
if (!network) network = networkEndpointDefault;
const { api: apiLiquid } = makeLiquidAPI(hostname);
return {
addresses: useAddressesLiquid(apiLiquid),
assets: useAssetsLiquid(apiLiquid),
blocks: useBlocksLiquid(apiLiquid),
fees: useFeesLiquid(apiLiquid),
mempool: useMempoolLiquid(apiLiquid),
transactions: useTransactionsLiquid(apiLiquid),
websocket: useWebsocketLiquid(hostname),
};
};
mempool.default = mempool;
export = mempool;

View File

@ -1,25 +1,15 @@
import { MempoolConfig, MempoolReturn } from './interfaces/index';
import {
makeBitcoinAPI,
makeBisqAPI,
makeLiquidAPI,
makeBisqMarketsAPI
} from './services/api/index';
import { makeBitcoinAPI, 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 { useMarkets as useMarkets } from './app/bisq/markets';
import { useAssets as useAssetsLiquid } from './app/liquid/assets';
import { useAddresses as useAddressesLiquid } from './app/liquid/addresses';
import { useBlocks as useBlocksLiquid } from './app/liquid/blocks';
@ -32,7 +22,7 @@ const hostnameEndpointDefault = 'mempool.space';
const networkEndpointDefault = 'main';
const mempool = (
{ hostname, network }: MempoolConfig = {
{ hostname, network, protocol, config }: MempoolConfig = {
hostname: hostnameEndpointDefault,
network: networkEndpointDefault,
}
@ -40,26 +30,28 @@ const mempool = (
if (!hostname) hostname = hostnameEndpointDefault;
if (!network) network = networkEndpointDefault;
const { api: apiBitcoin } = makeBitcoinAPI({ hostname, network });
const { api: apiBisq } = makeBisqAPI(hostname);
const { api: apiBisqMarkets } = makeBisqMarketsAPI();
const { api: apiLiquid } = makeLiquidAPI(hostname);
const { api: apiBitcoin } = makeBitcoinAPI({
hostname,
network,
protocol,
config,
});
const { api: apiLiquid } = makeLiquidAPI({
hostname,
network,
protocol,
config,
});
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),
},
bisq: {
statistics: useStatisticsBisq(apiBisq),
addresses: useAddressesBisq(apiBisq),
blocks: useBlocksBisq(apiBisq),
transactions: useTransactionsBisq(apiBisq),
markets: useMarkets(apiBisqMarkets),
websocket: useWebsocket(hostname, network, protocol),
},
liquid: {
addresses: useAddressesLiquid(apiLiquid),
@ -68,7 +60,7 @@ const mempool = (
fees: useFeesLiquid(apiLiquid),
mempool: useMempoolLiquid(apiLiquid),
transactions: useTransactionsLiquid(apiLiquid),
websocket: useWebsocketLiquid(hostname),
websocket: useWebsocketLiquid(hostname, network, protocol),
},
};
};

View File

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

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