Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dec588a0e |
147
README-bisq.md
Normal file
147
README-bisq.md
Normal file
@ -0,0 +1,147 @@
|
||||
# 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);
|
||||
```
|
||||
@ -1,6 +1,6 @@
|
||||
# mempool**JS** - Bitcoin API
|
||||
|
||||
Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `signet` APIs.
|
||||
Interface to access Bitcoin `mainet`, `testnet`, `signet` APIs.
|
||||
|
||||
[Back to home](./README.md)
|
||||
|
||||
@ -35,22 +35,6 @@ Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `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)
|
||||
@ -64,24 +48,10 @@ Interface to access Bitcoin `mainet`, `testnet`, `testnet4`, `signet` APIs.
|
||||
- [Get Tx Merkle Proof](#get-tx-merkle-proof)
|
||||
- [Get Tx Outspend](#get-tx-outspend)
|
||||
- [Get Tx Outspends](#get-tx-outspends)
|
||||
- [Post Tx](#post-tx)
|
||||
- [Post Tx Outspends]($post-tx-outspends)
|
||||
- Websocket
|
||||
- [Init Websocket](#init-websocket)
|
||||
- [Want Data](#want-data)
|
||||
- [Stop Want Data](#stop-want-data)
|
||||
- [Track Address](#track-address)
|
||||
- [Stop Track Address](#stop-track-address)
|
||||
- [Track Addresses](#track-addresses)
|
||||
- [Stop Track Addresses](#stop-track-addresses)
|
||||
- [Track Transaction](#track-transaction)
|
||||
- [Stop Track Transaction](#stop-track-transaction)
|
||||
- [Track Rbf Summary](#track-rbf-summary)
|
||||
- [Stop Track Rbf Summary](#stop-track-rbf-summary)
|
||||
- [Track Rbf](#track-rbf)
|
||||
- [Stop Track Rbf](#stop-track-rbf)
|
||||
- [Track Mempool Block](#track-mempool-block)
|
||||
- [Stop Track Mempool Block](#stop-track-mempool-block)
|
||||
|
||||
- [Websocket Client](#websocket-client)
|
||||
- [Websocket Server](#websocket-server)
|
||||
|
||||
---
|
||||
|
||||
@ -93,7 +63,7 @@ Returns details about an address. Available fields: `address`, `chain_stats`, an
|
||||
|
||||
- {string} address
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -114,7 +84,7 @@ Get transaction history for the specified address/scripthash, sorted with newest
|
||||
|
||||
- {string} address
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -135,7 +105,7 @@ Get confirmed transaction history for the specified address/scripthash, sorted w
|
||||
|
||||
- {string} address
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -156,7 +126,7 @@ Get unconfirmed transaction history for the specified `address/scripthash`. Retu
|
||||
|
||||
- {string} address
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -177,7 +147,7 @@ Get the list of unspent transaction outputs associated with the `address/scripth
|
||||
|
||||
- {string} address
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const { addresses } = mempoolJS();
|
||||
@ -450,267 +420,6 @@ const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
|
||||
console.log(feesMempoolBlocks);
|
||||
```
|
||||
|
||||
### **Get Network Stats**
|
||||
|
||||
Returns network-wide stats such as total number of channels and nodes, total capacity, and average/median fee figures.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const networkStats = await lightning.getNetworkStats();
|
||||
console.log(networkStats);
|
||||
```
|
||||
|
||||
### **Get Nodes In Country**
|
||||
|
||||
Returns a list of Lightning nodes running on clearnet in the requested `:country`, where `:country` is an ISO Alpha-2 country code.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} country
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const nodesInCountry = await lightning.getNodesInCountry({ country: 'US' });
|
||||
console.log(nodesInCountry);
|
||||
```
|
||||
|
||||
### **Get Nodes Stats Per Country**
|
||||
|
||||
Returns aggregate capacity and number of clearnet nodes per country. Capacity figures are in satoshis.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const nodesStatsPerCountry = await lightning.getNodesStatsPerCountry();
|
||||
console.log(nodesStatsPerCountry);
|
||||
```
|
||||
|
||||
### **Get Nodes Hosted by ISP**
|
||||
|
||||
Returns a list of nodes hosted by a specified `:isp`, where `:isp` is an ISP's ASN.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {number} isp
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const nodesHostedByISP = await lightning.getNodesHostedByISP({ isp: 16509 });
|
||||
console.log(nodesHostedByISP);
|
||||
```
|
||||
|
||||
### **Get ISP Ranking**
|
||||
|
||||
Returns aggregate capacity, number of nodes, and number of channels per ISP. Capacity figures are in satoshis.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const ispRanking = await lightning.getISPRanking();
|
||||
console.log(ispRanking);
|
||||
```
|
||||
|
||||
### **Get Liquidity Ranking**
|
||||
|
||||
Returns a list of the top 100 nodes by liquidity (aggregate channel capacity).
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const liquidityRanking = await lightning.getLiquidityRanking();
|
||||
console.log(liquidityRanking);
|
||||
```
|
||||
|
||||
### **Get Connectivity Ranking**
|
||||
|
||||
Returns a list of the top 100 nodes by connectivity (number of open channels).
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const connectivityRanking = await lightning.getConnectivityRanking();
|
||||
console.log(connectivityRanking);
|
||||
```
|
||||
|
||||
### **Get Oldest Nodes**
|
||||
|
||||
Returns a list of the top 100 oldest nodes.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const oldestNodes = await lightning.getOldestNodes();
|
||||
console.log(oldestNodes);
|
||||
```
|
||||
|
||||
### **Get Node Stats**
|
||||
|
||||
Returns details about a node with the given `:public_key`.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} public_key
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const nodeStats = await lightning.getNodeStats({ public_key });
|
||||
console.log(nodeStats);
|
||||
```
|
||||
|
||||
### **Get Historical Node Stats**
|
||||
|
||||
Returns historical stats for a node with the given `:public_key`.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} public_key
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const historicalNodeStats = await lightning.getHistoricalNodeStats({ public_key });
|
||||
console.log(historicalNodeStats);
|
||||
```
|
||||
|
||||
### **Get Channel**
|
||||
|
||||
Returns details about a channel with the given `:id`.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} id
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const channel = await lightning.getChannel({ id });
|
||||
console.log(channel);
|
||||
```
|
||||
|
||||
### **Get Channels From Transaction IDs**
|
||||
|
||||
Returns channels that correspond to the given `:txId` (multiple transaction IDs can be specified).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {[]string} txId
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const channelsFromTransactionIDs = await lightning.getChannelsFromTransactionIDs({ txId });
|
||||
console.log(channelsFromTransactionIDs);
|
||||
```
|
||||
|
||||
### **Get Channels From Node Public Key**
|
||||
|
||||
Returns a list of a node's channels given its `:public_key`. Ten channels are returned at a time. Use `:index` for paging. `:status` can be `open`, `active`, or `closed`.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} public_key
|
||||
- {string} status
|
||||
- {number} index
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const channelsFromNodePublicKey = await lightning.getChannelsFromNodePublicKey({ public_key, status, index });
|
||||
console.log(channelsFromNodePublicKey);
|
||||
```
|
||||
|
||||
### **Get Channels Geodata**
|
||||
|
||||
Returns a list of channels with corresponding node geodata.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const channelsGeodata = await lightning.getChannelsGeodata();
|
||||
console.log(channelsGeodata);
|
||||
```
|
||||
|
||||
### **Get Channels Geodata By Public Key**
|
||||
|
||||
Returns a list of channels with corresponding geodata for a node with the given `:public_key`.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} public_key
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/lightning.ts) ] [ [HTML Example](examples/html/bitcoin/lightning.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
bitcoin: { lightning },
|
||||
} = mempoolJS();
|
||||
|
||||
const channelsGeodataByPublicKey = await lightning.getChannelsGeodataByPublicKey({ public_key });
|
||||
console.log(channelsGeodataByPublicKey);
|
||||
```
|
||||
|
||||
|
||||
### **Get Children Pay for Parent**
|
||||
|
||||
Returns current mempool as projected blocks.
|
||||
@ -944,7 +653,7 @@ const txOutspends = await transactions.getTxOutspends({ txid });
|
||||
console.log(txOutspends);
|
||||
```
|
||||
|
||||
### **Post Tx **
|
||||
### **Post Tx Outspends**
|
||||
|
||||
Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success.
|
||||
|
||||
@ -965,157 +674,75 @@ const postTx = await transactions.postTx({ txhex });
|
||||
console.log(postTx);
|
||||
```
|
||||
|
||||
### **Init Websocket**
|
||||
### **Websocket**
|
||||
|
||||
Initializes a websocket connection.
|
||||
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats.
|
||||
|
||||
Push transactions related to address: `{ 'track-address': '3PbJ...bF9B' }` to receive all new transactions containing that address as input or output. Returns an array of transactions. address-transactions for new mempool transactions, and block-transactions for new block confirmed transactions.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
#### **Websocket Server**
|
||||
|
||||
Only use on server side apps.
|
||||
|
||||
```js
|
||||
const { bitcoin: { websocket } } = mempoolJS();
|
||||
const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
|
||||
ws.addEventListener('message', function incoming({data}) {
|
||||
console.log(JSON.parse(data.toString()));
|
||||
});
|
||||
|
||||
const init = async () => {
|
||||
|
||||
const ws = websocket.initServer({
|
||||
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
|
||||
});
|
||||
|
||||
ws.on("message", function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.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();
|
||||
```
|
||||
|
||||
### **Want Data**
|
||||
#### **Websocket Client**
|
||||
|
||||
Subscribe to `want` data. Available: `blocks`, `mempool-block`, `live-2h-chart`, and `stats`.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
Only use on browser apps.
|
||||
|
||||
```js
|
||||
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
|
||||
```
|
||||
|
||||
### **Stop Want Data**
|
||||
|
||||
Unsubscribe from `want` data.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopData(ws); // for in-browser websocket, use websocket.wsStopDataBrowser
|
||||
```
|
||||
|
||||
### **Track Address**
|
||||
|
||||
Subscribe to address updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackAddress(ws, '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'); // for in-browser websocket, use websocket.wsTrackAddressBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Address**
|
||||
|
||||
Unsubscribe from address updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingAddress(ws, '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC'); // for in-browser websocket, use websocket.wsStopTrackingAddressBrowser
|
||||
```
|
||||
|
||||
### **Track Addresses**
|
||||
|
||||
Subscribe to multiple address updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackAddresses(ws, ['1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC']); // for in-browser websocket, use websocket.wsTrackAddressesBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Addresses**
|
||||
|
||||
Unsubscribe from multiple address updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingAddresses(ws); // for in-browser websocket, use websocket.wsStopTrackingAddressesBrowser
|
||||
```
|
||||
|
||||
### **Track Transaction**
|
||||
|
||||
Subscribe to transaction updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackTransaction(ws, '01313ca0148a1bbe5676e5dd6a84e76f8b39038658bd8c333d3b2d3f7ea6dd08'); // for in-browser websocket, use websocket.wsTrackTransactionBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Transaction**
|
||||
|
||||
Unsubscribe from transaction updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingTransaction(ws); // for in-browser websocket, use websocket.wsStopTrackingTransactionBrowser
|
||||
```
|
||||
|
||||
### **Track Rbf Summary**
|
||||
|
||||
Subscribe to RBF summary updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackRbfSummary(ws); // for in-browser websocket, use websocket.wsTrackRbfSummaryBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Rbf Summary**
|
||||
|
||||
Unsubscribe from RBF summary updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingRbfSummary(ws); // for in-browser websocket, use websocket.wsStopTrackingRbfSummaryBrowser
|
||||
```
|
||||
|
||||
### **Track Rbf**
|
||||
|
||||
Subscribe to RBF updates. Set the second parameter to `true` to track Full RBF.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackRbf(ws, true); // for in-browser websocket, use websocket.wsTrackRbfBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Rbf**
|
||||
|
||||
Unsubscribe from RBF updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingRbf(ws); // for in-browser websocket, use websocket.wsStopTrackingRbfBrowser
|
||||
```
|
||||
|
||||
### **Track Mempool Block**
|
||||
|
||||
Subscribe to mempool blocks.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackMempoolBlock(ws, 1); // for in-browser websocket, use websocket.wsTrackMempoolBlockBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Mempool Block**
|
||||
|
||||
Unsubscribe from mempool blocks.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
|
||||
websocket.wsStopTrackingMempoolBlock(ws); // for in-browser websocket, use websocket.wsStopTrackingMempoolBlockBrowser
|
||||
const init = async () => {
|
||||
const {
|
||||
bitcoin: { websocket },
|
||||
} = mempoolJS();
|
||||
|
||||
const ws = websocket.initClient({
|
||||
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
|
||||
});
|
||||
|
||||
ws.addEventListener('message', function incoming({data}) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.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();
|
||||
```
|
||||
|
||||
205
README-liquid.md
205
README-liquid.md
@ -43,22 +43,14 @@ 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](#post-tx)
|
||||
- [Post Tx Outspends]($post-tx-outspends)
|
||||
- Websocket
|
||||
- [Init Websocket](#init-websocket)
|
||||
- [Want Data](#want-data)
|
||||
- [Stop Want Data](#stop-want-data)
|
||||
- [Track Address](#track-address)
|
||||
- [Stop Track Address](#stop-track-address)
|
||||
- [Track Addresses](#track-addresses)
|
||||
- [Stop Track Addresses](#stop-track-addresses)
|
||||
- [Track Transaction](#track-transaction)
|
||||
- [Stop Track Transaction](#stop-track-transaction)
|
||||
- [Track Mempool Block](#track-mempool-block)
|
||||
- [Stop Track Mempool Block](#stop-track-mempool-block)
|
||||
- [Websocket Client](#websocket-client)
|
||||
- [Websocket Server](#websocket-server)
|
||||
|
||||
---
|
||||
|
||||
@ -171,7 +163,7 @@ Returns information about a Liquid asset.
|
||||
|
||||
- {string} asset_id
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -194,7 +186,7 @@ Returns transactions associated with the specified Liquid asset. For the network
|
||||
- {string} asset_id
|
||||
- {boolean} is_mempool
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -217,7 +209,7 @@ Get the current total supply of the specified asset. For the native asset (L-BTC
|
||||
- {string} asset_id
|
||||
- {boolean} decimal
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/assets.ts) ] [ [HTML Example](examples/html/liquid/assets.html) ] [ [Top](#features) ]
|
||||
[ [NodeJS Example](examples/nodejs/liquid/addresses.ts) ] [ [HTML Example](examples/html/liquid/addresses.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
@ -590,6 +582,27 @@ const txRaw = await transactions.getTxRaw({ txid });
|
||||
console.log(txRaw);
|
||||
```
|
||||
|
||||
### **Get Tx Merkle Block Proof**
|
||||
|
||||
Returns a merkle inclusion proof for the transaction using bitcoind's merkleblock format.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- {string} txid
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/transactions.ts) ] [ [HTML Example](examples/html/liquid/transactions.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const {
|
||||
liquid: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid = '15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid });
|
||||
console.log(txMerkleBlockProof);
|
||||
```
|
||||
|
||||
### **Get Tx Merkle Proof**
|
||||
|
||||
Returns a merkle inclusion proof for the transaction using Electrum's blockchain.transaction.get_merkle format.
|
||||
@ -657,7 +670,7 @@ const txOutspends = await transactions.getTxOutspends({ txid });
|
||||
console.log(txOutspends);
|
||||
```
|
||||
|
||||
### **Post Tx **
|
||||
### **Post Tx Outspends**
|
||||
|
||||
Broadcast a raw transaction to the network. The transaction should be provided as hex in the request body. The `txid` will be returned on success.
|
||||
|
||||
@ -678,117 +691,75 @@ const postTx = await transactions.postTx({ txhex });
|
||||
console.log(postTx);
|
||||
```
|
||||
|
||||
### **Init Websocket**
|
||||
### **Websocket**
|
||||
|
||||
Initializes a websocket connection.
|
||||
Default push: `{ action: 'want', data: ['blocks', ...] }` to express what you want pushed. Available: blocks, mempool-block, live-2h-chart, and stats.
|
||||
|
||||
Push transactions related to address: `{ 'track-address': '3PbJ...bF9B' }` to receive all new transactions containing that address as input or output. Returns an array of transactions. address-transactions for new mempool transactions, and block-transactions for new block confirmed transactions.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
const { liquid: { websocket } } = mempoolJS( {hostname: 'liquid.network'} );
|
||||
const ws = websocket.wsInit(); // for in-browser websocket, use websocket.wsInitBrowser
|
||||
ws.addEventListener('message', function incoming({data}) {
|
||||
console.log(JSON.parse(data.toString()));
|
||||
});
|
||||
```
|
||||
#### **Websocket Server**
|
||||
|
||||
### **Want Data**
|
||||
|
||||
Subscribe to `want` data. Available: `blocks`, `mempool-block`, `live-2h-chart`, and `stats`.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
Only use on server side apps.
|
||||
|
||||
```js
|
||||
websocket.wsWantData(ws, ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']); // for in-browser websocket, use websocket.wsWantDataBrowser
|
||||
const { liquid: { websocket } } = mempoolJS();
|
||||
|
||||
const init = async () => {
|
||||
|
||||
const ws = websocket.initServer({
|
||||
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
|
||||
});
|
||||
|
||||
ws.on("message", function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
console.log(res.blocks);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
}
|
||||
if (res.transactions) {
|
||||
console.log(res.transactions);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
console.log(res.mempoolBlocks);
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
```
|
||||
|
||||
### **Stop Want Data**
|
||||
#### **Websocket Client**
|
||||
|
||||
Unsubscribe from `want` data.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
Only use on browser apps.
|
||||
|
||||
```js
|
||||
websocket.wsStopData(ws); // for in-browser websocket, use websocket.wsStopDataBrowser
|
||||
```
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { websocket },
|
||||
} = mempoolJS();
|
||||
|
||||
const ws = websocket.initClient({
|
||||
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
|
||||
});
|
||||
|
||||
### **Track Address**
|
||||
|
||||
Subscribe to address updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackAddress(ws, 'GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon'); // for in-browser websocket, use websocket.wsTrackAddressBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Address**
|
||||
|
||||
Unsubscribe from address updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingAddress(ws); // for in-browser websocket, use websocket.wsStopTrackingAddressBrowser
|
||||
```
|
||||
|
||||
### **Track Addresses**
|
||||
|
||||
Subscribe to multiple addresses updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackAddresses(ws, ['GiAi95k5JUPNPoDGNzSUZ8vWMijSiSMTon']); // for in-browser websocket, use websocket.wsTrackAddressesBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Addresses**
|
||||
|
||||
Unsubscribe from multiple addresses updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingAddresses(ws); // for in-browser websocket, use websocket.wsStopTrackingAddressesBrowser
|
||||
```
|
||||
|
||||
### **Track Transaction**
|
||||
|
||||
Subscribe to a transaction updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackTransaction(ws, '23195d459a70875c3b1f9fb9082acc9f0594f1c63dac71b40f2ff7298630a421'); // for in-browser websocket, use websocket.wsTrackTransactionBrowser()
|
||||
```
|
||||
|
||||
### **Stop Track Transaction**
|
||||
|
||||
Unsubscribe from a transaction updates.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsStopTrackingTransaction(ws); // for in-browser websocket, use websocket.wsStopTrackingTransactionBrowser
|
||||
```
|
||||
|
||||
### **Track Mempool Block**
|
||||
|
||||
Subscribe to mempool blocks.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
websocket.wsTrackMempoolBlock(ws, 1); // for in-browser websocket, use websocket.wsTrackMempoolBlockBrowser
|
||||
```
|
||||
|
||||
### **Stop Track Mempool Block**
|
||||
|
||||
Unsubscribe from mempool blocks.
|
||||
|
||||
[ [NodeJS Example](examples/nodejs/liquid/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
|
||||
|
||||
```js
|
||||
|
||||
websocket.wsStopTrackingMempoolBlock(ws); // for in-browser websocket, use websocket.wsStopTrackingMempoolBlockBrowser
|
||||
```
|
||||
ws.addEventListener('message', function incoming({data}) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
console.log(res.blocks);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
}
|
||||
if (res.transactions) {
|
||||
console.log(res.transactions);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
console.log(res.mempoolBlocks);
|
||||
}
|
||||
});
|
||||
};
|
||||
init();
|
||||
```
|
||||
49
README.md
49
README.md
@ -32,25 +32,13 @@ Import the module.
|
||||
```js
|
||||
import mempoolJS from '@mempool/mempool.js';
|
||||
|
||||
// default mempool.space endpointsconst { bitcoin, liquid } = mempoolJS();
|
||||
// default mempool.space endpoints
|
||||
const { bitcoin, bisq, liquid } = mempoolJS();
|
||||
|
||||
// (optional) your custom endpoints
|
||||
const { bitcoin } = mempoolJS({
|
||||
protocol: 'https', // optional, defaults to http for localhost, otherwise https
|
||||
hostname: 'mempool.space',
|
||||
network: 'testnet4' // 'signet' | 'testnet' | 'testnet4' | 'mainnet',
|
||||
config: { // optional axios request config to add to requests
|
||||
headers: {
|
||||
authorization: 'Basic auth'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Liquid API
|
||||
const { liquid } = mempoolJS({
|
||||
protocol: 'https', // optional, defaults to http for localhost, otherwise https
|
||||
hostname: 'liquid.network',
|
||||
network: 'liquid' // 'liquid' | 'liquidtestnet'
|
||||
const { bitcoin, bisq, liquid } = mempoolJS({
|
||||
hostname: 'mempool.space',
|
||||
network: 'testnet' // 'signet' | 'testnet' | 'mainnet'
|
||||
});
|
||||
```
|
||||
|
||||
@ -66,20 +54,12 @@ Call `mempoolJS()` function to access the API methods.
|
||||
|
||||
```js
|
||||
// default mempool.space endpoints
|
||||
const { bitcoin } = mempoolJS();
|
||||
const { bitcoin, bisq, liquid } = mempoolJS();
|
||||
|
||||
// (optional) your custom endpoints
|
||||
const { bitcoin } = mempoolJS({
|
||||
protocol: 'https', // optional, defaults to http for localhost, otherwise https
|
||||
const { bitcoin, bisq, liquid } = mempoolJS({
|
||||
hostname: 'mempool.space',
|
||||
network: 'testnet4', // 'signet' | 'testnet' | 'testnet4' | 'mainnet'
|
||||
});
|
||||
|
||||
// Liquid API
|
||||
const { liquid } = mempoolJS({
|
||||
protocol: 'https', // optional, defaults to http for localhost, otherwise https
|
||||
hostname: 'liquid.network',
|
||||
network: 'liquid' // 'liquid' | 'liquidtestnet'
|
||||
network: 'testnet' // 'signet' | 'testnet' | 'mainnet'
|
||||
});
|
||||
```
|
||||
|
||||
@ -92,10 +72,15 @@ const { liquid } = mempoolJS({
|
||||
- [Blocks](./README-bitcoin.md#get-blocks)
|
||||
- [Difficulty Adjustment](./README-bitcoin.md#get-difficulty-adjustment)
|
||||
- [Fees](./README-bitcoin.md#get-fees)
|
||||
- [Lightning](./README-bitcoin.md#get-network-stats)
|
||||
- [Mempool](./README-bitcoin.md#get-mempool)
|
||||
- [Transactions](./README-bitcoin.md#get-transactions)
|
||||
- [Websocket](./README-bitcoin.md#init-websocket)
|
||||
- [Websocket Client](./README-bitcoin.md#Websocket-Client)
|
||||
- [Websocket Server](./README-bitcoin.md#Websocket-Server)
|
||||
- [Bisq](./README-bisq.md#get-address)
|
||||
- [Addresses](./README-bisq.md#get-address)
|
||||
- [Blocks](./README-bisq.md#get-blocks)
|
||||
- [Statistics](./README-bisq.md#get-statistics)
|
||||
- [Transactions](./README-bisq.md#get-transactions)
|
||||
- [Liquid](./README-liquid.md#get-address)
|
||||
- [Addresses](./README-liquid.md#get-address)
|
||||
- [Assets](./README-liquid.md#get-address)
|
||||
@ -103,7 +88,8 @@ const { liquid } = mempoolJS({
|
||||
- [Fees](./README-liquid.md#get-address)
|
||||
- [Mempool](./README-liquid.md#get-address)
|
||||
- [Transactions](./README-liquid.md#get-address)
|
||||
- [Websocket](./README-liquid.md#init-websocket)
|
||||
- [Websocket Client](./README-liquid.md#Websocket-Client)
|
||||
- [Websocket Server](./README-liquid.md#Websocket-Server)
|
||||
|
||||
---
|
||||
|
||||
@ -114,3 +100,4 @@ Pull requests are welcome! For major changes, please open an issue first to disc
|
||||
---
|
||||
|
||||
## **License** [MIT](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
|
||||
23
examples/html/bisq-js/addresses.html
Normal file
23
examples/html/bisq-js/addresses.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!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>
|
||||
33
examples/html/bisq-js/blocks.html
Normal file
33
examples/html/bisq-js/blocks.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!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>
|
||||
46
examples/html/bisq-js/markets.html
Normal file
46
examples/html/bisq-js/markets.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!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>
|
||||
21
examples/html/bisq-js/statistics.html
Normal file
21
examples/html/bisq-js/statistics.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!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>
|
||||
28
examples/html/bisq-js/transactions.html
Normal file
28
examples/html/bisq-js/transactions.html
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
<!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>
|
||||
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
<script src="./../../../dist/mempool.js"></script>
|
||||
<script>
|
||||
const init = async () => {
|
||||
try {
|
||||
const { bitcoin: { lightning } } = mempoolJS();
|
||||
|
||||
const node = '03d607f3e69fd032524a867b288216bfab263b6eaee4e07783799a6fe69bb84fac';
|
||||
const channel = '768457472831193088';
|
||||
|
||||
const networkStats = await lightning.getNetworkStats();
|
||||
console.log(networkStats);
|
||||
|
||||
const nodesInCountry = await lightning.getNodesInCountry({ country: 'fr' });
|
||||
console.log(nodesInCountry);
|
||||
|
||||
const nodesStatsPerCountry = await lightning.getNodesStatsPerCountry();
|
||||
console.log(nodesStatsPerCountry);
|
||||
|
||||
const nodesHostedByISP = await lightning.getNodesHostedByISP({ isp: 16509 });
|
||||
console.log(nodesHostedByISP);
|
||||
|
||||
const ispRanking = await lightning.getISPRanking();
|
||||
console.log(ispRanking);
|
||||
|
||||
const liquidityRanking = await lightning.getLiquidityRanking();
|
||||
console.log(liquidityRanking);
|
||||
|
||||
const connectivityRanking = await lightning.getConnectivityRanking();
|
||||
console.log(connectivityRanking);
|
||||
|
||||
const oldestNodes = await lightning.getOldestNodes();
|
||||
console.log(oldestNodes);
|
||||
|
||||
const nodeStats = await lightning.getNodeStats({ public_key: node });
|
||||
console.log(nodeStats);
|
||||
|
||||
const historicalNodeStats = await lightning.getHistoricalNodeStats({ public_key: node });
|
||||
console.log(historicalNodeStats);
|
||||
|
||||
const channelData = await lightning.getChannel({ id: channel });
|
||||
console.log(channelData);
|
||||
|
||||
const channelsFromTxIds = await lightning.getChannelsFromTxIds({ txId: ['c3173549f502ede6440d5c48ea74af5607d88484c7a912bbef73d430049f8af4', 'd78f0b41a263af3df91fa4171cc2f60c40196aaf8f4bde5d1c8ff4474cfe753b'] });
|
||||
console.log(channelsFromTxIds);
|
||||
|
||||
const channelsFromNodePublicKey = await lightning.getChannelsFromNodePublicKey({ public_key: node, status: 'active'});
|
||||
console.log(channelsFromNodePublicKey);
|
||||
|
||||
const channelsGeodata = await lightning.getChannelsGeodata();
|
||||
console.log(channelsGeodata);
|
||||
|
||||
const channelsGeodataByPublicKey = await lightning.getChannelsGeodataByPublicKey({ public_key: node });
|
||||
console.log(channelsGeodataByPublicKey);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@ -1,53 +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.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>
|
||||
37
examples/html/liquid-js/addresses.html
Normal file
37
examples/html/liquid-js/addresses.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!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>
|
||||
35
examples/html/liquid-js/assets.html
Normal file
35
examples/html/liquid-js/assets.html
Normal file
@ -0,0 +1,35 @@
|
||||
<!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>
|
||||
51
examples/html/liquid-js/blocks.html
Normal file
51
examples/html/liquid-js/blocks.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!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>
|
||||
24
examples/html/liquid-js/fees.html
Normal file
24
examples/html/liquid-js/fees.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!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>
|
||||
27
examples/html/liquid-js/mempool.html
Normal file
27
examples/html/liquid-js/mempool.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!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>
|
||||
48
examples/html/liquid-js/transactions.html
Normal file
48
examples/html/liquid-js/transactions.html
Normal file
@ -0,0 +1,48 @@
|
||||
<!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>
|
||||
38
examples/html/liquid-js/websocket.html
Normal file
38
examples/html/liquid-js/websocket.html
Normal file
@ -0,0 +1,38 @@
|
||||
<!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>
|
||||
@ -1,47 +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( { 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>
|
||||
25
examples/html/mempool-js/bisq/addresses.html
Normal file
25
examples/html/mempool-js/bisq/addresses.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!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>
|
||||
35
examples/html/mempool-js/bisq/blocks.html
Normal file
35
examples/html/mempool-js/bisq/blocks.html
Normal file
@ -0,0 +1,35 @@
|
||||
<!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>
|
||||
23
examples/html/mempool-js/bisq/statistics.html
Normal file
23
examples/html/mempool-js/bisq/statistics.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page Title</title>
|
||||
<script src="./../../../../dist/mempool.js"></script>
|
||||
<script>
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bisq: { statistics },
|
||||
} = mempoolJS();
|
||||
|
||||
const stats = await statistics.getStats();
|
||||
console.log(stats);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
28
examples/html/mempool-js/bisq/transactions.html
Normal file
28
examples/html/mempool-js/bisq/transactions.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!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>
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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: txHex });
|
||||
const postTx = await transactions.postTx({ txhex });
|
||||
console.log(postTx);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
40
examples/html/mempool-js/bitcoin/websocket.html
Normal file
40
examples/html/mempool-js/bitcoin/websocket.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!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>
|
||||
@ -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( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
try {
|
||||
const {
|
||||
liquid: { assets },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const asset_id = 'a0c358a0f6947864af3a06f3f6a2aeb304df7fd95c922f2f22d7412399ce7691';
|
||||
|
||||
@ -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( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'54f02bdec5509ea769c8be82aed51f689969b653d92a2812d5a36266cbfbc55e';
|
||||
@ -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( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
@ -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( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
@ -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( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'064d1dff90cbb6fce81311f9804a737df9e3873bc4717ff6aae068fffab423ab';
|
||||
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
@ -25,6 +25,11 @@
|
||||
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);
|
||||
|
||||
@ -37,8 +42,8 @@
|
||||
const txOutspends = await transactions.getTxOutspends({ txid });
|
||||
console.log(txOutspends);
|
||||
|
||||
const postTx = await transactions.postTx({ txhex: txHex });
|
||||
console.log(postTx);
|
||||
// const postTx = await transactions.postTx({ txhex });
|
||||
// console.log(postTx);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
40
examples/html/mempool-js/liquid/websocket.html
Normal file
40
examples/html/mempool-js/liquid/websocket.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!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>
|
||||
11
examples/nodejs/bisq-js/addresses.ts
Normal file
11
examples/nodejs/bisq-js/addresses.ts
Normal file
@ -0,0 +1,11 @@
|
||||
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();
|
||||
24
examples/nodejs/bisq-js/blocks.ts
Normal file
24
examples/nodejs/bisq-js/blocks.ts
Normal file
@ -0,0 +1,24 @@
|
||||
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();
|
||||
38
examples/nodejs/bisq-js/markets.ts
Normal file
38
examples/nodejs/bisq-js/markets.ts
Normal file
@ -0,0 +1,38 @@
|
||||
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();
|
||||
13
examples/nodejs/bisq-js/statistics.ts
Normal file
13
examples/nodejs/bisq-js/statistics.ts
Normal file
@ -0,0 +1,13 @@
|
||||
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();
|
||||
18
examples/nodejs/bisq-js/transactions.ts
Normal file
18
examples/nodejs/bisq-js/transactions.ts
Normal file
@ -0,0 +1,18 @@
|
||||
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();
|
||||
@ -1,59 +0,0 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const { bitcoin: { lightning } } = mempoolJS();
|
||||
|
||||
const node = '03d607f3e69fd032524a867b288216bfab263b6eaee4e07783799a6fe69bb84fac';
|
||||
const channel = '768457472831193088';
|
||||
|
||||
const networkStats = await lightning.getNetworkStats();
|
||||
console.log(networkStats);
|
||||
|
||||
const nodesInCountry = await lightning.getNodesInCountry({ country: 'fr' });
|
||||
console.log(nodesInCountry);
|
||||
|
||||
const nodesStatsPerCountry = await lightning.getNodesStatsPerCountry();
|
||||
console.log(nodesStatsPerCountry);
|
||||
|
||||
const nodesHostedByISP = await lightning.getNodesHostedByISP({ isp: 16509 });
|
||||
console.log(nodesHostedByISP);
|
||||
|
||||
const ispRanking = await lightning.getISPRanking();
|
||||
console.log(ispRanking);
|
||||
|
||||
const liquidityRanking = await lightning.getLiquidityRanking();
|
||||
console.log(liquidityRanking);
|
||||
|
||||
const connectivityRanking = await lightning.getConnectivityRanking();
|
||||
console.log(connectivityRanking);
|
||||
|
||||
const oldestNodes = await lightning.getOldestNodes();
|
||||
console.log(oldestNodes);
|
||||
|
||||
const nodeStats = await lightning.getNodeStats({ public_key: node });
|
||||
console.log(nodeStats);
|
||||
|
||||
const historicalNodeStats = await lightning.getHistoricalNodeStats({ public_key: node });
|
||||
console.log(historicalNodeStats);
|
||||
|
||||
const channelData = await lightning.getChannel({ id: channel });
|
||||
console.log(channelData);
|
||||
|
||||
const channelsFromTxIds = await lightning.getChannelsFromTxIds({ txId: ['c3173549f502ede6440d5c48ea74af5607d88484c7a912bbef73d430049f8af4', 'd78f0b41a263af3df91fa4171cc2f60c40196aaf8f4bde5d1c8ff4474cfe753b'] });
|
||||
console.log(channelsFromTxIds);
|
||||
|
||||
const channelsFromNodePublicKey = await lightning.getChannelsFromNodePublicKey({ public_key: node, status: 'active'});
|
||||
console.log(channelsFromNodePublicKey);
|
||||
|
||||
const channelsGeodata = await lightning.getChannelsGeodata();
|
||||
console.log(channelsGeodata);
|
||||
|
||||
const channelsGeodataByPublicKey = await lightning.getChannelsGeodataByPublicKey({ public_key: node });
|
||||
console.log(channelsGeodataByPublicKey);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
@ -1,45 +0,0 @@
|
||||
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();
|
||||
@ -4,7 +4,7 @@ const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { addresses },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const address = 'Go65t19hP2FuhBMYtgbdMDgdmEzNwh1i48';
|
||||
|
||||
@ -4,7 +4,7 @@ const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { assets },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const asset_id =
|
||||
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
|
||||
45
examples/nodejs/liquid-js/blocks.ts
Normal file
45
examples/nodejs/liquid-js/blocks.ts
Normal file
@ -0,0 +1,45 @@
|
||||
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();
|
||||
@ -1,10 +1,10 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
try {
|
||||
const {
|
||||
liquid: { fees },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
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();
|
||||
@ -3,7 +3,7 @@ import mempoolJS from "./../../../src/index";
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bitcoin: { mempool },
|
||||
liquid: { mempool },
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
@ -3,7 +3,7 @@ import mempoolJS from "./../../../src/index";
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bitcoin: { transactions },
|
||||
liquid: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
30
examples/nodejs/liquid-js/websocket.ts
Normal file
30
examples/nodejs/liquid-js/websocket.ts
Normal file
@ -0,0 +1,30 @@
|
||||
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();
|
||||
@ -1,38 +0,0 @@
|
||||
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();
|
||||
17
examples/nodejs/mempool-js/bisq/addresses.ts
Normal file
17
examples/nodejs/mempool-js/bisq/addresses.ts
Normal file
@ -0,0 +1,17 @@
|
||||
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();
|
||||
27
examples/nodejs/mempool-js/bisq/blocks.ts
Normal file
27
examples/nodejs/mempool-js/bisq/blocks.ts
Normal file
@ -0,0 +1,27 @@
|
||||
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();
|
||||
40
examples/nodejs/mempool-js/bisq/markets.ts
Normal file
40
examples/nodejs/mempool-js/bisq/markets.ts
Normal file
@ -0,0 +1,40 @@
|
||||
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();
|
||||
15
examples/nodejs/mempool-js/bisq/statistics.ts
Normal file
15
examples/nodejs/mempool-js/bisq/statistics.ts
Normal file
@ -0,0 +1,15 @@
|
||||
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();
|
||||
21
examples/nodejs/mempool-js/bisq/transactions.ts
Normal file
21
examples/nodejs/mempool-js/bisq/transactions.ts
Normal file
@ -0,0 +1,21 @@
|
||||
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();
|
||||
@ -1,4 +1,4 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
@ -1,4 +1,4 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
@ -1,4 +1,4 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
@ -8,9 +8,6 @@ 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);
|
||||
}
|
||||
@ -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 = '94bb221746f0626caf63c8dd279e07963bfe514fabe596019c95a41c5f5af97c';
|
||||
const txid = 'txid';
|
||||
|
||||
const feesCPFP = await fees.getCPFP({ txid });
|
||||
console.log(feesCPFP);
|
||||
21
examples/nodejs/mempool-js/bitcoin/mempool.ts
Normal file
21
examples/nodejs/mempool-js/bitcoin/mempool.ts
Normal file
@ -0,0 +1,21 @@
|
||||
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();
|
||||
45
examples/nodejs/mempool-js/bitcoin/transactions.ts
Normal file
45
examples/nodejs/mempool-js/bitcoin/transactions.ts
Normal file
@ -0,0 +1,45 @@
|
||||
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();
|
||||
30
examples/nodejs/mempool-js/bitcoin/websocket.ts
Normal file
30
examples/nodejs/mempool-js/bitcoin/websocket.ts
Normal file
@ -0,0 +1,30 @@
|
||||
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();
|
||||
29
examples/nodejs/mempool-js/liquid/addresses.ts
Normal file
29
examples/nodejs/mempool-js/liquid/addresses.ts
Normal file
@ -0,0 +1,29 @@
|
||||
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();
|
||||
24
examples/nodejs/mempool-js/liquid/assets.ts
Normal file
24
examples/nodejs/mempool-js/liquid/assets.ts
Normal file
@ -0,0 +1,24 @@
|
||||
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();
|
||||
@ -1,13 +1,13 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { blocks },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'5ec96b63f95aad27391a8a41f1dce2161d48c4f26aeb1f72695a12c98a005e1f';
|
||||
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
|
||||
|
||||
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: 1 });
|
||||
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
|
||||
console.log(blockTxid);
|
||||
|
||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||
18
examples/nodejs/mempool-js/liquid/fees.ts
Normal file
18
examples/nodejs/mempool-js/liquid/fees.ts
Normal file
@ -0,0 +1,18 @@
|
||||
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();
|
||||
@ -1,10 +1,10 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { mempool },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
@ -1,13 +1,13 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { transactions },
|
||||
} = mempoolJS( { hostname: 'liquid.network' } );
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'555fbc3ca784903b238fdadc92515577dfa9124185259c5d9a773508bbc365e5';
|
||||
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
@ -20,7 +20,10 @@ 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);
|
||||
|
||||
@ -33,8 +36,8 @@ const init = async () => {
|
||||
const txOutspends = await transactions.getTxOutspends({ txid });
|
||||
console.log(txOutspends);
|
||||
|
||||
const postTx = await transactions.postTx({ txhex: txHex });
|
||||
console.log(postTx);
|
||||
// const postTx = await transactions.postTx({ txhex });
|
||||
// console.log(postTx);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
30
examples/nodejs/mempool-js/liquid/websocket.ts
Normal file
30
examples/nodejs/mempool-js/liquid/websocket.ts
Normal file
@ -0,0 +1,30 @@
|
||||
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();
|
||||
6
npm-bisq-js/.gitignore
vendored
Normal file
6
npm-bisq-js/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/node_modules
|
||||
/lib
|
||||
/dist/*
|
||||
!.gitkeep
|
||||
|
||||
yarn-error.log
|
||||
265
npm-bisq-js/README-bisq.md
Normal file
265
npm-bisq-js/README-bisq.md
Normal file
@ -0,0 +1,265 @@
|
||||
# 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);
|
||||
```
|
||||
67
npm-bisq-js/README.md
Normal file
67
npm-bisq-js/README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Bisq**JS** API
|
||||
|
||||
[](https://www.npmjs.org/package/@mempool/bisq.js)
|
||||
[](https://david-dm.org/mempool/bisq.js#info=dependencies)
|
||||
[](https://snyk.io/test/github/mempool/bisq.js)
|
||||
[](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/)
|
||||
57
npm-bisq-js/package.json
Normal file
57
npm-bisq-js/package.json
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
6
npm-liquid-js/.gitignore
vendored
Normal file
6
npm-liquid-js/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/node_modules
|
||||
/lib
|
||||
/dist/*
|
||||
!.gitkeep
|
||||
|
||||
yarn-error.log
|
||||
763
npm-liquid-js/README-liquid.md
Normal file
763
npm-liquid-js/README-liquid.md
Normal file
@ -0,0 +1,763 @@
|
||||
# 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();
|
||||
```
|
||||
70
npm-liquid-js/README.md
Normal file
70
npm-liquid-js/README.md
Normal file
@ -0,0 +1,70 @@
|
||||
# Liquid**JS** API
|
||||
|
||||
[](https://www.npmjs.org/package/@mempool/liquid.js)
|
||||
[](https://david-dm.org/mempool/liquid.js#info=dependencies)
|
||||
[](https://snyk.io/test/github/mempool/liquid.js)
|
||||
[](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/)
|
||||
56
npm-liquid-js/package.json
Normal file
56
npm-liquid-js/package.json
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
8043
package-lock.json
generated
8043
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "@mempool/mempool.js",
|
||||
"version": "3.0.0",
|
||||
"version": "2.3.0",
|
||||
"description": "NPM package module for Mempool APIs.",
|
||||
"main": "lib/index.js",
|
||||
"keywords": [
|
||||
"axios",
|
||||
"bitcoin",
|
||||
"bisq",
|
||||
"liquid",
|
||||
"mainet",
|
||||
"testnet",
|
||||
"testnet4",
|
||||
"signet",
|
||||
"blockchain",
|
||||
"html",
|
||||
@ -32,7 +32,9 @@
|
||||
"start": "ts-node src/index.ts",
|
||||
"dev": "nodemon src/index.ts",
|
||||
"build": "tsc",
|
||||
"export-mempool-js": "tsc | browserify -p esmify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify -p esmify lib/index.js --standalone mempoolJS > dist/mempool.min.js",
|
||||
"export-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",
|
||||
"prepare": "npm run build",
|
||||
"postversion": "git push && git push --tags"
|
||||
},
|
||||
@ -40,26 +42,21 @@
|
||||
"lib/**/*"
|
||||
],
|
||||
"dependencies": {
|
||||
"axios": "1.13.2",
|
||||
"ws": "^8.18.3"
|
||||
"axios": "0.24.0",
|
||||
"ws": "8.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/websocket": "^1.0.10",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
||||
"@typescript-eslint/parser": "^8.46.4",
|
||||
"browserify": "^17.0.1",
|
||||
"eslint": "^9.39.1",
|
||||
"esmify": "^2.1.1",
|
||||
"nodemon": "^3.1.11",
|
||||
"tinyify": "^4.0.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"overrides": {
|
||||
"terser": "^5.14.2",
|
||||
"babel-traverse": "npm:@babel/traverse@^7.23.2"
|
||||
"@types/node": "^14.14.25",
|
||||
"@types/websocket": "^1.0.2",
|
||||
"@types/ws": "^7.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.14.2",
|
||||
"@typescript-eslint/parser": "^4.14.2",
|
||||
"browserify": "^17.0.0",
|
||||
"eslint": "^7.19.0",
|
||||
"nodemon": "^2.0.7",
|
||||
"tinyify": "^3.0.0",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
13
src/app/bisq/addresses.ts
Normal file
13
src/app/bisq/addresses.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { Address, AddressesInstance } from '../../interfaces/bisq/addresses';
|
||||
|
||||
export const useAddresses = (api: AxiosInstance): AddressesInstance => {
|
||||
const getAddress = async (params: { address: string }) => {
|
||||
const { data } = await api.get<Address>(`/address/${params.address}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
return {
|
||||
getAddress,
|
||||
};
|
||||
};
|
||||
27
src/app/bisq/blocks.ts
Normal file
27
src/app/bisq/blocks.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { Block, BlocksInstance } from '../../interfaces/bisq/blocks';
|
||||
|
||||
export const useBlocks = (api: AxiosInstance): BlocksInstance => {
|
||||
const getBlock = async (params: { hash: string }) => {
|
||||
const { data } = await api.get<Block>(`/block/${params.hash}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
const getBlocks = async (params: { index: number; length: number }) => {
|
||||
const { data } = await api.get<Block>(
|
||||
`/blocks/${params.index}/${params.length}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
const getBlocksTipHeight = async () => {
|
||||
const { data } = await api.get<number>(`/blocks/tip/height`);
|
||||
return data;
|
||||
};
|
||||
|
||||
return {
|
||||
getBlock,
|
||||
getBlocks,
|
||||
getBlocksTipHeight,
|
||||
};
|
||||
};
|
||||
137
src/app/bisq/markets.ts
Normal file
137
src/app/bisq/markets.ts
Normal file
@ -0,0 +1,137 @@
|
||||
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,
|
||||
};
|
||||
};
|
||||
|
||||
13
src/app/bisq/statistics.ts
Normal file
13
src/app/bisq/statistics.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { Stats, StatsInstance } from '../../interfaces/bisq/statistics';
|
||||
|
||||
export const useStatistics = (api: AxiosInstance): StatsInstance => {
|
||||
const getStats = async () => {
|
||||
const { data } = await api.get<Stats>(`/stats`);
|
||||
return data;
|
||||
};
|
||||
|
||||
return {
|
||||
getStats,
|
||||
};
|
||||
};
|
||||
21
src/app/bisq/transactions.ts
Normal file
21
src/app/bisq/transactions.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { Tx, TransactionsInstance } from '../../interfaces/bisq/transactions';
|
||||
|
||||
export const useTransactions = (api: AxiosInstance): TransactionsInstance => {
|
||||
const getTx = async (params: { txid: string }) => {
|
||||
const { data } = await api.get<Tx>(`/tx/${params.txid}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
const getTxs = async (params: { index: number; length: number }) => {
|
||||
const { data } = await api.get<Tx[]>(
|
||||
`/txs/${params.index}/${params.length}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
return {
|
||||
getTx,
|
||||
getTxs,
|
||||
};
|
||||
};
|
||||
@ -12,11 +12,7 @@ export const useAddresses = (api: AxiosInstance): AddressInstance => {
|
||||
return data;
|
||||
};
|
||||
|
||||
const getAddressTxs = async (params: { address: string, after_txid?: string }) => {
|
||||
if (params.after_txid) {
|
||||
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs?after_txid=${params.after_txid}`);
|
||||
return data;
|
||||
}
|
||||
const getAddressTxs = async (params: { address: string }) => {
|
||||
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@ import { Tx } from '../../interfaces/bitcoin/transactions';
|
||||
|
||||
export const useBlocks = (api: AxiosInstance): BlockInstance => {
|
||||
const getBlock = async (params: { hash: string }) => {
|
||||
const { data } = await api.get<Block>(`/v1/block/${params.hash}`);
|
||||
const { data } = await api.get<Block>(`/block/${params.hash}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -55,7 +55,7 @@ export const useBlocks = (api: AxiosInstance): BlockInstance => {
|
||||
};
|
||||
|
||||
const getBlocks = async (params: { start_height?: number }) => {
|
||||
const { data } = await api.get<Block[]>(`/v1/blocks/${params.start_height}`);
|
||||
const { data } = await api.get<Block>(`/blocks/${params.start_height}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ import { AxiosInstance } from 'axios';
|
||||
import {
|
||||
Adjustment,
|
||||
DifficultyInstance,
|
||||
Hashrate,
|
||||
} from '../../interfaces/bitcoin/difficulty';
|
||||
|
||||
export const useDifficulty = (api: AxiosInstance): DifficultyInstance => {
|
||||
@ -11,13 +10,7 @@ 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,
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,97 +0,0 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { Channel, LightningInstance, NetworkStats, Node, NodeStats } from '../../interfaces/bitcoin/lightning';
|
||||
|
||||
export const useLightning = (api: AxiosInstance): LightningInstance => {
|
||||
const getNetworkStats = async () => {
|
||||
const { data } = await api.get<NetworkStats>(`/v1/lightning/statistics/latest`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getNodesInCountry = async (params: { country: string }) => {
|
||||
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/country/${params.country}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getNodesStatsPerCountry = async () => {
|
||||
const { data } = await api.get<any>(`/v1/lightning/nodes/countries`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getNodesHostedByISP = async (params: { isp: number }) => {
|
||||
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/isp/${params.isp}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getISPRanking = async () => {
|
||||
const { data } = await api.get<any>(`/v1/lightning/nodes/isp-ranking`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getLiquidityRanking = async () => {
|
||||
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/rankings/liquidity`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getConnectivityRanking = async () => {
|
||||
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/rankings/connectivity`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getOldestNodes = async () => {
|
||||
const { data } = await api.get<Node[]>(`/v1/lightning/nodes/rankings/age`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getNodeStats = async (params: { public_key: string }) => {
|
||||
const { data } = await api.get<Node>(`/v1/lightning/nodes/${params.public_key}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getHistoricalNodeStats = async (params: { public_key: string }) => {
|
||||
const { data } = await api.get<NodeStats[]>(`/v1/lightning/nodes/${params.public_key}/statistics`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getChannel = async (params: { id: string }) => {
|
||||
const { data } = await api.get<Channel>(`/v1/lightning/channels/${params.id}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getChannelsFromTxIds = async (params: { txId: string[] }) => {
|
||||
const { data } = await api.get<any[]>(`/v1/lightning/channels/txids?txId[]=${params.txId.join('&txId[]=')}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getChannelsFromNodePublicKey = async (params: { public_key: string, status: string, index?: number }) => {
|
||||
const { data } = await api.get<Channel[]>(`/v1/lightning/channels?public_key=${params.public_key}&status=${params.status}&index=${params?.index}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getChannelsGeodata = async () => {
|
||||
const { data } = await api.get<any[]>(`/v1/lightning/channels-geo`);
|
||||
return data;
|
||||
}
|
||||
|
||||
const getChannelsGeodataByPublicKey = async (params: { public_key: string }) => {
|
||||
const { data } = await api.get<any[]>(`/v1/lightning/channels-geo/${params.public_key}`);
|
||||
return data;
|
||||
}
|
||||
|
||||
return {
|
||||
getNetworkStats,
|
||||
getNodesInCountry,
|
||||
getNodesStatsPerCountry,
|
||||
getNodesHostedByISP,
|
||||
getISPRanking,
|
||||
getLiquidityRanking,
|
||||
getConnectivityRanking,
|
||||
getOldestNodes,
|
||||
getNodeStats,
|
||||
getHistoricalNodeStats,
|
||||
getChannel,
|
||||
getChannelsFromTxIds,
|
||||
getChannelsFromNodePublicKey,
|
||||
getChannelsGeodata,
|
||||
getChannelsGeodataByPublicKey,
|
||||
};
|
||||
};
|
||||
@ -36,7 +36,7 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
|
||||
};
|
||||
|
||||
const getTxMerkleProof = async (params: { txid: string }) => {
|
||||
const { data } = await api.get<TxMerkleProof>(
|
||||
const { data } = await api.get<Array<TxMerkleProof>>(
|
||||
`/tx/${params.txid}/merkle-proof`
|
||||
);
|
||||
return data;
|
||||
@ -57,7 +57,7 @@ export const useTransactions = (api: AxiosInstance): TxInstance => {
|
||||
};
|
||||
|
||||
const postTx = async (params: { txhex: string }) => {
|
||||
const { data } = await api.post<string>(`/tx`, params.txhex );
|
||||
const { data } = await api.post<string>(`/tx`, { txhex: params.txhex });
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@ -1,86 +1,14 @@
|
||||
import { WsInstance } from '../../interfaces/bitcoin/websockets';
|
||||
import {
|
||||
wsInit as wsInitBrowser,
|
||||
wsWantData as wsWantDataBrowser,
|
||||
wsStopData as wsStopDataBrowser,
|
||||
wsTrackAddress as wsTrackAddressBrowser,
|
||||
wsStopTrackingAddress as wsStopTrackingAddressBrowser,
|
||||
wsTrackAddresses as wsTrackAddressesBrowser,
|
||||
wsStopTrackingAddresses as wsStopTrackingAddressesBrowser,
|
||||
wsTrackTransaction as wsTrackTransactionBrowser,
|
||||
wsStopTrackingTransaction as wsStopTrackingTransactionBrowser,
|
||||
wsTrackRbfSummary as wsTrackRbfSummaryBrowser,
|
||||
wsStopTrackingRbfSummary as wsStopTrackingRbfSummaryBrowser,
|
||||
wsTrackRbf as wsTrackRbfBrowser,
|
||||
wsStopTrackingRbf as wsStopTrackingRbfBrowser,
|
||||
wsTrackMempoolBlock as wsTrackMempoolBlockBrowser,
|
||||
wsStopTrackingMempoolBlock as wsStopTrackingMempoolBlockBrowser,
|
||||
} from '../../services/ws/ws-client-browser';
|
||||
import {
|
||||
wsInit,
|
||||
wsWantData,
|
||||
wsStopData,
|
||||
wsTrackAddress,
|
||||
wsStopTrackingAddress,
|
||||
wsTrackAddresses,
|
||||
wsStopTrackingAddresses,
|
||||
wsTrackTransaction,
|
||||
wsStopTrackingTransaction,
|
||||
wsTrackRbfSummary,
|
||||
wsStopTrackingRbfSummary,
|
||||
wsTrackRbf,
|
||||
wsStopTrackingRbf,
|
||||
wsTrackMempoolBlock,
|
||||
wsStopTrackingMempoolBlock
|
||||
} from '../../services/ws/ws-client-node';
|
||||
import WebSocketServer from 'ws';
|
||||
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets';
|
||||
import wsClient from '../../services/ws/client';
|
||||
import wsServer from '../../services/ws/server';
|
||||
|
||||
export const useWebsocket = (hostname: string, network: string, protocol: string | undefined): WsInstance => {
|
||||
export const useWebsocket = (hostname: string, network: string): WsInstance => {
|
||||
|
||||
if (!protocol) {
|
||||
hostname?.includes('localhost') ? protocol = 'ws' : protocol = 'wss';
|
||||
} else if (protocol === 'http' || protocol === 'ws') {
|
||||
protocol = 'ws';
|
||||
} else {
|
||||
protocol = 'wss';
|
||||
}
|
||||
if (network && ['testnet', 'testnet4', 'signet'].includes(network)) {
|
||||
network = `/${network}`;
|
||||
} else {
|
||||
network = '';
|
||||
}
|
||||
|
||||
const wsEndpoint = `${protocol}://${hostname}${network}/api/v1/ws`
|
||||
const wsEndpoint = `wss://${hostname}${network === 'main' ? '' : `/${network}`}/api/v1/ws`;
|
||||
return {
|
||||
wsInit: () => wsInit(wsEndpoint),
|
||||
wsInitBrowser: () => wsInitBrowser(wsEndpoint),
|
||||
wsWantData: (ws: WebSocketServer, options: string[]) => wsWantData(ws, options),
|
||||
wsWantDataBrowser: (ws: WebSocket, options: string[]) => wsWantDataBrowser(ws, options),
|
||||
wsStopData: (ws: WebSocketServer) => wsStopData(ws),
|
||||
wsStopDataBrowser: (ws: WebSocket) => wsStopDataBrowser(ws),
|
||||
wsTrackAddress: (ws: WebSocketServer, address: string) => wsTrackAddress(ws, address),
|
||||
wsTrackAddressBrowser: (ws: WebSocket, address: string) => wsTrackAddressBrowser(ws, address),
|
||||
wsStopTrackingAddress: (ws: WebSocketServer) => wsStopTrackingAddress(ws),
|
||||
wsStopTrackingAddressBrowser: (ws: WebSocket) => wsStopTrackingAddressBrowser(ws),
|
||||
wsTrackAddresses: (ws: WebSocketServer, addresses: string[]) => wsTrackAddresses(ws, addresses),
|
||||
wsTrackAddressesBrowser: (ws: WebSocket, addresses: string[]) => wsTrackAddressesBrowser(ws, addresses),
|
||||
wsStopTrackingAddresses: (ws: WebSocketServer) => wsStopTrackingAddresses(ws),
|
||||
wsStopTrackingAddressesBrowser: (ws: WebSocket) => wsStopTrackingAddressesBrowser(ws),
|
||||
wsTrackTransaction: (ws: WebSocketServer, txid: string) => wsTrackTransaction(ws, txid),
|
||||
wsTrackTransactionBrowser: (ws: WebSocket, txid: string) => wsTrackTransactionBrowser(ws, txid),
|
||||
wsStopTrackingTransaction: (ws: WebSocketServer) => wsStopTrackingTransaction(ws),
|
||||
wsStopTrackingTransactionBrowser: (ws: WebSocket) => wsStopTrackingTransactionBrowser(ws),
|
||||
wsTrackRbfSummary: (ws: WebSocketServer) => wsTrackRbfSummary(ws),
|
||||
wsTrackRbfSummaryBrowser: (ws: WebSocket) => wsTrackRbfSummaryBrowser(ws),
|
||||
wsStopTrackingRbfSummary: (ws: WebSocketServer) => wsStopTrackingRbfSummary(ws),
|
||||
wsStopTrackingRbfSummaryBrowser: (ws: WebSocket) => wsStopTrackingRbfSummaryBrowser(ws),
|
||||
wsTrackRbf: (ws: WebSocketServer, fullRbf: boolean) => wsTrackRbf(ws, fullRbf),
|
||||
wsTrackRbfBrowser: (ws: WebSocket, fullRbf: boolean) => wsTrackRbfBrowser(ws, fullRbf),
|
||||
wsStopTrackingRbf: (ws: WebSocketServer) => wsStopTrackingRbf(ws),
|
||||
wsStopTrackingRbfBrowser: (ws: WebSocket) => wsStopTrackingRbfBrowser(ws),
|
||||
wsTrackMempoolBlock: (ws: WebSocketServer, index: number) => wsTrackMempoolBlock(ws, index),
|
||||
wsTrackMempoolBlockBrowser: (ws: WebSocket, index: number) => wsTrackMempoolBlockBrowser(ws, index),
|
||||
wsStopTrackingMempoolBlock: (ws: WebSocketServer) => wsStopTrackingMempoolBlock(ws),
|
||||
wsStopTrackingMempoolBlockBrowser: (ws: WebSocket) => wsStopTrackingMempoolBlockBrowser(ws),
|
||||
initClient: ({ options }: WsInterface) =>
|
||||
wsClient(options, wsEndpoint),
|
||||
initServer: ({ options }: WsInterface) =>
|
||||
wsServer(options, wsEndpoint),
|
||||
};
|
||||
};
|
||||
|
||||
@ -12,11 +12,7 @@ export const useAddresses = (api: AxiosInstance): AddressInstance => {
|
||||
return data;
|
||||
};
|
||||
|
||||
const getAddressTxs = async (params: { address: string, after_txid?: string }) => {
|
||||
if (params.after_txid) {
|
||||
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs?after_txid=${params.after_txid}`);
|
||||
return data;
|
||||
}
|
||||
const getAddressTxs = async (params: { address: string }) => {
|
||||
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -3,12 +3,12 @@ import {
|
||||
Block,
|
||||
BlockStatus,
|
||||
BlockLiquidInstance,
|
||||
} from '../../interfaces/liquid/blocks';
|
||||
} from '../../interfaces/liquid/block';
|
||||
import { Tx } from '../../interfaces/bitcoin/transactions';
|
||||
|
||||
export const useBlocks = (api: AxiosInstance): BlockLiquidInstance => {
|
||||
const getBlock = async (params: { hash: string }) => {
|
||||
const { data } = await api.get<Block>(`/v1/block/${params.hash}`);
|
||||
const { data } = await api.get<Block>(`/block/${params.hash}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -50,7 +50,7 @@ export const useBlocks = (api: AxiosInstance): BlockLiquidInstance => {
|
||||
};
|
||||
|
||||
const getBlocks = async (params: { start_height?: number }) => {
|
||||
const { data } = await api.get<Block[]>(`/v1/blocks/${params.start_height}`);
|
||||
const { data } = await api.get<Block>(`/blocks/${params.start_height}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ import {
|
||||
TxStatus,
|
||||
TxMerkleProof,
|
||||
TxOutspend,
|
||||
TxLiquidInstance,
|
||||
} from '../../interfaces/liquid/transactions';
|
||||
TxInstance,
|
||||
} from '../../interfaces/bitcoin/transactions';
|
||||
|
||||
export const useTransactions = (api: AxiosInstance): TxLiquidInstance => {
|
||||
export const useTransactions = (api: AxiosInstance): TxInstance => {
|
||||
const getTx = async (params: { txid: string }) => {
|
||||
const { data } = await api.get<Tx>(`/tx/${params.txid}`);
|
||||
return data;
|
||||
@ -28,8 +28,15 @@ export const useTransactions = (api: AxiosInstance): TxLiquidInstance => {
|
||||
return data;
|
||||
};
|
||||
|
||||
const getTxMerkleBlockProof = async (params: { txid: string }) => {
|
||||
const { data } = await api.get<string>(
|
||||
`/tx/${params.txid}/merkleblock-proof`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
const getTxMerkleProof = async (params: { txid: string }) => {
|
||||
const { data } = await api.get<TxMerkleProof>(
|
||||
const { data } = await api.get<Array<TxMerkleProof>>(
|
||||
`/tx/${params.txid}/merkle-proof`
|
||||
);
|
||||
return data;
|
||||
@ -50,7 +57,7 @@ export const useTransactions = (api: AxiosInstance): TxLiquidInstance => {
|
||||
};
|
||||
|
||||
const postTx = async (params: { txhex: string }) => {
|
||||
const { data } = await api.post<string>(`/tx`, params.txhex );
|
||||
const { data } = await api.post<string>(`/tx`, { txid: params.txhex });
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -59,6 +66,7 @@ export const useTransactions = (api: AxiosInstance): TxLiquidInstance => {
|
||||
getTxStatus,
|
||||
getTxHex,
|
||||
getTxRaw,
|
||||
getTxMerkleBlockProof,
|
||||
getTxMerkleProof,
|
||||
getTxOutspend,
|
||||
getTxOutspends,
|
||||
|
||||
@ -1,69 +1,14 @@
|
||||
import { WsLiquidInstance } from '../../interfaces/liquid/websockets';
|
||||
import {
|
||||
wsInit as wsInitBrowser,
|
||||
wsWantData as wsWantDataBrowser,
|
||||
wsStopData as wsStopDataBrowser,
|
||||
wsTrackAddress as wsTrackAddressBrowser,
|
||||
wsStopTrackingAddress as wsStopTrackingAddressBrowser,
|
||||
wsTrackAddresses as wsTrackAddressesBrowser,
|
||||
wsStopTrackingAddresses as wsStopTrackingAddressesBrowser,
|
||||
wsTrackTransaction as wsTrackTransactionBrowser,
|
||||
wsStopTrackingTransaction as wsStopTrackingTransactionBrowser,
|
||||
wsTrackMempoolBlock as wsTrackMempoolBlockBrowser,
|
||||
wsStopTrackingMempoolBlock as wsStopTrackingMempoolBlockBrowser,
|
||||
} from '../../services/ws/ws-client-browser';
|
||||
import {
|
||||
wsInit,
|
||||
wsWantData,
|
||||
wsStopData,
|
||||
wsTrackAddress,
|
||||
wsStopTrackingAddress,
|
||||
wsTrackAddresses,
|
||||
wsStopTrackingAddresses,
|
||||
wsTrackTransaction,
|
||||
wsStopTrackingTransaction,
|
||||
wsTrackMempoolBlock,
|
||||
wsStopTrackingMempoolBlock
|
||||
} from '../../services/ws/ws-client-node';
|
||||
import WebSocketServer from 'ws';
|
||||
import { WsInterface, WsInstance } from '../../interfaces/bitcoin/websockets';
|
||||
import wsClient from '../../services/ws/client';
|
||||
import wsServer from '../../services/ws/server';
|
||||
|
||||
export const useWebsocket = (hostname: string, network: string, protocol: string | undefined): WsLiquidInstance => {
|
||||
export const useWebsocket = (hostname: string): WsInstance => {
|
||||
|
||||
if (!protocol) {
|
||||
hostname?.includes('localhost') ? protocol = 'ws' : protocol = 'wss';
|
||||
} else if (protocol === 'http' || protocol === 'ws') {
|
||||
protocol = 'ws';
|
||||
} else {
|
||||
protocol = 'wss';
|
||||
}
|
||||
if (network && ['testnet', 'liquidtestnet'].includes(network)) {
|
||||
network = `/liquidtestnet`;
|
||||
} else {
|
||||
network = '/liquid';
|
||||
}
|
||||
|
||||
const wsEndpoint = `${protocol}://${hostname}${network}/api/v1/ws`
|
||||
const wsEndpoint = `wss://${hostname}/liquid/api/v1/ws`;
|
||||
return {
|
||||
wsInit: () => wsInit(wsEndpoint),
|
||||
wsInitBrowser: () => wsInitBrowser(wsEndpoint),
|
||||
wsWantData: (ws: WebSocketServer, options: string[]) => wsWantData(ws, options),
|
||||
wsWantDataBrowser: (ws: WebSocket, options: string[]) => wsWantDataBrowser(ws, options),
|
||||
wsStopData: (ws: WebSocketServer) => wsStopData(ws),
|
||||
wsStopDataBrowser: (ws: WebSocket) => wsStopDataBrowser(ws),
|
||||
wsTrackAddress: (ws: WebSocketServer, address: string) => wsTrackAddress(ws, address),
|
||||
wsTrackAddressBrowser: (ws: WebSocket, address: string) => wsTrackAddressBrowser(ws, address),
|
||||
wsStopTrackingAddress: (ws: WebSocketServer) => wsStopTrackingAddress(ws),
|
||||
wsStopTrackingAddressBrowser: (ws: WebSocket) => wsStopTrackingAddressBrowser(ws),
|
||||
wsTrackAddresses: (ws: WebSocketServer, addresses: string[]) => wsTrackAddresses(ws, addresses),
|
||||
wsTrackAddressesBrowser: (ws: WebSocket, addresses: string[]) => wsTrackAddressesBrowser(ws, addresses),
|
||||
wsStopTrackingAddresses: (ws: WebSocketServer) => wsStopTrackingAddresses(ws),
|
||||
wsStopTrackingAddressesBrowser: (ws: WebSocket) => wsStopTrackingAddressesBrowser(ws),
|
||||
wsTrackTransaction: (ws: WebSocketServer, txid: string) => wsTrackTransaction(ws, txid),
|
||||
wsTrackTransactionBrowser: (ws: WebSocket, txid: string) => wsTrackTransactionBrowser(ws, txid),
|
||||
wsStopTrackingTransaction: (ws: WebSocketServer) => wsStopTrackingTransaction(ws),
|
||||
wsStopTrackingTransactionBrowser: (ws: WebSocket) => wsStopTrackingTransactionBrowser(ws),
|
||||
wsTrackMempoolBlock: (ws: WebSocketServer, index: number) => wsTrackMempoolBlock(ws, index),
|
||||
wsTrackMempoolBlockBrowser: (ws: WebSocket, index: number) => wsTrackMempoolBlockBrowser(ws, index),
|
||||
wsStopTrackingMempoolBlock: (ws: WebSocketServer) => wsStopTrackingMempoolBlock(ws),
|
||||
wsStopTrackingMempoolBlockBrowser: (ws: WebSocket) => wsStopTrackingMempoolBlockBrowser(ws), };
|
||||
initClient: ({ options }: WsInterface) =>
|
||||
wsClient(options, wsEndpoint),
|
||||
initServer: ({ options }: WsInterface) =>
|
||||
wsServer(options, wsEndpoint),
|
||||
};
|
||||
};
|
||||
|
||||
33
src/index-bisq.ts
Normal file
33
src/index-bisq.ts
Normal file
@ -0,0 +1,33 @@
|
||||
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;
|
||||
41
src/index-liquid.ts
Normal file
41
src/index-liquid.ts
Normal file
@ -0,0 +1,41 @@
|
||||
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;
|
||||
44
src/index.ts
44
src/index.ts
@ -1,15 +1,25 @@
|
||||
import { MempoolConfig, MempoolReturn } from './interfaces/index';
|
||||
import { makeBitcoinAPI, makeLiquidAPI } from './services/api/index';
|
||||
import {
|
||||
makeBitcoinAPI,
|
||||
makeBisqAPI,
|
||||
makeLiquidAPI,
|
||||
makeBisqMarketsAPI
|
||||
} 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';
|
||||
@ -22,7 +32,7 @@ const hostnameEndpointDefault = 'mempool.space';
|
||||
const networkEndpointDefault = 'main';
|
||||
|
||||
const mempool = (
|
||||
{ hostname, network, protocol, config }: MempoolConfig = {
|
||||
{ hostname, network }: MempoolConfig = {
|
||||
hostname: hostnameEndpointDefault,
|
||||
network: networkEndpointDefault,
|
||||
}
|
||||
@ -30,28 +40,26 @@ const mempool = (
|
||||
if (!hostname) hostname = hostnameEndpointDefault;
|
||||
if (!network) network = networkEndpointDefault;
|
||||
|
||||
const { api: apiBitcoin } = makeBitcoinAPI({
|
||||
hostname,
|
||||
network,
|
||||
protocol,
|
||||
config,
|
||||
});
|
||||
const { api: apiLiquid } = makeLiquidAPI({
|
||||
hostname,
|
||||
network,
|
||||
protocol,
|
||||
config,
|
||||
});
|
||||
const { api: apiBitcoin } = makeBitcoinAPI({ hostname, network });
|
||||
const { api: apiBisq } = makeBisqAPI(hostname);
|
||||
const { api: apiBisqMarkets } = makeBisqMarketsAPI();
|
||||
const { api: apiLiquid } = makeLiquidAPI(hostname);
|
||||
return {
|
||||
bitcoin: {
|
||||
addresses: useAddresses(apiBitcoin),
|
||||
blocks: useBlocks(apiBitcoin),
|
||||
difficulty: useDifficulty(apiBitcoin),
|
||||
fees: useFees(apiBitcoin),
|
||||
lightning: useLightning(apiBitcoin),
|
||||
mempool: useMempool(apiBitcoin),
|
||||
transactions: useTransactions(apiBitcoin),
|
||||
websocket: useWebsocket(hostname, network, protocol),
|
||||
websocket: useWebsocket(hostname, network),
|
||||
},
|
||||
bisq: {
|
||||
statistics: useStatisticsBisq(apiBisq),
|
||||
addresses: useAddressesBisq(apiBisq),
|
||||
blocks: useBlocksBisq(apiBisq),
|
||||
transactions: useTransactionsBisq(apiBisq),
|
||||
markets: useMarkets(apiBisqMarkets),
|
||||
},
|
||||
liquid: {
|
||||
addresses: useAddressesLiquid(apiLiquid),
|
||||
@ -60,7 +68,7 @@ const mempool = (
|
||||
fees: useFeesLiquid(apiLiquid),
|
||||
mempool: useMempoolLiquid(apiLiquid),
|
||||
transactions: useTransactionsLiquid(apiLiquid),
|
||||
websocket: useWebsocketLiquid(hostname, network, protocol),
|
||||
websocket: useWebsocketLiquid(hostname),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
13
src/interfaces/bisq/addresses.ts
Normal file
13
src/interfaces/bisq/addresses.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Tx } from './transactions';
|
||||
|
||||
export interface Address {
|
||||
height: number;
|
||||
time: number;
|
||||
hash: string;
|
||||
previousBlockHash: string;
|
||||
txs: Tx[];
|
||||
}
|
||||
|
||||
export interface AddressesInstance {
|
||||
getAddress: (params: { address: string }) => Promise<Address>;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user