@xchainjs/xchain-bitcoin 0.21.3 → 0.22.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/lib/client.d.ts CHANGED
@@ -1,71 +1,71 @@
1
- import { Fee, FeeRate, TxHash, TxParams, UTXO, UTXOClient, UtxoClientParams } from '@xchainjs/xchain-client';
2
- import { Address } from '@xchainjs/xchain-util';
3
- import * as Bitcoin from 'bitcoinjs-lib';
4
- export declare const defaultBTCParams: UtxoClientParams;
5
- /**
6
- * Custom Bitcoin client
7
- */
8
- declare class Client extends UTXOClient {
9
- /**
10
- * Constructor
11
- * Client is initialised with network type
12
- *
13
- * @param {UtxoClientParams} params
14
- */
15
- constructor(params?: UtxoClientParams);
16
- /**
17
- * Get the current address.
18
- *
19
- * Generates a network-specific key-pair by first converting the buffer to a Wallet-Import-Format (WIF)
20
- * The address is then decoded into type P2WPKH and returned.
21
- *
22
- * @returns {Address} The current address.
23
- *
24
- * @throws {"Phrase must be provided"} Thrown if phrase has not been set before.
25
- * @throws {"Address not defined"} Thrown if failed creating account from phrase.
26
- */
27
- getAddress(index?: number): Address;
28
- /**
29
- * @private
30
- * Get private key.
31
- *
32
- * Private function to get keyPair from the this.phrase
33
- *
34
- * @param {string} phrase The phrase to be used for generating privkey
35
- * @returns {ECPairInterface} The privkey generated from the given phrase
36
- *
37
- * @throws {"Could not get private key from phrase"} Throws an error if failed creating BTC keys from the given phrase
38
- * */
39
- private getBtcKeys;
40
- /**
41
- * Validate the given address.
42
- *
43
- * @param {Address} address
44
- * @returns {boolean} `true` or `false`
45
- */
46
- validateAddress(address: string): boolean;
47
- protected getSuggestedFeeRate(): Promise<FeeRate>;
48
- protected calcFee(feeRate: FeeRate, memo?: string): Promise<Fee>;
49
- /**
50
- * Transfer BTC.
51
- *
52
- * @param {TxParams&FeeRate} params The transfer options.
53
- * @returns {TxHash} The transaction hash.
54
- *
55
- * @throws {"memo too long"} Thrown if memo longer than 80 chars.
56
- */
57
- transfer(params: TxParams & {
58
- feeRate?: FeeRate;
59
- }): Promise<TxHash>;
60
- buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO, }: TxParams & {
61
- feeRate: FeeRate;
62
- sender: Address;
63
- spendPendingUTXO?: boolean;
64
- withTxHex?: boolean;
65
- }): Promise<{
66
- psbt: Bitcoin.Psbt;
67
- utxos: UTXO[];
68
- inputs: UTXO[];
69
- }>;
70
- }
71
- export { Client };
1
+ import { Fee, FeeRate, TxHash, TxParams, UTXO, UTXOClient, UtxoClientParams } from '@xchainjs/xchain-client';
2
+ import { Address } from '@xchainjs/xchain-util';
3
+ import * as Bitcoin from 'bitcoinjs-lib';
4
+ export declare const defaultBTCParams: UtxoClientParams;
5
+ /**
6
+ * Custom Bitcoin client
7
+ */
8
+ declare class Client extends UTXOClient {
9
+ /**
10
+ * Constructor
11
+ * Client is initialised with network type
12
+ *
13
+ * @param {UtxoClientParams} params
14
+ */
15
+ constructor(params?: UtxoClientParams);
16
+ /**
17
+ * Get the current address.
18
+ *
19
+ * Generates a network-specific key-pair by first converting the buffer to a Wallet-Import-Format (WIF)
20
+ * The address is then decoded into type P2WPKH and returned.
21
+ *
22
+ * @returns {Address} The current address.
23
+ *
24
+ * @throws {"Phrase must be provided"} Thrown if phrase has not been set before.
25
+ * @throws {"Address not defined"} Thrown if failed creating account from phrase.
26
+ */
27
+ getAddress(index?: number): Address;
28
+ /**
29
+ * @private
30
+ * Get private key.
31
+ *
32
+ * Private function to get keyPair from the this.phrase
33
+ *
34
+ * @param {string} phrase The phrase to be used for generating privkey
35
+ * @returns {ECPairInterface} The privkey generated from the given phrase
36
+ *
37
+ * @throws {"Could not get private key from phrase"} Throws an error if failed creating BTC keys from the given phrase
38
+ * */
39
+ private getBtcKeys;
40
+ /**
41
+ * Validate the given address.
42
+ *
43
+ * @param {Address} address
44
+ * @returns {boolean} `true` or `false`
45
+ */
46
+ validateAddress(address: string): boolean;
47
+ protected getSuggestedFeeRate(): Promise<FeeRate>;
48
+ protected calcFee(feeRate: FeeRate, memo?: string): Promise<Fee>;
49
+ /**
50
+ * Transfer BTC.
51
+ *
52
+ * @param {TxParams&FeeRate} params The transfer options.
53
+ * @returns {TxHash} The transaction hash.
54
+ *
55
+ * @throws {"memo too long"} Thrown if memo longer than 80 chars.
56
+ */
57
+ transfer(params: TxParams & {
58
+ feeRate?: FeeRate;
59
+ }): Promise<TxHash>;
60
+ buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO, }: TxParams & {
61
+ feeRate: FeeRate;
62
+ sender: Address;
63
+ spendPendingUTXO?: boolean;
64
+ withTxHex?: boolean;
65
+ }): Promise<{
66
+ psbt: Bitcoin.Psbt;
67
+ utxos: UTXO[];
68
+ inputs: UTXO[];
69
+ }>;
70
+ }
71
+ export { Client };
package/lib/const.d.ts CHANGED
@@ -1,33 +1,33 @@
1
- import { ExplorerProvider, UtxoOnlineDataProviders } from '@xchainjs/xchain-client';
2
- import { Asset } from '@xchainjs/xchain-util';
3
- /**
4
- * Minimum transaction fee
5
- * 1000 satoshi/kB (similar to current `minrelaytxfee`)
6
- * @see https://github.com/bitcoin/bitcoin/blob/db88db47278d2e7208c50d16ab10cb355067d071/src/validation.h#L56
7
- */
8
- export declare const MIN_TX_FEE = 1000;
9
- export declare const BTC_DECIMAL = 8;
10
- export declare const LOWER_FEE_BOUND = 1;
11
- export declare const UPPER_FEE_BOUND = 500;
12
- export declare const BTC_SYMBOL = "\u20BF";
13
- export declare const BTC_SATOSHI_SYMBOL = "\u26A1";
14
- /**
15
- * Chain identifier for Bitcoin mainnet
16
- *
17
- */
18
- export declare const BTCChain: "BTC";
19
- /**
20
- * Base "chain" asset on bitcoin main net.
21
- *
22
- * Based on definition in Thorchain `common`
23
- * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-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;
1
+ import { ExplorerProvider, UtxoOnlineDataProviders } from '@xchainjs/xchain-client';
2
+ import { Asset } from '@xchainjs/xchain-util';
3
+ /**
4
+ * Minimum transaction fee
5
+ * 1000 satoshi/kB (similar to current `minrelaytxfee`)
6
+ * @see https://github.com/bitcoin/bitcoin/blob/db88db47278d2e7208c50d16ab10cb355067d071/src/validation.h#L56
7
+ */
8
+ export declare const MIN_TX_FEE = 1000;
9
+ export declare const BTC_DECIMAL = 8;
10
+ export declare const LOWER_FEE_BOUND = 1;
11
+ export declare const UPPER_FEE_BOUND = 500;
12
+ export declare const BTC_SYMBOL = "\u20BF";
13
+ export declare const BTC_SATOSHI_SYMBOL = "\u26A1";
14
+ /**
15
+ * Chain identifier for Bitcoin mainnet
16
+ *
17
+ */
18
+ export declare const BTCChain: "BTC";
19
+ /**
20
+ * Base "chain" asset on bitcoin main net.
21
+ *
22
+ * Based on definition in Thorchain `common`
23
+ * @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-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
- export * from './types';
2
- export * from './client';
3
- export * from './const';
4
- export { getDefaultFees, getDefaultFeesWithRates, getPrefix, validateAddress, calcFee } from './utils';
1
+ export * from './types';
2
+ export * from './client';
3
+ export * from './const';
4
+ export { getDefaultFees, getDefaultFeesWithRates, getPrefix, validateAddress, calcFee } from './utils';