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>
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { addresses } = mempoolJS();
|
||||
|
||||
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
|
||||
|
||||
const addressTest = await addresses.getAddress(address);
|
||||
console.log(addressTest);
|
||||
|
||||
const addressTxs = await addresses.getAddressTxs(address);
|
||||
console.log(addressTxs);
|
||||
|
||||
const addressTxsChain = await addresses.getAddressTxsChain(address);
|
||||
console.log(addressTxsChain);
|
||||
|
||||
const addressTxsMempool = await addresses.getAddressTxsMempool(address);
|
||||
console.log(addressTxsMempool);
|
||||
|
||||
const addressTxsUtxo = await addresses.getAddressTxsUtxo(address);
|
||||
console.log(addressTxsUtxo);
|
||||
};
|
||||
init();
|
||||
13
examples/nodejs/bisq/addresses.ts
Normal file
13
examples/nodejs/bisq/addresses.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { addresses },
|
||||
} = mempoolJS();
|
||||
|
||||
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
|
||||
|
||||
const myAddress = await addresses.getAddress({ address });
|
||||
console.log(myAddress);
|
||||
};
|
||||
init();
|
||||
23
examples/nodejs/bisq/blocks.ts
Normal file
23
examples/nodejs/bisq/blocks.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
|
||||
console.log(myBlocks);
|
||||
|
||||
const myBlocksHeight = await blocks.getBlocksTipHeight({
|
||||
index: 0,
|
||||
length: 1,
|
||||
});
|
||||
console.log(myBlocksHeight);
|
||||
};
|
||||
init();
|
||||
11
examples/nodejs/bisq/statistics.ts
Normal file
11
examples/nodejs/bisq/statistics.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { statistics },
|
||||
} = mempoolJS();
|
||||
|
||||
const stats = await statistics.getStats();
|
||||
console.log(stats);
|
||||
};
|
||||
init();
|
||||
17
examples/nodejs/bisq/transactions.ts
Normal file
17
examples/nodejs/bisq/transactions.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
|
||||
const txs = await transactions.getTxs({ index: 0, length: 1 });
|
||||
console.log(txs);
|
||||
};
|
||||
init();
|
||||
25
examples/nodejs/bitcoin/addresses.ts
Normal file
25
examples/nodejs/bitcoin/addresses.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bitcoin: { addresses },
|
||||
} = mempoolJS();
|
||||
|
||||
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
|
||||
|
||||
const myAddress = await addresses.getAddress({ address });
|
||||
console.log(myAddress);
|
||||
|
||||
const addressTxs = await addresses.getAddressTxs({ address });
|
||||
console.log(addressTxs);
|
||||
|
||||
const addressTxsChain = await addresses.getAddressTxsChain({ address });
|
||||
console.log(addressTxsChain);
|
||||
|
||||
const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
|
||||
console.log(addressTxsMempool);
|
||||
|
||||
const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address });
|
||||
console.log(addressTxsUtxo);
|
||||
};
|
||||
init();
|
||||
41
examples/nodejs/bitcoin/blocks.ts
Normal file
41
examples/nodejs/bitcoin/blocks.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
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 blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
console.log(getBlocks);
|
||||
|
||||
const blocksTipHeight = await blocks.getBlocksTipHeight();
|
||||
console.log(blocksTipHeight);
|
||||
|
||||
const blocksTipHash = await blocks.getBlocksTipHash();
|
||||
console.log(blocksTipHash);
|
||||
};
|
||||
init();
|
||||
19
examples/nodejs/bitcoin/fees.ts
Normal file
19
examples/nodejs/bitcoin/fees.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bitcoin: { fees },
|
||||
} = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
|
||||
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
|
||||
console.log(feesMempoolBlocks);
|
||||
|
||||
const txid = 'txid';
|
||||
|
||||
const feesCPFP = await fees.getCPFP({ txid });
|
||||
console.log(feesCPFP);
|
||||
};
|
||||
init();
|
||||
17
examples/nodejs/bitcoin/mempool.ts
Normal file
17
examples/nodejs/bitcoin/mempool.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bitcoin: { mempool },
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
|
||||
const getMempoolRecent = await mempool.getMempoolRecent();
|
||||
console.log(getMempoolRecent);
|
||||
|
||||
const getMempoolTxids = await mempool.getMempoolTxids();
|
||||
console.log(getMempoolTxids);
|
||||
};
|
||||
init();
|
||||
41
examples/nodejs/bitcoin/transactions.ts
Normal file
41
examples/nodejs/bitcoin/transactions.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
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({ txid });
|
||||
// console.log(postTx);
|
||||
};
|
||||
init();
|
||||
@@ -1,8 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import mempoolJS from '../../src/index';
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { websocket } = mempoolJS();
|
||||
const {
|
||||
bitcoin: { websocket },
|
||||
} = mempoolJS();
|
||||
|
||||
const ws = websocket.initServer({
|
||||
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
|
||||
@@ -11,9 +12,7 @@ const init = async () => {
|
||||
ws.on('message', function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
res.blocks.forEach((block: { height: any }) => {
|
||||
console.log(block.height);
|
||||
});
|
||||
console.log(res.blocks);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
25
examples/nodejs/liquid/addresses.ts
Normal file
25
examples/nodejs/liquid/addresses.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { addresses },
|
||||
} = mempoolJS();
|
||||
|
||||
const address = '1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC';
|
||||
|
||||
const myAddress = await addresses.getAddress({ address });
|
||||
console.log(myAddress);
|
||||
|
||||
const addressTxs = await addresses.getAddressTxs({ address });
|
||||
console.log(addressTxs);
|
||||
|
||||
const addressTxsChain = await addresses.getAddressTxsChain({ address });
|
||||
console.log(addressTxsChain);
|
||||
|
||||
const addressTxsMempool = await addresses.getAddressTxsMempool({ address });
|
||||
console.log(addressTxsMempool);
|
||||
|
||||
const addressTxsUtxo = await addresses.getAddressTxsUtxo({ address });
|
||||
console.log(addressTxsUtxo);
|
||||
};
|
||||
init();
|
||||
20
examples/nodejs/liquid/assets.ts
Normal file
20
examples/nodejs/liquid/assets.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
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);
|
||||
};
|
||||
init();
|
||||
@@ -1,30 +1,32 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { blocks } = mempoolJS();
|
||||
const {
|
||||
liquid: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
|
||||
|
||||
const block = await blocks.getBlock(hash);
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const blockStatus = await blocks.getBlockStatus(hash);
|
||||
const blockStatus = await blocks.getBlockStatus({ hash });
|
||||
console.log(blockStatus);
|
||||
|
||||
const blockTxs = await blocks.getBlockTxs({ hash });
|
||||
console.log(blockTxs);
|
||||
|
||||
const blockTxids = await blocks.getBlockTxids(hash);
|
||||
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);
|
||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||
console.log(blockRaw);
|
||||
|
||||
const blockHeight = await blocks.getBlockHeight(9999);
|
||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
@@ -1,7 +1,9 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { fees } = mempoolJS();
|
||||
const {
|
||||
liquid: { fees },
|
||||
} = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
@@ -1,7 +1,9 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { mempool } = mempoolJS();
|
||||
const {
|
||||
liquid: { mempool },
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
41
examples/nodejs/liquid/transactions.ts
Normal file
41
examples/nodejs/liquid/transactions.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
|
||||
const txStatus = await transactions.getTxStatus({ txid });
|
||||
console.log(txStatus);
|
||||
|
||||
const txHex = await transactions.getTxHex({ txid });
|
||||
console.log(txHex);
|
||||
|
||||
const txRaw = await transactions.getTxRaw({ txid });
|
||||
console.log(txRaw);
|
||||
|
||||
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid });
|
||||
console.log(txMerkleBlockProof);
|
||||
|
||||
const txMerkleProof = await transactions.getTxMerkleProof({ txid });
|
||||
console.log(txMerkleProof);
|
||||
|
||||
const txOutspend = await transactions.getTxOutspend({
|
||||
txid,
|
||||
vout: 3,
|
||||
});
|
||||
console.log(txOutspend);
|
||||
|
||||
const txOutspends = await transactions.getTxOutspends({ txid });
|
||||
console.log(txOutspends);
|
||||
|
||||
// const postTx = await transactions.postTx({ txid });
|
||||
// console.log(postTx);
|
||||
};
|
||||
init();
|
||||
28
examples/nodejs/liquid/websocket.ts
Normal file
28
examples/nodejs/liquid/websocket.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import mempoolJS from '../../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { websocket },
|
||||
} = mempoolJS();
|
||||
|
||||
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();
|
||||
@@ -1,39 +0,0 @@
|
||||
import mempoolJS from '../../src/index';
|
||||
|
||||
const init = async () => {
|
||||
const { transactions } = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const tx = await transactions.getTx(txid);
|
||||
console.log(tx);
|
||||
|
||||
const txStatus = await transactions.getTxStatus(txid);
|
||||
console.log(txStatus);
|
||||
|
||||
const txHex = await transactions.getTxHex(txid);
|
||||
console.log(txHex);
|
||||
|
||||
const txRaw = await transactions.getTxRaw(txid);
|
||||
console.log(txRaw);
|
||||
|
||||
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof(txid);
|
||||
console.log(txMerkleBlockProof);
|
||||
|
||||
const txMerkleProof = await transactions.getTxMerkleProof(txid);
|
||||
console.log(txMerkleProof);
|
||||
|
||||
const txOutspend = await transactions.getTxOutspend({
|
||||
txid,
|
||||
vout: 3,
|
||||
});
|
||||
console.log(txOutspend);
|
||||
|
||||
const txOutspends = await transactions.getTxOutspends(txid);
|
||||
console.log(txOutspends);
|
||||
|
||||
// const postTx = await transactions.postTx(txid);
|
||||
// console.log(postTx);
|
||||
};
|
||||
init();
|
||||
Reference in New Issue
Block a user