@bsv/wallet-toolbox 1.1.5 → 1.1.6
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/docs/README.md +1 -1
- package/docs/client.md +698 -442
- package/docs/monitor.md +54 -37
- package/docs/services.md +53 -34
- package/docs/setup.md +295 -38
- package/docs/storage.md +115 -103
- package/docs/wallet.md +697 -442
- package/out/src/Setup.d.ts +3 -3
- package/out/src/Setup.js +5 -5
- package/out/src/SetupClient.d.ts +105 -12
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +3 -4
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/Wallet.d.ts +4 -0
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +7 -0
- package/out/src/Wallet.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts +0 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +0 -1
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/validationHelpers.d.ts +1 -0
- package/out/src/sdk/validationHelpers.d.ts.map +1 -1
- package/out/src/sdk/validationHelpers.js +2 -1
- package/out/src/sdk/validationHelpers.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +1 -4
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +1 -4
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +42 -11
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.js +1 -1
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts +4 -4
- package/out/test/examples/README.man.test.js +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +2 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +112 -27
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/createAction.test.js +31 -5
- package/out/test/wallet/action/createAction.test.js.map +1 -1
- package/out/test/wallet/action/createAction2.test.d.ts +37 -0
- package/out/test/wallet/action/createAction2.test.d.ts.map +1 -0
- package/out/test/wallet/action/createAction2.test.js +1145 -0
- package/out/test/wallet/action/createAction2.test.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Setup.ts +5 -5
- package/src/SetupClient.ts +107 -15
- package/src/Wallet.ts +9 -0
- package/src/sdk/WalletError.ts +0 -1
- package/src/sdk/validationHelpers.ts +3 -1
- package/src/storage/StorageProvider.ts +1 -4
- package/src/storage/methods/createAction.ts +48 -12
- package/src/storage/methods/generateChange.ts +1 -1
- package/src/storage/schema/tables/ProvenTxReq.ts +4 -4
- package/test/examples/README.man.test.ts +1 -1
- package/test/utils/TestUtilsWalletStorage.ts +131 -35
- package/test/wallet/action/createAction.test.ts +36 -5
- package/test/wallet/action/createAction2.test.ts +1400 -0
- package/ts2md.json +6 -6
package/docs/setup.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
# API
|
|
1
|
+
# SETUP: BSV Wallet Toolbox API Documentation
|
|
2
|
+
|
|
3
|
+
The documentation is split into various pages, this page covers the [Setup](#class-setup) and [SetupClient](#class-setupclient) classes and interfaces.
|
|
4
|
+
|
|
5
|
+
Unless you are targetting the browser deployment context, focus on [Setup](#class-setup) as it extends the [SetupClient](#class-setupclient) class.
|
|
6
|
+
|
|
7
|
+
The purpose of this API is to simplify and demonstrate the construction of wallets in various configurations.
|
|
8
|
+
|
|
9
|
+
[Return To Top](./README.md)
|
|
10
|
+
|
|
11
|
+
<!--#region ts2md-api-merged-here-->
|
|
12
|
+
### API
|
|
2
13
|
|
|
3
14
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
4
15
|
|
|
5
|
-
|
|
16
|
+
#### Interfaces
|
|
6
17
|
|
|
7
18
|
| |
|
|
8
19
|
| --- |
|
|
@@ -20,7 +31,13 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
20
31
|
|
|
21
32
|
---
|
|
22
33
|
|
|
23
|
-
|
|
34
|
+
##### Interface: SetupEnv
|
|
35
|
+
|
|
36
|
+
`SetupEnv` provides a starting point for managing secrets that
|
|
37
|
+
must not appear in source code.
|
|
38
|
+
|
|
39
|
+
The `makeEnv` and `getEnv` functions of the `Setup` and `SetupClient` classes
|
|
40
|
+
provide an easy way to create and import these secrets and related properties.
|
|
24
41
|
|
|
25
42
|
```ts
|
|
26
43
|
export interface SetupEnv {
|
|
@@ -35,10 +52,72 @@ export interface SetupEnv {
|
|
|
35
52
|
|
|
36
53
|
See also: [Chain](#type-chain)
|
|
37
54
|
|
|
55
|
+
<details>
|
|
56
|
+
|
|
57
|
+
<summary>Interface SetupEnv Details</summary>
|
|
58
|
+
|
|
59
|
+
###### Property chain
|
|
60
|
+
|
|
61
|
+
The chan being accessed: 'main' for mainnet, 'test' for 'testnet'.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
chain: sdk.Chain
|
|
65
|
+
```
|
|
66
|
+
See also: [Chain](#type-chain)
|
|
67
|
+
|
|
68
|
+
###### Property devKeys
|
|
69
|
+
|
|
70
|
+
A map of public keys (identity keys, hex strings) to private keys (hex strings).
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
devKeys: Record<string, string>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
###### Property identityKey
|
|
77
|
+
|
|
78
|
+
The user's primary identity key (public key).
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
identityKey: string
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
###### Property identityKey2
|
|
85
|
+
|
|
86
|
+
A secondary identity key (public key), used to test exchanges with other users.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
identityKey2: string
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
###### Property mySQLConnection
|
|
93
|
+
|
|
94
|
+
A MySQL connection string including user and password properties.
|
|
95
|
+
Must be valid to make use of MySQL `Setup` class support.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
mySQLConnection: string
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
###### Property taalApiKey
|
|
102
|
+
|
|
103
|
+
A vaild TAAL API key for use by `Services`
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
taalApiKey: string
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
|
|
38
111
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
39
112
|
|
|
40
113
|
---
|
|
41
|
-
|
|
114
|
+
##### Interface: SetupWallet
|
|
115
|
+
|
|
116
|
+
When creating a BRC-100 compatible `Wallet`, many components come into play.
|
|
117
|
+
|
|
118
|
+
All of the `createWallet` functions in the `Setup` and `SetupClient` classes return
|
|
119
|
+
an object with direct access to each component to facilitate experimentation, testing
|
|
120
|
+
and customization.
|
|
42
121
|
|
|
43
122
|
```ts
|
|
44
123
|
export interface SetupWallet {
|
|
@@ -55,17 +134,107 @@ export interface SetupWallet {
|
|
|
55
134
|
|
|
56
135
|
See also: [Chain](#type-chain), [Monitor](#class-monitor), [Services](#class-services), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
57
136
|
|
|
137
|
+
<details>
|
|
138
|
+
|
|
139
|
+
<summary>Interface SetupWallet Details</summary>
|
|
140
|
+
|
|
141
|
+
###### Property chain
|
|
142
|
+
|
|
143
|
+
The chain ('main' or 'test') which the wallet accesses.
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
chain: sdk.Chain
|
|
147
|
+
```
|
|
148
|
+
See also: [Chain](#type-chain)
|
|
149
|
+
|
|
150
|
+
###### Property identityKey
|
|
151
|
+
|
|
152
|
+
The pubilc key associated with the `rootKey` which also serves as the wallet's identity.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
identityKey: string
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
###### Property keyDeriver
|
|
159
|
+
|
|
160
|
+
The `KeyDeriver` component used by the wallet for key derivation and cryptographic functions.
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
keyDeriver: KeyDeriver
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
###### Property monitor
|
|
167
|
+
|
|
168
|
+
The background task `Monitor` component available to the wallet to offload tasks
|
|
169
|
+
that speed up wallet operations and maintain data integrity.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
monitor: Monitor
|
|
173
|
+
```
|
|
174
|
+
See also: [Monitor](#class-monitor)
|
|
175
|
+
|
|
176
|
+
###### Property rootKey
|
|
177
|
+
|
|
178
|
+
The rootKey of the `KeyDeriver`. The private key from which other keys are derived.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
rootKey: PrivateKey
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
###### Property services
|
|
185
|
+
|
|
186
|
+
The network `Services` component which provides the wallet with access to external services hosted
|
|
187
|
+
on the public network.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
services: Services
|
|
191
|
+
```
|
|
192
|
+
See also: [Services](#class-services)
|
|
193
|
+
|
|
194
|
+
###### Property storage
|
|
195
|
+
|
|
196
|
+
The `WalletStorageManager` that manages all the configured storage providers (active and backups)
|
|
197
|
+
accessed by the wallet.
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
storage: WalletStorageManager
|
|
201
|
+
```
|
|
202
|
+
See also: [WalletStorageManager](#class-walletstoragemanager)
|
|
203
|
+
|
|
204
|
+
###### Property wallet
|
|
205
|
+
|
|
206
|
+
The actual BRC-100 `Wallet` to which all the other properties and components contribute.
|
|
207
|
+
|
|
208
|
+
Note that internally, the wallet is itself linked to all these properties and components.
|
|
209
|
+
They are included in this interface to facilitate access after wallet construction for
|
|
210
|
+
experimentation, testing and customization. Any changes made to the configuration of these
|
|
211
|
+
components after construction may disrupt the normal operation of the wallet.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
wallet: Wallet
|
|
215
|
+
```
|
|
216
|
+
See also: [Wallet](#class-wallet)
|
|
217
|
+
|
|
218
|
+
</details>
|
|
219
|
+
|
|
58
220
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
59
221
|
|
|
60
222
|
---
|
|
61
|
-
|
|
223
|
+
##### Interface: SetupWalletArgs
|
|
224
|
+
|
|
225
|
+
Arguments used by `createWallet` to construct a `SetupWallet`.
|
|
226
|
+
|
|
227
|
+
Extension `SetupWalletClientArgs` used by `createWalletClient` to construct a `SetupWalletClient`.
|
|
62
228
|
|
|
63
|
-
|
|
229
|
+
Extension `SetupWalletKnexArgs` used by `createWalletKnex` to construct a `SetupWalletKnex`.
|
|
230
|
+
|
|
231
|
+
Extension `SetupWalletMySQLArgs` used by `createWalletMySQL` to construct a `SetupWalletKnex`.
|
|
232
|
+
|
|
233
|
+
Extension `SetupWalletSQLiteArgs` used by `createWalletSQLite` to construct a `SetupWalletKnex`.
|
|
64
234
|
|
|
65
235
|
```ts
|
|
66
236
|
export interface SetupWalletArgs {
|
|
67
237
|
env: SetupEnv;
|
|
68
|
-
chain?: sdk.Chain;
|
|
69
238
|
rootKeyHex?: string;
|
|
70
239
|
privKeyHex?: string;
|
|
71
240
|
active?: sdk.WalletStorageProvider;
|
|
@@ -73,12 +242,65 @@ export interface SetupWalletArgs {
|
|
|
73
242
|
}
|
|
74
243
|
```
|
|
75
244
|
|
|
76
|
-
See also: [
|
|
245
|
+
See also: [SetupEnv](#interface-setupenv), [WalletStorageProvider](#interface-walletstorageprovider)
|
|
246
|
+
|
|
247
|
+
<details>
|
|
248
|
+
|
|
249
|
+
<summary>Interface SetupWalletArgs Details</summary>
|
|
250
|
+
|
|
251
|
+
###### Property active
|
|
252
|
+
|
|
253
|
+
Optional. Active wallet storage. Can be added later.
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
active?: sdk.WalletStorageProvider
|
|
257
|
+
```
|
|
258
|
+
See also: [WalletStorageProvider](#interface-walletstorageprovider)
|
|
259
|
+
|
|
260
|
+
###### Property backups
|
|
261
|
+
|
|
262
|
+
Optional. One or more storage providers managed as backup destinations. Can be added later.
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
backups?: sdk.WalletStorageProvider[]
|
|
266
|
+
```
|
|
267
|
+
See also: [WalletStorageProvider](#interface-walletstorageprovider)
|
|
268
|
+
|
|
269
|
+
###### Property env
|
|
270
|
+
|
|
271
|
+
Configuration "secrets" typically obtained by `Setup.makeEnv` and `Setup.getEnv` functions.
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
env: SetupEnv
|
|
275
|
+
```
|
|
276
|
+
See also: [SetupEnv](#interface-setupenv)
|
|
277
|
+
|
|
278
|
+
###### Property privKeyHex
|
|
279
|
+
|
|
280
|
+
Optional. The privileged private key used to initialize the `PrivilegedKeyManager`.
|
|
281
|
+
Defaults to undefined.
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
privKeyHex?: string
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
###### Property rootKeyHex
|
|
288
|
+
|
|
289
|
+
Optional. The non-privileged private key used to initialize the `KeyDeriver` and determine the `identityKey`.
|
|
290
|
+
Defaults to `env.devKeys[env.identityKey]
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
rootKeyHex?: string
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
</details>
|
|
77
297
|
|
|
78
298
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
79
299
|
|
|
80
300
|
---
|
|
81
|
-
|
|
301
|
+
##### Interface: SetupWalletClient
|
|
302
|
+
|
|
303
|
+
Extension `SetupWalletClient` of `SetupWallet` is returned by `createWalletClient`
|
|
82
304
|
|
|
83
305
|
```ts
|
|
84
306
|
export interface SetupWalletClient extends SetupWallet {
|
|
@@ -88,10 +310,29 @@ export interface SetupWalletClient extends SetupWallet {
|
|
|
88
310
|
|
|
89
311
|
See also: [SetupWallet](#interface-setupwallet)
|
|
90
312
|
|
|
313
|
+
<details>
|
|
314
|
+
|
|
315
|
+
<summary>Interface SetupWalletClient Details</summary>
|
|
316
|
+
|
|
317
|
+
###### Property endpointUrl
|
|
318
|
+
|
|
319
|
+
The endpoint URL of the service hosting the `StorageServer` JSON-RPC service to
|
|
320
|
+
which a `StorageClient` instance is connected to function as
|
|
321
|
+
the active storage provider of the wallet.
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
endpointUrl: string
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
</details>
|
|
328
|
+
|
|
91
329
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
92
330
|
|
|
93
331
|
---
|
|
94
|
-
|
|
332
|
+
##### Interface: SetupWalletClientArgs
|
|
333
|
+
|
|
334
|
+
Extension `SetupWalletClientArgs` of `SetupWalletArgs` is used by `createWalletClient`
|
|
335
|
+
to construct a `SetupWalletClient`.
|
|
95
336
|
|
|
96
337
|
```ts
|
|
97
338
|
export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
@@ -101,10 +342,26 @@ export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
|
101
342
|
|
|
102
343
|
See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
103
344
|
|
|
345
|
+
<details>
|
|
346
|
+
|
|
347
|
+
<summary>Interface SetupWalletClientArgs Details</summary>
|
|
348
|
+
|
|
349
|
+
###### Property endpointUrl
|
|
350
|
+
|
|
351
|
+
The endpoint URL of a service hosting the `StorageServer` JSON-RPC service to
|
|
352
|
+
which a `StorageClient` instance should connect to function as
|
|
353
|
+
the active storage provider of the newly created wallet.
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
endpointUrl?: string
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
</details>
|
|
360
|
+
|
|
104
361
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
105
362
|
|
|
106
363
|
---
|
|
107
|
-
|
|
364
|
+
##### Interface: SetupWalletKnex
|
|
108
365
|
|
|
109
366
|
```ts
|
|
110
367
|
export interface SetupWalletKnex extends SetupWallet {
|
|
@@ -126,7 +383,7 @@ See also: [Chain](#type-chain), [Monitor](#class-monitor), [Services](#class-ser
|
|
|
126
383
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
127
384
|
|
|
128
385
|
---
|
|
129
|
-
|
|
386
|
+
##### Interface: SetupWalletKnexArgs
|
|
130
387
|
|
|
131
388
|
```ts
|
|
132
389
|
export interface SetupWalletKnexArgs extends SetupWalletArgs {
|
|
@@ -140,7 +397,7 @@ See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
|
140
397
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
141
398
|
|
|
142
399
|
---
|
|
143
|
-
|
|
400
|
+
##### Interface: SetupWalletMySQLArgs
|
|
144
401
|
|
|
145
402
|
```ts
|
|
146
403
|
export interface SetupWalletMySQLArgs extends SetupWalletArgs {
|
|
@@ -153,7 +410,7 @@ See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
|
153
410
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
154
411
|
|
|
155
412
|
---
|
|
156
|
-
|
|
413
|
+
##### Interface: SetupWalletSQLiteArgs
|
|
157
414
|
|
|
158
415
|
```ts
|
|
159
416
|
export interface SetupWalletSQLiteArgs extends SetupWalletArgs {
|
|
@@ -167,7 +424,7 @@ See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
|
167
424
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
168
425
|
|
|
169
426
|
---
|
|
170
|
-
|
|
427
|
+
#### Classes
|
|
171
428
|
|
|
172
429
|
| |
|
|
173
430
|
| --- |
|
|
@@ -178,7 +435,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
178
435
|
|
|
179
436
|
---
|
|
180
437
|
|
|
181
|
-
|
|
438
|
+
##### Class: Setup
|
|
182
439
|
|
|
183
440
|
The 'Setup` class provides static setup functions to construct BRC-100 compatible
|
|
184
441
|
wallets in a variety of configurations.
|
|
@@ -190,7 +447,7 @@ It serves as a starting point for experimentation and customization.
|
|
|
190
447
|
|
|
191
448
|
```ts
|
|
192
449
|
export abstract class Setup extends SetupClient {
|
|
193
|
-
static async
|
|
450
|
+
static async createWalletKnex(args: SetupWalletKnexArgs): Promise<SetupWalletKnex> {
|
|
194
451
|
const wo = await Setup.createWallet(args);
|
|
195
452
|
const activeStorage = new StorageKnex({
|
|
196
453
|
chain: wo.chain,
|
|
@@ -234,14 +491,14 @@ export abstract class Setup extends SetupClient {
|
|
|
234
491
|
const knex = makeKnex(config);
|
|
235
492
|
return knex;
|
|
236
493
|
}
|
|
237
|
-
static async
|
|
238
|
-
return await this.
|
|
494
|
+
static async createWalletMySQL(args: SetupWalletMySQLArgs): Promise<SetupWalletKnex> {
|
|
495
|
+
return await this.createWalletKnex({
|
|
239
496
|
...args,
|
|
240
497
|
knex: Setup.createMySQLKnex(args.env.mySQLConnection, args.databaseName)
|
|
241
498
|
});
|
|
242
499
|
}
|
|
243
|
-
static async
|
|
244
|
-
return await this.
|
|
500
|
+
static async createWalletSQLite(args: SetupWalletSQLiteArgs): Promise<SetupWalletKnex> {
|
|
501
|
+
return await this.createWalletKnex({
|
|
245
502
|
...args,
|
|
246
503
|
knex: Setup.createSQLiteKnex(args.filePath)
|
|
247
504
|
});
|
|
@@ -255,12 +512,12 @@ See also: [SetupClient](#class-setupclient), [SetupWalletKnex](#interface-setupw
|
|
|
255
512
|
|
|
256
513
|
<summary>Class Setup Details</summary>
|
|
257
514
|
|
|
258
|
-
|
|
515
|
+
###### Method createWalletKnex
|
|
259
516
|
|
|
260
517
|
Adds `Knex` based storage to a `Wallet` configured by `Setup.createWalletOnly`
|
|
261
518
|
|
|
262
519
|
```ts
|
|
263
|
-
static async
|
|
520
|
+
static async createWalletKnex(args: SetupWalletKnexArgs): Promise<SetupWalletKnex> {
|
|
264
521
|
const wo = await Setup.createWallet(args);
|
|
265
522
|
const activeStorage = new StorageKnex({
|
|
266
523
|
chain: wo.chain,
|
|
@@ -300,7 +557,7 @@ For MySQL, a schema corresponding to databaseName must exist with full access pe
|
|
|
300
557
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
301
558
|
|
|
302
559
|
---
|
|
303
|
-
|
|
560
|
+
##### Class: SetupClient
|
|
304
561
|
|
|
305
562
|
The `SetupClient` class provides static setup functions to construct BRC-100 compatible
|
|
306
563
|
wallets in a variety of configurations.
|
|
@@ -342,18 +599,17 @@ export abstract class SetupClient {
|
|
|
342
599
|
}
|
|
343
600
|
static getEnv(chain: sdk.Chain): SetupEnv
|
|
344
601
|
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
345
|
-
|
|
602
|
+
const chain = args.env.chain;
|
|
346
603
|
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
347
604
|
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
348
605
|
const identityKey = rootKey.toPublicKey().toString();
|
|
349
606
|
const keyDeriver = new KeyDeriver(rootKey);
|
|
350
|
-
const chain = args.chain;
|
|
351
607
|
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
352
608
|
if (storage.stores.length > 0)
|
|
353
609
|
await storage.makeAvailable();
|
|
354
610
|
const serviceOptions = Services.createDefaultOptions(chain);
|
|
355
611
|
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
356
|
-
const services = new Services(
|
|
612
|
+
const services = new Services(chain);
|
|
357
613
|
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
358
614
|
const monitor = new Monitor(monopts);
|
|
359
615
|
monitor.addDefaultTasks();
|
|
@@ -382,7 +638,7 @@ export abstract class SetupClient {
|
|
|
382
638
|
};
|
|
383
639
|
return r;
|
|
384
640
|
}
|
|
385
|
-
static async
|
|
641
|
+
static async createWalletClient(args: SetupWalletClientArgs): Promise<SetupWalletClient>
|
|
386
642
|
static getKeyPair(priv?: string | PrivateKey): KeyPairAddress
|
|
387
643
|
static getLockP2PKH(address: string)
|
|
388
644
|
static getUnlockP2PKH(priv: PrivateKey, satoshis: number): sdk.ScriptTemplateUnlock
|
|
@@ -413,7 +669,7 @@ See also: [Chain](#type-chain), [KeyPairAddress](#type-keypairaddress), [Monitor
|
|
|
413
669
|
|
|
414
670
|
<summary>Class SetupClient Details</summary>
|
|
415
671
|
|
|
416
|
-
|
|
672
|
+
###### Method createWallet
|
|
417
673
|
|
|
418
674
|
Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
419
675
|
|
|
@@ -422,18 +678,17 @@ Optionally, PrivilegedKeyManager is also configured.
|
|
|
422
678
|
|
|
423
679
|
```ts
|
|
424
680
|
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
425
|
-
|
|
681
|
+
const chain = args.env.chain;
|
|
426
682
|
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
427
683
|
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
428
684
|
const identityKey = rootKey.toPublicKey().toString();
|
|
429
685
|
const keyDeriver = new KeyDeriver(rootKey);
|
|
430
|
-
const chain = args.chain;
|
|
431
686
|
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
432
687
|
if (storage.stores.length > 0)
|
|
433
688
|
await storage.makeAvailable();
|
|
434
689
|
const serviceOptions = Services.createDefaultOptions(chain);
|
|
435
690
|
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
436
|
-
const services = new Services(
|
|
691
|
+
const services = new Services(chain);
|
|
437
692
|
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
438
693
|
const monitor = new Monitor(monopts);
|
|
439
694
|
monitor.addDefaultTasks();
|
|
@@ -465,7 +720,7 @@ static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
|
465
720
|
```
|
|
466
721
|
See also: [Monitor](#class-monitor), [PrivilegedKeyManager](#class-privilegedkeymanager), [Services](#class-services), [SetupWallet](#interface-setupwallet), [SetupWalletArgs](#interface-setupwalletargs), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
467
722
|
|
|
468
|
-
|
|
723
|
+
###### Method getEnv
|
|
469
724
|
|
|
470
725
|
Reads a .env file of the format created by `makeEnv`.
|
|
471
726
|
|
|
@@ -487,7 +742,7 @@ Argument Details
|
|
|
487
742
|
+ **chain**
|
|
488
743
|
+ Which chain to use: 'test' or 'main'
|
|
489
744
|
|
|
490
|
-
|
|
745
|
+
###### Method makeEnv
|
|
491
746
|
|
|
492
747
|
Creates content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
|
|
493
748
|
|
|
@@ -505,11 +760,11 @@ static makeEnv(): string
|
|
|
505
760
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
506
761
|
|
|
507
762
|
---
|
|
508
|
-
|
|
763
|
+
#### Functions
|
|
509
764
|
|
|
510
|
-
|
|
765
|
+
#### Types
|
|
511
766
|
|
|
512
|
-
|
|
767
|
+
##### Type: KeyPairAddress
|
|
513
768
|
|
|
514
769
|
```ts
|
|
515
770
|
export type KeyPairAddress = {
|
|
@@ -522,5 +777,7 @@ export type KeyPairAddress = {
|
|
|
522
777
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
523
778
|
|
|
524
779
|
---
|
|
525
|
-
|
|
780
|
+
#### Variables
|
|
781
|
+
|
|
526
782
|
|
|
783
|
+
<!--#endregion ts2md-api-merged-here-->
|