@bopen-io/wallet-toolbox 1.7.20-idb-fix.1 → 1.7.20-idb-fix.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bopen-io/wallet-toolbox",
3
- "version": "1.7.20-idb-fix.1",
3
+ "version": "1.7.20-idb-fix.2",
4
4
  "description": "BRC100 conforming wallet, wallet storage and wallet signer components",
5
5
  "main": "./out/src/index.js",
6
6
  "types": "./out/src/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@bsv/auth-express-middleware": "^1.2.3",
35
35
  "@bsv/payment-express-middleware": "^1.2.3",
36
- "@bsv/sdk": "^1.10.1",
36
+ "@bsv/sdk": "^1.9.29",
37
37
  "express": "^4.21.2",
38
38
  "idb": "^8.0.2",
39
39
  "knex": "^3.1.0",
@@ -546,17 +546,21 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
546
546
  let skipped = 0
547
547
  let count = 0
548
548
  const dbTrx = this.toDbTrx(['output_tags_map'], 'readonly', args.trx)
549
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
549
550
  let cursor:
550
551
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_tags_map', unknown, 'readwrite' | 'readonly'>
551
552
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_tags_map', 'outputTagId', 'readwrite' | 'readonly'>
552
553
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_tags_map', 'outputId', 'readwrite' | 'readonly'>
553
554
  | null
554
555
  if (args.partial?.outputTagId !== undefined) {
555
- cursor = await dbTrx.objectStore('output_tags_map').index('outputTagId').openCursor(args.partial.outputTagId)
556
+ cursor = await dbTrx
557
+ .objectStore('output_tags_map')
558
+ .index('outputTagId')
559
+ .openCursor(args.partial.outputTagId, direction)
556
560
  } else if (args.partial?.outputId !== undefined) {
557
- cursor = await dbTrx.objectStore('output_tags_map').index('outputId').openCursor(args.partial.outputId)
561
+ cursor = await dbTrx.objectStore('output_tags_map').index('outputId').openCursor(args.partial.outputId, direction)
558
562
  } else {
559
- cursor = await dbTrx.objectStore('output_tags_map').openCursor()
563
+ cursor = await dbTrx.objectStore('output_tags_map').openCursor(null, direction)
560
564
  }
561
565
  let firstTime = true
