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:
13
src/interfaces/bisq/addresses.ts
Normal file
13
src/interfaces/bisq/addresses.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Tx } from './transactions';
|
||||
|
||||
export interface Address {
|
||||
height: number;
|
||||
time: number;
|
||||
hash: string;
|
||||
previousBlockHash: string;
|
||||
txs: Tx[];
|
||||
}
|
||||
|
||||
export interface AddressesInstance {
|
||||
getAddress: (params: { address: string }) => Promise<Address>;
|
||||
}
|
||||
18
src/interfaces/bisq/blocks.ts
Normal file
18
src/interfaces/bisq/blocks.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Tx } from './transactions';
|
||||
|
||||
export interface Block {
|
||||
height: number;
|
||||
time: number;
|
||||
hash: string;
|
||||
previousBlockHash: string;
|
||||
txs: Tx[];
|
||||
}
|
||||
|
||||
export interface BlocksInstance {
|
||||
getBlock: (params: { hash: string }) => Promise<Block>;
|
||||
getBlocks: (params: { index: number; length: number }) => Promise<Block>;
|
||||
getBlocksTipHeight: (params: {
|
||||
index: number;
|
||||
length: number;
|
||||
}) => Promise<number>;
|
||||
}
|
||||
11
src/interfaces/bisq/statistics.ts
Normal file
11
src/interfaces/bisq/statistics.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export interface Stats {
|
||||
address: number;
|
||||
minted: number;
|
||||
burnt: number;
|
||||
spent_txos: number;
|
||||
unspent_txos: number;
|
||||
}
|
||||
|
||||
export interface StatsInstance {
|
||||
getStats: () => Promise<Stats>;
|
||||
}
|
||||
46
src/interfaces/bisq/transactions.ts
Normal file
46
src/interfaces/bisq/transactions.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
export interface Tx {
|
||||
txVersion: string;
|
||||
id: string;
|
||||
blockHeight: number;
|
||||
blockHash: string;
|
||||
time: number;
|
||||
inputs: [];
|
||||
outputs: [
|
||||
{
|
||||
txVersion: string;
|
||||
txId: string;
|
||||
index: number;
|
||||
bsqAmount: number;
|
||||
btcAmount: number;
|
||||
height: number;
|
||||
isVerified: true;
|
||||
burntFee: number;
|
||||
invalidatedBsq: number;
|
||||
address: string;
|
||||
scriptPubKey: {
|
||||
addresses: [string];
|
||||
asm: string;
|
||||
hex: string;
|
||||
reqSigs: number;
|
||||
type: string;
|
||||
};
|
||||
time: number;
|
||||
txType: string;
|
||||
txTypeDisplayString: string;
|
||||
txOutputType: string;
|
||||
txOutputTypeDisplayString: string;
|
||||
lockTime: number;
|
||||
isUnspent: true;
|
||||
}
|
||||
];
|
||||
txType: string;
|
||||
txTypeDisplayString: string;
|
||||
burntFee: number;
|
||||
invalidatedBsq: number;
|
||||
unlockBlockHeight: number;
|
||||
}
|
||||
|
||||
export interface TransactionsInstance {
|
||||
getTx: (params: { txid: string }) => Promise<Tx>;
|
||||
getTxs: (params: { index: number; length: number }) => Promise<Tx[]>;
|
||||
}
|
||||
30
src/interfaces/bitcoin/addresses.ts
Normal file
30
src/interfaces/bitcoin/addresses.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Tx, TxStatus } from './transactions';
|
||||
|
||||
export interface Address {
|
||||
address: string;
|
||||
chain_stats: StatsInfo;
|
||||
mempool_stats: StatsInfo;
|
||||
}
|
||||
|
||||
export interface StatsInfo {
|
||||
funded_txo_count: number;
|
||||
funded_txo_sum: number;
|
||||
spent_txo_count: number;
|
||||
spent_txo_sum: number;
|
||||
tx_count: number;
|
||||
}
|
||||
|
||||
export interface AddressTxsUtxo {
|
||||
txid: string;
|
||||
vout: number;
|
||||
status: TxStatus;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface AddressInstance {
|
||||
getAddress: (params: { address: string }) => Promise<Address>;
|
||||
getAddressTxs: (params: { address: string }) => Promise<Tx[]>;
|
||||
getAddressTxsChain: (params: { address: string }) => Promise<Tx[]>;
|
||||
getAddressTxsMempool: (params: { address: string }) => Promise<Tx[]>;
|
||||
getAddressTxsUtxo: (params: { address: string }) => Promise<AddressTxsUtxo[]>;
|
||||
}
|
||||
36
src/interfaces/bitcoin/blocks.ts
Normal file
36
src/interfaces/bitcoin/blocks.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Tx } from './transactions';
|
||||
|
||||
export interface Block {
|
||||
id: string;
|
||||
height: number;
|
||||
version: number;
|
||||
timestamp: number;
|
||||
tx_count: number;
|
||||
size: number;
|
||||
weight: number;
|
||||
merkle_root: string;
|
||||
previousblockhash: string;
|
||||
mediantime: number;
|
||||
nonce: number;
|
||||
bits: number;
|
||||
difficulty: number;
|
||||
}
|
||||
|
||||
export interface BlockStatus {
|
||||
in_best_chain: boolean;
|
||||
height: number;
|
||||
next_best: string;
|
||||
}
|
||||
|
||||
export interface BlockInstance {
|
||||
getBlock: (params: { hash: string }) => Promise<Block>;
|
||||
getBlocks: (params: { start_height?: number }) => Promise<Block>;
|
||||
getBlockStatus: (params: { hash: string }) => Promise<BlockStatus>;
|
||||
getBlockTxs: (params: { hash: string; start_index?: number }) => Promise<Tx>;
|
||||
getBlockTxids: (params: { hash: string }) => Promise<string[]>;
|
||||
getBlockTxid: (params: { hash: string; index: number }) => Promise<string>;
|
||||
getBlockRaw: (params: { hash: string }) => Promise<string>;
|
||||
getBlockHeight: (params: { height: number }) => Promise<string>;
|
||||
getBlocksTipHeight: () => Promise<number>;
|
||||
getBlocksTipHash: () => Promise<string>;
|
||||
}
|
||||
21
src/interfaces/bitcoin/fees.ts
Normal file
21
src/interfaces/bitcoin/fees.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export interface FeesMempoolBlocks {
|
||||
blockSize: number;
|
||||
blockVSize: number;
|
||||
nTx: number;
|
||||
totalFees: number;
|
||||
medianFee: number;
|
||||
feeRange: number[];
|
||||
}
|
||||
|
||||
export interface FeesRecommended {
|
||||
fastestFee: number;
|
||||
halfHourFee: number;
|
||||
hourFee: number;
|
||||
minimumFee: number;
|
||||
}
|
||||
|
||||
export interface FeeInstance {
|
||||
getFeesRecommended: () => Promise<FeesRecommended>;
|
||||
getFeesMempoolBlocks: () => Promise<FeesMempoolBlocks[]>;
|
||||
getCPFP: (params: { txid: string }) => Promise<FeesMempoolBlocks[]>;
|
||||
}
|
||||
19
src/interfaces/bitcoin/mempool.ts
Normal file
19
src/interfaces/bitcoin/mempool.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export interface Mempool {
|
||||
count: number;
|
||||
vsize: number;
|
||||
total_fee: number;
|
||||
fee_histogram: number[];
|
||||
}
|
||||
|
||||
export interface MempoolInstance {
|
||||
getMempool: () => Promise<Mempool[]>;
|
||||
getMempoolTxids: () => Promise<string[]>;
|
||||
getMempoolRecent: () => Promise<MempoolRecent[]>;
|
||||
}
|
||||
|
||||
export interface MempoolRecent {
|
||||
txid: string;
|
||||
fee: number;
|
||||
vsize: number;
|
||||
value: number;
|
||||
}
|
||||
62
src/interfaces/bitcoin/transactions.ts
Normal file
62
src/interfaces/bitcoin/transactions.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
export interface Tx {
|
||||
txid: string;
|
||||
version: number;
|
||||
locktime: number;
|
||||
vin: {
|
||||
txid: string;
|
||||
vout: number;
|
||||
prevout: Vout;
|
||||
scriptsig: string;
|
||||
scriptsig_asm: string;
|
||||
is_coinbase: boolean;
|
||||
sequence: string;
|
||||
}[];
|
||||
vout: Vout[];
|
||||
size: number;
|
||||
weight: number;
|
||||
fee: number;
|
||||
status: TxStatus;
|
||||
}
|
||||
|
||||
export interface Vout {
|
||||
scriptpubkey: string;
|
||||
scriptpubkey_asm: string;
|
||||
scriptpubkey_type: string;
|
||||
scriptpubkey_address: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface TxStatus {
|
||||
confirmed: boolean;
|
||||
block_height: number;
|
||||
block_hash: string;
|
||||
block_time: number;
|
||||
}
|
||||
|
||||
export interface TxMerkleProof {
|
||||
block_height: number;
|
||||
merkle: string[];
|
||||
pos: number;
|
||||
}
|
||||
|
||||
export interface TxOutspend {
|
||||
spent: boolean;
|
||||
txid: string;
|
||||
vin: number;
|
||||
status: TxStatus;
|
||||
}
|
||||
|
||||
export interface TxInstance {
|
||||
getTx: (params: { txid: string }) => Promise<Tx>;
|
||||
getTxStatus: (params: { txid: string }) => Promise<TxStatus>;
|
||||
getTxHex: (params: { txid: string }) => Promise<string>;
|
||||
getTxRaw: (params: { txid: string }) => Promise<string>;
|
||||
getTxMerkleBlockProof: (params: { txid: string }) => Promise<string>;
|
||||
getTxMerkleProof: (params: { txid: string }) => Promise<Array<TxMerkleProof>>;
|
||||
getTxOutspend: (params: {
|
||||
txid: string;
|
||||
vout: number;
|
||||
}) => Promise<TxOutspend>;
|
||||
getTxOutspends: (params: { txid: string }) => Promise<Array<TxOutspend>>;
|
||||
postTx: (params: { txid: string }) => Promise<unknown>;
|
||||
}
|
||||
10
src/interfaces/bitcoin/websockets.ts
Normal file
10
src/interfaces/bitcoin/websockets.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface WsInterface {
|
||||
options: string[];
|
||||
}
|
||||
|
||||
import WebSocketServer from 'ws';
|
||||
|
||||
export interface WsInstance {
|
||||
initClient: ({ options }: WsInterface) => WebSocket;
|
||||
initServer: ({ options }: WsInterface) => WebSocketServer;
|
||||
}
|
||||
44
src/interfaces/index.ts
Normal file
44
src/interfaces/index.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { AddressInstance } from './bitcoin/addresses';
|
||||
import { BlockInstance } from './bitcoin/blocks';
|
||||
import { FeeInstance } from './bitcoin/fees';
|
||||
import { MempoolInstance } from './bitcoin/mempool';
|
||||
import { TxInstance } from './bitcoin/transactions';
|
||||
import { WsInstance } from './bitcoin/websockets';
|
||||
|
||||
import { AddressesInstance } from './bisq/addresses';
|
||||
import { BlocksInstance } from './bisq/blocks';
|
||||
import { StatsInstance } from './bisq/statistics';
|
||||
import { TransactionsInstance } from './bisq/transactions';
|
||||
|
||||
import { AssetsInstance } from './liquid/assets';
|
||||
|
||||
export interface MempoolConfig {
|
||||
hostname?: string;
|
||||
network?: string;
|
||||
}
|
||||
|
||||
export interface MempoolReturn {
|
||||
bitcoin: {
|
||||
addresses: AddressInstance;
|
||||
blocks: BlockInstance;
|
||||
fees: FeeInstance;
|
||||
mempool: MempoolInstance;
|
||||
transactions: TxInstance;
|
||||
websocket: WsInstance;
|
||||
};
|
||||
bisq: {
|
||||
addresses: AddressesInstance;
|
||||
blocks: BlocksInstance;
|
||||
statistics: StatsInstance;
|
||||
transactions: TransactionsInstance;
|
||||
};
|
||||
liquid: {
|
||||
assets: AssetsInstance;
|
||||
addresses: AddressInstance;
|
||||
blocks: BlockInstance;
|
||||
fees: FeeInstance;
|
||||
mempool: MempoolInstance;
|
||||
transactions: TxInstance;
|
||||
websocket: WsInstance;
|
||||
};
|
||||
}
|
||||
27
src/interfaces/liquid/assets.ts
Normal file
27
src/interfaces/liquid/assets.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export interface Asset {
|
||||
asset_id: string;
|
||||
chain_stats: AssetStats;
|
||||
mempool_stats: AssetStats;
|
||||
}
|
||||
|
||||
interface AssetStats {
|
||||
tx_count: number;
|
||||
peg_in_count: number;
|
||||
peg_in_amount: number;
|
||||
peg_out_count: number;
|
||||
peg_out_amount: number;
|
||||
burn_count: number;
|
||||
burned_amount: number;
|
||||
}
|
||||
|
||||
export interface AssetsInstance {
|
||||
getAsset: (params: { asset_id: string }) => Promise<Asset>;
|
||||
getAssetTxs: (params: {
|
||||
asset_id: string;
|
||||
is_mempool: boolean;
|
||||
}) => Promise<Asset>;
|
||||
getAssetSupply: (params: {
|
||||
asset_id: string;
|
||||
decimal: boolean;
|
||||
}) => Promise<Asset>;
|
||||
}
|
||||
Reference in New Issue
Block a user