@bsv/wallet-toolbox 1.1.50 → 1.1.52
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 +26 -14
- package/docs/wallet.md +26 -14
- package/out/src/sdk/validationHelpers.d.ts +9 -4
- package/out/src/sdk/validationHelpers.d.ts.map +1 -1
- package/out/src/sdk/validationHelpers.js +4 -4
- package/out/src/sdk/validationHelpers.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +12 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/entities/Transaction.js +2 -2
- package/out/src/storage/schema/entities/Transaction.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +2 -1
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/support/janitor.man.test.js +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +1 -0
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +20 -4
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/sdk/validationHelpers.ts +14 -8
- package/src/storage/schema/KnexMigrations.ts +13 -0
- package/src/storage/schema/entities/Transaction.ts +2 -2
- package/test/Wallet/local/localWallet.man.test.ts +2 -1
- package/test/Wallet/support/janitor.man.test.ts +1 -1
- package/test/utils/TestUtilsWalletStorage.ts +24 -5
package/package.json
CHANGED
|
@@ -260,11 +260,17 @@ export function isHexString(s: string): boolean {
|
|
|
260
260
|
return true
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
/**
|
|
264
|
+
* @typedef {string & { minLength: 5, maxLength: 2000 }} DescriptionString5to2000Bytes
|
|
265
|
+
* A string used for descriptions, with a length between 5 and 2000 characters.
|
|
266
|
+
*/
|
|
267
|
+
export type DescriptionString5to2000Bytes = string
|
|
268
|
+
|
|
263
269
|
export interface ValidWalletSignerArgs {}
|
|
264
270
|
|
|
265
271
|
export interface ValidCreateActionInput {
|
|
266
272
|
outpoint: OutPoint
|
|
267
|
-
inputDescription:
|
|
273
|
+
inputDescription: DescriptionString5to2000Bytes
|
|
268
274
|
sequenceNumber: PositiveIntegerOrZero
|
|
269
275
|
unlockingScript?: HexString
|
|
270
276
|
unlockingScriptLength: PositiveInteger
|
|
@@ -295,7 +301,7 @@ export function validateCreateActionInput(
|
|
|
295
301
|
i.inputDescription,
|
|
296
302
|
'inputDescription',
|
|
297
303
|
5,
|
|
298
|
-
|
|
304
|
+
2000
|
|
299
305
|
),
|
|
300
306
|
unlockingScript,
|
|
301
307
|
unlockingScriptLength,
|
|
@@ -307,7 +313,7 @@ export function validateCreateActionInput(
|
|
|
307
313
|
export interface ValidCreateActionOutput {
|
|
308
314
|
lockingScript: HexString
|
|
309
315
|
satoshis: SatoshiValue
|
|
310
|
-
outputDescription:
|
|
316
|
+
outputDescription: DescriptionString5to2000Bytes
|
|
311
317
|
basket?: BasketStringUnder300Bytes
|
|
312
318
|
customInstructions?: string
|
|
313
319
|
tags: BasketStringUnder300Bytes[]
|
|
@@ -323,7 +329,7 @@ export function validateCreateActionOutput(
|
|
|
323
329
|
o.outputDescription,
|
|
324
330
|
'outputDescription',
|
|
325
331
|
5,
|
|
326
|
-
|
|
332
|
+
2000
|
|
327
333
|
),
|
|
328
334
|
basket: validateOptionalBasket(o.basket),
|
|
329
335
|
customInstructions: o.customInstructions,
|
|
@@ -394,7 +400,7 @@ export interface ValidProcessActionArgs extends ValidWalletSignerArgs {
|
|
|
394
400
|
}
|
|
395
401
|
|
|
396
402
|
export interface ValidCreateActionArgs extends ValidProcessActionArgs {
|
|
397
|
-
description:
|
|
403
|
+
description: DescriptionString5to2000Bytes
|
|
398
404
|
inputBEEF?: BEEF
|
|
399
405
|
inputs: sdk.ValidCreateActionInput[]
|
|
400
406
|
outputs: sdk.ValidCreateActionOutput[]
|
|
@@ -425,7 +431,7 @@ export function validateCreateActionArgs(
|
|
|
425
431
|
args: CreateActionArgs
|
|
426
432
|
): ValidCreateActionArgs {
|
|
427
433
|
const vargs: ValidCreateActionArgs = {
|
|
428
|
-
description: validateStringLength(args.description, 'description', 5,
|
|
434
|
+
description: validateStringLength(args.description, 'description', 5, 2000),
|
|
429
435
|
inputBEEF: args.inputBEEF,
|
|
430
436
|
inputs: defaultEmpty(args.inputs).map(i => validateCreateActionInput(i)),
|
|
431
437
|
outputs: defaultEmpty(args.outputs).map(o => validateCreateActionOutput(o)),
|
|
@@ -590,7 +596,7 @@ export function validateInternalizeOutput(
|
|
|
590
596
|
export interface ValidInternalizeActionArgs extends ValidWalletSignerArgs {
|
|
591
597
|
tx: AtomicBEEF
|
|
592
598
|
outputs: InternalizeOutput[]
|
|
593
|
-
description:
|
|
599
|
+
description: DescriptionString5to2000Bytes
|
|
594
600
|
labels: LabelStringUnder300Bytes[]
|
|
595
601
|
seekPermission: BooleanDefaultTrue
|
|
596
602
|
}
|
|
@@ -611,7 +617,7 @@ export function validateInternalizeActionArgs(
|
|
|
611
617
|
const vargs: ValidInternalizeActionArgs = {
|
|
612
618
|
tx: args.tx,
|
|
613
619
|
outputs: args.outputs.map(o => validateInternalizeOutput(o)),
|
|
614
|
-
description: validateStringLength(args.description, 'description', 5,
|
|
620
|
+
description: validateStringLength(args.description, 'description', 5, 2000),
|
|
615
621
|
labels: (args.labels || []).map(t => validateLabel(t)),
|
|
616
622
|
seekPermission: defaultTrue(args.seekPermission)
|
|
617
623
|
}
|
|
@@ -91,6 +91,19 @@ export class KnexMigrations implements MigrationSource<string> {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
migrations['2025-03-03-001 descriptions to 2000'] = {
|
|
95
|
+
async up(knex) {
|
|
96
|
+
await knex.schema.alterTable('transactions', table => {
|
|
97
|
+
table.string('description', 2048).alter()
|
|
98
|
+
})
|
|
99
|
+
await knex.schema.alterTable('outputs', table => {
|
|
100
|
+
table.string('outputDescription', 2048).alter()
|
|
101
|
+
table.string('spendingDescription', 2048).alter()
|
|
102
|
+
})
|
|
103
|
+
},
|
|
104
|
+
async down(knex) {}
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
migrations['2025-03-01-001 reset req history'] = {
|
|
95
108
|
async up(knex) {
|
|
96
109
|
const storage = new StorageKnex({
|
|
@@ -242,7 +242,7 @@ export class EntityTransaction extends EntityBase<TableTransaction> {
|
|
|
242
242
|
(ei.provenTxId &&
|
|
243
243
|
eo.provenTxId !==
|
|
244
244
|
(syncMap
|
|
245
|
-
? syncMap.
|
|
245
|
+
? syncMap.provenTx.idMap[verifyId(ei.provenTxId)]
|
|
246
246
|
: ei.provenTxId))
|
|
247
247
|
)
|
|
248
248
|
return false
|
|
@@ -303,7 +303,7 @@ export class EntityTransaction extends EntityBase<TableTransaction> {
|
|
|
303
303
|
this.isOutgoing = ei.isOutgoing
|
|
304
304
|
this.status = ei.status
|
|
305
305
|
this.provenTxId = ei.provenTxId
|
|
306
|
-
? syncMap.
|
|
306
|
+
? syncMap.provenTx.idMap[ei.provenTxId]
|
|
307
307
|
: undefined
|
|
308
308
|
this.satoshis = ei.satoshis
|
|
309
309
|
this.txid = ei.txid
|
|
@@ -163,7 +163,8 @@ async function createSetup(chain: sdk.Chain): Promise<TestWalletNoSetup> {
|
|
|
163
163
|
rootKeyHex: env.devKeys[env.testIdentityKey],
|
|
164
164
|
filePath: env.testFilePath,
|
|
165
165
|
setActiveClient: false,
|
|
166
|
-
addLocalBackup: false
|
|
166
|
+
addLocalBackup: false,
|
|
167
|
+
useMySQLConnectionForClient: false
|
|
167
168
|
})
|
|
168
169
|
|
|
169
170
|
console.log(`ACTIVE STORAGE: ${setup.storage.getActiveStoreName()}`)
|
|
@@ -20,7 +20,7 @@ describe('janitor tests', () => {
|
|
|
20
20
|
const services = new Services(env.chain)
|
|
21
21
|
|
|
22
22
|
const identityKey =
|
|
23
|
-
'
|
|
23
|
+
'0304985aa632dde471d3bf1ffb030d0af253fe65f5d186bb4cf878ca0fbee54c1c'
|
|
24
24
|
const { invalidSpendableOutputs: notUtxos } = await confirmSpendableOutputs(
|
|
25
25
|
storage,
|
|
26
26
|
services,
|
|
@@ -352,6 +352,7 @@ export abstract class TestUtilsWalletStorage {
|
|
|
352
352
|
let filePath: string
|
|
353
353
|
let addLocalBackup = false
|
|
354
354
|
let setActiveClient = false
|
|
355
|
+
let useMySQLConnectionForClient = false
|
|
355
356
|
if (typeof args === 'string') {
|
|
356
357
|
chain = args
|
|
357
358
|
const env = _tu.getEnv(chain)
|
|
@@ -369,6 +370,7 @@ export abstract class TestUtilsWalletStorage {
|
|
|
369
370
|
filePath = args.filePath
|
|
370
371
|
addLocalBackup = args.addLocalBackup === true
|
|
371
372
|
setActiveClient = args.setActiveClient === true
|
|
373
|
+
useMySQLConnectionForClient = args.useMySQLConnectionForClient === true
|
|
372
374
|
}
|
|
373
375
|
|
|
374
376
|
const databaseName = path.parse(filePath).name
|
|
@@ -380,12 +382,28 @@ export abstract class TestUtilsWalletStorage {
|
|
|
380
382
|
})
|
|
381
383
|
setup.localStorageIdentityKey = setup.storage.getActiveStore()
|
|
382
384
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
385
|
+
let client: sdk.WalletStorageProvider
|
|
386
|
+
if (useMySQLConnectionForClient) {
|
|
387
|
+
const env = _tu.getEnv(chain)
|
|
388
|
+
if (!env.cloudMySQLConnection)
|
|
389
|
+
throw new sdk.WERR_INVALID_PARAMETER(
|
|
390
|
+
'env.cloundMySQLConnection',
|
|
391
|
+
'valid'
|
|
392
|
+
)
|
|
393
|
+
const connection = JSON.parse(env.cloudMySQLConnection)
|
|
394
|
+
client = new StorageKnex({
|
|
395
|
+
...StorageKnex.defaultOptions(),
|
|
396
|
+
knex: _tu.createMySQLFromConnection(connection),
|
|
397
|
+
chain: env.chain
|
|
398
|
+
})
|
|
399
|
+
} else {
|
|
400
|
+
const endpointUrl =
|
|
401
|
+
chain === 'main'
|
|
402
|
+
? 'https://storage.babbage.systems'
|
|
403
|
+
: 'https://staging-storage.babbage.systems'
|
|
387
404
|
|
|
388
|
-
|
|
405
|
+
client = new StorageClient(setup.wallet, endpointUrl)
|
|
406
|
+
}
|
|
389
407
|
setup.clientStorageIdentityKey = (
|
|
390
408
|
await client.makeAvailable()
|
|
391
409
|
).storageIdentityKey
|
|
@@ -2515,4 +2533,5 @@ export interface CreateTestWalletArgs {
|
|
|
2515
2533
|
filePath: string
|
|
2516
2534
|
addLocalBackup?: boolean
|
|
2517
2535
|
setActiveClient?: boolean
|
|
2536
|
+
useMySQLConnectionForClient?: boolean
|
|
2518
2537
|
}
|