@xchainjs/xchain-bitcoin 0.20.8 → 0.21.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.
- package/README.md +50 -0
- package/lib/client.d.ts +6 -63
- package/lib/const.d.ts +9 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +58763 -63240
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +58770 -63247
- package/lib/index.js.map +1 -1
- package/lib/types/common.d.ts +0 -18
- package/lib/types/index.d.ts +0 -3
- package/lib/utils.d.ts +1 -51
- package/package.json +6 -3
- package/CHANGELOG.md +0 -383
- package/lib/haskoin-api.d.ts +0 -38
- package/lib/sochain-api.d.ts +0 -88
- package/lib/types/haskoin-api-types.d.ts +0 -18
- package/lib/types/sochain-api-types.d.ts +0 -94
package/README.md
CHANGED
|
@@ -60,3 +60,53 @@ register9Rheader(cosmosclient.config.globalAxios)
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
For a complete example please see this [test](https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-thorchain-amm/__e2e__/wallet.e2e.ts)
|
|
63
|
+
|
|
64
|
+
### UtxoOnlineDataProviders
|
|
65
|
+
|
|
66
|
+
## default providers
|
|
67
|
+
|
|
68
|
+
Creating a no-arg BTC Client will default to the following settings:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const defaultBTCParams: UtxoClientParams = {
|
|
72
|
+
network: Network.Mainnet,
|
|
73
|
+
phrase: '',
|
|
74
|
+
explorerProviders: blockstreamExplorerProviders,
|
|
75
|
+
dataProviders: [BlockcypherDataProviders],
|
|
76
|
+
rootDerivationPaths: {
|
|
77
|
+
[Network.Mainnet]: `84'/0'/0'/0/`,
|
|
78
|
+
[Network.Testnet]: `84'/1'/0'/0/`,
|
|
79
|
+
[Network.Stagenet]: `84'/0'/0'/0/`,
|
|
80
|
+
},
|
|
81
|
+
feeBounds: {
|
|
82
|
+
lower: LOWER_FEE_BOUND,
|
|
83
|
+
upper: UPPER_FEE_BOUND,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note: BlockCypher is the default online data provider (to fetch realtime utxos, balances, etc)
|
|
89
|
+
|
|
90
|
+
## Overriding providers
|
|
91
|
+
|
|
92
|
+
You can specify own array of providers, whoch will be executed in array-order, to provide automated failover to the subsequent providers if calls to the first providers fail
|
|
93
|
+
|
|
94
|
+
### example sochain v3, blockcypher backup
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { Client, defaultBTCParams, AssetBTC, SochainDataProviders, BlockcypherDataProviders } from '@xchainjs/xchain-bitcoin'
|
|
98
|
+
import { SochainNetwork, SochainProvider } from '@xchainjs/xchain-utxo-providers'
|
|
99
|
+
import { Network, UtxoClientParams } from '@xchainjs/xchain-client'
|
|
100
|
+
|
|
101
|
+
// override with your API key
|
|
102
|
+
SochainDataProviders[Network.Mainnet].apiKey = 'YOU_SOCHAIN_API_KEY'
|
|
103
|
+
|
|
104
|
+
//overridde the default init params with your onfig
|
|
105
|
+
const initParams: UtxoClientParams = {
|
|
106
|
+
...defaultBTCParams,
|
|
107
|
+
dataProviders: [SochainDataProviders, BlockcypherDataProviders]// use sochain first and blockcypher as fallback
|
|
108
|
+
phrase: process.env.YOURPHRASE,
|
|
109
|
+
}
|
|
110
|
+
const btcClient = new Client(sochainParams)
|
|
111
|
+
|
|
112
|
+
```
|
package/lib/client.d.ts
CHANGED
|
@@ -1,50 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Address
|
|
3
|
-
|
|
4
|
-
export declare type BitcoinClientParams = XChainClientParams & {
|
|
5
|
-
sochainUrl?: string;
|
|
6
|
-
haskoinUrl?: ClientUrl;
|
|
7
|
-
};
|
|
1
|
+
import { Fee, FeeRate, TxHash, TxParams, UTXOClient, UtxoClientParams } from '@xchainjs/xchain-client';
|
|
2
|
+
import { Address } from '@xchainjs/xchain-util';
|
|
3
|
+
export declare const defaultBTCParams: UtxoClientParams;
|
|
8
4
|
/**
|
|
9
5
|
* Custom Bitcoin client
|
|
10
6
|
*/
|
|
11
7
|
declare class Client extends UTXOClient {
|
|
12
|
-
private sochainUrl;
|
|
13
|
-
private haskoinUrl;
|
|
14
8
|
/**
|
|
15
9
|
* Constructor
|
|
16
10
|
* Client is initialised with network type
|
|
17
11
|
*
|
|
18
|
-
* @param {
|
|
12
|
+
* @param {UtxoClientParams} params
|
|
19
13
|
*/
|
|
20
|
-
constructor(
|
|
21
|
-
/**
|
|
22
|
-
* Set/Update the sochain url.
|
|
23
|
-
*
|
|
24
|
-
* @param {string} url The new sochain url.
|
|
25
|
-
* @returns {void}
|
|
26
|
-
*/
|
|
27
|
-
setSochainUrl(url: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Get the explorer url.
|
|
30
|
-
*
|
|
31
|
-
* @returns {string} The explorer url based on the network.
|
|
32
|
-
*/
|
|
33
|
-
getExplorerUrl(): string;
|
|
34
|
-
/**
|
|
35
|
-
* Get the explorer url for the given address.
|
|
36
|
-
*
|
|
37
|
-
* @param {Address} address
|
|
38
|
-
* @returns {string} The explorer url for the given address based on the network.
|
|
39
|
-
*/
|
|
40
|
-
getExplorerAddressUrl(address: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Get the explorer url for the given transaction id.
|
|
43
|
-
*
|
|
44
|
-
* @param {string} txID The transaction id
|
|
45
|
-
* @returns {string} The explorer url for the given transaction id based on the network.
|
|
46
|
-
*/
|
|
47
|
-
getExplorerTxUrl(txID: string): string;
|
|
14
|
+
constructor(params?: UtxoClientParams);
|
|
48
15
|
/**
|
|
49
16
|
* Get the current address.
|
|
50
17
|
*
|
|
@@ -76,31 +43,6 @@ declare class Client extends UTXOClient {
|
|
|
76
43
|
* @returns {boolean} `true` or `false`
|
|
77
44
|
*/
|
|
78
45
|
validateAddress(address: string): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Gets BTC balances of a given address.
|
|
81
|
-
*
|
|
82
|
-
* @param {Address} BTC address to get balances from
|
|
83
|
-
* @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version
|
|
84
|
-
* @param {confirmedOnly} Flag to get balances of confirmed txs only
|
|
85
|
-
*
|
|
86
|
-
* @returns {Balance[]} BTC balances
|
|
87
|
-
*/
|
|
88
|
-
getBalance(address: Address, _assets?: Asset[], confirmedOnly?: boolean): Promise<Balance[]>;
|
|
89
|
-
/**
|
|
90
|
-
* Get transaction history of a given address with pagination options.
|
|
91
|
-
* By default it will return the transaction history of the current wallet.
|
|
92
|
-
*
|
|
93
|
-
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
94
|
-
* @returns {TxsPage} The transaction history.
|
|
95
|
-
*/
|
|
96
|
-
getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
|
|
97
|
-
/**
|
|
98
|
-
* Get the transaction details of a given transaction id.
|
|
99
|
-
*
|
|
100
|
-
* @param {string} txId The transaction id.
|
|
101
|
-
* @returns {Tx} The transaction details of the given transaction id.
|
|
102
|
-
*/
|
|
103
|
-
getTransactionData(txId: string): Promise<Tx>;
|
|
104
46
|
protected getSuggestedFeeRate(): Promise<FeeRate>;
|
|
105
47
|
protected calcFee(feeRate: FeeRate, memo?: string): Promise<Fee>;
|
|
106
48
|
/**
|
|
@@ -114,5 +56,6 @@ declare class Client extends UTXOClient {
|
|
|
114
56
|
transfer(params: TxParams & {
|
|
115
57
|
feeRate?: FeeRate;
|
|
116
58
|
}): Promise<TxHash>;
|
|
59
|
+
private buildTx;
|
|
117
60
|
}
|
|
118
61
|
export { Client };
|
package/lib/const.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExplorerProvider, UtxoOnlineDataProviders } from '@xchainjs/xchain-client';
|
|
1
2
|
import { Asset } from '@xchainjs/xchain-util';
|
|
2
3
|
/**
|
|
3
4
|
* Minimum transaction fee
|
|
@@ -22,3 +23,11 @@ export declare const BTCChain: "BTC";
|
|
|
22
23
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
23
24
|
*/
|
|
24
25
|
export declare const AssetBTC: Asset;
|
|
26
|
+
export declare const blockstreamExplorerProviders: {
|
|
27
|
+
testnet: ExplorerProvider;
|
|
28
|
+
stagenet: ExplorerProvider;
|
|
29
|
+
mainnet: ExplorerProvider;
|
|
30
|
+
};
|
|
31
|
+
export declare const SochainDataProviders: UtxoOnlineDataProviders;
|
|
32
|
+
export declare const HaskoinDataProviders: UtxoOnlineDataProviders;
|
|
33
|
+
export declare const BlockcypherDataProviders: UtxoOnlineDataProviders;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './client';
|
|
3
3
|
export * from './const';
|
|
4
|
-
export {
|
|
4
|
+
export { getDefaultFees, getDefaultFeesWithRates, getPrefix, validateAddress, calcFee } from './utils';
|