@bsv/wallet-toolbox 1.1.21 → 1.1.23
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/client.md +47 -20
- package/docs/setup.md +47 -20
- package/docs/wallet.md +47 -20
- package/out/src/SetupClient.d.ts +16 -2
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +37 -8
- package/out/src/SetupClient.js.map +1 -1
- package/out/test/examples/pushdrop.test.d.ts.map +1 -1
- package/out/test/examples/pushdrop.test.js +1 -3
- package/out/test/examples/pushdrop.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/SetupClient.ts +46 -10
- package/test/examples/pushdrop.test.ts +1 -4
package/package.json
CHANGED
package/src/SetupClient.ts
CHANGED
|
@@ -76,10 +76,10 @@ MY_MAIN_IDENTITY = '${mainIdentityKey1}'
|
|
|
76
76
|
MY_MAIN_IDENTITY2 = '${mainIdentityKey2}'
|
|
77
77
|
MAIN_TAAL_API_KEY='mainnet_9596de07e92300c6287e4393594ae39c'
|
|
78
78
|
TEST_TAAL_API_KEY='testnet_0e6cf72133b43ea2d7861da2a38684e3'
|
|
79
|
-
MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"
|
|
79
|
+
MYSQL_CONNECTION='{"port":3306,"host":"127.0.0.1","user":"root","password":"your_password","database":"your_database", "timezone": "Z"}'
|
|
80
80
|
DEV_KEYS = '{
|
|
81
81
|
"${testIdentityKey1}": "${testPrivKey1.toString()}",
|
|
82
|
-
"${testIdentityKey2}": "${testPrivKey2.toString()}"
|
|
82
|
+
"${testIdentityKey2}": "${testPrivKey2.toString()}",
|
|
83
83
|
"${mainIdentityKey1}": "${mainPrivKey1.toString()}",
|
|
84
84
|
"${mainIdentityKey2}": "${mainPrivKey2.toString()}"
|
|
85
85
|
}'
|
|
@@ -162,7 +162,7 @@ DEV_KEYS = '{
|
|
|
162
162
|
if (storage.stores.length > 0) await storage.makeAvailable()
|
|
163
163
|
const serviceOptions = Services.createDefaultOptions(chain)
|
|
164
164
|
serviceOptions.taalApiKey = args.env.taalApiKey
|
|
165
|
-
const services = new Services(
|
|
165
|
+
const services = new Services(serviceOptions)
|
|
166
166
|
const monopts = Monitor.createDefaultWalletMonitorOptions(
|
|
167
167
|
chain,
|
|
168
168
|
storage,
|
|
@@ -170,11 +170,9 @@ DEV_KEYS = '{
|
|
|
170
170
|
)
|
|
171
171
|
const monitor = new Monitor(monopts)
|
|
172
172
|
monitor.addDefaultTasks()
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
privilegedKeyManager = new sdk.PrivilegedKeyManager(async () => privKey)
|
|
177
|
-
}
|
|
173
|
+
const privilegedKeyManager = args.privilegedKeyGetter
|
|
174
|
+
? new sdk.PrivilegedKeyManager(args.privilegedKeyGetter)
|
|
175
|
+
: undefined
|
|
178
176
|
const wallet = new Wallet({
|
|
179
177
|
chain,
|
|
180
178
|
keyDeriver,
|
|
@@ -196,6 +194,44 @@ DEV_KEYS = '{
|
|
|
196
194
|
return r
|
|
197
195
|
}
|
|
198
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Setup a new `Wallet` without requiring a .env file.
|
|
199
|
+
*
|
|
200
|
+
* @param args.chain - 'main' or 'test'
|
|
201
|
+
* @param args.rootKeyHex - Root private key for wallet's key deriver.
|
|
202
|
+
* @param args.storageUrl - Optional. `StorageClient` and `chain` compatible endpoint URL.
|
|
203
|
+
* @param args.privilegedKeyGetter - Optional. Method that will return the privileged `PrivateKey`, on demand.
|
|
204
|
+
*/
|
|
205
|
+
static async createWalletClientNoEnv(args: {
|
|
206
|
+
chain: sdk.Chain
|
|
207
|
+
rootKeyHex: string
|
|
208
|
+
storageUrl?: string
|
|
209
|
+
privilegedKeyGetter?: () => Promise<PrivateKey>
|
|
210
|
+
}): Promise<Wallet> {
|
|
211
|
+
const chain = args.chain
|
|
212
|
+
const endpointUrl =
|
|
213
|
+
args.storageUrl ||
|
|
214
|
+
`https://${args.chain !== 'main' ? 'staging-' : ''}storage.babbage.systems`
|
|
215
|
+
const rootKey = PrivateKey.fromHex(args.rootKeyHex)
|
|
216
|
+
const keyDeriver = new KeyDeriver(rootKey)
|
|
217
|
+
const storage = new WalletStorageManager(keyDeriver.identityKey)
|
|
218
|
+
const services = new Services(chain)
|
|
219
|
+
const privilegedKeyManager = args.privilegedKeyGetter
|
|
220
|
+
? new sdk.PrivilegedKeyManager(args.privilegedKeyGetter)
|
|
221
|
+
: undefined
|
|
222
|
+
const wallet = new Wallet({
|
|
223
|
+
chain,
|
|
224
|
+
keyDeriver,
|
|
225
|
+
storage,
|
|
226
|
+
services,
|
|
227
|
+
privilegedKeyManager
|
|
228
|
+
})
|
|
229
|
+
const client = new StorageClient(wallet, endpointUrl)
|
|
230
|
+
await storage.addWalletStorageProvider(client)
|
|
231
|
+
await storage.makeAvailable()
|
|
232
|
+
return wallet
|
|
233
|
+
}
|
|
234
|
+
|
|
199
235
|
/**
|
|
200
236
|
* @publicbody
|
|
201
237
|
*/
|
|
@@ -406,10 +442,10 @@ export interface SetupWalletArgs {
|
|
|
406
442
|
*/
|
|
407
443
|
rootKeyHex?: string
|
|
408
444
|
/**
|
|
409
|
-
* Optional. The privileged private key used to initialize the `PrivilegedKeyManager`.
|
|
445
|
+
* Optional. The privileged private key getter used to initialize the `PrivilegedKeyManager`.
|
|
410
446
|
* Defaults to undefined.
|
|
411
447
|
*/
|
|
412
|
-
|
|
448
|
+
privilegedKeyGetter?: () => Promise<PrivateKey>
|
|
413
449
|
/**
|
|
414
450
|
* Optional. Active wallet storage. Can be added later.
|
|
415
451
|
*/
|
|
@@ -107,8 +107,7 @@ async function outputPushDrop(
|
|
|
107
107
|
randomizeOutputs: false,
|
|
108
108
|
// This example prefers to immediately wait for the new transaction to be broadcast to the network.
|
|
109
109
|
// Typically, most production applications benefit from performance gains when broadcasts are handled in the background.
|
|
110
|
-
|
|
111
|
-
noSend: true
|
|
110
|
+
acceptDelayedBroadcast: false
|
|
112
111
|
},
|
|
113
112
|
labels: [label],
|
|
114
113
|
description: label
|
|
@@ -133,8 +132,6 @@ ${beef.toHex()}
|
|
|
133
132
|
${beef.toLogString()}
|
|
134
133
|
`)
|
|
135
134
|
|
|
136
|
-
await setup.wallet.abortAction({ reference: car.txid! })
|
|
137
|
-
|
|
138
135
|
// Return the bits and pieces of the new output created.
|
|
139
136
|
return {
|
|
140
137
|
beef,
|