@bsv/wallet-toolbox-client 2.1.21 → 2.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/out/src/sdk/WERR_errors.d.ts +2 -2
- package/out/src/sdk/WERR_errors.js +2 -2
- package/out/src/sdk/WalletStorage.interfaces.d.ts +1 -1
- package/out/src/storage/StorageIdb.d.ts +8 -0
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +220 -145
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.js +10 -6
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.js +15 -4
- package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -1
- package/package.json +1 -1
|
@@ -298,6 +298,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
298
298
|
const args = {
|
|
299
299
|
partial: { userId, basketId, spendable: true },
|
|
300
300
|
txStatus,
|
|
301
|
+
// Skip per-output script hydration during the candidate scan — we only need
|
|
302
|
+
// the locking script for the one we actually pick below. Matches Knex's
|
|
303
|
+
// pattern: SELECT candidates cheaply, hydrate the chosen output explicitly.
|
|
304
|
+
noScript: true,
|
|
301
305
|
trx: dbTrx
|
|
302
306
|
};
|
|
303
307
|
const outputs = await this.findOutputs(args);
|
|
@@ -332,6 +336,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
332
336
|
if (output) {
|
|
333
337
|
// mark output as spent by transactionId
|
|
334
338
|
await this.updateOutput(output.outputId, { spendable: false, spentBy: transactionId }, dbTrx);
|
|
339
|
+
// Hydrate the locking script for the chosen output. Identical to Knex canon at
|
|
340
|
+
// StorageKnex.allocateChangeInput: required when the script was offloaded into
|
|
341
|
+
// rawTx storage due to exceeding maxOutputScript.
|
|
342
|
+
await this.validateOutputScript(output, dbTrx);
|
|
335
343
|
}
|
|
336
344
|
return output;
|
|
337
345
|
}
|
|
@@ -361,12 +369,30 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
361
369
|
if (!this.isAvailable())
|
|
362
370
|
await this.makeAvailable();
|
|
363
371
|
let rawTx = undefined;
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
372
|
+
const sliceRequested = offset !== undefined && length !== undefined && Number.isInteger(offset) && Number.isInteger(length);
|
|
373
|
+
// Slice path uses an extended status set that includes 'unfail' — matches Knex
|
|
374
|
+
// canon at StorageKnex.ts:131. The non-slice path continues to delegate to
|
|
375
|
+
// getProvenOrRawTx which uses the narrower set.
|
|
376
|
+
if (sliceRequested) {
|
|
377
|
+
const proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid }, trx }));
|
|
378
|
+
if (proven) {
|
|
379
|
+
rawTx = proven.rawTx;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid }, trx }));
|
|
383
|
+
if (req && ['unsent', 'nosend', 'sending', 'unmined', 'completed', 'unfail'].includes(req.status)) {
|
|
384
|
+
rawTx = req.rawTx;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
const r = await this.getProvenOrRawTx(txid, trx);
|
|
390
|
+
if (r.proven)
|
|
391
|
+
rawTx = r.proven.rawTx;
|
|
392
|
+
else
|
|
393
|
+
rawTx = r.rawTx;
|
|
394
|
+
}
|
|
395
|
+
if (rawTx && sliceRequested) {
|
|
370
396
|
rawTx = rawTx.slice(offset, offset + length);
|
|
371
397
|
}
|
|
372
398
|
return rawTx;
|
|
@@ -376,8 +402,14 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
376
402
|
const labelIds = maps.map(m => m.txLabelId);
|
|
377
403
|
const labels = [];
|
|
378
404
|
for (const txLabelId of labelIds) {
|
|
379
|
-
|
|
380
|
-
|
|
405
|
+
// verifyOneOrNone: a map row may reference a label that was later soft-deleted.
|
|
406
|
+
// Knex/Bun drop it via JOIN; we must do the same silently or we'd break the whole
|
|
407
|
+
// listActions response. Skip + log so persistent orphans still produce a signal.
|
|
408
|
+
const label = (0, utilityHelpers_1.verifyOneOrNone)(await this.findTxLabels({ partial: { txLabelId, isDeleted: false }, trx }));
|
|
409
|
+
if (label)
|
|
410
|
+
labels.push(label);
|
|
411
|
+
else
|
|
412
|
+
console.debug(`[StorageIdb] orphan tx_labels_map row skipped: transactionId=${transactionId} txLabelId=${txLabelId}`);
|
|
381
413
|
}
|
|
382
414
|
return labels;
|
|
383
415
|
}
|
|
@@ -386,8 +418,11 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
386
418
|
const tagIds = maps.map(m => m.outputTagId);
|
|
387
419
|
const tags = [];
|
|
388
420
|
for (const outputTagId of tagIds) {
|
|
389
|
-
const tag = (0, utilityHelpers_1.
|
|
390
|
-
|
|
421
|
+
const tag = (0, utilityHelpers_1.verifyOneOrNone)(await this.findOutputTags({ partial: { outputTagId, isDeleted: false }, trx }));
|
|
422
|
+
if (tag)
|
|
423
|
+
tags.push(tag);
|
|
424
|
+
else
|
|
425
|
+
console.debug(`[StorageIdb] orphan output_tags_map row skipped: outputId=${outputId} outputTagId=${outputTagId}`);
|
|
391
426
|
}
|
|
392
427
|
return tags;
|
|
393
428
|
}
|
|
@@ -442,8 +477,25 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
442
477
|
async dropAllData() {
|
|
443
478
|
await (0, idb_1.deleteDB)(this.dbName);
|
|
444
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Reject undefined values in a `partial` filter argument. Matches
|
|
482
|
+
* Knex behavior (which throws `Undefined binding(s) detected`) so that
|
|
483
|
+
* callers can't pass an unmapped idMap lookup through as a silent
|
|
484
|
+
* match-anything. Omit the key to skip filtering on it; pass null if
|
|
485
|
+
* you need IS NULL semantics (only meaningful for nullable columns).
|
|
486
|
+
*/
|
|
487
|
+
assertNoUndefinedInPartial(partial) {
|
|
488
|
+
if (!partial)
|
|
489
|
+
return;
|
|
490
|
+
for (const k of Object.keys(partial)) {
|
|
491
|
+
if (partial[k] === undefined) {
|
|
492
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`args.partial.${k}`, `not undefined. Passing undefined as a filter value is not supported — omit the key to skip filtering. Matches Knex semantics.`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
445
496
|
async filterOutputTagMaps(args, filtered, userId) {
|
|
446
497
|
var _a, _b, _c, _d;
|
|
498
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
447
499
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
448
500
|
let skipped = 0;
|
|
449
501
|
let count = 0;
|
|
@@ -471,20 +523,20 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
471
523
|
if (args.tagIds && !args.tagIds.includes(r.outputTagId))
|
|
472
524
|
continue;
|
|
473
525
|
if (args.partial) {
|
|
474
|
-
if (args.partial.outputTagId && r.outputTagId !== args.partial.outputTagId)
|
|
526
|
+
if (args.partial.outputTagId !== undefined && r.outputTagId !== args.partial.outputTagId)
|
|
475
527
|
continue;
|
|
476
|
-
if (args.partial.outputId && r.outputId !== args.partial.outputId)
|
|
528
|
+
if (args.partial.outputId !== undefined && r.outputId !== args.partial.outputId)
|
|
477
529
|
continue;
|
|
478
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
530
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
479
531
|
continue;
|
|
480
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
532
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
481
533
|
continue;
|
|
482
534
|
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
483
535
|
continue;
|
|
484
536
|
}
|
|
485
|
-
if (userId !== undefined
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
537
|
+
if (userId !== undefined) {
|
|
538
|
+
const tagsForUser = await this.countOutputTags({ partial: { userId, outputTagId: r.outputTagId }, trx: dbTrx });
|
|
539
|
+
if (tagsForUser === 0)
|
|
488
540
|
continue;
|
|
489
541
|
}
|
|
490
542
|
if (skipped < offset) {
|
|
@@ -508,6 +560,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
508
560
|
}
|
|
509
561
|
async filterProvenTxReqs(args, filtered, userId) {
|
|
510
562
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
563
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
511
564
|
if (args.partial.rawTx)
|
|
512
565
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. ProvenTxReqs may not be found by rawTx value.`);
|
|
513
566
|
if (args.partial.inputBEEF)
|
|
@@ -550,36 +603,36 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
550
603
|
if (args.since && args.since > r.updated_at)
|
|
551
604
|
continue;
|
|
552
605
|
if (args.partial) {
|
|
553
|
-
if (args.partial.provenTxReqId && r.provenTxReqId !== args.partial.provenTxReqId)
|
|
606
|
+
if (args.partial.provenTxReqId !== undefined && r.provenTxReqId !== args.partial.provenTxReqId)
|
|
554
607
|
continue;
|
|
555
|
-
if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId)
|
|
608
|
+
if (args.partial.provenTxId !== undefined && r.provenTxId !== args.partial.provenTxId)
|
|
556
609
|
continue;
|
|
557
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
610
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
558
611
|
continue;
|
|
559
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
612
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
560
613
|
continue;
|
|
561
|
-
if (args.partial.status && r.status !== args.partial.status)
|
|
614
|
+
if (args.partial.status !== undefined && r.status !== args.partial.status)
|
|
562
615
|
continue;
|
|
563
616
|
if (args.partial.attempts !== undefined && r.attempts !== args.partial.attempts)
|
|
564
617
|
continue;
|
|
565
618
|
if (args.partial.notified !== undefined && r.notified !== args.partial.notified)
|
|
566
619
|
continue;
|
|
567
|
-
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
620
|
+
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
568
621
|
continue;
|
|
569
|
-
if (args.partial.batch && r.batch !== args.partial.batch)
|
|
622
|
+
if (args.partial.batch !== undefined && r.batch !== args.partial.batch)
|
|
570
623
|
continue;
|
|
571
|
-
if (args.partial.history && r.history !== args.partial.history)
|
|
624
|
+
if (args.partial.history !== undefined && r.history !== args.partial.history)
|
|
572
625
|
continue;
|
|
573
|
-
if (args.partial.notify && r.notify !== args.partial.notify)
|
|
626
|
+
if (args.partial.notify !== undefined && r.notify !== args.partial.notify)
|
|
574
627
|
continue;
|
|
575
628
|
}
|
|
576
629
|
if (args.status && args.status.length > 0 && !args.status.includes(r.status))
|
|
577
630
|
continue;
|
|
578
631
|
if (args.txids && args.txids.length > 0 && !args.txids.includes(r.txid))
|
|
579
632
|
continue;
|
|
580
|
-
if (userId !== undefined
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
633
|
+
if (userId !== undefined) {
|
|
634
|
+
const txsForUser = await this.countTransactions({ partial: { userId, txid: r.txid }, trx: dbTrx });
|
|
635
|
+
if (txsForUser === 0)
|
|
583
636
|
continue;
|
|
584
637
|
}
|
|
585
638
|
if (skipped < offset) {
|
|
@@ -603,6 +656,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
603
656
|
}
|
|
604
657
|
async filterProvenTxs(args, filtered, userId) {
|
|
605
658
|
var _a, _b, _c, _d;
|
|
659
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
606
660
|
if (args.partial.rawTx)
|
|
607
661
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. ProvenTxs may not be found by rawTx value.`);
|
|
608
662
|
if (args.partial.merklePath)
|
|
@@ -633,21 +687,21 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
633
687
|
if (args.since && args.since > r.updated_at)
|
|
634
688
|
continue;
|
|
635
689
|
if (args.partial) {
|
|
636
|
-
if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId)
|
|
690
|
+
if (args.partial.provenTxId !== undefined && r.provenTxId !== args.partial.provenTxId)
|
|
637
691
|
continue;
|
|
638
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
692
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
639
693
|
continue;
|
|
640
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
694
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
641
695
|
continue;
|
|
642
|
-
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
696
|
+
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
643
697
|
continue;
|
|
644
698
|
if (args.partial.height !== undefined && r.height !== args.partial.height)
|
|
645
699
|
continue;
|
|
646
700
|
if (args.partial.index !== undefined && r.index !== args.partial.index)
|
|
647
701
|
continue;
|
|
648
|
-
if (args.partial.blockHash && r.blockHash !== args.partial.blockHash)
|
|
702
|
+
if (args.partial.blockHash !== undefined && r.blockHash !== args.partial.blockHash)
|
|
649
703
|
continue;
|
|
650
|
-
if (args.partial.merkleRoot && r.merkleRoot !== args.partial.merkleRoot)
|
|
704
|
+
if (args.partial.merkleRoot !== undefined && r.merkleRoot !== args.partial.merkleRoot)
|
|
651
705
|
continue;
|
|
652
706
|
}
|
|
653
707
|
if (userId !== undefined) {
|
|
@@ -676,6 +730,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
676
730
|
}
|
|
677
731
|
async filterTxLabelMaps(args, filtered, userId) {
|
|
678
732
|
var _a, _b, _c, _d;
|
|
733
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
679
734
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
680
735
|
let skipped = 0;
|
|
681
736
|
let count = 0;
|
|
@@ -701,13 +756,13 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
701
756
|
if (args.since && args.since > r.updated_at)
|
|
702
757
|
continue;
|
|
703
758
|
if (args.partial) {
|
|
704
|
-
if (args.partial.txLabelId && r.txLabelId !== args.partial.txLabelId)
|
|
759
|
+
if (args.partial.txLabelId !== undefined && r.txLabelId !== args.partial.txLabelId)
|
|
705
760
|
continue;
|
|
706
|
-
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
761
|
+
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
707
762
|
continue;
|
|
708
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
763
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
709
764
|
continue;
|
|
710
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
765
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
711
766
|
continue;
|
|
712
767
|
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
713
768
|
continue;
|
|
@@ -766,6 +821,9 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
766
821
|
}
|
|
767
822
|
async insertCertificate(certificate, trx) {
|
|
768
823
|
const e = await this.validateEntityForInsert(certificate, trx, undefined, ['isDeleted']);
|
|
824
|
+
// Strip non-schema runtime fields before insert. Matches Knex canon.
|
|
825
|
+
if (e.logger)
|
|
826
|
+
delete e.logger;
|
|
769
827
|
const fields = e.fields;
|
|
770
828
|
if (e.fields)
|
|
771
829
|
delete e.fields;
|
|
@@ -1010,11 +1068,14 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1010
1068
|
const dbTrx = this.toDbTrx([storeName], 'readwrite', trx);
|
|
1011
1069
|
const store = dbTrx.objectStore(storeName);
|
|
1012
1070
|
const ids = Array.isArray(id) ? id : [id];
|
|
1071
|
+
let updated = 0;
|
|
1013
1072
|
try {
|
|
1014
1073
|
for (const i of ids) {
|
|
1015
1074
|
const e = await store.get(i);
|
|
1075
|
+
// Match Knex/Bun semantics: missing rows produce a 0-row result, not an error.
|
|
1076
|
+
// Caller receives the true updated count and can decide how to react.
|
|
1016
1077
|
if (!e)
|
|
1017
|
-
|
|
1078
|
+
continue;
|
|
1018
1079
|
const v = {
|
|
1019
1080
|
...e,
|
|
1020
1081
|
...u
|
|
@@ -1022,13 +1083,14 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1022
1083
|
const uid = await store.put(v);
|
|
1023
1084
|
if (uid !== i)
|
|
1024
1085
|
throw new WERR_errors_1.WERR_INTERNAL(`updated id ${uid} does not match original ${id}`);
|
|
1086
|
+
updated++;
|
|
1025
1087
|
}
|
|
1026
1088
|
}
|
|
1027
1089
|
finally {
|
|
1028
1090
|
if (!trx)
|
|
1029
1091
|
await dbTrx.done;
|
|
1030
1092
|
}
|
|
1031
|
-
return
|
|
1093
|
+
return updated;
|
|
1032
1094
|
}
|
|
1033
1095
|
async updateIdbKey(key, update, keyProps, storeName, trx) {
|
|
1034
1096
|
if (key.length !== keyProps.length)
|
|
@@ -1140,6 +1202,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1140
1202
|
}
|
|
1141
1203
|
async filterCertificateFields(args, filtered) {
|
|
1142
1204
|
var _a, _b, _c, _d;
|
|
1205
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1143
1206
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1144
1207
|
let skipped = 0;
|
|
1145
1208
|
let count = 0;
|
|
@@ -1168,19 +1231,19 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1168
1231
|
if (args.since && args.since > r.updated_at)
|
|
1169
1232
|
continue;
|
|
1170
1233
|
if (args.partial) {
|
|
1171
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1234
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1172
1235
|
continue;
|
|
1173
|
-
if (args.partial.certificateId && r.certificateId !== args.partial.certificateId)
|
|
1236
|
+
if (args.partial.certificateId !== undefined && r.certificateId !== args.partial.certificateId)
|
|
1174
1237
|
continue;
|
|
1175
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1238
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1176
1239
|
continue;
|
|
1177
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1240
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1178
1241
|
continue;
|
|
1179
|
-
if (args.partial.fieldName && r.fieldName !== args.partial.fieldName)
|
|
1242
|
+
if (args.partial.fieldName !== undefined && r.fieldName !== args.partial.fieldName)
|
|
1180
1243
|
continue;
|
|
1181
|
-
if (args.partial.fieldValue && r.fieldValue !== args.partial.fieldValue)
|
|
1244
|
+
if (args.partial.fieldValue !== undefined && r.fieldValue !== args.partial.fieldValue)
|
|
1182
1245
|
continue;
|
|
1183
|
-
if (args.partial.masterKey && r.masterKey !== args.partial.masterKey)
|
|
1246
|
+
if (args.partial.masterKey !== undefined && r.masterKey !== args.partial.masterKey)
|
|
1184
1247
|
continue;
|
|
1185
1248
|
}
|
|
1186
1249
|
if (skipped < offset) {
|
|
@@ -1204,6 +1267,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1204
1267
|
}
|
|
1205
1268
|
async filterCertificates(args, filtered) {
|
|
1206
1269
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1270
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1207
1271
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1208
1272
|
let skipped = 0;
|
|
1209
1273
|
let count = 0;
|
|
@@ -1241,29 +1305,29 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1241
1305
|
if (args.types && !args.types.includes(r.type))
|
|
1242
1306
|
continue;
|
|
1243
1307
|
if (args.partial) {
|
|
1244
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1308
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1245
1309
|
continue;
|
|
1246
|
-
if (args.partial.certificateId && r.certificateId !== args.partial.certificateId)
|
|
1310
|
+
if (args.partial.certificateId !== undefined && r.certificateId !== args.partial.certificateId)
|
|
1247
1311
|
continue;
|
|
1248
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1312
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1249
1313
|
continue;
|
|
1250
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1314
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1251
1315
|
continue;
|
|
1252
|
-
if (args.partial.type && r.type !== args.partial.type)
|
|
1316
|
+
if (args.partial.type !== undefined && r.type !== args.partial.type)
|
|
1253
1317
|
continue;
|
|
1254
|
-
if (args.partial.serialNumber && r.serialNumber !== args.partial.serialNumber)
|
|
1318
|
+
if (args.partial.serialNumber !== undefined && r.serialNumber !== args.partial.serialNumber)
|
|
1255
1319
|
continue;
|
|
1256
|
-
if (args.partial.certifier && r.certifier !== args.partial.certifier)
|
|
1320
|
+
if (args.partial.certifier !== undefined && r.certifier !== args.partial.certifier)
|
|
1257
1321
|
continue;
|
|
1258
|
-
if (args.partial.subject && r.subject !== args.partial.subject)
|
|
1322
|
+
if (args.partial.subject !== undefined && r.subject !== args.partial.subject)
|
|
1259
1323
|
continue;
|
|
1260
|
-
if (args.partial.verifier && r.verifier !== args.partial.verifier)
|
|
1324
|
+
if (args.partial.verifier !== undefined && r.verifier !== args.partial.verifier)
|
|
1261
1325
|
continue;
|
|
1262
|
-
if (args.partial.revocationOutpoint && r.revocationOutpoint !== args.partial.revocationOutpoint)
|
|
1326
|
+
if (args.partial.revocationOutpoint !== undefined && r.revocationOutpoint !== args.partial.revocationOutpoint)
|
|
1263
1327
|
continue;
|
|
1264
|
-
if (args.partial.signature && r.signature !== args.partial.signature)
|
|
1328
|
+
if (args.partial.signature !== undefined && r.signature !== args.partial.signature)
|
|
1265
1329
|
continue;
|
|
1266
|
-
if (args.partial.isDeleted && r.isDeleted !== args.partial.isDeleted)
|
|
1330
|
+
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1267
1331
|
continue;
|
|
1268
1332
|
}
|
|
1269
1333
|
if (skipped < offset) {
|
|
@@ -1293,6 +1357,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1293
1357
|
}
|
|
1294
1358
|
async filterCommissions(args, filtered) {
|
|
1295
1359
|
var _a, _b, _c, _d, _e;
|
|
1360
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1296
1361
|
if (args.partial.lockingScript)
|
|
1297
1362
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('partial.lockingScript', `undefined. Commissions may not be found by lockingScript value.`);
|
|
1298
1363
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
@@ -1323,19 +1388,19 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1323
1388
|
if (args.since && args.since > r.updated_at)
|
|
1324
1389
|
continue;
|
|
1325
1390
|
if (args.partial) {
|
|
1326
|
-
if (args.partial.commissionId && r.commissionId !== args.partial.commissionId)
|
|
1391
|
+
if (args.partial.commissionId !== undefined && r.commissionId !== args.partial.commissionId)
|
|
1327
1392
|
continue;
|
|
1328
|
-
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
1393
|
+
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
1329
1394
|
continue;
|
|
1330
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1395
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1331
1396
|
continue;
|
|
1332
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1397
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1333
1398
|
continue;
|
|
1334
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1399
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1335
1400
|
continue;
|
|
1336
1401
|
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1337
1402
|
continue;
|
|
1338
|
-
if (args.partial.keyOffset && r.keyOffset !== args.partial.keyOffset)
|
|
1403
|
+
if (args.partial.keyOffset !== undefined && r.keyOffset !== args.partial.keyOffset)
|
|
1339
1404
|
continue;
|
|
1340
1405
|
if (args.partial.isRedeemed !== undefined && r.isRedeemed !== args.partial.isRedeemed)
|
|
1341
1406
|
continue;
|
|
@@ -1361,6 +1426,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1361
1426
|
}
|
|
1362
1427
|
async filterMonitorEvents(args, filtered) {
|
|
1363
1428
|
var _a, _b, _c;
|
|
1429
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1364
1430
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1365
1431
|
let skipped = 0;
|
|
1366
1432
|
let count = 0;
|
|
@@ -1383,15 +1449,15 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1383
1449
|
if (args.since && args.since > r.updated_at)
|
|
1384
1450
|
continue;
|
|
1385
1451
|
if (args.partial) {
|
|
1386
|
-
if (args.partial.id && r.id !== args.partial.id)
|
|
1452
|
+
if (args.partial.id !== undefined && r.id !== args.partial.id)
|
|
1387
1453
|
continue;
|
|
1388
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1454
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1389
1455
|
continue;
|
|
1390
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1456
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1391
1457
|
continue;
|
|
1392
|
-
if (args.partial.event && r.event !== args.partial.event)
|
|
1458
|
+
if (args.partial.event !== undefined && r.event !== args.partial.event)
|
|
1393
1459
|
continue;
|
|
1394
|
-
if (args.partial.details && r.details !== args.partial.details)
|
|
1460
|
+
if (args.partial.details !== undefined && r.details !== args.partial.details)
|
|
1395
1461
|
continue;
|
|
1396
1462
|
}
|
|
1397
1463
|
if (skipped < offset) {
|
|
@@ -1415,6 +1481,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1415
1481
|
}
|
|
1416
1482
|
async filterOutputBaskets(args, filtered) {
|
|
1417
1483
|
var _a, _b, _c, _d, _e;
|
|
1484
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1418
1485
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1419
1486
|
let skipped = 0;
|
|
1420
1487
|
let count = 0;
|
|
@@ -1448,15 +1515,15 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1448
1515
|
if (args.since && args.since > r.updated_at)
|
|
1449
1516
|
continue;
|
|
1450
1517
|
if (args.partial) {
|
|
1451
|
-
if (args.partial.basketId && r.basketId !== args.partial.basketId)
|
|
1518
|
+
if (args.partial.basketId !== undefined && r.basketId !== args.partial.basketId)
|
|
1452
1519
|
continue;
|
|
1453
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1520
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1454
1521
|
continue;
|
|
1455
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1522
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1456
1523
|
continue;
|
|
1457
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1524
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1458
1525
|
continue;
|
|
1459
|
-
if (args.partial.name && r.name !== args.partial.name)
|
|
1526
|
+
if (args.partial.name !== undefined && r.name !== args.partial.name)
|
|
1460
1527
|
continue;
|
|
1461
1528
|
if (args.partial.numberOfDesiredUTXOs !== undefined &&
|
|
1462
1529
|
r.numberOfDesiredUTXOs !== args.partial.numberOfDesiredUTXOs)
|
|
@@ -1488,6 +1555,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1488
1555
|
}
|
|
1489
1556
|
async filterOutputs(args, filtered, tagIds, isQueryModeAll) {
|
|
1490
1557
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1558
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1491
1559
|
// args.txStatus
|
|
1492
1560
|
// args.noScript
|
|
1493
1561
|
if (args.partial.lockingScript)
|
|
@@ -1503,32 +1571,36 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1503
1571
|
stores.push('transactions');
|
|
1504
1572
|
}
|
|
1505
1573
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1574
|
+
const direction = args.orderDescending ? 'prev' : 'next';
|
|
1506
1575
|
let cursor;
|
|
1507
1576
|
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.outputId) {
|
|
1508
|
-
cursor = await dbTrx.objectStore('outputs').openCursor(args.partial.outputId);
|
|
1577
|
+
cursor = await dbTrx.objectStore('outputs').openCursor(args.partial.outputId, direction);
|
|
1509
1578
|
}
|
|
1510
1579
|
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.userId) !== undefined) {
|
|
1511
1580
|
if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.transactionId) && ((_e = args.partial) === null || _e === void 0 ? void 0 : _e.vout) !== undefined) {
|
|
1512
1581
|
cursor = await dbTrx
|
|
1513
1582
|
.objectStore('outputs')
|
|
1514
1583
|
.index('transactionId_vout_userId')
|
|
1515
|
-
.openCursor([args.partial.transactionId, args.partial.vout, args.partial.userId]);
|
|
1584
|
+
.openCursor([args.partial.transactionId, args.partial.vout, args.partial.userId], direction);
|
|
1516
1585
|
}
|
|
1517
1586
|
else {
|
|
1518
|
-
cursor = await dbTrx.objectStore('outputs').index('userId').openCursor(args.partial.userId);
|
|
1587
|
+
cursor = await dbTrx.objectStore('outputs').index('userId').openCursor(args.partial.userId, direction);
|
|
1519
1588
|
}
|
|
1520
1589
|
}
|
|
1521
1590
|
else if (((_f = args.partial) === null || _f === void 0 ? void 0 : _f.transactionId) !== undefined) {
|
|
1522
|
-
cursor = await dbTrx
|
|
1591
|
+
cursor = await dbTrx
|
|
1592
|
+
.objectStore('outputs')
|
|
1593
|
+
.index('transactionId')
|
|
1594
|
+
.openCursor(args.partial.transactionId, direction);
|
|
1523
1595
|
}
|
|
1524
1596
|
else if (((_g = args.partial) === null || _g === void 0 ? void 0 : _g.basketId) !== undefined) {
|
|
1525
|
-
cursor = await dbTrx.objectStore('outputs').index('basketId').openCursor(args.partial.basketId);
|
|
1597
|
+
cursor = await dbTrx.objectStore('outputs').index('basketId').openCursor(args.partial.basketId, direction);
|
|
1526
1598
|
}
|
|
1527
1599
|
else if (((_h = args.partial) === null || _h === void 0 ? void 0 : _h.spentBy) !== undefined) {
|
|
1528
|
-
cursor = await dbTrx.objectStore('outputs').index('spentBy').openCursor(args.partial.spentBy);
|
|
1600
|
+
cursor = await dbTrx.objectStore('outputs').index('spentBy').openCursor(args.partial.spentBy, direction);
|
|
1529
1601
|
}
|
|
1530
1602
|
else {
|
|
1531
|
-
cursor = await dbTrx.objectStore('outputs').openCursor();
|
|
1603
|
+
cursor = await dbTrx.objectStore('outputs').openCursor(null, direction);
|
|
1532
1604
|
}
|
|
1533
1605
|
let firstTime = true;
|
|
1534
1606
|
while (cursor) {
|
|
@@ -1541,45 +1613,45 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1541
1613
|
if (args.since && args.since > r.updated_at)
|
|
1542
1614
|
continue;
|
|
1543
1615
|
if (args.partial) {
|
|
1544
|
-
if (args.partial.outputId && r.outputId !== args.partial.outputId)
|
|
1616
|
+
if (args.partial.outputId !== undefined && r.outputId !== args.partial.outputId)
|
|
1545
1617
|
continue;
|
|
1546
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1618
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1547
1619
|
continue;
|
|
1548
|
-
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
1620
|
+
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
1549
1621
|
continue;
|
|
1550
|
-
if (args.partial.basketId && r.basketId !== args.partial.basketId)
|
|
1622
|
+
if (args.partial.basketId !== undefined && r.basketId !== args.partial.basketId)
|
|
1551
1623
|
continue;
|
|
1552
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1624
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1553
1625
|
continue;
|
|
1554
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1626
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1555
1627
|
continue;
|
|
1556
1628
|
if (args.partial.spendable !== undefined && r.spendable !== args.partial.spendable)
|
|
1557
1629
|
continue;
|
|
1558
1630
|
if (args.partial.change !== undefined && r.change !== args.partial.change)
|
|
1559
1631
|
continue;
|
|
1560
|
-
if (args.partial.outputDescription && r.outputDescription !== args.partial.outputDescription)
|
|
1632
|
+
if (args.partial.outputDescription !== undefined && r.outputDescription !== args.partial.outputDescription)
|
|
1561
1633
|
continue;
|
|
1562
1634
|
if (args.partial.vout !== undefined && r.vout !== args.partial.vout)
|
|
1563
1635
|
continue;
|
|
1564
1636
|
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1565
1637
|
continue;
|
|
1566
|
-
if (args.partial.providedBy && r.providedBy !== args.partial.providedBy)
|
|
1638
|
+
if (args.partial.providedBy !== undefined && r.providedBy !== args.partial.providedBy)
|
|
1567
1639
|
continue;
|
|
1568
|
-
if (args.partial.purpose && r.purpose !== args.partial.purpose)
|
|
1640
|
+
if (args.partial.purpose !== undefined && r.purpose !== args.partial.purpose)
|
|
1569
1641
|
continue;
|
|
1570
|
-
if (args.partial.type && r.type !== args.partial.type)
|
|
1642
|
+
if (args.partial.type !== undefined && r.type !== args.partial.type)
|
|
1571
1643
|
continue;
|
|
1572
|
-
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
1644
|
+
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
1573
1645
|
continue;
|
|
1574
|
-
if (args.partial.senderIdentityKey && r.senderIdentityKey !== args.partial.senderIdentityKey)
|
|
1646
|
+
if (args.partial.senderIdentityKey !== undefined && r.senderIdentityKey !== args.partial.senderIdentityKey)
|
|
1575
1647
|
continue;
|
|
1576
|
-
if (args.partial.derivationPrefix && r.derivationPrefix !== args.partial.derivationPrefix)
|
|
1648
|
+
if (args.partial.derivationPrefix !== undefined && r.derivationPrefix !== args.partial.derivationPrefix)
|
|
1577
1649
|
continue;
|
|
1578
|
-
if (args.partial.derivationSuffix && r.derivationSuffix !== args.partial.derivationSuffix)
|
|
1650
|
+
if (args.partial.derivationSuffix !== undefined && r.derivationSuffix !== args.partial.derivationSuffix)
|
|
1579
1651
|
continue;
|
|
1580
|
-
if (args.partial.customInstructions && r.customInstructions !== args.partial.customInstructions)
|
|
1652
|
+
if (args.partial.customInstructions !== undefined && r.customInstructions !== args.partial.customInstructions)
|
|
1581
1653
|
continue;
|
|
1582
|
-
if (args.partial.spentBy && r.spentBy !== args.partial.spentBy)
|
|
1654
|
+
if (args.partial.spentBy !== undefined && r.spentBy !== args.partial.spentBy)
|
|
1583
1655
|
continue;
|
|
1584
1656
|
if (args.partial.sequenceNumber !== undefined && r.sequenceNumber !== args.partial.sequenceNumber)
|
|
1585
1657
|
continue;
|
|
@@ -1588,7 +1660,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1588
1660
|
if (args.partial.scriptOffset !== undefined && r.scriptOffset !== args.partial.scriptOffset)
|
|
1589
1661
|
continue;
|
|
1590
1662
|
}
|
|
1591
|
-
if (args.txStatus !== undefined) {
|
|
1663
|
+
if (args.txStatus !== undefined && args.txStatus.length > 0) {
|
|
1592
1664
|
const count = await this.countTransactions({
|
|
1593
1665
|
partial: { transactionId: r.transactionId },
|
|
1594
1666
|
status: args.txStatus,
|
|
@@ -1636,17 +1708,16 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1636
1708
|
results.push(this.validateEntity(r));
|
|
1637
1709
|
}, tagIds, isQueryModeAll);
|
|
1638
1710
|
for (const o of results) {
|
|
1639
|
-
|
|
1711
|
+
// noScript skips the rawTx-slice re-hydration but does not wipe script already
|
|
1712
|
+
// on the row — parity with Knex/Bun, which simply don't SELECT the column.
|
|
1713
|
+
if (!args.noScript)
|
|
1640
1714
|
await this.validateOutputScript(o, args.trx);
|
|
1641
|
-
}
|
|
1642
|
-
else {
|
|
1643
|
-
o.lockingScript = undefined;
|
|
1644
|
-
}
|
|
1645
1715
|
}
|
|
1646
1716
|
return results;
|
|
1647
1717
|
}
|
|
1648
1718
|
async filterOutputTags(args, filtered) {
|
|
1649
1719
|
var _a, _b, _c, _d, _e;
|
|
1720
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1650
1721
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1651
1722
|
let skipped = 0;
|
|
1652
1723
|
let count = 0;
|
|
@@ -1680,15 +1751,15 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1680
1751
|
if (args.since && args.since > r.updated_at)
|
|
1681
1752
|
continue;
|
|
1682
1753
|
if (args.partial) {
|
|
1683
|
-
if (args.partial.outputTagId && r.outputTagId !== args.partial.outputTagId)
|
|
1754
|
+
if (args.partial.outputTagId !== undefined && r.outputTagId !== args.partial.outputTagId)
|
|
1684
1755
|
continue;
|
|
1685
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1756
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1686
1757
|
continue;
|
|
1687
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1758
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1688
1759
|
continue;
|
|
1689
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1760
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1690
1761
|
continue;
|
|
1691
|
-
if (args.partial.tag && r.tag !== args.partial.tag)
|
|
1762
|
+
if (args.partial.tag !== undefined && r.tag !== args.partial.tag)
|
|
1692
1763
|
continue;
|
|
1693
1764
|
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1694
1765
|
continue;
|
|
@@ -1714,6 +1785,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1714
1785
|
}
|
|
1715
1786
|
async filterSyncStates(args, filtered) {
|
|
1716
1787
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1788
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1717
1789
|
if (args.partial.syncMap)
|
|
1718
1790
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.syncMap', `undefined. SyncStates may not be found by syncMap value.`);
|
|
1719
1791
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
@@ -1747,31 +1819,31 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1747
1819
|
if (args.since && args.since > r.updated_at)
|
|
1748
1820
|
continue;
|
|
1749
1821
|
if (args.partial) {
|
|
1750
|
-
if (args.partial.syncStateId && r.syncStateId !== args.partial.syncStateId)
|
|
1822
|
+
if (args.partial.syncStateId !== undefined && r.syncStateId !== args.partial.syncStateId)
|
|
1751
1823
|
continue;
|
|
1752
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1824
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1753
1825
|
continue;
|
|
1754
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1826
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1755
1827
|
continue;
|
|
1756
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1828
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1757
1829
|
continue;
|
|
1758
|
-
if (args.partial.storageIdentityKey && r.storageIdentityKey !== args.partial.storageIdentityKey)
|
|
1830
|
+
if (args.partial.storageIdentityKey !== undefined && r.storageIdentityKey !== args.partial.storageIdentityKey)
|
|
1759
1831
|
continue;
|
|
1760
|
-
if (args.partial.storageName && r.storageName !== args.partial.storageName)
|
|
1832
|
+
if (args.partial.storageName !== undefined && r.storageName !== args.partial.storageName)
|
|
1761
1833
|
continue;
|
|
1762
|
-
if (args.partial.status && r.status !== args.partial.status)
|
|
1834
|
+
if (args.partial.status !== undefined && r.status !== args.partial.status)
|
|
1763
1835
|
continue;
|
|
1764
1836
|
if (args.partial.init !== undefined && r.init !== args.partial.init)
|
|
1765
1837
|
continue;
|
|
1766
1838
|
if (args.partial.refNum !== undefined && r.refNum !== args.partial.refNum)
|
|
1767
1839
|
continue;
|
|
1768
|
-
if (args.partial.when && ((_f = r.when) === null || _f === void 0 ? void 0 : _f.getTime()) !== args.partial.when.getTime())
|
|
1840
|
+
if (args.partial.when !== undefined && ((_f = r.when) === null || _f === void 0 ? void 0 : _f.getTime()) !== args.partial.when.getTime())
|
|
1769
1841
|
continue;
|
|
1770
1842
|
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1771
1843
|
continue;
|
|
1772
|
-
if (args.partial.errorLocal && r.errorLocale !== args.partial.errorLocal)
|
|
1844
|
+
if (args.partial.errorLocal !== undefined && r.errorLocale !== args.partial.errorLocal)
|
|
1773
1845
|
continue;
|
|
1774
|
-
if (args.partial.errorOther && r.errorOther !== args.partial.errorOther)
|
|
1846
|
+
if (args.partial.errorOther !== undefined && r.errorOther !== args.partial.errorOther)
|
|
1775
1847
|
continue;
|
|
1776
1848
|
}
|
|
1777
1849
|
if (skipped < offset) {
|
|
@@ -1795,6 +1867,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1795
1867
|
}
|
|
1796
1868
|
async filterTransactions(args, filtered, labelIds, isQueryModeAll) {
|
|
1797
1869
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1870
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1798
1871
|
if (args.partial.rawTx)
|
|
1799
1872
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', `undefined. Transactions may not be found by rawTx value.`);
|
|
1800
1873
|
if (args.partial.inputBEEF)
|
|
@@ -1852,34 +1925,34 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1852
1925
|
continue;
|
|
1853
1926
|
if (args.to && r.created_at.getTime() >= args.to.getTime())
|
|
1854
1927
|
continue;
|
|
1855
|
-
if (args.status && !args.status.includes(r.status))
|
|
1928
|
+
if (args.status && args.status.length > 0 && !args.status.includes(r.status))
|
|
1856
1929
|
continue;
|
|
1857
1930
|
if (args.partial) {
|
|
1858
|
-
if (args.partial.transactionId && r.transactionId !== args.partial.transactionId)
|
|
1931
|
+
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
1859
1932
|
continue;
|
|
1860
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
1933
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1861
1934
|
continue;
|
|
1862
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1935
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1863
1936
|
continue;
|
|
1864
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1937
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1865
1938
|
continue;
|
|
1866
|
-
if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId)
|
|
1939
|
+
if (args.partial.provenTxId !== undefined && r.provenTxId !== args.partial.provenTxId)
|
|
1867
1940
|
continue;
|
|
1868
|
-
if (args.partial.status && r.status !== args.partial.status)
|
|
1941
|
+
if (args.partial.status !== undefined && r.status !== args.partial.status)
|
|
1869
1942
|
continue;
|
|
1870
|
-
if (args.partial.reference && r.reference !== args.partial.reference)
|
|
1943
|
+
if (args.partial.reference !== undefined && r.reference !== args.partial.reference)
|
|
1871
1944
|
continue;
|
|
1872
1945
|
if (args.partial.isOutgoing !== undefined && r.isOutgoing !== args.partial.isOutgoing)
|
|
1873
1946
|
continue;
|
|
1874
1947
|
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1875
1948
|
continue;
|
|
1876
|
-
if (args.partial.description && r.description !== args.partial.description)
|
|
1949
|
+
if (args.partial.description !== undefined && r.description !== args.partial.description)
|
|
1877
1950
|
continue;
|
|
1878
1951
|
if (args.partial.version !== undefined && r.version !== args.partial.version)
|
|
1879
1952
|
continue;
|
|
1880
1953
|
if (args.partial.lockTime !== undefined && r.lockTime !== args.partial.lockTime)
|
|
1881
1954
|
continue;
|
|
1882
|
-
if (args.partial.txid && r.txid !== args.partial.txid)
|
|
1955
|
+
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
1883
1956
|
continue;
|
|
1884
1957
|
}
|
|
1885
1958
|
if (labelIds && labelIds.length > 0) {
|
|
@@ -1918,18 +1991,19 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1918
1991
|
results.push(this.validateEntity(r));
|
|
1919
1992
|
}, labelIds, isQueryModeAll);
|
|
1920
1993
|
for (const t of results) {
|
|
1921
|
-
|
|
1994
|
+
// noRawTx skips rawTx re-hydration but does not wipe inputBEEF — Knex's
|
|
1995
|
+
// transactionColumnsWithoutRawTx only strips rawTx, and callers such as
|
|
1996
|
+
// getReqsAndBeefToShareWithWorld legitimately need inputBEEF when noRawTx is set.
|
|
1997
|
+
if (!args.noRawTx)
|
|
1922
1998
|
await this.validateRawTransaction(t, args.trx);
|
|
1923
|
-
|
|
1924
|
-
else {
|
|
1999
|
+
else
|
|
1925
2000
|
t.rawTx = undefined;
|
|
1926
|
-
t.inputBEEF = undefined;
|
|
1927
|
-
}
|
|
1928
2001
|
}
|
|
1929
2002
|
return results;
|
|
1930
2003
|
}
|
|
1931
2004
|
async filterTxLabels(args, filtered) {
|
|
1932
2005
|
var _a, _b, _c, _d, _e;
|
|
2006
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1933
2007
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1934
2008
|
let skipped = 0;
|
|
1935
2009
|
let count = 0;
|
|
@@ -1963,15 +2037,15 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1963
2037
|
if (args.since && args.since > r.updated_at)
|
|
1964
2038
|
continue;
|
|
1965
2039
|
if (args.partial) {
|
|
1966
|
-
if (args.partial.txLabelId && r.txLabelId !== args.partial.txLabelId)
|
|
2040
|
+
if (args.partial.txLabelId !== undefined && r.txLabelId !== args.partial.txLabelId)
|
|
1967
2041
|
continue;
|
|
1968
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
2042
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1969
2043
|
continue;
|
|
1970
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
2044
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1971
2045
|
continue;
|
|
1972
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
2046
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1973
2047
|
continue;
|
|
1974
|
-
if (args.partial.label && r.label !== args.partial.label)
|
|
2048
|
+
if (args.partial.label !== undefined && r.label !== args.partial.label)
|
|
1975
2049
|
continue;
|
|
1976
2050
|
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1977
2051
|
continue;
|
|
@@ -1997,6 +2071,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1997
2071
|
}
|
|
1998
2072
|
async filterUsers(args, filtered) {
|
|
1999
2073
|
var _a, _b;
|
|
2074
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
2000
2075
|
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
2001
2076
|
let skipped = 0;
|
|
2002
2077
|
let count = 0;
|
|
@@ -2013,15 +2088,15 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2013
2088
|
if (args.since && args.since > r.updated_at)
|
|
2014
2089
|
continue;
|
|
2015
2090
|
if (args.partial) {
|
|
2016
|
-
if (args.partial.userId && r.userId !== args.partial.userId)
|
|
2091
|
+
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
2017
2092
|
continue;
|
|
2018
|
-
if (args.partial.created_at && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
2093
|
+
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
2019
2094
|
continue;
|
|
2020
|
-
if (args.partial.updated_at && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
2095
|
+
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
2021
2096
|
continue;
|
|
2022
|
-
if (args.partial.identityKey && r.identityKey !== args.partial.identityKey)
|
|
2097
|
+
if (args.partial.identityKey !== undefined && r.identityKey !== args.partial.identityKey)
|
|
2023
2098
|
continue;
|
|
2024
|
-
if (args.partial.activeStorage && r.activeStorage !== args.partial.activeStorage)
|
|
2099
|
+
if (args.partial.activeStorage !== undefined && r.activeStorage !== args.partial.activeStorage)
|
|
2025
2100
|
continue;
|
|
2026
2101
|
}
|
|
2027
2102
|
if (skipped < offset) {
|