@xchainjs/xchain-utxo-providers 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,150 +1,150 @@
1
- /**
2
- * Module to interact with Haskoin API
3
- *
4
- * Doc (SwaggerHub) https://app.swaggerhub.com/apis/eligecode/blockchain-api/0.0.1-oas3
5
- *
6
- */
7
- import { TxHash } from '@xchainjs/xchain-client';
8
- import { BaseAmount } from '@xchainjs/xchain-util';
9
- import { AddressBalance, AddressDTO, AddressParams, HaskoinNetwork, Transaction, TxConfirmedStatus, TxHashParams, TxUnspent } from './haskoin-api-types';
10
- /**
11
- * Get account from address.
12
- *
13
- * @param {string} haskoinUrl The haskoin API url.
14
- * @param {string} address The BCH address.
15
- * @returns {AddressBalance}
16
- *
17
- * @throws {"failed to query account by a given address"} thrown if failed to query account by a given address
18
- */
19
- export declare const getAccount: ({ haskoinUrl, network, address }: AddressParams) => Promise<AddressBalance>;
20
- /**
21
- * Get address information.
22
- *
23
- * @param {string} haskoinUrl The haskoin node url.
24
- * @param {string} network
25
- * @param {string} address
26
- * @returns {AddressDTO}
27
- */
28
- export declare const getAddress: ({ haskoinUrl, network, address }: AddressParams) => Promise<AddressDTO>;
29
- /**
30
- * Get transaction by hash.
31
- *
32
- * @param {string} haskoinUrl The haskoin API url.
33
- * @param {string} txId The transaction id.
34
- * @returns {Transaction}
35
- *
36
- * @throws {"failed to query transaction by a given hash"} thrown if failed to query transaction by a given hash
37
- */
38
- export declare const getTx: ({ haskoinUrl, txId, network }: TxHashParams) => Promise<Transaction>;
39
- /**
40
- * Get raw transaction by hash.
41
- *
42
- * @param {string} haskoinUrl The haskoin API url.
43
- * @param {string} txId The transaction id.
44
- * @returns {Transaction}
45
- *
46
- * @throws {"failed to query transaction by a given hash"} thrown if failed to query raw transaction by a given hash
47
- */
48
- export declare const getRawTransaction: ({ haskoinUrl, network, txId }: TxHashParams) => Promise<string>;
49
- /**
50
- * Get transactions
51
- *
52
- * @see https://haskoin.com/api#get-tx
53
- *
54
- * @param {string} haskoinUrl The haskoin node url.
55
- * @param {string} network network id
56
- * @param {string} hash The transaction hash.
57
- * @returns {Transactions}
58
- */
59
- export declare const getTxs: ({ address, haskoinUrl, network, limit, offset, }: {
60
- address: string;
61
- haskoinUrl: string;
62
- network: HaskoinNetwork;
63
- limit: number;
64
- offset?: number | undefined;
65
- }) => Promise<Transaction[]>;
66
- /**
67
- *
68
- * @param param
69
- * @returns Returns BaseAmount
70
- */
71
- export declare const getBalance: ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, assetDecimals, }: {
72
- haskoinUrl: string;
73
- haskoinNetwork: string;
74
- address: string;
75
- confirmedOnly: boolean;
76
- assetDecimals: number;
77
- }) => Promise<BaseAmount>;
78
- /**
79
- * Get unspent transactions.
80
- *
81
- * @param {string} haskoinUrl The haskoin API url.
82
- * @param {string} address The BCH address.
83
- * @returns {TxUnspent[]}
84
- *
85
- * @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
86
- */
87
- export declare const getUnspentTxs: ({ haskoinUrl, network, address }: AddressParams) => Promise<TxUnspent[]>;
88
- /**
89
- * Get Tx Confirmation status
90
- *
91
- * @param {string} haskoinUrl The haskoin node url.
92
- * @param {Network} network
93
- * @param {string} hash tx id
94
- * @returns {TxConfirmedStatus}
95
- */
96
- export declare const getIsTxConfirmed: ({ haskoinUrl, network, txId }: TxHashParams) => Promise<TxConfirmedStatus>;
97
- /**
98
- * Helper to get `confirmed` status of a tx.
99
- *
100
- * It will get it from cache or try to get it from haskoin (if not cached before)
101
- */
102
- export declare const getConfirmedTxStatus: ({ txHash, haskoinUrl, network, }: {
103
- haskoinUrl: string;
104
- txHash: TxHash;
105
- network: HaskoinNetwork;
106
- }) => Promise<boolean>;
107
- /**
108
- * Get unspent txs and filter out pending UTXOs
109
- *
110
- * @see https://haskoin.com/api#get-unspent-tx
111
- *
112
- * @param {string} haskoinUrl The haskoin node url.
113
- * @param {Network} network
114
- * @param {string} address
115
- * @returns {AddressUTXO[]}
116
- */
117
- export declare const getConfirmedUnspentTxs: ({ haskoinUrl, network, address }: AddressParams) => Promise<TxUnspent[]>;
118
- /**
119
- * Helper to get `hex` of `Tx`
120
- *
121
- * It will try to get it from cache before requesting it from Sochain
122
- */
123
- export declare const getTxHex: ({ haskoinUrl, network, txId }: TxHashParams) => Promise<string>;
124
- /**
125
- * Get unspent transactions.
126
- *
127
- * @param {string} haskoinUrl The haskoin API url.
128
- * @param {string} address The BCH address.
129
- * @returns {TxUnspent[]}
130
- *
131
- * @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
132
- */
133
- export declare const getUnspentTransactions: ({ haskoinUrl, network, address }: AddressParams) => Promise<TxUnspent[]>;
134
- /**
135
- * Broadcast transaction.
136
- *
137
- * @see https://app.swaggerhub.com/apis/eligecode/blockchain-api/0.0.1-oas3#/blockchain/sendTransaction
138
- *
139
- * Note: Because of an Haskoin issue (@see https://github.com/haskoin/haskoin-store/issues/25),
140
- * we need to broadcast same tx several times in case of `500` errors
141
- * @see https://github.com/xchainjs/xchainjs-lib/issues/492
142
- *
143
- * @param {BroadcastTxParams} params
144
- * @returns {TxHash} Transaction hash.
145
- */
146
- export declare const broadcastTx: ({ txHex, haskoinUrl, haskoinNetwork, }: {
147
- txHex: string;
148
- haskoinUrl: string;
149
- haskoinNetwork: string;
150
- }) => Promise<TxHash>;
1
+ /**
2
+ * Module to interact with Haskoin API
3
+ *
4
+ * Doc (SwaggerHub) https://app.swaggerhub.com/apis/eligecode/blockchain-api/0.0.1-oas3
5
+ *
6
+ */
7
+ import { TxHash } from '@xchainjs/xchain-client';
8
+ import { BaseAmount } from '@xchainjs/xchain-util';
9
+ import { AddressBalance, AddressDTO, AddressParams, HaskoinNetwork, Transaction, TxConfirmedStatus, TxHashParams, TxUnspent } from './haskoin-api-types';
10
+ /**
11
+ * Get account from address.
12
+ *
13
+ * @param {string} haskoinUrl The haskoin API url.
14
+ * @param {string} address The BCH address.
15
+ * @returns {AddressBalance}
16
+ *
17
+ * @throws {"failed to query account by a given address"} thrown if failed to query account by a given address
18
+ */
19
+ export declare const getAccount: ({ haskoinUrl, network, address }: AddressParams) => Promise<AddressBalance>;
20
+ /**
21
+ * Get address information.
22
+ *
23
+ * @param {string} haskoinUrl The haskoin node url.
24
+ * @param {string} network
25
+ * @param {string} address
26
+ * @returns {AddressDTO}
27
+ */
28
+ export declare const getAddress: ({ haskoinUrl, network, address }: AddressParams) => Promise<AddressDTO>;
29
+ /**
30
+ * Get transaction by hash.
31
+ *
32
+ * @param {string} haskoinUrl The haskoin API url.
33
+ * @param {string} txId The transaction id.
34
+ * @returns {Transaction}
35
+ *
36
+ * @throws {"failed to query transaction by a given hash"} thrown if failed to query transaction by a given hash
37
+ */
38
+ export declare const getTx: ({ haskoinUrl, txId, network }: TxHashParams) => Promise<Transaction>;
39
+ /**
40
+ * Get raw transaction by hash.
41
+ *
42
+ * @param {string} haskoinUrl The haskoin API url.
43
+ * @param {string} txId The transaction id.
44
+ * @returns {Transaction}
45
+ *
46
+ * @throws {"failed to query transaction by a given hash"} thrown if failed to query raw transaction by a given hash
47
+ */
48
+ export declare const getRawTransaction: ({ haskoinUrl, network, txId }: TxHashParams) => Promise<string>;
49
+ /**
50
+ * Get transactions
51
+ *
52
+ * @see https://haskoin.com/api#get-tx
53
+ *
54
+ * @param {string} haskoinUrl The haskoin node url.
55
+ * @param {string} network network id
56
+ * @param {string} hash The transaction hash.
57
+ * @returns {Transactions}
58
+ */
59
+ export declare const getTxs: ({ address, haskoinUrl, network, limit, offset, }: {
60
+ address: string;
61
+ haskoinUrl: string;
62
+ network: HaskoinNetwork;
63
+ limit: number;
64
+ offset?: number | undefined;
65
+ }) => Promise<Transaction[]>;
66
+ /**
67
+ *
68
+ * @param param
69
+ * @returns Returns BaseAmount
70
+ */
71
+ export declare const getBalance: ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, assetDecimals, }: {
72
+ haskoinUrl: string;
73
+ haskoinNetwork: string;
74
+ address: string;
75
+ confirmedOnly: boolean;
76
+ assetDecimals: number;
77
+ }) => Promise<BaseAmount>;
78
+ /**
79
+ * Get unspent transactions.
80
+ *
81
+ * @param {string} haskoinUrl The haskoin API url.
82
+ * @param {string} address The BCH address.
83
+ * @returns {TxUnspent[]}
84
+ *
85
+ * @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
86
+ */
87
+ export declare const getUnspentTxs: ({ haskoinUrl, network, address }: AddressParams) => Promise<TxUnspent[]>;
88
+ /**
89
+ * Get Tx Confirmation status
90
+ *
91
+ * @param {string} haskoinUrl The haskoin node url.
92
+ * @param {Network} network
93
+ * @param {string} hash tx id
94
+ * @returns {TxConfirmedStatus}
95
+ */
96
+ export declare const getIsTxConfirmed: ({ haskoinUrl, network, txId }: TxHashParams) => Promise<TxConfirmedStatus>;
97
+ /**
98
+ * Helper to get `confirmed` status of a tx.
99
+ *
100
+ * It will get it from cache or try to get it from haskoin (if not cached before)
101
+ */
102
+ export declare const getConfirmedTxStatus: ({ txHash, haskoinUrl, network, }: {
103
+ haskoinUrl: string;
104
+ txHash: TxHash;
105
+ network: HaskoinNetwork;
106
+ }) => Promise<boolean>;
107
+ /**
108
+ * Get unspent txs and filter out pending UTXOs
109
+ *
110
+ * @see https://haskoin.com/api#get-unspent-tx
111
+ *
112
+ * @param {string} haskoinUrl The haskoin node url.
113
+ * @param {Network} network
114
+ * @param {string} address
115
+ * @returns {AddressUTXO[]}
116
+ */
117
+ export declare const getConfirmedUnspentTxs: ({ haskoinUrl, network, address }: AddressParams) => Promise<TxUnspent[]>;
118
+ /**
119
+ * Helper to get `hex` of `Tx`
120
+ *
121
+ * It will try to get it from cache before requesting it from Sochain
122
+ */
123
+ export declare const getTxHex: ({ haskoinUrl, network, txId }: TxHashParams) => Promise<string>;
124
+ /**
125
+ * Get unspent transactions.
126
+ *
127
+ * @param {string} haskoinUrl The haskoin API url.
128
+ * @param {string} address The BCH address.
129
+ * @returns {TxUnspent[]}
130
+ *
131
+ * @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
132
+ */
133
+ export declare const getUnspentTransactions: ({ haskoinUrl, network, address }: AddressParams) => Promise<TxUnspent[]>;
134
+ /**
135
+ * Broadcast transaction.
136
+ *
137
+ * @see https://app.swaggerhub.com/apis/eligecode/blockchain-api/0.0.1-oas3#/blockchain/sendTransaction
138
+ *
139
+ * Note: Because of an Haskoin issue (@see https://github.com/haskoin/haskoin-store/issues/25),
140
+ * we need to broadcast same tx several times in case of `500` errors
141
+ * @see https://github.com/xchainjs/xchainjs-lib/issues/492
142
+ *
143
+ * @param {BroadcastTxParams} params
144
+ * @returns {TxHash} Transaction hash.
145
+ */
146
+ export declare const broadcastTx: ({ txHex, haskoinUrl, haskoinNetwork, }: {
147
+ txHex: string;
148
+ haskoinUrl: string;
149
+ haskoinNetwork: string;
150
+ }) => Promise<TxHash>;
@@ -1,37 +1,37 @@
1
- import { Balance, Tx, TxHash, TxHistoryParams, TxsPage, UTXO, UtxoOnlineDataProvider } from '@xchainjs/xchain-client';
2
- import { Address, Asset, Chain } from '@xchainjs/xchain-util';
3
- import { HaskoinNetwork } from './haskoin-api-types';
4
- export declare class HaskoinProvider implements UtxoOnlineDataProvider {
5
- private baseUrl;
6
- private chain;
7
- private asset;
8
- private assetDecimals;
9
- private haskoinNetwork;
10
- constructor(baseUrl: string | undefined, chain: Chain, asset: Asset, assetDecimals: number, haskoinNetwork: HaskoinNetwork);
11
- broadcastTx(txHex: string): Promise<TxHash>;
12
- getConfirmedUnspentTxs(address: string): Promise<UTXO[]>;
13
- getUnspentTxs(address: string): Promise<UTXO[]>;
14
- getBalance(address: Address, assets?: Asset[], confirmedOnly?: boolean): Promise<Balance[]>;
15
- /**
16
- * Get transaction history of a given address with pagination options.
17
- * By default it will return the transaction history of the current wallet.
18
- *
19
- * @param {TxHistoryParams} params The options to get transaction history. (optional)
20
- * @returns {TxsPage} The transaction history.
21
- */
22
- getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
23
- private mapTransactionToTx;
24
- /**
25
- * Get the transaction details of a given transaction id.
26
- *
27
- * @param {string} txId The transaction id.
28
- * @returns {Tx} The transaction details of the given transaction id.
29
- */
30
- getTransactionData(txId: string): Promise<Tx>;
31
- /**
32
- *
33
- * @param utxos
34
- * @returns utxo array
35
- */
36
- private mapUTXOs;
37
- }
1
+ import { Balance, Tx, TxHash, TxHistoryParams, TxsPage, UTXO, UtxoOnlineDataProvider } from '@xchainjs/xchain-client';
2
+ import { Address, Asset, Chain } from '@xchainjs/xchain-util';
3
+ import { HaskoinNetwork } from './haskoin-api-types';
4
+ export declare class HaskoinProvider implements UtxoOnlineDataProvider {
5
+ private baseUrl;
6
+ private chain;
7
+ private asset;
8
+ private assetDecimals;
9
+ private haskoinNetwork;
10
+ constructor(baseUrl: string | undefined, chain: Chain, asset: Asset, assetDecimals: number, haskoinNetwork: HaskoinNetwork);
11
+ broadcastTx(txHex: string): Promise<TxHash>;
12
+ getConfirmedUnspentTxs(address: string): Promise<UTXO[]>;
13
+ getUnspentTxs(address: string): Promise<UTXO[]>;
14
+ getBalance(address: Address, assets?: Asset[], confirmedOnly?: boolean): Promise<Balance[]>;
15
+ /**
16
+ * Get transaction history of a given address with pagination options.
17
+ * By default it will return the transaction history of the current wallet.
18
+ *
19
+ * @param {TxHistoryParams} params The options to get transaction history. (optional)
20
+ * @returns {TxsPage} The transaction history.
21
+ */
22
+ getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
23
+ private mapTransactionToTx;
24
+ /**
25
+ * Get the transaction details of a given transaction id.
26
+ *
27
+ * @param {string} txId The transaction id.
28
+ * @returns {Tx} The transaction details of the given transaction id.
29
+ */
30
+ getTransactionData(txId: string): Promise<Tx>;
31
+ /**
32
+ *
33
+ * @param utxos
34
+ * @returns utxo array
35
+ */
36
+ private mapUTXOs;
37
+ }
@@ -1,8 +1,8 @@
1
- export * from './sochainv3/sochain-api-types';
2
- export * from './sochainv3/sochain-api';
3
- export * from './sochainv3/sochain-data-provider';
4
- export { AddressDTO, AddressParams, AddressUTXO, BalanceData, GetTxsDTO, HaskoinNetwork, HaskoinResponse, Transaction, TxConfirmedStatus, TxHashParams, } from './haskoin/haskoin-api-types';
5
- export { getAddress, getBalance, getConfirmedTxStatus, getConfirmedUnspentTxs, getAccount, getIsTxConfirmed, getTx, getTxs, getUnspentTxs, broadcastTx, } from './haskoin/haskoin-api';
6
- export * from './haskoin/haskoin-data-provider';
7
- export * from './blockcypher/blockcypher-data-provider';
8
- export { BlockcypherNetwork } from './blockcypher/blockcypher-api-types';
1
+ export * from './sochainv3/sochain-api-types';
2
+ export * from './sochainv3/sochain-api';
3
+ export * from './sochainv3/sochain-data-provider';
4
+ export { AddressDTO, AddressParams, AddressUTXO, BalanceData, GetTxsDTO, HaskoinNetwork, HaskoinResponse, Transaction, TxConfirmedStatus, TxHashParams, } from './haskoin/haskoin-api-types';
5
+ export { getAddress, getBalance, getConfirmedTxStatus, getConfirmedUnspentTxs, getAccount, getIsTxConfirmed, getTx, getTxs, getUnspentTxs, broadcastTx, } from './haskoin/haskoin-api';
6
+ export * from './haskoin/haskoin-data-provider';
7
+ export * from './blockcypher/blockcypher-data-provider';
8
+ export { BlockcypherNetwork } from './blockcypher/blockcypher-api-types';
@@ -1,101 +1,101 @@
1
- import { TxHash } from '@xchainjs/xchain-client';
2
- export declare enum SochainNetwork {
3
- BTC = "BTC",
4
- BTCTEST = "BTCTEST",
5
- LTC = "LTC",
6
- LTCTEST = "LTCTEST",
7
- DOGE = "DOGE",
8
- DOGETEST = "DOGETEST"
9
- }
10
- export declare type AddressParams = {
11
- apiKey: string;
12
- sochainUrl: string;
13
- network: SochainNetwork;
14
- address: string;
15
- page: number;
16
- };
17
- export declare type BalanceParams = {
18
- apiKey: string;
19
- sochainUrl: string;
20
- network: SochainNetwork;
21
- address: string;
22
- confirmedOnly: boolean;
23
- assetDecimals: number;
24
- };
25
- export declare type TxHashParams = {
26
- apiKey: string;
27
- sochainUrl: string;
28
- network: SochainNetwork;
29
- hash: TxHash;
30
- };
31
- export declare type TxBroadcastParams = {
32
- apiKey: string;
33
- sochainUrl: string;
34
- network: SochainNetwork;
35
- txHex: string;
36
- };
37
- export interface SochainResponse<T> {
38
- data: T;
39
- status: string;
40
- }
41
- export interface TxIO {
42
- index: number;
43
- value: string;
44
- address: string;
45
- type?: string;
46
- script: string;
47
- }
48
- export interface Transaction {
49
- hash: string;
50
- block_hash: string;
51
- confirmations: number;
52
- time: number;
53
- tx_hex: string;
54
- inputs: TxIO[];
55
- outputs: TxIO[];
56
- }
57
- export declare type AddressUTXO = {
58
- hash: string;
59
- index: number;
60
- script: string;
61
- address: string;
62
- tx_hex: string;
63
- value: string;
64
- block: number;
65
- };
66
- export declare type AddressTxDTO = {
67
- hash: string;
68
- block: number;
69
- time: number;
70
- };
71
- export declare type AddressDTO = {
72
- network: string;
73
- address: string;
74
- balance: string;
75
- received_value: string;
76
- pending_value: string;
77
- total_txs: number;
78
- };
79
- export declare type GetTxsDTO = {
80
- transactions: AddressTxDTO[];
81
- };
82
- export declare type GetBalanceDTO = {
83
- confirmed: string;
84
- unconfirmed: string;
85
- };
86
- export declare type BroadcastDTO = {
87
- tx_hex: string;
88
- };
89
- export declare type UnspentTxsDTO = {
90
- outputs: AddressUTXO[];
91
- };
92
- export declare type BroadcastTransfer = {
93
- network: string;
94
- txid: string;
95
- };
96
- export declare type TxConfirmedStatus = {
97
- network: string;
98
- txid: string;
99
- confirmations: number;
100
- is_confirmed: boolean;
101
- };
1
+ import { TxHash } from '@xchainjs/xchain-client';
2
+ export declare enum SochainNetwork {
3
+ BTC = "BTC",
4
+ BTCTEST = "BTCTEST",
5
+ LTC = "LTC",
6
+ LTCTEST = "LTCTEST",
7
+ DOGE = "DOGE",
8
+ DOGETEST = "DOGETEST"
9
+ }
10
+ export type AddressParams = {
11
+ apiKey: string;
12
+ sochainUrl: string;
13
+ network: SochainNetwork;
14
+ address: string;
15
+ page: number;
16
+ };
17
+ export type BalanceParams = {
18
+ apiKey: string;
19
+ sochainUrl: string;
20
+ network: SochainNetwork;
21
+ address: string;
22
+ confirmedOnly: boolean;
23
+ assetDecimals: number;
24
+ };
25
+ export type TxHashParams = {
26
+ apiKey: string;
27
+ sochainUrl: string;
28
+ network: SochainNetwork;
29
+ hash: TxHash;
30
+ };
31
+ export type TxBroadcastParams = {
32
+ apiKey: string;
33
+ sochainUrl: string;
34
+ network: SochainNetwork;
35
+ txHex: string;
36
+ };
37
+ export interface SochainResponse<T> {
38
+ data: T;
39
+ status: string;
40
+ }
41
+ export interface TxIO {
42
+ index: number;
43
+ value: string;
44
+ address: string;
45
+ type?: string;
46
+ script: string;
47
+ }
48
+ export interface Transaction {
49
+ hash: string;
50
+ block_hash: string;
51
+ confirmations: number;
52
+ time: number;
53
+ tx_hex: string;
54
+ inputs: TxIO[];
55
+ outputs: TxIO[];
56
+ }
57
+ export type AddressUTXO = {
58
+ hash: string;
59
+ index: number;
60
+ script: string;
61
+ address: string;
62
+ tx_hex: string;
63
+ value: string;
64
+ block: number;
65
+ };
66
+ export type AddressTxDTO = {
67
+ hash: string;
68
+ block: number;
69
+ time: number;
70
+ };
71
+ export type AddressDTO = {
72
+ network: string;
73
+ address: string;
74
+ balance: string;
75
+ received_value: string;
76
+ pending_value: string;
77
+ total_txs: number;
78
+ };
79
+ export type GetTxsDTO = {
80
+ transactions: AddressTxDTO[];
81
+ };
82
+ export type GetBalanceDTO = {
83
+ confirmed: string;
84
+ unconfirmed: string;
85
+ };
86
+ export type BroadcastDTO = {
87
+ tx_hex: string;
88
+ };
89
+ export type UnspentTxsDTO = {
90
+ outputs: AddressUTXO[];
91
+ };
92
+ export type BroadcastTransfer = {
93
+ network: string;
94
+ txid: string;
95
+ };
96
+ export type TxConfirmedStatus = {
97
+ network: string;
98
+ txid: string;
99
+ confirmations: number;
100
+ is_confirmed: boolean;
101
+ };