@bsv/wallet-toolbox 1.1.5 → 1.1.7
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 +668 -826
- package/docs/monitor.md +54 -79
- package/docs/services.md +53 -52
- package/docs/setup.md +265 -50
- package/docs/storage.md +115 -187
- package/docs/wallet.md +667 -826
- 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/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +4 -2
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +1 -1
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts +4 -4
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +34 -0
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- 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/methods/purgeData.ts +4 -2
- package/src/storage/methods/reviewStatus.ts +1 -1
- package/src/storage/schema/tables/ProvenTxReq.ts +4 -4
- package/test/Wallet/live/walletLive.man.test.ts +40 -0
- 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 +16 -10
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,66 @@ export interface SetupEnv {
|
|
|
35
52
|
|
|
36
53
|
See also: [Chain](#type-chain)
|
|
37
54
|
|
|
55
|
+
###### Property chain
|
|
56
|
+
|
|
57
|
+
The chan being accessed: 'main' for mainnet, 'test' for 'testnet'.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
chain: sdk.Chain
|
|
61
|
+
```
|
|
62
|
+
See also: [Chain](#type-chain)
|
|
63
|
+
|
|
64
|
+
###### Property devKeys
|
|
65
|
+
|
|
66
|
+
A map of public keys (identity keys, hex strings) to private keys (hex strings).
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
devKeys: Record<string, string>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
###### Property identityKey
|
|
73
|
+
|
|
74
|
+
The user's primary identity key (public key).
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
identityKey: string
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
###### Property identityKey2
|
|
81
|
+
|
|
82
|
+
A secondary identity key (public key), used to test exchanges with other users.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
identityKey2: string
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
###### Property mySQLConnection
|
|
89
|
+
|
|
90
|
+
A MySQL connection string including user and password properties.
|
|
91
|
+
Must be valid to make use of MySQL `Setup` class support.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
mySQLConnection: string
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
###### Property taalApiKey
|
|
98
|
+
|
|
99
|
+
A vaild TAAL API key for use by `Services`
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
taalApiKey: string
|
|
103
|
+
```
|
|
104
|
+
|
|
38
105
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
39
106
|
|
|
40
107
|
---
|
|
41
|
-
|
|
108
|
+
##### Interface: SetupWallet
|
|
109
|
+
|
|
110
|
+
When creating a BRC-100 compatible `Wallet`, many components come into play.
|
|
111
|
+
|
|
112
|
+
All of the `createWallet` functions in the `Setup` and `SetupClient` classes return
|
|
113
|
+
an object with direct access to each component to facilitate experimentation, testing
|
|
114
|
+
and customization.
|
|
42
115
|
|
|
43
116
|
```ts
|
|
44
117
|
export interface SetupWallet {
|
|
@@ -55,17 +128,101 @@ export interface SetupWallet {
|
|
|
55
128
|
|
|
56
129
|
See also: [Chain](#type-chain), [Monitor](#class-monitor), [Services](#class-services), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
57
130
|
|
|
131
|
+
###### Property chain
|
|
132
|
+
|
|
133
|
+
The chain ('main' or 'test') which the wallet accesses.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
chain: sdk.Chain
|
|
137
|
+
```
|
|
138
|
+
See also: [Chain](#type-chain)
|
|
139
|
+
|
|
140
|
+
###### Property identityKey
|
|
141
|
+
|
|
142
|
+
The pubilc key associated with the `rootKey` which also serves as the wallet's identity.
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
identityKey: string
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
###### Property keyDeriver
|
|
149
|
+
|
|
150
|
+
The `KeyDeriver` component used by the wallet for key derivation and cryptographic functions.
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
keyDeriver: KeyDeriver
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
###### Property monitor
|
|
157
|
+
|
|
158
|
+
The background task `Monitor` component available to the wallet to offload tasks
|
|
159
|
+
that speed up wallet operations and maintain data integrity.
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
monitor: Monitor
|
|
163
|
+
```
|
|
164
|
+
See also: [Monitor](#class-monitor)
|
|
165
|
+
|
|
166
|
+
###### Property rootKey
|
|
167
|
+
|
|
168
|
+
The rootKey of the `KeyDeriver`. The private key from which other keys are derived.
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
rootKey: PrivateKey
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
###### Property services
|
|
175
|
+
|
|
176
|
+
The network `Services` component which provides the wallet with access to external services hosted
|
|
177
|
+
on the public network.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
services: Services
|
|
181
|
+
```
|
|
182
|
+
See also: [Services](#class-services)
|
|
183
|
+
|
|
184
|
+
###### Property storage
|
|
185
|
+
|
|
186
|
+
The `WalletStorageManager` that manages all the configured storage providers (active and backups)
|
|
187
|
+
accessed by the wallet.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
storage: WalletStorageManager
|
|
191
|
+
```
|
|
192
|
+
See also: [WalletStorageManager](#class-walletstoragemanager)
|
|
193
|
+
|
|
194
|
+
###### Property wallet
|
|
195
|
+
|
|
196
|
+
The actual BRC-100 `Wallet` to which all the other properties and components contribute.
|
|
197
|
+
|
|
198
|
+
Note that internally, the wallet is itself linked to all these properties and components.
|
|
199
|
+
They are included in this interface to facilitate access after wallet construction for
|
|
200
|
+
experimentation, testing and customization. Any changes made to the configuration of these
|
|
201
|
+
components after construction may disrupt the normal operation of the wallet.
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
wallet: Wallet
|
|
205
|
+
```
|
|
206
|
+
See also: [Wallet](#class-wallet)
|
|
207
|
+
|
|
58
208
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
59
209
|
|
|
60
210
|
---
|
|
61
|
-
|
|
211
|
+
##### Interface: SetupWalletArgs
|
|
62
212
|
|
|
63
|
-
Arguments used to construct a `
|
|
213
|
+
Arguments used by `createWallet` to construct a `SetupWallet`.
|
|
214
|
+
|
|
215
|
+
Extension `SetupWalletClientArgs` used by `createWalletClient` to construct a `SetupWalletClient`.
|
|
216
|
+
|
|
217
|
+
Extension `SetupWalletKnexArgs` used by `createWalletKnex` to construct a `SetupWalletKnex`.
|
|
218
|
+
|
|
219
|
+
Extension `SetupWalletMySQLArgs` used by `createWalletMySQL` to construct a `SetupWalletKnex`.
|
|
220
|
+
|
|
221
|
+
Extension `SetupWalletSQLiteArgs` used by `createWalletSQLite` to construct a `SetupWalletKnex`.
|
|
64
222
|
|
|
65
223
|
```ts
|
|
66
224
|
export interface SetupWalletArgs {
|
|
67
225
|
env: SetupEnv;
|
|
68
|
-
chain?: sdk.Chain;
|
|
69
226
|
rootKeyHex?: string;
|
|
70
227
|
privKeyHex?: string;
|
|
71
228
|
active?: sdk.WalletStorageProvider;
|
|
@@ -73,12 +230,59 @@ export interface SetupWalletArgs {
|
|
|
73
230
|
}
|
|
74
231
|
```
|
|
75
232
|
|
|
76
|
-
See also: [
|
|
233
|
+
See also: [SetupEnv](#interface-setupenv), [WalletStorageProvider](#interface-walletstorageprovider)
|
|
234
|
+
|
|
235
|
+
###### Property active
|
|
236
|
+
|
|
237
|
+
Optional. Active wallet storage. Can be added later.
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
active?: sdk.WalletStorageProvider
|
|
241
|
+
```
|
|
242
|
+
See also: [WalletStorageProvider](#interface-walletstorageprovider)
|
|
243
|
+
|
|
244
|
+
###### Property backups
|
|
245
|
+
|
|
246
|
+
Optional. One or more storage providers managed as backup destinations. Can be added later.
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
backups?: sdk.WalletStorageProvider[]
|
|
250
|
+
```
|
|
251
|
+
See also: [WalletStorageProvider](#interface-walletstorageprovider)
|
|
252
|
+
|
|
253
|
+
###### Property env
|
|
254
|
+
|
|
255
|
+
Configuration "secrets" typically obtained by `Setup.makeEnv` and `Setup.getEnv` functions.
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
env: SetupEnv
|
|
259
|
+
```
|
|
260
|
+
See also: [SetupEnv](#interface-setupenv)
|
|
261
|
+
|
|
262
|
+
###### Property privKeyHex
|
|
263
|
+
|
|
264
|
+
Optional. The privileged private key used to initialize the `PrivilegedKeyManager`.
|
|
265
|
+
Defaults to undefined.
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
privKeyHex?: string
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
###### Property rootKeyHex
|
|
272
|
+
|
|
273
|
+
Optional. The non-privileged private key used to initialize the `KeyDeriver` and determine the `identityKey`.
|
|
274
|
+
Defaults to `env.devKeys[env.identityKey]
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
rootKeyHex?: string
|
|
278
|
+
```
|
|
77
279
|
|
|
78
280
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
79
281
|
|
|
80
282
|
---
|
|
81
|
-
|
|
283
|
+
##### Interface: SetupWalletClient
|
|
284
|
+
|
|
285
|
+
Extension `SetupWalletClient` of `SetupWallet` is returned by `createWalletClient`
|
|
82
286
|
|
|
83
287
|
```ts
|
|
84
288
|
export interface SetupWalletClient extends SetupWallet {
|
|
@@ -88,10 +292,23 @@ export interface SetupWalletClient extends SetupWallet {
|
|
|
88
292
|
|
|
89
293
|
See also: [SetupWallet](#interface-setupwallet)
|
|
90
294
|
|
|
295
|
+
###### Property endpointUrl
|
|
296
|
+
|
|
297
|
+
The endpoint URL of the service hosting the `StorageServer` JSON-RPC service to
|
|
298
|
+
which a `StorageClient` instance is connected to function as
|
|
299
|
+
the active storage provider of the wallet.
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
endpointUrl: string
|
|
303
|
+
```
|
|
304
|
+
|
|
91
305
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
92
306
|
|
|
93
307
|
---
|
|
94
|
-
|
|
308
|
+
##### Interface: SetupWalletClientArgs
|
|
309
|
+
|
|
310
|
+
Extension `SetupWalletClientArgs` of `SetupWalletArgs` is used by `createWalletClient`
|
|
311
|
+
to construct a `SetupWalletClient`.
|
|
95
312
|
|
|
96
313
|
```ts
|
|
97
314
|
export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
@@ -101,10 +318,20 @@ export interface SetupWalletClientArgs extends SetupWalletArgs {
|
|
|
101
318
|
|
|
102
319
|
See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
103
320
|
|
|
321
|
+
###### Property endpointUrl
|
|
322
|
+
|
|
323
|
+
The endpoint URL of a service hosting the `StorageServer` JSON-RPC service to
|
|
324
|
+
which a `StorageClient` instance should connect to function as
|
|
325
|
+
the active storage provider of the newly created wallet.
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
endpointUrl?: string
|
|
329
|
+
```
|
|
330
|
+
|
|
104
331
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
105
332
|
|
|
106
333
|
---
|
|
107
|
-
|
|
334
|
+
##### Interface: SetupWalletKnex
|
|
108
335
|
|
|
109
336
|
```ts
|
|
110
337
|
export interface SetupWalletKnex extends SetupWallet {
|
|
@@ -126,7 +353,7 @@ See also: [Chain](#type-chain), [Monitor](#class-monitor), [Services](#class-ser
|
|
|
126
353
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
127
354
|
|
|
128
355
|
---
|
|
129
|
-
|
|
356
|
+
##### Interface: SetupWalletKnexArgs
|
|
130
357
|
|
|
131
358
|
```ts
|
|
132
359
|
export interface SetupWalletKnexArgs extends SetupWalletArgs {
|
|
@@ -140,7 +367,7 @@ See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
|
140
367
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
141
368
|
|
|
142
369
|
---
|
|
143
|
-
|
|
370
|
+
##### Interface: SetupWalletMySQLArgs
|
|
144
371
|
|
|
145
372
|
```ts
|
|
146
373
|
export interface SetupWalletMySQLArgs extends SetupWalletArgs {
|
|
@@ -153,7 +380,7 @@ See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
|
153
380
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
154
381
|
|
|
155
382
|
---
|
|
156
|
-
|
|
383
|
+
##### Interface: SetupWalletSQLiteArgs
|
|
157
384
|
|
|
158
385
|
```ts
|
|
159
386
|
export interface SetupWalletSQLiteArgs extends SetupWalletArgs {
|
|
@@ -167,7 +394,7 @@ See also: [SetupWalletArgs](#interface-setupwalletargs)
|
|
|
167
394
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
168
395
|
|
|
169
396
|
---
|
|
170
|
-
|
|
397
|
+
#### Classes
|
|
171
398
|
|
|
172
399
|
| |
|
|
173
400
|
| --- |
|
|
@@ -178,7 +405,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
178
405
|
|
|
179
406
|
---
|
|
180
407
|
|
|
181
|
-
|
|
408
|
+
##### Class: Setup
|
|
182
409
|
|
|
183
410
|
The 'Setup` class provides static setup functions to construct BRC-100 compatible
|
|
184
411
|
wallets in a variety of configurations.
|
|
@@ -190,7 +417,7 @@ It serves as a starting point for experimentation and customization.
|
|
|
190
417
|
|
|
191
418
|
```ts
|
|
192
419
|
export abstract class Setup extends SetupClient {
|
|
193
|
-
static async
|
|
420
|
+
static async createWalletKnex(args: SetupWalletKnexArgs): Promise<SetupWalletKnex> {
|
|
194
421
|
const wo = await Setup.createWallet(args);
|
|
195
422
|
const activeStorage = new StorageKnex({
|
|
196
423
|
chain: wo.chain,
|
|
@@ -234,14 +461,14 @@ export abstract class Setup extends SetupClient {
|
|
|
234
461
|
const knex = makeKnex(config);
|
|
235
462
|
return knex;
|
|
236
463
|
}
|
|
237
|
-
static async
|
|
238
|
-
return await this.
|
|
464
|
+
static async createWalletMySQL(args: SetupWalletMySQLArgs): Promise<SetupWalletKnex> {
|
|
465
|
+
return await this.createWalletKnex({
|
|
239
466
|
...args,
|
|
240
467
|
knex: Setup.createMySQLKnex(args.env.mySQLConnection, args.databaseName)
|
|
241
468
|
});
|
|
242
469
|
}
|
|
243
|
-
static async
|
|
244
|
-
return await this.
|
|
470
|
+
static async createWalletSQLite(args: SetupWalletSQLiteArgs): Promise<SetupWalletKnex> {
|
|
471
|
+
return await this.createWalletKnex({
|
|
245
472
|
...args,
|
|
246
473
|
knex: Setup.createSQLiteKnex(args.filePath)
|
|
247
474
|
});
|
|
@@ -251,16 +478,12 @@ export abstract class Setup extends SetupClient {
|
|
|
251
478
|
|
|
252
479
|
See also: [SetupClient](#class-setupclient), [SetupWalletKnex](#interface-setupwalletknex), [SetupWalletKnexArgs](#interface-setupwalletknexargs), [SetupWalletMySQLArgs](#interface-setupwalletmysqlargs), [SetupWalletSQLiteArgs](#interface-setupwalletsqliteargs), [StorageKnex](#class-storageknex)
|
|
253
480
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
<summary>Class Setup Details</summary>
|
|
257
|
-
|
|
258
|
-
#### Method createKnexWallet
|
|
481
|
+
###### Method createWalletKnex
|
|
259
482
|
|
|
260
483
|
Adds `Knex` based storage to a `Wallet` configured by `Setup.createWalletOnly`
|
|
261
484
|
|
|
262
485
|
```ts
|
|
263
|
-
static async
|
|
486
|
+
static async createWalletKnex(args: SetupWalletKnexArgs): Promise<SetupWalletKnex> {
|
|
264
487
|
const wo = await Setup.createWallet(args);
|
|
265
488
|
const activeStorage = new StorageKnex({
|
|
266
489
|
chain: wo.chain,
|
|
@@ -295,12 +518,10 @@ For MySQL, a schema corresponding to databaseName must exist with full access pe
|
|
|
295
518
|
+ **args.chain**
|
|
296
519
|
+ Which chain this wallet is on: 'main' or 'test'. Defaults to 'test'.
|
|
297
520
|
|
|
298
|
-
</details>
|
|
299
|
-
|
|
300
521
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
301
522
|
|
|
302
523
|
---
|
|
303
|
-
|
|
524
|
+
##### Class: SetupClient
|
|
304
525
|
|
|
305
526
|
The `SetupClient` class provides static setup functions to construct BRC-100 compatible
|
|
306
527
|
wallets in a variety of configurations.
|
|
@@ -342,18 +563,17 @@ export abstract class SetupClient {
|
|
|
342
563
|
}
|
|
343
564
|
static getEnv(chain: sdk.Chain): SetupEnv
|
|
344
565
|
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
345
|
-
|
|
566
|
+
const chain = args.env.chain;
|
|
346
567
|
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
347
568
|
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
348
569
|
const identityKey = rootKey.toPublicKey().toString();
|
|
349
570
|
const keyDeriver = new KeyDeriver(rootKey);
|
|
350
|
-
const chain = args.chain;
|
|
351
571
|
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
352
572
|
if (storage.stores.length > 0)
|
|
353
573
|
await storage.makeAvailable();
|
|
354
574
|
const serviceOptions = Services.createDefaultOptions(chain);
|
|
355
575
|
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
356
|
-
const services = new Services(
|
|
576
|
+
const services = new Services(chain);
|
|
357
577
|
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
358
578
|
const monitor = new Monitor(monopts);
|
|
359
579
|
monitor.addDefaultTasks();
|
|
@@ -382,7 +602,7 @@ export abstract class SetupClient {
|
|
|
382
602
|
};
|
|
383
603
|
return r;
|
|
384
604
|
}
|
|
385
|
-
static async
|
|
605
|
+
static async createWalletClient(args: SetupWalletClientArgs): Promise<SetupWalletClient>
|
|
386
606
|
static getKeyPair(priv?: string | PrivateKey): KeyPairAddress
|
|
387
607
|
static getLockP2PKH(address: string)
|
|
388
608
|
static getUnlockP2PKH(priv: PrivateKey, satoshis: number): sdk.ScriptTemplateUnlock
|
|
@@ -409,11 +629,7 @@ export abstract class SetupClient {
|
|
|
409
629
|
|
|
410
630
|
See also: [Chain](#type-chain), [KeyPairAddress](#type-keypairaddress), [Monitor](#class-monitor), [PrivilegedKeyManager](#class-privilegedkeymanager), [ScriptTemplateUnlock](#interface-scripttemplateunlock), [Services](#class-services), [SetupEnv](#interface-setupenv), [SetupWallet](#interface-setupwallet), [SetupWalletArgs](#interface-setupwalletargs), [SetupWalletClient](#interface-setupwalletclient), [SetupWalletClientArgs](#interface-setupwalletclientargs), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
411
631
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
<summary>Class SetupClient Details</summary>
|
|
415
|
-
|
|
416
|
-
#### Method createWallet
|
|
632
|
+
###### Method createWallet
|
|
417
633
|
|
|
418
634
|
Create a `Wallet`. Storage can optionally be provided or configured later.
|
|
419
635
|
|
|
@@ -422,18 +638,17 @@ Optionally, PrivilegedKeyManager is also configured.
|
|
|
422
638
|
|
|
423
639
|
```ts
|
|
424
640
|
static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
425
|
-
|
|
641
|
+
const chain = args.env.chain;
|
|
426
642
|
args.rootKeyHex ||= args.env.devKeys[args.env.identityKey];
|
|
427
643
|
const rootKey = PrivateKey.fromHex(args.rootKeyHex);
|
|
428
644
|
const identityKey = rootKey.toPublicKey().toString();
|
|
429
645
|
const keyDeriver = new KeyDeriver(rootKey);
|
|
430
|
-
const chain = args.chain;
|
|
431
646
|
const storage = new WalletStorageManager(identityKey, args.active, args.backups);
|
|
432
647
|
if (storage.stores.length > 0)
|
|
433
648
|
await storage.makeAvailable();
|
|
434
649
|
const serviceOptions = Services.createDefaultOptions(chain);
|
|
435
650
|
serviceOptions.taalApiKey = args.env.taalApiKey;
|
|
436
|
-
const services = new Services(
|
|
651
|
+
const services = new Services(chain);
|
|
437
652
|
const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
|
|
438
653
|
const monitor = new Monitor(monopts);
|
|
439
654
|
monitor.addDefaultTasks();
|
|
@@ -465,7 +680,7 @@ static async createWallet(args: SetupWalletArgs): Promise<SetupWallet> {
|
|
|
465
680
|
```
|
|
466
681
|
See also: [Monitor](#class-monitor), [PrivilegedKeyManager](#class-privilegedkeymanager), [Services](#class-services), [SetupWallet](#interface-setupwallet), [SetupWalletArgs](#interface-setupwalletargs), [Wallet](#class-wallet), [WalletStorageManager](#class-walletstoragemanager)
|
|
467
682
|
|
|
468
|
-
|
|
683
|
+
###### Method getEnv
|
|
469
684
|
|
|
470
685
|
Reads a .env file of the format created by `makeEnv`.
|
|
471
686
|
|
|
@@ -487,7 +702,7 @@ Argument Details
|
|
|
487
702
|
+ **chain**
|
|
488
703
|
+ Which chain to use: 'test' or 'main'
|
|
489
704
|
|
|
490
|
-
|
|
705
|
+
###### Method makeEnv
|
|
491
706
|
|
|
492
707
|
Creates content for .env file with some private keys, identity keys, sample API keys, and sample MySQL connection string.
|
|
493
708
|
|
|
@@ -500,16 +715,14 @@ Private keys should never be included directly in your source code.
|
|
|
500
715
|
static makeEnv(): string
|
|
501
716
|
```
|
|
502
717
|
|
|
503
|
-
</details>
|
|
504
|
-
|
|
505
718
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
506
719
|
|
|
507
720
|
---
|
|
508
|
-
|
|
721
|
+
#### Functions
|
|
509
722
|
|
|
510
|
-
|
|
723
|
+
#### Types
|
|
511
724
|
|
|
512
|
-
|
|
725
|
+
##### Type: KeyPairAddress
|
|
513
726
|
|
|
514
727
|
```ts
|
|
515
728
|
export type KeyPairAddress = {
|
|
@@ -522,5 +735,7 @@ export type KeyPairAddress = {
|
|
|
522
735
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
523
736
|
|
|
524
737
|
---
|
|
525
|
-
|
|
738
|
+
#### Variables
|
|
739
|
+
|
|
526
740
|
|
|
741
|
+
<!--#endregion ts2md-api-merged-here-->
|