562
566
  while (cursor) {
@@ -625,6 +629,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
625
629
  let skipped = 0
626
630
  let count = 0
627
631
  const dbTrx = this.toDbTrx(['proven_tx_reqs'], 'readonly', args.trx)
632
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
628
633
  let cursor:
629
634
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'proven_tx_reqs', unknown, 'readwrite' | 'readonly'>
630
635
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'proven_tx_reqs', 'provenTxId', 'readwrite' | 'readonly'>
@@ -633,17 +638,20 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
633
638
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'proven_tx_reqs', 'batch', 'readwrite' | 'readonly'>
634
639
  | null
635
640
  if (args.partial?.provenTxReqId) {
636
- cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor(args.partial.provenTxReqId)
641
+ cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor(args.partial.provenTxReqId, direction)
637
642
  } else if (args.partial?.provenTxId !== undefined) {
638
- cursor = await dbTrx.objectStore('proven_tx_reqs').index('provenTxId').openCursor(args.partial.provenTxId)
643
+ cursor = await dbTrx
644
+ .objectStore('proven_tx_reqs')
645
+ .index('provenTxId')
646
+ .openCursor(args.partial.provenTxId, direction)
639
647
  } else if (args.partial?.txid !== undefined) {
640
- cursor = await dbTrx.objectStore('proven_tx_reqs').index('txid').openCursor(args.partial.txid)
648
+ cursor = await dbTrx.objectStore('proven_tx_reqs').index('txid').openCursor(args.partial.txid, direction)
641
649
  } else if (args.partial?.status !== undefined) {
642
- cursor = await dbTrx.objectStore('proven_tx_reqs').index('status').openCursor(args.partial.status)
650
+ cursor = await dbTrx.objectStore('proven_tx_reqs').index('status').openCursor(args.partial.status, direction)
643
651
  } else if (args.partial?.batch !== undefined) {
644
- cursor = await dbTrx.objectStore('proven_tx_reqs').index('batch').openCursor(args.partial.batch)
652
+ cursor = await dbTrx.objectStore('proven_tx_reqs').index('batch').openCursor(args.partial.batch, direction)
645
653
  } else {
646
- cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor()
654
+ cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor(null, direction)
647
655
  }
648
656
  let firstTime = true
649
657
  while (cursor) {
@@ -652,6 +660,8 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
652
660
  firstTime = false
653
661
  const r = cursor.value
654
662
  if (args.since && args.since > r.updated_at) continue
663
+ if (args.status && args.status.length > 0 && !args.status.includes(r.status)) continue
664
+ if (args.txids && args.txids.length > 0 && !args.txids.includes(r.txid)) continue
655
665
  if (args.partial) {
656
666
  if (args.partial.provenTxReqId && r.provenTxReqId !== args.partial.provenTxReqId) continue
657
667
  if (args.partial.provenTxId && r.provenTxId !== args.partial.provenTxId) continue
@@ -713,16 +723,17 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
713
723
  let skipped = 0
714
724
  let count = 0
715
725
  const dbTrx = this.toDbTrx(['proven_txs'], 'readonly', args.trx)
726
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
716
727
  let cursor:
717
728
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'proven_txs', unknown, 'readwrite' | 'readonly'>
718
729
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'proven_txs', 'txid', 'readwrite' | 'readonly'>
719
730
  | null
720
731
  if (args.partial?.provenTxId) {
721
- cursor = await dbTrx.objectStore('proven_txs').openCursor(args.partial.provenTxId)
732
+ cursor = await dbTrx.objectStore('proven_txs').openCursor(args.partial.provenTxId, direction)
722
733
  } else if (args.partial?.txid !== undefined) {
723
- cursor = await dbTrx.objectStore('proven_txs').index('txid').openCursor(args.partial.txid)
734
+ cursor = await dbTrx.objectStore('proven_txs').index('txid').openCursor(args.partial.txid, direction)
724
735
  } else {
725
- cursor = await dbTrx.objectStore('proven_txs').openCursor()
736
+ cursor = await dbTrx.objectStore('proven_txs').openCursor(null, direction)
726
737
  }
727
738
  let firstTime = true
728
739
  while (cursor) {
@@ -783,17 +794,21 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
783
794
  let skipped = 0
784
795
  let count = 0
785
796
  const dbTrx = this.toDbTrx(['tx_labels_map'], 'readonly', args.trx)
797
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
786
798
  let cursor:
787
799
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'tx_labels_map', unknown, 'readwrite' | 'readonly'>
788
800
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'tx_labels_map', 'transactionId', 'readwrite' | 'readonly'>
789
801
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'tx_labels_map', 'txLabelId', 'readwrite' | 'readonly'>
790
802
  | null
791
803
  if (args.partial?.transactionId !== undefined) {
792
- cursor = await dbTrx.objectStore('tx_labels_map').index('transactionId').openCursor(args.partial.transactionId)
804
+ cursor = await dbTrx
805
+ .objectStore('tx_labels_map')
806
+ .index('transactionId')
807
+ .openCursor(args.partial.transactionId, direction)
793
808
  } else if (args.partial?.txLabelId !== undefined) {
794
- cursor = await dbTrx.objectStore('tx_labels_map').index('txLabelId').openCursor(args.partial.txLabelId)
809
+ cursor = await dbTrx.objectStore('tx_labels_map').index('txLabelId').openCursor(args.partial.txLabelId, direction)
795
810
  } else {
796
- cursor = await dbTrx.objectStore('tx_labels_map').openCursor()
811
+ cursor = await dbTrx.objectStore('tx_labels_map').openCursor(null, direction)
797
812
  }
798
813
  let firstTime = true
799
814
  while (cursor) {
@@ -802,6 +817,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
802
817
  firstTime = false
803
818
  const r = cursor.value
804
819
  if (args.since && args.since > r.updated_at) continue
820
+ if (args.labelIds && !args.labelIds.includes(r.txLabelId)) continue
805
821
  if (args.partial) {
806
822
  if (args.partial.txLabelId && r.txLabelId !== args.partial.txLabelId) continue
807
823
  if (args.partial.transactionId && r.transactionId !== args.partial.transactionId) continue
@@ -1276,6 +1292,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1276
1292
  let skipped = 0
1277
1293
  let count = 0
1278
1294
  const dbTrx = this.toDbTrx(['certificate_fields'], 'readonly', args.trx)
1295
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1279
1296
  let cursor:
1280
1297
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'certificate_fields', unknown, 'readwrite' | 'readonly'>
1281
1298
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'certificate_fields', 'userId', 'readwrite' | 'readonly'>
@@ -1285,11 +1302,11 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1285
1302
  cursor = await dbTrx
1286
1303
  .objectStore('certificate_fields')
1287
1304
  .index('certificateId')
1288
- .openCursor(args.partial.certificateId)
1305
+ .openCursor(args.partial.certificateId, direction)
1289
1306
  } else if (args.partial?.userId !== undefined) {
1290
- cursor = await dbTrx.objectStore('certificate_fields').index('userId').openCursor(args.partial.userId)
1307
+ cursor = await dbTrx.objectStore('certificate_fields').index('userId').openCursor(args.partial.userId, direction)
1291
1308
  } else {
1292
- cursor = await dbTrx.objectStore('certificate_fields').openCursor()
1309
+ cursor = await dbTrx.objectStore('certificate_fields').openCursor(null, direction)
1293
1310
  }
1294
1311
  let firstTime = true
1295
1312
  while (cursor) {
@@ -1331,6 +1348,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1331
1348
  let skipped = 0
1332
1349
  let count = 0
1333
1350
  const dbTrx = this.toDbTrx(['certificates'], 'readonly', args.trx)
1351
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1334
1352
  let cursor:
1335
1353
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'certificates', unknown, 'readwrite' | 'readonly'>
1336
1354
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'certificates', 'userId', 'readwrite' | 'readonly'>
@@ -1343,18 +1361,21 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1343
1361
  >
1344
1362
  | null
1345
1363
  if (args.partial?.certificateId) {
1346
- cursor = await dbTrx.objectStore('certificates').openCursor(args.partial.certificateId)
1364
+ cursor = await dbTrx.objectStore('certificates').openCursor(args.partial.certificateId, direction)
1347
1365
  } else if (args.partial?.userId !== undefined) {
1348
1366
  if (args.partial?.type && args.partial?.certifier && args.partial?.serialNumber) {
1349
1367
  cursor = await dbTrx
1350
1368
  .objectStore('certificates')
1351
1369
  .index('userId_type_certifier_serialNumber')
1352
- .openCursor([args.partial.userId, args.partial.type, args.partial.certifier, args.partial.serialNumber])
1370
+ .openCursor(
1371
+ [args.partial.userId, args.partial.type, args.partial.certifier, args.partial.serialNumber],
1372
+ direction
1373
+ )
1353
1374
  } else {
1354
- cursor = await dbTrx.objectStore('certificates').index('userId').openCursor(args.partial.userId)
1375
+ cursor = await dbTrx.objectStore('certificates').index('userId').openCursor(args.partial.userId, direction)
1355
1376
  }
1356
1377
  } else {
1357
- cursor = await dbTrx.objectStore('certificates').openCursor()
1378
+ cursor = await dbTrx.objectStore('certificates').openCursor(null, direction)
1358
1379
  }
1359
1380
  let firstTime = true
1360
1381
  while (cursor) {
@@ -1414,19 +1435,23 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1414
1435
  let skipped = 0
1415
1436
  let count = 0
1416
1437
  const dbTrx = this.toDbTrx(['commissions'], 'readonly', args.trx)
1438
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1417
1439
  let cursor:
1418
1440
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'commissions', unknown, 'readwrite' | 'readonly'>
1419
1441
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'commissions', 'userId', 'readwrite' | 'readonly'>
1420
1442
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'commissions', 'transactionId', 'readwrite' | 'readonly'>
1421
1443
  | null
1422
1444
  if (args.partial?.commissionId) {
1423
- cursor = await dbTrx.objectStore('commissions').openCursor(args.partial.commissionId)
1445
+ cursor = await dbTrx.objectStore('commissions').openCursor(args.partial.commissionId, direction)
1424
1446
  } else if (args.partial?.userId !== undefined) {
1425
- cursor = await dbTrx.objectStore('commissions').index('userId').openCursor(args.partial.userId)
1447
+ cursor = await dbTrx.objectStore('commissions').index('userId').openCursor(args.partial.userId, direction)
1426
1448
  } else if (args.partial?.transactionId !== undefined) {
1427
- cursor = await dbTrx.objectStore('commissions').index('transactionId').openCursor(args.partial.transactionId)
1449
+ cursor = await dbTrx
1450
+ .objectStore('commissions')
1451
+ .index('transactionId')
1452
+ .openCursor(args.partial.transactionId, direction)
1428
1453
  } else {
1429
- cursor = await dbTrx.objectStore('commissions').openCursor()
1454
+ cursor = await dbTrx.objectStore('commissions').openCursor(null, direction)
1430
1455
  }
1431
1456
  let firstTime = true
1432
1457
  while (cursor) {
@@ -1469,6 +1494,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1469
1494
  let skipped = 0
1470
1495
  let count = 0
1471
1496
  const dbTrx = this.toDbTrx(['monitor_events'], 'readonly', args.trx)
1497
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1472
1498
  let cursor: IDBPCursorWithValue<
1473
1499
  StorageIdbSchema,
1474
1500
  string[],
@@ -1477,9 +1503,9 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1477
1503
  'readwrite' | 'readonly'
1478
1504
  > | null
1479
1505
  if (args.partial?.id) {
1480
- cursor = await dbTrx.objectStore('monitor_events').openCursor(args.partial.id)
1506
+ cursor = await dbTrx.objectStore('monitor_events').openCursor(args.partial.id, direction)
1481
1507
  } else {
1482
- cursor = await dbTrx.objectStore('monitor_events').openCursor()
1508
+ cursor = await dbTrx.objectStore('monitor_events').openCursor(null, direction)
1483
1509
  }
1484
1510
  let firstTime = true
1485
1511
  while (cursor) {
@@ -1519,24 +1545,25 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1519
1545
  let skipped = 0
1520
1546
  let count = 0
1521
1547
  const dbTrx = this.toDbTrx(['output_baskets'], 'readonly', args.trx)
1548
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1522
1549
  let cursor:
1523
1550
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_baskets', unknown, 'readwrite' | 'readonly'>
1524
1551
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_baskets', 'userId', 'readwrite' | 'readonly'>
1525
1552
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_baskets', 'name_userId', 'readwrite' | 'readonly'>
1526
1553
  | null
1527
1554
  if (args.partial?.basketId) {
1528
- cursor = await dbTrx.objectStore('output_baskets').openCursor(args.partial.basketId)
1555
+ cursor = await dbTrx.objectStore('output_baskets').openCursor(args.partial.basketId, direction)
1529
1556
  } else if (args.partial?.userId !== undefined) {
1530
1557
  if (args.partial?.name !== undefined) {
1531
1558
  cursor = await dbTrx
1532
1559
  .objectStore('output_baskets')
1533
1560
  .index('name_userId')
1534
- .openCursor([args.partial.name, args.partial.userId])
1561
+ .openCursor([args.partial.name, args.partial.userId], direction)
1535
1562
  } else {
1536
- cursor = await dbTrx.objectStore('output_baskets').index('userId').openCursor(args.partial.userId)
1563
+ cursor = await dbTrx.objectStore('output_baskets').index('userId').openCursor(args.partial.userId, direction)
1537
1564
  }
1538
1565
  } else {
1539
- cursor = await dbTrx.objectStore('output_baskets').openCursor()
1566
+ cursor = await dbTrx.objectStore('output_baskets').openCursor(null, direction)
1540
1567
  }
1541
1568
  let firstTime = true
1542
1569
  while (cursor) {
@@ -1558,7 +1585,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1558
1585
  continue
1559
1586
  if (
1560
1587
  args.partial.minimumDesiredUTXOValue !== undefined &&
1561
- r.numberOfDesiredSatoshis !== args.partial.minimumDesiredUTXOValue
1588
+ r.minimumDesiredUTXOValue !== args.partial.minimumDesiredUTXOValue
1562
1589
  )
1563
1590
  continue
1564
1591
  if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted) continue
@@ -1606,6 +1633,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1606
1633
  stores.push('transactions')
1607
1634
  }
1608
1635
  const dbTrx = this.toDbTrx(stores, 'readonly', args.trx)
1636
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1609
1637
  let cursor:
1610
1638
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'outputs', unknown, 'readwrite' | 'readonly'>
1611
1639
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'outputs', 'userId', 'readwrite' | 'readonly'>
@@ -1621,24 +1649,27 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1621
1649
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'outputs', 'spentBy', 'readwrite' | 'readonly'>
1622
1650
  | null
1623
1651
  if (args.partial?.outputId) {
1624
- cursor = await dbTrx.objectStore('outputs').openCursor(args.partial.outputId)
1652
+ cursor = await dbTrx.objectStore('outputs').openCursor(args.partial.outputId, direction)
1625
1653
  } else if (args.partial?.userId !== undefined) {
1626
1654
  if (args.partial?.transactionId && args.partial?.vout !== undefined) {
1627
1655
  cursor = await dbTrx
1628
1656
  .objectStore('outputs')
1629
1657
  .index('transactionId_vout_userId')
1630
- .openCursor([args.partial.transactionId, args.partial.vout, args.partial.userId])
1658
+ .openCursor([args.partial.transactionId, args.partial.vout, args.partial.userId], direction)
1631
1659
  } else {
1632
- cursor = await dbTrx.objectStore('outputs').index('userId').openCursor(args.partial.userId)
1660
+ cursor = await dbTrx.objectStore('outputs').index('userId').openCursor(args.partial.userId, direction)
1633
1661
  }
1634
1662
  } else if (args.partial?.transactionId !== undefined) {
1635
- cursor = await dbTrx.objectStore('outputs').index('transactionId').openCursor(args.partial.transactionId)
1663
+ cursor = await dbTrx
1664
+ .objectStore('outputs')
1665
+ .index('transactionId')
1666
+ .openCursor(args.partial.transactionId, direction)
1636
1667
  } else if (args.partial?.basketId !== undefined) {
1637
- cursor = await dbTrx.objectStore('outputs').index('basketId').openCursor(args.partial.basketId)
1668
+ cursor = await dbTrx.objectStore('outputs').index('basketId').openCursor(args.partial.basketId, direction)
1638
1669
  } else if (args.partial?.spentBy !== undefined) {
1639
- cursor = await dbTrx.objectStore('outputs').index('spentBy').openCursor(args.partial.spentBy)
1670
+ cursor = await dbTrx.objectStore('outputs').index('spentBy').openCursor(args.partial.spentBy, direction)
1640
1671
  } else {
1641
- cursor = await dbTrx.objectStore('outputs').openCursor()
1672
+ cursor = await dbTrx.objectStore('outputs').openCursor(null, direction)
1642
1673
  }
1643
1674
  let firstTime = true
1644
1675
  while (cursor) {
@@ -1737,24 +1768,25 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1737
1768
  let skipped = 0
1738
1769
  let count = 0
1739
1770
  const dbTrx = this.toDbTrx(['output_tags'], 'readonly', args.trx)
1771
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1740
1772
  let cursor:
1741
1773
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_tags', unknown, 'readwrite' | 'readonly'>
1742
1774
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_tags', 'userId', 'readwrite' | 'readonly'>
1743
1775
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'output_tags', 'tag_userId', 'readwrite' | 'readonly'>
1744
1776
  | null
1745
1777
  if (args.partial?.outputTagId) {
1746
- cursor = await dbTrx.objectStore('output_tags').openCursor(args.partial.outputTagId)
1778
+ cursor = await dbTrx.objectStore('output_tags').openCursor(args.partial.outputTagId, direction)
1747
1779
  } else if (args.partial?.userId !== undefined) {
1748
1780
  if (args.partial?.tag !== undefined) {
1749
1781
  cursor = await dbTrx
1750
1782
  .objectStore('output_tags')
1751
1783
  .index('tag_userId')
1752
- .openCursor([args.partial.tag, args.partial.userId])
1784
+ .openCursor([args.partial.tag, args.partial.userId], direction)
1753
1785
  } else {
1754
- cursor = await dbTrx.objectStore('output_tags').index('userId').openCursor(args.partial.userId)
1786
+ cursor = await dbTrx.objectStore('output_tags').index('userId').openCursor(args.partial.userId, direction)
1755
1787
  }
1756
1788
  } else {
1757
- cursor = await dbTrx.objectStore('output_tags').openCursor()
1789
+ cursor = await dbTrx.objectStore('output_tags').openCursor(null, direction)
1758
1790
  }
1759
1791
  let firstTime = true
1760
1792
  while (cursor) {
@@ -1800,6 +1832,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1800
1832
  let skipped = 0
1801
1833
  let count = 0
1802
1834
  const dbTrx = this.toDbTrx(['sync_states'], 'readonly', args.trx)
1835
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1803
1836
  let cursor:
1804
1837
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'sync_states', unknown, 'readwrite' | 'readonly'>
1805
1838
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'sync_states', 'userId', 'readwrite' | 'readonly'>
@@ -1807,15 +1840,15 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1807
1840
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'sync_states', 'status', 'readwrite' | 'readonly'>
1808
1841
  | null
1809
1842
  if (args.partial?.syncStateId) {
1810
- cursor = await dbTrx.objectStore('sync_states').openCursor(args.partial.syncStateId)
1843
+ cursor = await dbTrx.objectStore('sync_states').openCursor(args.partial.syncStateId, direction)
1811
1844
  } else if (args.partial?.userId !== undefined) {
1812
- cursor = await dbTrx.objectStore('sync_states').index('userId').openCursor(args.partial.userId)
1845
+ cursor = await dbTrx.objectStore('sync_states').index('userId').openCursor(args.partial.userId, direction)
1813
1846
  } else if (args.partial?.refNum !== undefined) {
1814
- cursor = await dbTrx.objectStore('sync_states').index('refNum').openCursor(args.partial.refNum)
1847
+ cursor = await dbTrx.objectStore('sync_states').index('refNum').openCursor(args.partial.refNum, direction)
1815
1848
  } else if (args.partial?.status !== undefined) {
1816
- cursor = await dbTrx.objectStore('sync_states').index('status').openCursor(args.partial.status)
1849
+ cursor = await dbTrx.objectStore('sync_states').index('status').openCursor(args.partial.status, direction)
1817
1850
  } else {
1818
- cursor = await dbTrx.objectStore('sync_states').openCursor()
1851
+ cursor = await dbTrx.objectStore('sync_states').openCursor(null, direction)
1819
1852
  }
1820
1853
  let firstTime = true
1821
1854
  while (cursor) {
@@ -1836,7 +1869,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1836
1869
  if (args.partial.refNum !== undefined && r.refNum !== args.partial.refNum) continue
1837
1870
  if (args.partial.when && r.when?.getTime() !== args.partial.when.getTime()) continue
1838
1871
  if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis) continue
1839
- if (args.partial.errorLocal && r.errorLocale !== args.partial.errorLocal) continue
1872
+ if (args.partial.errorLocal && r.errorLocal !== args.partial.errorLocal) continue
1840
1873
  if (args.partial.errorOther && r.errorOther !== args.partial.errorOther) continue
1841
1874
  }
1842
1875
  if (skipped < offset) {
@@ -1879,6 +1912,7 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1879
1912
  stores.push('tx_labels_map')
1880
1913
  }
1881
1914
  const dbTrx = this.toDbTrx(stores, 'readonly', args.trx)
1915
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1882
1916
  let cursor:
1883
1917
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'transactions', unknown, 'readwrite' | 'readonly'>
1884
1918
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'transactions', 'userId', 'readwrite' | 'readonly'>
@@ -1888,24 +1922,27 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1888
1922
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'transactions', 'reference', 'readwrite' | 'readonly'>
1889
1923
  | null
1890
1924
  if (args.partial?.transactionId) {
1891
- cursor = await dbTrx.objectStore('transactions').openCursor(args.partial.transactionId)
1925
+ cursor = await dbTrx.objectStore('transactions').openCursor(args.partial.transactionId, direction)
1892
1926
  } else if (args.partial?.userId !== undefined) {
1893
1927
  if (args.partial?.status !== undefined) {
1894
1928
  cursor = await dbTrx
1895
1929
  .objectStore('transactions')
1896
1930
  .index('status_userId')
1897
- .openCursor([args.partial.status, args.partial.userId])
1931
+ .openCursor([args.partial.status, args.partial.userId], direction)
1898
1932
  } else {
1899
- cursor = await dbTrx.objectStore('transactions').index('userId').openCursor(args.partial.userId)
1933
+ cursor = await dbTrx.objectStore('transactions').index('userId').openCursor(args.partial.userId, direction)
1900
1934
  }
1901
1935
  } else if (args.partial?.status !== undefined) {
1902
- cursor = await dbTrx.objectStore('transactions').index('status').openCursor(args.partial.status)
1936
+ cursor = await dbTrx.objectStore('transactions').index('status').openCursor(args.partial.status, direction)
1903
1937
  } else if (args.partial?.provenTxId !== undefined) {
1904
- cursor = await dbTrx.objectStore('transactions').index('provenTxId').openCursor(args.partial.provenTxId)
1938
+ cursor = await dbTrx
1939
+ .objectStore('transactions')
1940
+ .index('provenTxId')
1941
+ .openCursor(args.partial.provenTxId, direction)
1905
1942
  } else if (args.partial?.reference !== undefined) {
1906
- cursor = await dbTrx.objectStore('transactions').index('reference').openCursor(args.partial.reference)
1943
+ cursor = await dbTrx.objectStore('transactions').index('reference').openCursor(args.partial.reference, direction)
1907
1944
  } else {
1908
- cursor = await dbTrx.objectStore('transactions').openCursor()
1945
+ cursor = await dbTrx.objectStore('transactions').openCursor(null, direction)
1909
1946
  }
1910
1947
  let firstTime = true
1911
1948
  while (cursor) {
@@ -1987,24 +2024,25 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
1987
2024
  let skipped = 0
1988
2025
  let count = 0
1989
2026
  const dbTrx = this.toDbTrx(['tx_labels'], 'readonly', args.trx)
2027
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
1990
2028
  let cursor:
1991
2029
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'tx_labels', unknown, 'readwrite' | 'readonly'>
1992
2030
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'tx_labels', 'userId', 'readwrite' | 'readonly'>
1993
2031
  | IDBPCursorWithValue<StorageIdbSchema, string[], 'tx_labels', 'label_userId', 'readwrite' | 'readonly'>
1994
2032
  | null
1995
2033
  if (args.partial?.txLabelId) {
1996
- cursor = await dbTrx.objectStore('tx_labels').openCursor(args.partial.txLabelId)
2034
+ cursor = await dbTrx.objectStore('tx_labels').openCursor(args.partial.txLabelId, direction)
1997
2035
  } else if (args.partial?.userId !== undefined) {
1998
2036
  if (args.partial?.label !== undefined) {
1999
2037
  cursor = await dbTrx
2000
2038
  .objectStore('tx_labels')
2001
2039
  .index('label_userId')
2002
- .openCursor([args.partial.label, args.partial.userId])
2040
+ .openCursor([args.partial.label, args.partial.userId], direction)
2003
2041
  } else {
2004
- cursor = await dbTrx.objectStore('tx_labels').index('userId').openCursor(args.partial.userId)
2042
+ cursor = await dbTrx.objectStore('tx_labels').index('userId').openCursor(args.partial.userId, direction)
2005
2043
  }
2006
2044
  } else {
2007
- cursor = await dbTrx.objectStore('tx_labels').openCursor()
2045
+ cursor = await dbTrx.objectStore('tx_labels').openCursor(null, direction)
2008
2046
  }
2009
2047
  let firstTime = true
2010
2048
  while (cursor) {
@@ -2045,7 +2083,8 @@ export class StorageIdb extends StorageProvider implements WalletStorageProvider
2045
2083
  let skipped = 0
2046
2084
  let count = 0
2047
2085
  const dbTrx = this.toDbTrx(['users'], 'readonly', args.trx)
2048
- let cursor = await dbTrx.objectStore('users').openCursor()
2086
+ const direction: IDBCursorDirection = args.orderDescending ? 'prev' : 'next'
2087
+ let cursor = await dbTrx.objectStore('users').openCursor(null, direction)
2049
2088
  let firstTime = true
2050
2089
  while (cursor) {
2051
2090
  if (!firstTime) cursor = await cursor.continue()