Add bisqJS and liquidJS npm modules.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
import bisqJS from "./../../../src/index-bisq";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { addresses },
|
||||
} = mempoolJS();
|
||||
const { addresses } = bisqJS();
|
||||
|
||||
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
|
||||
|
||||
24
examples/nodejs/bisq-js/blocks.ts
Normal file
24
examples/nodejs/bisq-js/blocks.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import bisqJS from "./../../../src/index-bisq";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const { blocks } = bisqJS();
|
||||
|
||||
const hash = '000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
|
||||
console.log(myBlocks);
|
||||
|
||||
const myBlocksHeight = await blocks.getBlocksTipHeight({
|
||||
index: 0,
|
||||
length: 1,
|
||||
});
|
||||
console.log(myBlocksHeight);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
38
examples/nodejs/bisq-js/markets.ts
Normal file
38
examples/nodejs/bisq-js/markets.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import bisqJS from "./../../../src/index-bisq";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const { markets } = bisqJS();
|
||||
|
||||
const market = "BTC_USD";
|
||||
const basecurrency = "BTC";
|
||||
|
||||
const allMarkets = await markets.getMarkets();
|
||||
console.log(allMarkets);
|
||||
|
||||
const currencies = await markets.getCurrencies();
|
||||
console.log(currencies);
|
||||
|
||||
const depth = await markets.getDepth({ market });
|
||||
console.log(depth)
|
||||
|
||||
const hloc = await markets.getHloc({ market });
|
||||
console.log(hloc);
|
||||
|
||||
const offers = await markets.getOffers({ market });
|
||||
console.log(offers);
|
||||
|
||||
const ticker = await markets.getTicker({ market });
|
||||
console.log(ticker);
|
||||
|
||||
const trades = await markets.getTrades({ market });
|
||||
console.log(trades);
|
||||
|
||||
const volumes = await markets.getVolumes({ basecurrency, market });
|
||||
console.log(volumes);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
13
examples/nodejs/bisq-js/statistics.ts
Normal file
13
examples/nodejs/bisq-js/statistics.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import bisqJS from "./../../../src/index-bisq";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const { statistics } = bisqJS();
|
||||
|
||||
const stats = await statistics.getStats();
|
||||
console.log(stats);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
18
examples/nodejs/bisq-js/transactions.ts
Normal file
18
examples/nodejs/bisq-js/transactions.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import bisqJS from "./../../../src/index-bisq";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const { transactions } = bisqJS();
|
||||
|
||||
const txid = '4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
|
||||
const txs = await transactions.getTxs({ index: 0, length: 1 });
|
||||
console.log(txs);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
@@ -1,23 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
|
||||
console.log(myBlocks);
|
||||
|
||||
const myBlocksHeight = await blocks.getBlocksTipHeight({
|
||||
index: 0,
|
||||
length: 1,
|
||||
});
|
||||
console.log(myBlocksHeight);
|
||||
};
|
||||
init();
|
||||
@@ -1,11 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { statistics },
|
||||
} = mempoolJS();
|
||||
|
||||
const stats = await statistics.getStats();
|
||||
console.log(stats);
|
||||
};
|
||||
init();
|
||||
@@ -1,17 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bisq: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
|
||||
const txs = await transactions.getTxs({ index: 0, length: 1 });
|
||||
console.log(txs);
|
||||
};
|
||||
init();
|
||||
@@ -1,25 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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();
|
||||
@@ -1,44 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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 blockHeader = await blocks.getBlockHeader({ hash });
|
||||
console.log(blockHeader);
|
||||
|
||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
console.log(getBlocks);
|
||||
|
||||
const blocksTipHeight = await blocks.getBlocksTipHeight();
|
||||
console.log(blocksTipHeight);
|
||||
|
||||
const blocksTipHash = await blocks.getBlocksTipHash();
|
||||
console.log(blocksTipHash);
|
||||
};
|
||||
init();
|
||||
@@ -1,11 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
bitcoin: { difficulty },
|
||||
} = mempoolJS();
|
||||
|
||||
const difficultyAdjustment = await difficulty.getDifficultyAdjustment();
|
||||
console.log(difficultyAdjustment);
|
||||
};
|
||||
init();
|
||||
@@ -1,19 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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();
|
||||
@@ -1,17 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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();
|
||||
@@ -1,41 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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,27 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.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.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,19 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const { bitcoin } = mempoolJS({
|
||||
hostname:'localhost:4200'
|
||||
});
|
||||
|
||||
const feesRecommended = await bitcoin.fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
|
||||
const hash = "0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2";
|
||||
const block = await bitcoin.blocks.getBlockHeader({hash});
|
||||
console.log(block);
|
||||
|
||||
const difficultyAdjustment = await bitcoin.difficulty.getDifficultyAdjustment();
|
||||
console.log(difficultyAdjustment);
|
||||
};
|
||||
|
||||
init();
|
||||
29
examples/nodejs/liquid-js/addresses.ts
Normal file
29
examples/nodejs/liquid-js/addresses.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
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);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
24
examples/nodejs/liquid-js/assets.ts
Normal file
24
examples/nodejs/liquid-js/assets.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { assets },
|
||||
} = mempoolJS();
|
||||
|
||||
const asset_id =
|
||||
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
|
||||
|
||||
const asset = await assets.getAsset({ asset_id });
|
||||
console.log(asset);
|
||||
|
||||
const assetTxs = await assets.getAssetTxs({ asset_id, is_mempool: false });
|
||||
console.log(assetTxs);
|
||||
|
||||
const assetSupply = await assets.getAssetSupply({ asset_id, decimal: false });
|
||||
console.log(assetSupply);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
45
examples/nodejs/liquid-js/blocks.ts
Normal file
45
examples/nodejs/liquid-js/blocks.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const blockStatus = await blocks.getBlockStatus({ hash });
|
||||
console.log(blockStatus);
|
||||
|
||||
const blockTxs = await blocks.getBlockTxs({ hash });
|
||||
console.log(blockTxs);
|
||||
|
||||
const blockTxids = await blocks.getBlockTxids({ hash });
|
||||
console.log(blockTxids);
|
||||
|
||||
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
|
||||
console.log(blockTxid);
|
||||
|
||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||
console.log(blockRaw);
|
||||
|
||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
console.log(getBlocks);
|
||||
|
||||
const blocksTipHeight = await blocks.getBlocksTipHeight();
|
||||
console.log(blocksTipHeight);
|
||||
|
||||
const blocksTipHash = await blocks.getBlocksTipHash();
|
||||
console.log(blocksTipHash);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
18
examples/nodejs/liquid-js/fees.ts
Normal file
18
examples/nodejs/liquid-js/fees.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { fees },
|
||||
} = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
|
||||
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
|
||||
console.log(feesMempoolBlocks);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
21
examples/nodejs/liquid-js/mempool.ts
Normal file
21
examples/nodejs/liquid-js/mempool.ts
Normal 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();
|
||||
45
examples/nodejs/liquid-js/transactions.ts
Normal file
45
examples/nodejs/liquid-js/transactions.ts
Normal 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();
|
||||
30
examples/nodejs/liquid-js/websocket.ts
Normal file
30
examples/nodejs/liquid-js/websocket.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const { liquid: { websocket } } = mempoolJS();
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const ws = websocket.initServer({
|
||||
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
|
||||
});
|
||||
|
||||
ws.on("message", function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
console.log(res.blocks);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
}
|
||||
if (res.transactions) {
|
||||
console.log(res.transactions);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
console.log(res.mempoolBlocks);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
init();
|
||||
@@ -1,25 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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();
|
||||
@@ -1,20 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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,41 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const blockStatus = await blocks.getBlockStatus({ hash });
|
||||
console.log(blockStatus);
|
||||
|
||||
const blockTxs = await blocks.getBlockTxs({ hash });
|
||||
console.log(blockTxs);
|
||||
|
||||
const blockTxids = await blocks.getBlockTxids({ hash });
|
||||
console.log(blockTxids);
|
||||
|
||||
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
|
||||
console.log(blockTxid);
|
||||
|
||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||
console.log(blockRaw);
|
||||
|
||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
console.log(getBlocks);
|
||||
|
||||
const blocksTipHeight = await blocks.getBlocksTipHeight();
|
||||
console.log(blocksTipHeight);
|
||||
|
||||
const blocksTipHash = await blocks.getBlocksTipHash();
|
||||
console.log(blocksTipHash);
|
||||
};
|
||||
init();
|
||||
@@ -1,14 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { fees },
|
||||
} = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
|
||||
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
|
||||
console.log(feesMempoolBlocks);
|
||||
};
|
||||
init();
|
||||
@@ -1,17 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
const init = async () => {
|
||||
const {
|
||||
liquid: { mempool },
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
|
||||
const getMempoolRecent = await mempool.getMempoolRecent();
|
||||
console.log(getMempoolRecent);
|
||||
|
||||
const getMempoolTxids = await mempool.getMempoolTxids();
|
||||
console.log(getMempoolTxids);
|
||||
};
|
||||
init();
|
||||
@@ -1,41 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.js";
|
||||
|
||||
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();
|
||||
@@ -1,27 +0,0 @@
|
||||
import mempoolJS from "@mempool/mempool.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();
|
||||
17
examples/nodejs/mempool-js/bisq/addresses.ts
Normal file
17
examples/nodejs/mempool-js/bisq/addresses.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bisq: { addresses },
|
||||
} = mempoolJS();
|
||||
|
||||
const address = 'B1DgwRN92rdQ9xpEVCdXRfgeqGw9X4YtrZz';
|
||||
|
||||
const myAddress = await addresses.getAddress({ address });
|
||||
console.log(myAddress);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
27
examples/nodejs/mempool-js/bisq/blocks.ts
Normal file
27
examples/nodejs/mempool-js/bisq/blocks.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bisq: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000000079aa6bfa46eb8fc20474e8673d6e8a123b211236bf82d';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const myBlocks = await blocks.getBlocks({ index: 0, length: 1 });
|
||||
console.log(myBlocks);
|
||||
|
||||
const myBlocksHeight = await blocks.getBlocksTipHeight({
|
||||
index: 0,
|
||||
length: 1,
|
||||
});
|
||||
console.log(myBlocksHeight);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
40
examples/nodejs/mempool-js/bisq/markets.ts
Normal file
40
examples/nodejs/mempool-js/bisq/markets.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bisq: { markets },
|
||||
} = mempoolJS();
|
||||
|
||||
const market = "BTC_USD";
|
||||
const basecurrency = "BTC";
|
||||
|
||||
const allMarkets = await markets.getMarkets();
|
||||
console.log(allMarkets);
|
||||
|
||||
const currencies = await markets.getCurrencies();
|
||||
console.log(currencies);
|
||||
|
||||
const depth = await markets.getDepth({ market });
|
||||
console.log(depth)
|
||||
|
||||
const hloc = await markets.getHloc({ market });
|
||||
console.log(hloc);
|
||||
|
||||
const offers = await markets.getOffers({ market });
|
||||
console.log(offers);
|
||||
|
||||
const ticker = await markets.getTicker({ market });
|
||||
console.log(ticker);
|
||||
|
||||
const trades = await markets.getTrades({ market });
|
||||
console.log(trades);
|
||||
|
||||
const volumes = await markets.getVolumes({ basecurrency, market });
|
||||
console.log(volumes);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
15
examples/nodejs/mempool-js/bisq/statistics.ts
Normal file
15
examples/nodejs/mempool-js/bisq/statistics.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bisq: { statistics },
|
||||
} = mempoolJS();
|
||||
|
||||
const stats = await statistics.getStats();
|
||||
console.log(stats);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
21
examples/nodejs/mempool-js/bisq/transactions.ts
Normal file
21
examples/nodejs/mempool-js/bisq/transactions.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bisq: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
|
||||
const txs = await transactions.getTxs({ index: 0, length: 1 });
|
||||
console.log(txs);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
27
examples/nodejs/mempool-js/bitcoin/addresses.ts
Normal file
27
examples/nodejs/mempool-js/bitcoin/addresses.ts
Normal 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();
|
||||
49
examples/nodejs/mempool-js/bitcoin/blocks.ts
Normal file
49
examples/nodejs/mempool-js/bitcoin/blocks.ts
Normal 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();
|
||||
|
||||
15
examples/nodejs/mempool-js/bitcoin/difficulty.ts
Normal file
15
examples/nodejs/mempool-js/bitcoin/difficulty.ts
Normal 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();
|
||||
23
examples/nodejs/mempool-js/bitcoin/fees.ts
Normal file
23
examples/nodejs/mempool-js/bitcoin/fees.ts
Normal 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();
|
||||
21
examples/nodejs/mempool-js/bitcoin/mempool.ts
Normal file
21
examples/nodejs/mempool-js/bitcoin/mempool.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bitcoin: { mempool },
|
||||
} = mempoolJS();
|
||||
|
||||
const getMempool = await mempool.getMempool();
|
||||
console.log(getMempool);
|
||||
|
||||
const getMempoolRecent = await mempool.getMempoolRecent();
|
||||
console.log(getMempoolRecent);
|
||||
|
||||
const getMempoolTxids = await mempool.getMempoolTxids();
|
||||
console.log(getMempoolTxids);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
45
examples/nodejs/mempool-js/bitcoin/transactions.ts
Normal file
45
examples/nodejs/mempool-js/bitcoin/transactions.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
bitcoin: { transactions },
|
||||
} = mempoolJS();
|
||||
|
||||
const txid =
|
||||
'15e10745f15593a899cef391191bdd3d7c12412cc4696b7bcb669d0feadc8521';
|
||||
|
||||
const tx = await transactions.getTx({ txid });
|
||||
console.log(tx);
|
||||
|
||||
const txStatus = await transactions.getTxStatus({ txid });
|
||||
console.log(txStatus);
|
||||
|
||||
const txHex = await transactions.getTxHex({ txid });
|
||||
console.log(txHex);
|
||||
|
||||
const txRaw = await transactions.getTxRaw({ txid });
|
||||
console.log(txRaw);
|
||||
|
||||
const txMerkleBlockProof = await transactions.getTxMerkleBlockProof({ txid });
|
||||
console.log(txMerkleBlockProof);
|
||||
|
||||
const txMerkleProof = await transactions.getTxMerkleProof({ txid });
|
||||
console.log(txMerkleProof);
|
||||
|
||||
const txOutspend = await transactions.getTxOutspend({
|
||||
txid,
|
||||
vout: 3,
|
||||
});
|
||||
console.log(txOutspend);
|
||||
|
||||
const txOutspends = await transactions.getTxOutspends({ txid });
|
||||
console.log(txOutspends);
|
||||
|
||||
// const postTx = await transactions.postTx({ txhex });
|
||||
// console.log(postTx);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
30
examples/nodejs/mempool-js/bitcoin/websocket.ts
Normal file
30
examples/nodejs/mempool-js/bitcoin/websocket.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const { bitcoin: { websocket } } = mempoolJS();
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const ws = websocket.initServer({
|
||||
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
|
||||
});
|
||||
|
||||
ws.on("message", function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
console.log(res.blocks);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
}
|
||||
if (res.transactions) {
|
||||
console.log(res.transactions);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
console.log(res.mempoolBlocks);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
init();
|
||||
29
examples/nodejs/mempool-js/liquid/addresses.ts
Normal file
29
examples/nodejs/mempool-js/liquid/addresses.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { addresses },
|
||||
} = mempoolJS();
|
||||
|
||||
const address = '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();
|
||||
24
examples/nodejs/mempool-js/liquid/assets.ts
Normal file
24
examples/nodejs/mempool-js/liquid/assets.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { assets },
|
||||
} = mempoolJS();
|
||||
|
||||
const asset_id =
|
||||
'6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
|
||||
|
||||
const asset = await assets.getAsset({ asset_id });
|
||||
console.log(asset);
|
||||
|
||||
const assetTxs = await assets.getAssetTxs({ asset_id, is_mempool: false });
|
||||
console.log(assetTxs);
|
||||
|
||||
const assetSupply = await assets.getAssetSupply({ asset_id, decimal: false });
|
||||
console.log(assetSupply);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
45
examples/nodejs/mempool-js/liquid/blocks.ts
Normal file
45
examples/nodejs/mempool-js/liquid/blocks.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { blocks },
|
||||
} = mempoolJS();
|
||||
|
||||
const hash =
|
||||
'000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce';
|
||||
|
||||
const block = await blocks.getBlock({ hash });
|
||||
console.log(block);
|
||||
|
||||
const blockStatus = await blocks.getBlockStatus({ hash });
|
||||
console.log(blockStatus);
|
||||
|
||||
const blockTxs = await blocks.getBlockTxs({ hash });
|
||||
console.log(blockTxs);
|
||||
|
||||
const blockTxids = await blocks.getBlockTxids({ hash });
|
||||
console.log(blockTxids);
|
||||
|
||||
const blockTxid = await blocks.getBlockTxid({ hash, index: 218 });
|
||||
console.log(blockTxid);
|
||||
|
||||
const blockRaw = await blocks.getBlockRaw({ hash });
|
||||
console.log(blockRaw);
|
||||
|
||||
const blockHeight = await blocks.getBlockHeight({ height: 0 });
|
||||
console.log(blockHeight);
|
||||
|
||||
const getBlocks = await blocks.getBlocks({ start_height: 9999 });
|
||||
console.log(getBlocks);
|
||||
|
||||
const blocksTipHeight = await blocks.getBlocksTipHeight();
|
||||
console.log(blocksTipHeight);
|
||||
|
||||
const blocksTipHash = await blocks.getBlocksTipHash();
|
||||
console.log(blocksTipHash);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
18
examples/nodejs/mempool-js/liquid/fees.ts
Normal file
18
examples/nodejs/mempool-js/liquid/fees.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const {
|
||||
liquid: { fees },
|
||||
} = mempoolJS();
|
||||
|
||||
const feesRecommended = await fees.getFeesRecommended();
|
||||
console.log(feesRecommended);
|
||||
|
||||
const feesMempoolBlocks = await fees.getFeesMempoolBlocks();
|
||||
console.log(feesMempoolBlocks);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
21
examples/nodejs/mempool-js/liquid/mempool.ts
Normal file
21
examples/nodejs/mempool-js/liquid/mempool.ts
Normal 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();
|
||||
45
examples/nodejs/mempool-js/liquid/transactions.ts
Normal file
45
examples/nodejs/mempool-js/liquid/transactions.ts
Normal 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();
|
||||
30
examples/nodejs/mempool-js/liquid/websocket.ts
Normal file
30
examples/nodejs/mempool-js/liquid/websocket.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import mempoolJS from "./../../../../src/index";
|
||||
|
||||
const { liquid: { websocket } } = mempoolJS();
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
const ws = websocket.initServer({
|
||||
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
|
||||
});
|
||||
|
||||
ws.on("message", function incoming(data) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
console.log(res.blocks);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
console.log(res.mempoolInfo);
|
||||
}
|
||||
if (res.transactions) {
|
||||
console.log(res.transactions);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
console.log(res.mempoolBlocks);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
init();
|
||||
Reference in New Issue
Block a user