Compare commits

...

65 Commits

Author SHA1 Message Date
wiz
139c621a90
Merge remote-tracking branch 'mempooljs/main' into wiz/subtree-merge-mempool.js-repo 2022-01-29 08:02:10 +00:00
softsimon
3f0ab7307a
Bumping version to 2.3.0 2022-01-10 15:53:10 +04:00
softsimon
7e8d5547fd
Bumping to 2.3.0-dev1 2021-12-22 19:31:25 +04:00
softsimon
029cd8ad48
Bumping package version to v2.2.6 2021-12-20 23:36:19 +04:00
softsimon
f2a8ac7087
Updating endpoint addresses for Liquid and Bisq backend 2021-12-20 23:34:52 +04:00
softsimon
721ed60ba5
Fixing type for image response 2021-12-20 23:34:36 +04:00
softsimon
4893ff1d81
Adding support for Asset Icon API endpoints 2021-12-20 23:25:44 +04:00
softsimon
d238b1a779
Correcting "blocks" typo 2021-12-20 23:14:11 +04:00
softsimon
a9b2f31ae5
Merge pull request #32 from mikeriss/patch-2
Typo fixed
2021-12-20 23:13:32 +04:00
Dmitry Martynenko
ce56c1b03b
websocket testnet url fix 2021-12-20 23:08:13 +04:00
softsimon
b5a8a5dc24
Merge pull request #35 from mempool/simon/version-bump-2.2.4
Bumping dependency versions and package version to 2.2.4
2021-12-20 22:26:57 +04:00
softsimon
06f23c5f37
Bumping dependency versions and package version to 2.2.4 2021-12-20 22:25:12 +04:00
softsimon
870bae5180
Merge pull request #30 from Draichi/patch-1
Update README-bitcoin.md
2021-12-08 21:36:58 +04:00
mikeriss
a614ad4119
Typo fixed 2021-11-02 17:15:01 +01:00
mikeriss
3a42e20cf1
Typo (#31)
changed res.blocks to res.block
2021-10-25 09:21:01 -03:00
Lucas
905ef5ed19
Update README-bitcoin.md
Fix 404 on page links
2021-09-06 13:36:58 -03:00
Miguel Medeiros
9fe77e49a2 Change liquid address doc example. 2021-08-10 13:09:38 -03:00
Miguel Medeiros
62902ba8c7 Add liquid.js documentation. 2021-08-10 13:03:23 -03:00
Miguel Medeiros
1873eb41c6 Change version to 2.2.1 for bisq / liquid modules. 2021-08-10 12:39:11 -03:00
Miguel Medeiros
efd0436851 Add bisq.js readme. 2021-08-10 12:38:33 -03:00
Miguel Medeiros
edab1ad3d5 Fix post tx documentation. 2021-08-10 01:44:50 -03:00
Miguel Medeiros
4efc927303 Add bisqJS and liquidJS npm modules. 2021-08-10 01:30:13 -03:00
Miguel Medeiros
acc0c80953 2.2.4 2021-08-04 08:11:27 -03:00
Miguel Medeiros
334ed2b173 Fix difficulty adjustment endpoint. 2021-08-04 08:09:29 -03:00
Miguel Medeiros
24f0ab8f84 2.2.3 2021-07-23 18:08:43 -03:00
Miguel Medeiros
c1f41d6e1c Add difficulty adjustment documentation link. 2021-07-23 18:02:14 -03:00
Miguel Medeiros
aed4bc5fc9 Add difficulty adjustment examples. 2021-07-23 17:58:54 -03:00
Miguel Medeiros
caf8d956b5 Add difficulty adjustment endpoints methods. 2021-07-23 17:37:28 -03:00
Miguel Medeiros
1c32b05abe Add localhost support. 2021-07-23 17:36:40 -03:00
Miguel Medeiros
7dec92a1bf Change documentation link to official mempool.space. 2021-07-22 02:22:03 -03:00
Miguel Medeiros
4cd7665e8c Add blockHeader instructions and examples. 2021-07-22 02:18:15 -03:00
Miguel Medeiros
47fa100786 Add getBlockHeader method. 2021-07-22 02:14:11 -03:00
Miguel Medeiros
f244ad191e Change command build. 2021-07-22 00:55:29 -03:00
Miguel Medeiros
92bf87821a 2.2.2 2021-05-31 21:03:20 -03:00
Miguel Medeiros
920622137b Fix readme instructions. 2021-05-31 20:36:00 -03:00
Miguel Medeiros
b3606e46c1 Fix getAddress endpoint url. 2021-05-31 20:02:16 -03:00
Miguel Medeiros
112e54ae57
2.2.1 (#22) 2021-05-20 12:25:11 -03:00
Miguel Medeiros
e3068c2d8d
Bugfix Websocket hostname. (#21)
* Add yarn-error.log to gitignore.

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

* Update yarn.lock libs.

* FIX websocket endpoint hostname.
FIX corrent import for all examples.
FIX websocket instrucions on readme.
2021-05-20 12:03:40 -03:00
Miguel Medeiros
0aa3757217 FIX rename package. 2021-04-17 00:34:47 -03:00
Miguel Medeiros
f26adbd982
FIX rename package name. (#19) (#20) 2021-04-17 00:20:32 -03:00
Miguel Medeiros
b63b5d7d92 2.2.0 2021-04-16 22:51:40 -03:00
Miguel Medeiros
ad41063fdb Merge branch 'main' of https://github.com/mempool/mempool-js 2021-04-15 15:54:04 -03:00
Miguel Medeiros
9c483af487
v2.2.0 (#18)
* FIX: getBlocks optional params

* v2.3.0 - new minor version for mempool-js
- Add support for Bisq API
- Add support for Liquid API
- Change the main object to export network objects.
- Change README.md instructions.

* 2.3.0

* FIX wrong npm link. (#15)

* FIX version name v2.2.0 (#17)

Co-authored-by: softsimon <softsimon@users.noreply.github.com>
2021-04-15 15:33:12 -03:00
Miguel Medeiros
5cea5595f9 2.3.0 2021-04-14 17:30:38 -03:00
Miguel Medeiros
c80f82a0b1
v2.3.0 (#12)
* FIX: getBlocks optional params

* v2.3.0 - new minor version for mempool-js
- Add support for Bisq API
- Add support for Liquid API
- Change the main object to export network objects.
- Change README.md instructions.

Co-authored-by: softsimon <softsimon@users.noreply.github.com>
2021-04-14 17:27:28 -03:00
softsimon
70d31f2062
Merge pull request #9 from mempool/feature/add-cnd-link
Add CDN provider to the mempool.js.
2021-04-10 19:38:07 +04:00
Miguel Medeiros
2dd50add4a - Add mempool.js link to all examples.
- Ignore files in dist folder, adding .gitkeep instead.
- Update readme text with CND instructions.
- Update readme badges.
- Update readme typo.
- Update all the html examples with new CDN link.
2021-04-10 12:30:24 -03:00
Miguel Medeiros
760bf97c1b 2.2.1 2021-04-10 11:53:07 -03:00
softsimon
f7ab448cd1
Merge pull request #8 from mempool/bugfix/build-script-standalone-tinyify
FIX: change build script to enable standalone
2021-04-10 18:45:36 +04:00
Miguel Medeiros
5003538319 FIX: change build script to enable standalone 2021-04-10 11:31:16 -03:00
Miguel Medeiros
f39361263a
v2.2.0 - new major version for mempool-js (#2)
* - Refactoring code.
- Refactoring folder structure.
- Adding apiEndpoint and websocketEndpoint to Mempool config.
- Adding brownserify feature.
- Adding MIT LICENSE

* - Changing package.json information.
- Reorganizing README.md information.
- Default export for CommonJs and ES6 Modules.
- Changing default variable to mempoolJS.
- Organizing the API and WS providers.
- Splitting websocket connection types: client and server.

* Change version to 2.2.0.
Reorder keywords in alphabetical order.
2021-04-08 10:15:30 -03:00
MiguelMedeiros\Miguel Medeiros
3bfae54069 1.1.2 2021-02-10 11:26:46 -03:00
MiguelMedeiros\Miguel Medeiros
6efc2aefe4 Change URL website. 2021-02-10 11:26:34 -03:00
MiguelMedeiros\Miguel Medeiros
e837bf7be3 1.1.1 2021-02-10 11:20:13 -03:00
MiguelMedeiros\Miguel Medeiros
8fe9a67352 Changing readme badges. 2021-02-10 11:20:01 -03:00
MiguelMedeiros\Miguel Medeiros
68a11bfae5 1.1.0 2021-02-09 16:23:52 -03:00
MiguelMedeiros\Miguel Medeiros
90be85f6f0 Adding websocket. 2021-02-09 16:22:48 -03:00
MiguelMedeiros\Miguel Medeiros
b39fb0bd60 1.0.2 2021-02-08 17:13:27 -03:00
MiguelMedeiros\Miguel Medeiros
9c5c1b8ff0 Changing badges links. 2021-02-08 17:13:15 -03:00
MiguelMedeiros\Miguel Medeiros
eacf5a584d 1.0.1 2021-02-08 17:11:10 -03:00
MiguelMedeiros\Miguel Medeiros
6946f22aea Changing Donations addresses. 2021-02-08 17:10:19 -03:00
MiguelMedeiros\Miguel Medeiros
caed38420b Changing project name. 2021-02-08 17:03:18 -03:00
MiguelMedeiros\Miguel Medeiros
67ad99006f Changing text Instalation. 2021-02-08 17:00:32 -03:00
MiguelMedeiros\Miguel Medeiros
9a97b411c9 Adding links to README.md. 2021-02-08 16:59:48 -03:00
MiguelMedeiros\Miguel Medeiros
ff53139f78 Init 2021-02-08 16:54:37 -03:00
124 changed files with 20800 additions and 0 deletions

12
mempool.js/.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

16
mempool.js/.eslintrc.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
};

6
mempool.js/.gitignore vendored Normal file
View File

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

6
mempool.js/.prettierrc Normal file
View File

@ -0,0 +1,6 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"printWidth": 80
}

21
mempool.js/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Miguel Medeiros
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

147
mempool.js/README-bisq.md Normal file
View 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);
```

View File

@ -0,0 +1,748 @@
# mempool**JS** - Bitcoin API
Interface to access Bitcoin `mainet`, `testnet`, `signet` 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 Header](#get-blocks-header)
- [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Difficulty
- [Get Difficulty Adjustment](#get-difficulty-adjustment)
- Fees
- [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- Mempool
- [Get Mempool](#get-mempool)
- [Get Mempool Recent](#get-mempool-recent)
- [Get Mempool Txids](#get-mempool-txids)
- Transactions
- [Get Tx](#get-tx)
- [Get Tx Status](#get-tx-status)
- [Get Tx Hex](#get-tx-hex)
- [Get Tx Raw](#get-tx-raw)
- [Get Tx Merkle Block Proof](#get-tx-merkle-block-proof)
- [Get Tx Merkle Proof](#get-tx-merkle-proof)
- [Get Tx Outspend](#get-tx-outspend)
- [Get Tx Outspends](#get-tx-outspends)
- [Post Tx Outspends]($post-tx-outspends)
- Websocket
- [Websocket Client](#websocket-client)
- [Websocket Server](#websocket-server)
---
### **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/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { addresses },
} = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
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/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { addresses },
} = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
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/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { addresses },
} = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
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/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { addresses },
} = mempoolJS();
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
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/mempool-js/bitcoin/addresses.ts) ] [ [HTML Example](examples/html/mempool-js/bitcoin/addresses.html) ] [ [Top](#features) ]
```js
const { addresses } = mempoolJS();
const addressTxsUtxo = await addresses.getAddressTxsUtxo('15e10745f15593a...');
console.log(addressTxsUtxo);
```
### **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/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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} params.hash
- {number} params.start_index
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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} params.hash
- {number} params.index
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { blocks },
} = mempoolJS();
const hash = '000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
const blockRaw = await blocks.getBlockRaw({ hash });
console.log(blockRaw);
```
### **Get Blocks Header**
Returns the hex-encoded block header.
**Parameters:**
- {string} hash
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { blocks },
} = mempoolJS();
const blockHeader = await blocks.getBlockHeader({ hash: '0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2' });
console.log(blockHeader);
```
### **Get Blocks Height**
Returns the hash of the block currently at `:height`.
**Parameters:**
- {number} height
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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} params.start_height
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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} params.start_height
[ [NodeJS Example](examples/nodejs/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/blocks.ts) ] [ [HTML Example](examples/html/bitcoin/blocks.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { blocks },
} = mempoolJS();
const blocksTipHash = await blocks.getBlocksTipHash();
console.log(blocksTipHash);
```
### **Get Difficulty Adjustment**
Returns the hash of the last block.
[ [NodeJS Example](examples/nodejs/bitcoin/difficulty.ts) ] [ [HTML Example](examples/html/bitcoin/difficulty.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { difficulty },
} = mempoolJS();
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
console.log(difficultyAdjustment);
```
### **Get Fees Recommended**
Returns our currently suggested fees for new transactions.
[ [NodeJS Example](examples/nodejs/bitcoin/fees.ts) ] [ [HTML Example](examples/html/bitcoin/fees.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { fees },
} = mempoolJS();
const feesRecommended = await fees.getFeesRecommended();
console.log(feesRecommended);
```
### **Get Fees Mempool Blocks**
Returns current mempool as projected blocks.
[ [NodeJS Example](examples/nodejs/bitcoin/fees.ts) ] [ [HTML Example](examples/html/bitcoin/fees.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { fees },
} = mempoolJS();
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
console.log(feesMempoolBlocks);
```
### **Get Children Pay for Parent**
Returns current mempool as projected blocks.
[ [NodeJS Example](examples/nodejs/bitcoin/fees.ts) ] [ [HTML Example](examples/html/bitcoin/fees.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { fees },
} = mempoolJS();
const txid = 'txid';
const feesCPFP = await fees.getCPFP({ txid });
console.log(feesCPFP);
```
### **Get Mempool**
Returns current mempool backlog statistics.
[ [NodeJS Example](examples/nodejs/bitcoin/mempool.ts) ] [ [HTML Example](examples/html/bitcoin/mempool.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/mempool.ts) ] [ [HTML Example](examples/html/bitcoin/mempool.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/mempool.ts) ] [ [HTML Example](examples/html/bitcoin/mempool.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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} params.txid
- {number} params.vout
[ [NodeJS Example](examples/nodejs/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/transactions.ts) ] [ [HTML Example](examples/html/bitcoin/transactions.html) ] [ [Top](#features) ]
```js
const {
bitcoin: { 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/bitcoin/websocket.ts) ] [ [HTML Example](examples/html/bitcoin/websocket.html) ] [ [Top](#features) ]
#### **Websocket Server**
Only use on server side apps.
```js
const { bitcoin: { websocket } } = mempoolJS();
const init = async () => {
const ws = websocket.initServer({
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
});
ws.on("message", function incoming(data) {
const res = JSON.parse(data.toString());
if (res.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
}
init();
```
#### **Websocket Client**
Only use on browser apps.
```js
const init = async () => {
const {
bitcoin: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.addEventListener('message', function incoming({data}) {
const res = JSON.parse(data.toString());
if (res.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
};
init();
```

765
mempool.js/README-liquid.md Normal file
View File

@ -0,0 +1,765 @@
# mempool**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 Icon](#get-asset-icon)
- [Get Asset Txs](#get-asset-txs)
- [Get Asset Supply](#get-asset-supply)
- [Get Assets Icons](#get-assets-icons)
- Blocks
- [Get Block](#get-block)
- [Get Block Status](#get-block-status)
- [Get Block Txs](#get-block-txs)
- [Get Block Txids](#get-block-txids)
- [Get Block Txid](#get-block-txid)
- [Get Block Raw](#get-block-raw)
- [Get Blocks Height](#get-blocks-height)
- [Get Blocks](#get-blocks)
- [Get Blocks Tip Height](#get-blocks-tip-height)
- [Get Blocks Tip Hash](#get-blocks-tip-hash)
- Fees
- [Get Fees Recommended](#get-fees-recommended)
- [Get Fees Mempool Blocks](#get-fees-mempool-blocks)
- Mempool
- [Get Mempool](#get-mempool)
- [Get Mempool Recent](#get-mempool-recent)
- [Get Mempool Txids](#get-mempool-txids)
- Transactions
- [Get Tx](#get-tx)
- [Get Tx Status](#get-tx-status)
- [Get Tx Hex](#get-tx-hex)
- [Get Tx Raw](#get-tx-raw)
- [Get Tx Merkle 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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/addresses.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/blocks.ts) ] [ [HTML Example](examples/html/liquid/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/fees.ts) ] [ [HTML Example](examples/html/liquid/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/fees.ts) ] [ [HTML Example](examples/html/liquid/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/mempool.ts) ] [ [HTML Example](examples/html/liquid/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/mempool.ts) ] [ [HTML Example](examples/html/liquid/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/mempool.ts) ] [ [HTML Example](examples/html/liquid/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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/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.
**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 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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/transactions.ts) ] [ [HTML Example](examples/html/liquid/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/websocket.ts) ] [ [HTML Example](examples/html/liquid/websocket.html) ] [ [Top](#features) ]
#### **Websocket Server**
Only use on server side apps.
```js
const { liquid: { websocket } } = mempoolJS();
const init = async () => {
const ws = websocket.initServer({
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
});
ws.on("message", function incoming(data) {
const res = JSON.parse(data.toString());
if (res.blocks) {
console.log(res.blocks);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
}
init();
```
#### **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();
```

102
mempool.js/README.md Normal file
View File

@ -0,0 +1,102 @@
# Mempool JS API
[![npm version](https://img.shields.io/npm/v/@mempool/mempool.js.svg?style=flat-square)](https://www.npmjs.org/package/@mempool/mempool.js)
[![NPM](https://img.shields.io/david/mempool/mempool.js.svg?style=flat-square)](https://david-dm.org/mempool/mempool.js#info=dependencies)
[![Known Vulnerabilities](https://snyk.io/test/github/mempool/mempool.js/badge.svg?style=flat-square)](https://snyk.io/test/github/mempool/mempool.js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
NPM package module for Mempool APIs.
Documentation: [https://mempool.space/api](https://mempool.space/api)
---
## **Installation**
### **ES Modules**
Install the npm module.
```bash
# npm
$ npm install @mempool/mempool.js --save
# yarn
$ yarn add @mempool/mempool.js
```
Or if you're not into package management, just [download a ZIP](https://github.com/mempool/mempool.js/archive/refs/heads/main.zip) file.
Import the module.
```js
import mempoolJS from '@mempool/mempool.js';
// default mempool.space endpoints
const { bitcoin, bisq, liquid } = mempoolJS();
// (optional) your custom endpoints
const { bitcoin, bisq, liquid } = mempoolJS({
hostname: 'mempool.space',
network: 'testnet' // 'signet' | 'testnet' | 'mainnet'
});
```
### **CommonJS**
Include the line below in the `head` tag of your html file.
```html
<script type="text/javascript" src="https://mempool.space/mempool.js"></script>
```
Call `mempoolJS()` function to access the API methods.
```js
// default mempool.space endpoints
const { bitcoin, bisq, liquid } = mempoolJS();
// (optional) your custom endpoints
const { bitcoin, bisq, liquid } = mempoolJS({
hostname: 'mempool.space',
network: 'testnet' // 'signet' | 'testnet' | 'mainnet'
});
```
---
## **Features**
- [Bitcoin](./README-bitcoin.md)
- [Addresses](./README-bitcoin.md#get-address)
- [Blocks](./README-bitcoin.md#get-blocks)
- [Difficulty Adjustment](./README-bitcoin.md#get-difficulty-adjustment)
- [Fees](./README-bitcoin.md#get-fees)
- [Mempool](./README-bitcoin.md#get-mempool)
- [Transactions](./README-bitcoin.md#get-transactions)
- [Websocket Client](./README-bitcoin.md#Websocket-Client)
- [Websocket Server](./README-bitcoin.md#Websocket-Server)
- [Bisq](./README-bisq.md#get-address)
- [Addresses](./README-bisq.md#get-address)
- [Blocks](./README-bisq.md#get-blocks)
- [Statistics](./README-bisq.md#get-statistics)
- [Transactions](./README-bisq.md#get-transactions)
- [Liquid](./README-liquid.md#get-address)
- [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/)

0
mempool.js/dist/.gitkeep vendored Normal file
View File

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View File

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

View 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>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
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();
</script>
</head>
<body></body>
</html>

View 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>

View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
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();
</script>
</head>
<body></body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
liquid: { assets },
} = mempoolJS();
const asset_id = 'a0c358a0f6947864af3a06f3f6a2aeb304df7fd95c922f2f22d7412399ce7691';
const asset = await assets.getAsset({ asset_id });
console.log(asset);
const assetTxs = await assets.getAssetTxs({
asset_id,
is_mempool: false,
});
console.log(assetTxs);
const assetSupply = await assets.getAssetSupply({
asset_id,
decimal: false,
});
console.log(assetSupply);
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>

View File

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

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
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();
</script>
</head>
<body></body>
</html>

View File

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

View File

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

View 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>

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View File

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

View File

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

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View File

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

View File

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

View File

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

View File

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

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View 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();

View File

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

View File

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

View 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
mempool.js/nodemon.json Normal file
View File

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

6
mempool.js/npm-bisq-js/.gitignore vendored Normal file
View File

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

View 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);
```

View File

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

View File

@ -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
mempool.js/npm-liquid-js/.gitignore vendored Normal file
View File

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

View 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();
```

View File

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

View File

@ -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"
}

10467
mempool.js/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

62
mempool.js/package.json Normal file
View File

@ -0,0 +1,62 @@
{
"name": "@mempool/mempool.js",
"version": "2.3.0",
"description": "NPM package module for Mempool APIs.",
"main": "lib/index.js",
"keywords": [
"axios",
"bitcoin",
"bisq",
"liquid",
"mainet",
"testnet",
"signet",
"blockchain",
"html",
"mempool.space",
"mempool.js",
"mempool",
"websocket",
"nodejs",
"typescript"
],
"author": "Miguel Medeiros <contact@miguelmedeiros.com.br> (miguelmedeiros.com.br)",
"url": "https://mempool.space/",
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/mempool/mempool.js.git"
},
"types": "lib/index.d.ts",
"scripts": {
"start": "ts-node src/index.ts",
"dev": "nodemon src/index.ts",
"build": "tsc",
"export-mempool-js": "tsc | browserify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify lib/index.js --standalone mempoolJS > dist/mempool.min.js",
"export-bisq-js": "tsc | browserify lib/index-bisq.js --standalone bisqJS > dist/bisq.js | browserify -p tinyify lib/index-bisq.js --standalone bisqJS > dist/bisq.min.js",
"export-liquid-js": "tsc | browserify lib/index-liquid.js --standalone liquidJS > dist/liquid.js | browserify -p tinyify lib/index-liquid.js --standalone liquidJS > dist/liquid.min.js",
"prepare": "npm run build",
"postversion": "git push && git push --tags"
},
"files": [
"lib/**/*"
],
"dependencies": {
"axios": "0.24.0",
"ws": "8.3.0"
},
"devDependencies": {
"@types/node": "^14.14.25",
"@types/websocket": "^1.0.2",
"@types/ws": "^7.4.1",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"browserify": "^17.0.0",
"eslint": "^7.19.0",
"nodemon": "^2.0.7",
"tinyify": "^3.0.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},
"license": "MIT"
}

View File

@ -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,
};
};

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,48 @@
import { AxiosInstance } from 'axios';
import {
Address,
AddressTxsUtxo,
AddressInstance,
} from '../../interfaces/bitcoin/addresses';
import { Tx } from '../../interfaces/bitcoin/transactions';
export const useAddresses = (api: AxiosInstance): AddressInstance => {
const getAddress = async (params: { address: string }) => {
const { data } = await api.get<Address>(`/address/${params.address}`);
return data;
};
const getAddressTxs = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
return data;
};
const getAddressTxsChain = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(
`/address/${params.address}/txs/chain`
);
return data;
};
const getAddressTxsMempool = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(
`/address/${params.address}/txs/mempool`
);
return data;
};
const getAddressTxsUtxo = async (params: { address: string }) => {
const { data } = await api.get<AddressTxsUtxo[]>(
`/address/${params.address}/utxo`
);
return data;
};
return {
getAddress,
getAddressTxs,
getAddressTxsChain,
getAddressTxsMempool,
getAddressTxsUtxo,
};
};

View File

@ -0,0 +1,85 @@
import { AxiosInstance } from 'axios';
import {
Block,
BlockStatus,
BlockInstance,
} from '../../interfaces/bitcoin/blocks';
import { Tx } from '../../interfaces/bitcoin/transactions';
export const useBlocks = (api: AxiosInstance): BlockInstance => {
const getBlock = async (params: { hash: string }) => {
const { data } = await api.get<Block>(`/block/${params.hash}`);
return data;
};
const getBlockStatus = async (params: { hash: string }) => {
const { data } = await api.get<BlockStatus>(`/block/${params.hash}/status`);
return data;
};
const getBlockTxs = async (params: {
hash: string;
start_index?: number;
}) => {
const { data } = await api.get<Tx>(
`/block/${params.hash}/txs/${params.start_index}`
);
return data;
};
const getBlockTxids = async (params: { hash: string }) => {
const { data } = await api.get<string[]>(`/block/${params.hash}/txids`);
return data;
};
const getBlockTxid = async (params: { hash: string; index: number }) => {
const { data } = await api.get<string>(
`/block/${params.hash}/txid/${params.index}`
);
return data;
};
const getBlockRaw = async (params: { hash: string }) => {
const { data } = await api.get<string>(`/block/${params.hash}/raw`);
return data;
};
const getBlockHeader = async (params: { hash: string }) => {
const { data } = await api.get<string>(`/block/${params.hash}/header`);
return data;
};
const getBlockHeight = async (params: { height: number }) => {
const { data } = await api.get<string>(`/block-height/${params.height}`);
return data;
};
const getBlocks = async (params: { start_height?: number }) => {
const { data } = await api.get<Block>(`/blocks/${params.start_height}`);
return data;
};
const getBlocksTipHeight = async () => {
const { data } = await api.get<number>(`/blocks/tip/height`);
return data;
};
const getBlocksTipHash = async () => {
const { data } = await api.get<string>(`/blocks/tip/hash`);
return data;
};
return {
getBlock,
getBlocks,
getBlockStatus,
getBlockTxs,
getBlockTxid,
getBlockTxids,
getBlockRaw,
getBlockHeader,
getBlockHeight,
getBlocksTipHash,
getBlocksTipHeight,
};
};

View File

@ -0,0 +1,16 @@
import { AxiosInstance } from 'axios';
import {
Adjustment,
DifficultyInstance,
} from '../../interfaces/bitcoin/difficulty';
export const useDifficulty = (api: AxiosInstance): DifficultyInstance => {
const getDifficultyAdjustment = async () => {
const { data } = await api.get<Adjustment>(`/v1/difficulty-adjustment`);
return data;
};
return {
getDifficultyAdjustment,
};
};

View File

@ -0,0 +1,33 @@
import { AxiosInstance } from 'axios';
import {
FeesRecommended,
FeesMempoolBlocks,
FeeInstance,
} from '../../interfaces/bitcoin/fees';
export const useFees = (api: AxiosInstance): FeeInstance => {
const getFeesRecommended = async () => {
const { data } = await api.get<FeesRecommended>(`/v1/fees/recommended`);
return data;
};
const getFeesMempoolBlocks = async () => {
const { data } = await api.get<FeesMempoolBlocks[]>(
`/v1/fees/mempool-blocks`
);
return data;
};
const getCPFP = async (params: { txid: string }) => {
const { data } = await api.get<FeesMempoolBlocks[]>(
`/v1/cpfp/${params.txid}`
);
return data;
};
return {
getFeesRecommended,
getFeesMempoolBlocks,
getCPFP,
};
};

View File

@ -0,0 +1,29 @@
import { AxiosInstance } from 'axios';
import {
Mempool,
MempoolRecent,
MempoolInstance,
} from '../../interfaces/bitcoin/mempool';
export const useMempool = (api: AxiosInstance): MempoolInstance => {
const getMempool = async () => {
const { data } = await api.get<Mempool[]>(`/mempool`);
return data;
};
const getMempoolTxids = async () => {
const { data } = await api.get<string[]>(`/mempool/txids`);
return data;
};
const getMempoolRecent = async () => {
const { data } = await api.get<MempoolRecent[]>(`/mempool/recent`);
return data;
};
return {
getMempool,
getMempoolTxids,
getMempoolRecent,
};
};

View File

@ -0,0 +1,75 @@
import { AxiosInstance } from 'axios';
import {
Tx,
TxStatus,
TxMerkleProof,
TxOutspend,
TxInstance,
} from '../../interfaces/bitcoin/transactions';
export const useTransactions = (api: AxiosInstance): TxInstance => {
const getTx = async (params: { txid: string }) => {
const { data } = await api.get<Tx>(`/tx/${params.txid}`);
return data;
};
const getTxStatus = async (params: { txid: string }) => {
const { data } = await api.get<TxStatus>(`/tx/${params.txid}/status`);
return data;
};
const getTxHex = async (params: { txid: string }) => {
const { data } = await api.get<string>(`/tx/${params.txid}/hex`);
return data;
};
const getTxRaw = async (params: { txid: string }) => {
const { data } = await api.get<string>(`/tx/${params.txid}/raw`);
return data;
};
const getTxMerkleBlockProof = async (params: { txid: string }) => {
const { data } = await api.get<string>(
`/tx/${params.txid}/merkleblock-proof`
);
return data;
};
const getTxMerkleProof = async (params: { txid: string }) => {
const { data } = await api.get<Array<TxMerkleProof>>(
`/tx/${params.txid}/merkle-proof`
);
return data;
};
const getTxOutspend = async (params: { txid: string; vout: number }) => {
const { data } = await api.get<TxOutspend>(
`/tx/${params.txid}/outspend/${params.vout}`
);
return data;
};
const getTxOutspends = async (params: { txid: string }) => {
const { data } = await api.get<Array<TxOutspend>>(
`/tx/${params.txid}/outspends`
);
return data;
};
const postTx = async (params: { txhex: string }) => {
const { data } = await api.post<string>(`/tx`, { txhex: params.txhex });
return data;
};
return {
getTx,
getTxStatus,
getTxHex,
getTxRaw,
getTxMerkleBlockProof,
getTxMerkleProof,
getTxOutspend,
getTxOutspends,
postTx,
};
};

View File

@ -0,0 +1,14 @@
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): WsInstance => {
const wsEndpoint = `wss://${hostname}${network === 'main' ? '' : `/${network}`}/api/v1/ws`;
return {
initClient: ({ options }: WsInterface) =>
wsClient(options, wsEndpoint),
initServer: ({ options }: WsInterface) =>
wsServer(options, wsEndpoint),
};
};

View File

@ -0,0 +1,48 @@
import { AxiosInstance } from 'axios';
import {
Address,
AddressTxsUtxo,
AddressInstance,
} from '../../interfaces/bitcoin/addresses';
import { Tx } from '../../interfaces/bitcoin/transactions';
export const useAddresses = (api: AxiosInstance): AddressInstance => {
const getAddress = async (params: { address: string }) => {
const { data } = await api.get<Address>(`/address/${params.address}`);
return data;
};
const getAddressTxs = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(`/address/${params.address}/txs`);
return data;
};
const getAddressTxsChain = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(
`/address/${params.address}/txs/chain`
);
return data;
};
const getAddressTxsMempool = async (params: { address: string }) => {
const { data } = await api.get<Tx[]>(
`/address/${params.address}/txs/mempool`
);
return data;
};
const getAddressTxsUtxo = async (params: { address: string }) => {
const { data } = await api.get<AddressTxsUtxo[]>(
`/address/${params.address}/utxo`
);
return data;
};
return {
getAddress,
getAddressTxs,
getAddressTxsChain,
getAddressTxsMempool,
getAddressTxsUtxo,
};
};

View File

@ -0,0 +1,49 @@
import { AxiosInstance } from 'axios';
import { Asset, AssetsInstance } from '../../interfaces/liquid/assets';
export const useAssets = (api: AxiosInstance): AssetsInstance => {
const getAsset = async (params: { asset_id: string }) => {
const { data } = await api.get<Asset>(`/asset/${params.asset_id}`);
return data;
};
const getAssetIcon = async (params: { asset_id: string }) => {
const { data } = await api.get(`/v1/asset/${params.asset_id}/icon`);
return data;
};
const getAssetTxs = async (params: {
asset_id: string;
is_mempool: boolean;
}) => {
const paramsMempools = params.is_mempool === true ? '/mempool' : '/chain';
const { data } = await api.get<Asset>(
`/asset/${params.asset_id}/txs${paramsMempools}`
);
return data;
};
const getAssetSupply = async (params: {
asset_id: string;
decimal: boolean;
}) => {
const paramDecimal = params.decimal === true ? '/decimal' : '';
const { data } = await api.get<Asset>(
`/asset/${params.asset_id}/supply${paramDecimal}`
);
return data;
};
const getAssetsIcons = async () => {
const { data } = await api.get<string[]>(`/v1/assets/icons`);
return data;
};
return {
getAsset,
getAssetIcon,
getAssetTxs,
getAssetSupply,
getAssetsIcons,
};
};

View File

@ -0,0 +1,79 @@
import { AxiosInstance } from 'axios';
import {
Block,
BlockStatus,
BlockLiquidInstance,
} 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>(`/block/${params.hash}`);
return data;
};
const getBlockStatus = async (params: { hash: string }) => {
const { data } = await api.get<BlockStatus>(`/block/${params.hash}/status`);
return data;
};
const getBlockTxs = async (params: {
hash: string;
start_index?: number;
}) => {
const { data } = await api.get<Tx>(
`/block/${params.hash}/txs/${params.start_index}`
);
return data;
};
const getBlockTxids = async (params: { hash: string }) => {
const { data } = await api.get<string[]>(`/block/${params.hash}/txids`);
return data;
};
const getBlockTxid = async (params: { hash: string; index: number }) => {
const { data } = await api.get<string>(
`/block/${params.hash}/txid/${params.index}`
);
return data;
};
const getBlockRaw = async (params: { hash: string }) => {
const { data } = await api.get<string>(`/block/${params.hash}/raw`);
return data;
};
const getBlockHeight = async (params: { height: number }) => {
const { data } = await api.get<string>(`/block-height/${params.height}`);
return data;
};
const getBlocks = async (params: { start_height?: number }) => {
const { data } = await api.get<Block>(`/blocks/${params.start_height}`);
return data;
};
const getBlocksTipHeight = async () => {
const { data } = await api.get<number>(`/blocks/tip/height`);
return data;
};
const getBlocksTipHash = async () => {
const { data } = await api.get<string>(`/blocks/tip/hash`);
return data;
};
return {
getBlock,
getBlocks,
getBlockStatus,
getBlockTxs,
getBlockTxid,
getBlockTxids,
getBlockRaw,
getBlockHeight,
getBlocksTipHash,
getBlocksTipHeight,
};
};

View File

@ -0,0 +1,33 @@
import { AxiosInstance } from 'axios';
import {
FeesRecommended,
FeesMempoolBlocks,
FeeInstance,
} from '../../interfaces/bitcoin/fees';
export const useFees = (api: AxiosInstance): FeeInstance => {
const getFeesRecommended = async () => {
const { data } = await api.get<FeesRecommended>(`/v1/fees/recommended`);
return data;
};
const getFeesMempoolBlocks = async () => {
const { data } = await api.get<FeesMempoolBlocks[]>(
`/v1/fees/mempool-blocks`
);
return data;
};
const getCPFP = async (params: { txid: string }) => {
const { data } = await api.get<FeesMempoolBlocks[]>(
`/v1/cpfp/${params.txid}`
);
return data;
};
return {
getFeesRecommended,
getFeesMempoolBlocks,
getCPFP,
};
};

View File

@ -0,0 +1,29 @@
import { AxiosInstance } from 'axios';
import {
Mempool,
MempoolRecent,
MempoolInstance,
} from '../../interfaces/bitcoin/mempool';
export const useMempool = (api: AxiosInstance): MempoolInstance => {
const getMempool = async () => {
const { data } = await api.get<Mempool[]>(`/mempool`);
return data;
};
const getMempoolTxids = async () => {
const { data } = await api.get<string[]>(`/mempool/txids`);
return data;
};
const getMempoolRecent = async () => {
const { data } = await api.get<MempoolRecent[]>(`/mempool/recent`);
return data;
};
return {
getMempool,
getMempoolTxids,
getMempoolRecent,
};
};

View File

@ -0,0 +1,75 @@
import { AxiosInstance } from 'axios';
import {
Tx,
TxStatus,
TxMerkleProof,
TxOutspend,
TxInstance,
} from '../../interfaces/bitcoin/transactions';
export const useTransactions = (api: AxiosInstance): TxInstance => {
const getTx = async (params: { txid: string }) => {
const { data } = await api.get<Tx>(`/tx/${params.txid}`);
return data;
};
const getTxStatus = async (params: { txid: string }) => {
const { data } = await api.get<TxStatus>(`/tx/${params.txid}/status`);
return data;
};
const getTxHex = async (params: { txid: string }) => {
const { data } = await api.get<string>(`/tx/${params.txid}/hex`);
return data;
};
const getTxRaw = async (params: { txid: string }) => {
const { data } = await api.get<string>(`/tx/${params.txid}/raw`);
return data;
};
const getTxMerkleBlockProof = async (params: { txid: string }) => {
const { data } = await api.get<string>(
`/tx/${params.txid}/merkleblock-proof`
);
return data;
};
const getTxMerkleProof = async (params: { txid: string }) => {
const { data } = await api.get<Array<TxMerkleProof>>(
`/tx/${params.txid}/merkle-proof`
);
return data;
};
const getTxOutspend = async (params: { txid: string; vout: number }) => {
const { data } = await api.get<TxOutspend>(
`/tx/${params.txid}/outspend/${params.vout}`
);
return data;
};
const getTxOutspends = async (params: { txid: string }) => {
const { data } = await api.get<Array<TxOutspend>>(
`/tx/${params.txid}/outspends`
);
return data;
};
const postTx = async (params: { txhex: string }) => {
const { data } = await api.post<string>(`/tx`, { txid: params.txhex });
return data;
};
return {
getTx,
getTxStatus,
getTxHex,
getTxRaw,
getTxMerkleBlockProof,
getTxMerkleProof,
getTxOutspend,
getTxOutspends,
postTx,
};
};

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