@xchainjs/xchain-bitcoin 0.18.0 → 0.18.4
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 +8 -40
- package/lib/client.d.ts +15 -2
- package/lib/const.d.ts +2 -0
- package/lib/index.esm.js +649 -933
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +650 -932
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/CHANGELOG.md +0 -292
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# `@xchainjs/xchain-
|
|
1
|
+
# `@xchainjs/xchain-bitcoin`
|
|
2
2
|
|
|
3
3
|
## Modules
|
|
4
4
|
|
|
@@ -16,6 +16,13 @@ Following peer dependencies have to be installed into your project. These are no
|
|
|
16
16
|
yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios bitcoinjs-lib wif
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
### [`xchain bitcoin`](http://docs.xchainjs.org/xchain-client/xchain-bitcoin/)
|
|
22
|
+
[`How xchain-bitcoin works`](http://docs.xchainjs.org/xchain-client/xchain-bitcoin/how-it-works.html)\
|
|
23
|
+
[`How to use xchain-bitcoin`](http://docs.xchainjs.org/xchain-client/xchain-bitcoin/how-to-use.html)
|
|
24
|
+
|
|
25
|
+
|
|
19
26
|
## Service Providers
|
|
20
27
|
|
|
21
28
|
This package uses the following service providers:
|
|
@@ -33,46 +40,7 @@ Sochain API rate limits: https://sochain.com/api#rate-limits (300 requests/minut
|
|
|
33
40
|
|
|
34
41
|
Bitgo API rate limits: https://app.bitgo.com/docs/#section/Rate-Limiting (10 requests/second)
|
|
35
42
|
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
Initialize client and use class methods:
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
import { Client, Network } from '../src/client'
|
|
43
|
-
|
|
44
|
-
// Create a new client interface
|
|
45
|
-
const btcClient = new Client({ network: Network.Mainnet, nodeUrl: 'https://sochain.com/api/v2' })
|
|
46
|
-
|
|
47
|
-
// Set phrase
|
|
48
|
-
btcClient.setPhrase('phrase here')
|
|
49
|
-
|
|
50
|
-
// Get address
|
|
51
|
-
const address = btcClient.getAddress()
|
|
52
43
|
|
|
53
|
-
// Get balance
|
|
54
|
-
const balance = await btcClient.getBalance()
|
|
55
44
|
|
|
56
|
-
// Transfer with feeRate
|
|
57
|
-
const txid = await btcClient.transfer({ asset: AssetBTC, recipient: 'recipient address here', amount: baseAmount(100, BTC_DECIMAL), feeRate: 1 })
|
|
58
45
|
|
|
59
|
-
// Transfer with default feeRate (default is `fast`)
|
|
60
|
-
const txid = await btcClient.transfer({ asset: AssetBTC, recipient: 'recipient address here', amount: baseAmount(100, BTC_DECIMAL) })
|
|
61
46
|
|
|
62
|
-
// Get fee estimations
|
|
63
|
-
const { fast, fastest, average } = await btcClient.getFees()
|
|
64
|
-
|
|
65
|
-
// Get feeRate estimations
|
|
66
|
-
const { fast, fastest, average } = await btcClient.getFeeRates()
|
|
67
|
-
|
|
68
|
-
// Search transactions
|
|
69
|
-
const transactions = await btcClient.getTransactions({ address: 'address here', limit: 4 })
|
|
70
|
-
|
|
71
|
-
// Get a transaction with a given txId/hash
|
|
72
|
-
const txData = await btcClient.getTransactionData('b660ee07167cfa32681e2623f3a29dc64a089cabd9a3a07dd17f9028ac956eb8')
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
```
|
package/lib/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, Balance, Fee, FeeRate, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, UTXOClient, XChainClientParams } from '@xchainjs/xchain-client';
|
|
1
|
+
import { Address, Balance, DepositParams, Fee, FeeRate, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, UTXOClient, XChainClientParams } from '@xchainjs/xchain-client';
|
|
2
2
|
import { Asset } from '@xchainjs/xchain-util';
|
|
3
3
|
import { ClientUrl } from './types/client-types';
|
|
4
4
|
export declare type BitcoinClientParams = XChainClientParams & {
|
|
@@ -17,7 +17,7 @@ declare class Client extends UTXOClient {
|
|
|
17
17
|
*
|
|
18
18
|
* @param {BitcoinClientParams} params
|
|
19
19
|
*/
|
|
20
|
-
constructor({ network, sochainUrl, haskoinUrl, rootDerivationPaths, phrase, }: BitcoinClientParams);
|
|
20
|
+
constructor({ network, feeBounds, sochainUrl, haskoinUrl, rootDerivationPaths, phrase, }: BitcoinClientParams);
|
|
21
21
|
/**
|
|
22
22
|
* Set/Update the sochain url.
|
|
23
23
|
*
|
|
@@ -108,9 +108,22 @@ declare class Client extends UTXOClient {
|
|
|
108
108
|
*
|
|
109
109
|
* @param {TxParams&FeeRate} params The transfer options.
|
|
110
110
|
* @returns {TxHash} The transaction hash.
|
|
111
|
+
*
|
|
112
|
+
* @throws {"memo too long"} Thrown if memo longer than 80 chars.
|
|
111
113
|
*/
|
|
112
114
|
transfer(params: TxParams & {
|
|
113
115
|
feeRate?: FeeRate;
|
|
114
116
|
}): Promise<TxHash>;
|
|
117
|
+
/**
|
|
118
|
+
* Transaction to THORChain inbound address.
|
|
119
|
+
*
|
|
120
|
+
* @param {DepositParams} params The transaction options.
|
|
121
|
+
* @returns {TxHash} The transaction hash.
|
|
122
|
+
*
|
|
123
|
+
* @throws {"halted chain"} Thrown if chain is halted.
|
|
124
|
+
* @throws {"halted trading"} Thrown if trading is halted.
|
|
125
|
+
* @throws {"memo too long"} Thrown if memo longer than 80 chars.
|
|
126
|
+
*/
|
|
127
|
+
deposit({ walletIndex, asset, amount, memo }: DepositParams): Promise<TxHash>;
|
|
115
128
|
}
|
|
116
129
|
export { Client };
|