@bsv/wallet-toolbox 2.1.25 → 2.1.27

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.
Files changed (206) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +8 -17
  3. package/docs/client.md +1671 -989
  4. package/docs/monitor.md +34 -19
  5. package/docs/services.md +303 -279
  6. package/docs/setup.md +24 -24
  7. package/docs/storage.md +864 -199
  8. package/docs/wallet.md +5285 -10988
  9. package/out/src/Wallet.d.ts +46 -2
  10. package/out/src/Wallet.d.ts.map +1 -1
  11. package/out/src/Wallet.js +65 -4
  12. package/out/src/Wallet.js.map +1 -1
  13. package/out/src/__tests/CWIStyleWalletManager.test.js +3 -2
  14. package/out/src/__tests/CWIStyleWalletManager.test.js.map +1 -1
  15. package/out/src/__tests/ShamirWalletManager.test.js +4 -0
  16. package/out/src/__tests/ShamirWalletManager.test.js.map +1 -1
  17. package/out/src/__tests/WalletPermissionsManager.callbacks.test.js +9 -17
  18. package/out/src/__tests/WalletPermissionsManager.callbacks.test.js.map +1 -1
  19. package/out/src/__tests/WalletPermissionsManager.checks.test.js +4 -4
  20. package/out/src/__tests/WalletPermissionsManager.checks.test.js.map +1 -1
  21. package/out/src/__tests/WalletPermissionsManager.encryption.test.js +8 -8
  22. package/out/src/__tests/WalletPermissionsManager.encryption.test.js.map +1 -1
  23. package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts +2 -1
  24. package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
  25. package/out/src/__tests/WalletPermissionsManager.fixtures.js +7 -5
  26. package/out/src/__tests/WalletPermissionsManager.fixtures.js.map +1 -1
  27. package/out/src/__tests/WalletPermissionsManager.flows.test.js +14 -14
  28. package/out/src/__tests/WalletPermissionsManager.flows.test.js.map +1 -1
  29. package/out/src/__tests/WalletPermissionsManager.initialization.test.js +4 -4
  30. package/out/src/__tests/WalletPermissionsManager.initialization.test.js.map +1 -1
  31. package/out/src/__tests/WalletPermissionsManager.pmodules.test.js +4 -4
  32. package/out/src/__tests/WalletPermissionsManager.pmodules.test.js.map +1 -1
  33. package/out/src/__tests/WalletPermissionsManager.proxying.test.js +6 -5
  34. package/out/src/__tests/WalletPermissionsManager.proxying.test.js.map +1 -1
  35. package/out/src/__tests/WalletPermissionsManager.tokens.test.js +2 -1
  36. package/out/src/__tests/WalletPermissionsManager.tokens.test.js.map +1 -1
  37. package/out/src/entropy/EntropyCollector.js.map +1 -1
  38. package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
  39. package/out/src/mockchain/MockChainStorage.js +3 -3
  40. package/out/src/mockchain/MockChainStorage.js.map +1 -1
  41. package/out/src/mockchain/MockMiner.js +1 -1
  42. package/out/src/mockchain/MockMiner.js.map +1 -1
  43. package/out/src/mockchain/MockServices.js +14 -13
  44. package/out/src/mockchain/MockServices.js.map +1 -1
  45. package/out/src/monitor/Monitor.js +8 -6
  46. package/out/src/monitor/Monitor.js.map +1 -1
  47. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  48. package/out/src/monitor/MonitorDaemon.js +11 -13
  49. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  50. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
  51. package/out/src/sdk/PrivilegedKeyManager.js +6 -3
  52. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
  53. package/out/src/sdk/WalletError.d.ts.map +1 -1
  54. package/out/src/sdk/WalletError.js +19 -18
  55. package/out/src/sdk/WalletError.js.map +1 -1
  56. package/out/src/sdk/WalletErrorFromJson.js +1 -1
  57. package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
  58. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  59. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  60. package/out/src/services/ServiceCollection.d.ts.map +1 -1
  61. package/out/src/services/ServiceCollection.js +3 -4
  62. package/out/src/services/ServiceCollection.js.map +1 -1
  63. package/out/src/services/Services.d.ts.map +1 -1
  64. package/out/src/services/Services.js +27 -25
  65. package/out/src/services/Services.js.map +1 -1
  66. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  67. package/out/src/storage/StorageIdb.js +99 -94
  68. package/out/src/storage/StorageIdb.js.map +1 -1
  69. package/out/src/storage/StorageKnex.d.ts +1 -1
  70. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  71. package/out/src/storage/StorageKnex.js +159 -156
  72. package/out/src/storage/StorageKnex.js.map +1 -1
  73. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  74. package/out/src/storage/StorageProvider.js +35 -31
  75. package/out/src/storage/StorageProvider.js.map +1 -1
  76. package/out/src/storage/StorageReader.js +7 -7
  77. package/out/src/storage/StorageReader.js.map +1 -1
  78. package/out/src/storage/StorageReaderWriter.d.ts +0 -1
  79. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  80. package/out/src/storage/StorageReaderWriter.js +0 -3
  81. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  82. package/out/src/storage/StorageSyncReader.js +1 -1
  83. package/out/src/storage/StorageSyncReader.js.map +1 -1
  84. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  85. package/out/src/storage/WalletStorageManager.js +22 -21
  86. package/out/src/storage/WalletStorageManager.js.map +1 -1
  87. package/out/src/storage/index.all.d.ts +3 -0
  88. package/out/src/storage/index.all.d.ts.map +1 -1
  89. package/out/src/storage/index.all.js +3 -0
  90. package/out/src/storage/index.all.js.map +1 -1
  91. package/out/src/storage/index.client.d.ts +3 -0
  92. package/out/src/storage/index.client.d.ts.map +1 -1
  93. package/out/src/storage/index.client.js +3 -0
  94. package/out/src/storage/index.client.js.map +1 -1
  95. package/out/src/storage/index.mobile.d.ts +3 -0
  96. package/out/src/storage/index.mobile.d.ts.map +1 -1
  97. package/out/src/storage/index.mobile.js +3 -0
  98. package/out/src/storage/index.mobile.js.map +1 -1
  99. package/out/src/storage/portable/index.d.ts +55 -0
  100. package/out/src/storage/portable/index.d.ts.map +1 -0
  101. package/out/src/storage/portable/index.js +830 -0
  102. package/out/src/storage/portable/index.js.map +1 -0
  103. package/out/src/storage/storageProviderHelpers.js +2 -2
  104. package/out/src/storage/storageProviderHelpers.js.map +1 -1
  105. package/out/src/utility/Format.d.ts.map +1 -1
  106. package/out/src/utility/Format.js +10 -45
  107. package/out/src/utility/Format.js.map +1 -1
  108. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  109. package/out/src/utility/ScriptTemplateBRC29.js +3 -2
  110. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  111. package/out/src/utility/brc114ActionTimeLabels.js +1 -1
  112. package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
  113. package/out/src/utility/identityUtils.d.ts +12 -6
  114. package/out/src/utility/identityUtils.d.ts.map +1 -1
  115. package/out/src/utility/identityUtils.js +83 -35
  116. package/out/src/utility/identityUtils.js.map +1 -1
  117. package/out/src/utility/index.all.d.ts +1 -0
  118. package/out/src/utility/index.all.d.ts.map +1 -1
  119. package/out/src/utility/index.all.js +1 -0
  120. package/out/src/utility/index.all.js.map +1 -1
  121. package/out/src/utility/index.client.d.ts +1 -0
  122. package/out/src/utility/index.client.d.ts.map +1 -1
  123. package/out/src/utility/index.client.js +1 -0
  124. package/out/src/utility/index.client.js.map +1 -1
  125. package/out/src/utility/stampLog.js +3 -3
  126. package/out/src/utility/stampLog.js.map +1 -1
  127. package/out/src/utility/utilityHelpers.buffer.js +1 -1
  128. package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
  129. package/out/src/utility/utilityHelpers.d.ts.map +1 -1
  130. package/out/src/utility/utilityHelpers.js +2 -2
  131. package/out/src/utility/utilityHelpers.js.map +1 -1
  132. package/out/src/wab-client/WABClient.d.ts +2 -2
  133. package/out/src/wab-client/WABClient.d.ts.map +1 -1
  134. package/package.json +2 -2
  135. package/out/src/storage/schema/__tests/v7Backfill.runner.test.d.ts +0 -2
  136. package/out/src/storage/schema/__tests/v7Backfill.runner.test.d.ts.map +0 -1
  137. package/out/src/storage/schema/__tests/v7Backfill.runner.test.js +0 -148
  138. package/out/src/storage/schema/__tests/v7Backfill.runner.test.js.map +0 -1
  139. package/out/src/storage/schema/__tests/v7Backfill.test.d.ts +0 -2
  140. package/out/src/storage/schema/__tests/v7Backfill.test.d.ts.map +0 -1
  141. package/out/src/storage/schema/__tests/v7Backfill.test.js +0 -96
  142. package/out/src/storage/schema/__tests/v7Backfill.test.js.map +0 -1
  143. package/out/src/storage/schema/__tests/v7Fsm.test.d.ts +0 -2
  144. package/out/src/storage/schema/__tests/v7Fsm.test.d.ts.map +0 -1
  145. package/out/src/storage/schema/__tests/v7Fsm.test.js +0 -42
  146. package/out/src/storage/schema/__tests/v7Fsm.test.js.map +0 -1
  147. package/out/src/storage/schema/__tests/v7Spendability.test.d.ts +0 -2
  148. package/out/src/storage/schema/__tests/v7Spendability.test.d.ts.map +0 -1
  149. package/out/src/storage/schema/__tests/v7Spendability.test.js +0 -29
  150. package/out/src/storage/schema/__tests/v7Spendability.test.js.map +0 -1
  151. package/out/src/storage/schema/tables/TableAction.d.ts +0 -38
  152. package/out/src/storage/schema/tables/TableAction.d.ts.map +0 -1
  153. package/out/src/storage/schema/tables/TableAction.js +0 -3
  154. package/out/src/storage/schema/tables/TableAction.js.map +0 -1
  155. package/out/src/storage/schema/tables/TableChainTip.d.ts +0 -17
  156. package/out/src/storage/schema/tables/TableChainTip.d.ts.map +0 -1
  157. package/out/src/storage/schema/tables/TableChainTip.js +0 -3
  158. package/out/src/storage/schema/tables/TableChainTip.js.map +0 -1
  159. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +0 -23
  160. package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +0 -1
  161. package/out/src/storage/schema/tables/TableMonitorLease.js +0 -3
  162. package/out/src/storage/schema/tables/TableMonitorLease.js.map +0 -1
  163. package/out/src/storage/schema/tables/TableTransactionV7.d.ts +0 -50
  164. package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +0 -1
  165. package/out/src/storage/schema/tables/TableTransactionV7.js +0 -3
  166. package/out/src/storage/schema/tables/TableTransactionV7.js.map +0 -1
  167. package/out/src/storage/schema/tables/TableTxAudit.d.ts +0 -26
  168. package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +0 -1
  169. package/out/src/storage/schema/tables/TableTxAudit.js +0 -3
  170. package/out/src/storage/schema/tables/TableTxAudit.js.map +0 -1
  171. package/out/src/storage/schema/v7Backfill.d.ts +0 -35
  172. package/out/src/storage/schema/v7Backfill.d.ts.map +0 -1
  173. package/out/src/storage/schema/v7Backfill.idb.d.ts +0 -32
  174. package/out/src/storage/schema/v7Backfill.idb.d.ts.map +0 -1
  175. package/out/src/storage/schema/v7Backfill.idb.js +0 -95
  176. package/out/src/storage/schema/v7Backfill.idb.js.map +0 -1
  177. package/out/src/storage/schema/v7Backfill.js +0 -147
  178. package/out/src/storage/schema/v7Backfill.js.map +0 -1
  179. package/out/src/storage/schema/v7Backfill.knex.d.ts +0 -32
  180. package/out/src/storage/schema/v7Backfill.knex.d.ts.map +0 -1
  181. package/out/src/storage/schema/v7Backfill.knex.js +0 -240
  182. package/out/src/storage/schema/v7Backfill.knex.js.map +0 -1
  183. package/out/src/storage/schema/v7Backfill.runner.d.ts +0 -63
  184. package/out/src/storage/schema/v7Backfill.runner.d.ts.map +0 -1
  185. package/out/src/storage/schema/v7Backfill.runner.js +0 -62
  186. package/out/src/storage/schema/v7Backfill.runner.js.map +0 -1
  187. package/out/src/storage/schema/v7Crud.d.ts +0 -39
  188. package/out/src/storage/schema/v7Crud.d.ts.map +0 -1
  189. package/out/src/storage/schema/v7Crud.js +0 -203
  190. package/out/src/storage/schema/v7Crud.js.map +0 -1
  191. package/out/src/storage/schema/v7Fsm.d.ts +0 -27
  192. package/out/src/storage/schema/v7Fsm.d.ts.map +0 -1
  193. package/out/src/storage/schema/v7Fsm.js +0 -108
  194. package/out/src/storage/schema/v7Fsm.js.map +0 -1
  195. package/out/src/storage/schema/v7MonitorLease.d.ts +0 -57
  196. package/out/src/storage/schema/v7MonitorLease.d.ts.map +0 -1
  197. package/out/src/storage/schema/v7MonitorLease.js +0 -101
  198. package/out/src/storage/schema/v7MonitorLease.js.map +0 -1
  199. package/out/src/storage/schema/v7Spendability.d.ts +0 -45
  200. package/out/src/storage/schema/v7Spendability.d.ts.map +0 -1
  201. package/out/src/storage/schema/v7Spendability.js +0 -52
  202. package/out/src/storage/schema/v7Spendability.js.map +0 -1
  203. package/out/src/storage/schema/v7TxAudit.d.ts +0 -33
  204. package/out/src/storage/schema/v7TxAudit.d.ts.map +0 -1
  205. package/out/src/storage/schema/v7TxAudit.js +0 -64
  206. package/out/src/storage/schema/v7TxAudit.js.map +0 -1
@@ -14,7 +14,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
14
14
  constructor(options) {
15
15
  super(options);
16
16
  this._verifiedReadyForDatabaseAccess = false;
17
- if (!options.knex)
17
+ if (options.knex == null)
18
18
  throw new WERR_errors_1.WERR_INVALID_PARAMETER('options.knex', 'valid');
19
19
  this.knex = options.knex;
20
20
  }
@@ -34,7 +34,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
34
34
  .where('txid', txid)
35
35
  .whereIn('status', ['unsent', 'unmined', 'unconfirmed', 'sending', 'nosend', 'completed'])
36
36
  .select('rawTx', 'inputBEEF'));
37
- if (reqRawTx) {
37
+ if (reqRawTx != null) {
38
38
  r.rawTx = Array.from(reqRawTx.rawTx);
39
39
  r.inputBEEF = Array.from(reqRawTx.inputBEEF);
40
40
  }
@@ -43,8 +43,8 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
43
43
  }
44
44
  dbTypeSubstring(source, fromOffset, forLength) {
45
45
  if (this.dbtype === 'MySQL')
46
- return `substring(${source} from ${fromOffset} for ${forLength})`;
47
- return `substr(${source}, ${fromOffset}, ${forLength})`;
46
+ return `substring(${source} from ${fromOffset} for ${String(forLength)})`;
47
+ return `substr(${source}, ${fromOffset}, ${String(forLength)})`;
48
48
  }
49
49
  normaliseKnexRawResult(rs) {
50
50
  if (this.dbtype === 'MySQL')
@@ -62,27 +62,28 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
62
62
  return (req === null || req === void 0 ? void 0 : req.rawTx) != null ? Array.from(req.rawTx) : undefined;
63
63
  }
64
64
  async getRawTxOfKnownValidTransaction(txid, offset, length, trx) {
65
- if (!txid)
65
+ if (txid == null || txid === '')
66
66
  return undefined;
67
67
  if (!this.isAvailable())
68
68
  await this.makeAvailable();
69
69
  if (Number.isInteger(offset) && Number.isInteger(length)) {
70
- return this.getRawTxSlice(txid, offset, length, trx);
70
+ return await this.getRawTxSlice(txid, offset, length, trx);
71
71
  }
72
72
  const r = await this.getProvenOrRawTx(txid, trx);
73
73
  return r.proven != null ? r.proven.rawTx : r.rawTx;
74
74
  }
75
75
  getProvenTxsForUserQuery(args) {
76
+ var _a;
76
77
  const k = this.toDb(args.trx);
77
78
  let q = k('proven_txs').where(function () {
78
- this.whereExists(k
79
+ void this.whereExists(k
79
80
  .select('*')
80
81
  .from('transactions')
81
82
  .whereRaw(`proven_txs.provenTxId = transactions.provenTxId and transactions.userId = ${args.userId}`));
82
83
  });
83
84
  if (args.paged != null) {
84
85
  q = q.limit(args.paged.limit);
85
- q = q.offset(args.paged.offset || 0);
86
+ q = q.offset((_a = args.paged.offset) !== null && _a !== void 0 ? _a : 0);
86
87
  }
87
88
  if (args.since != null)
88
89
  q = q.where('updated_at', '>=', this.validateDateForWhere(args.since));
@@ -94,16 +95,17 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
94
95
  return this.validateEntities(rs);
95
96
  }
96
97
  getProvenTxReqsForUserQuery(args) {
98
+ var _a;
97
99
  const k = this.toDb(args.trx);
98
100
  let q = k('proven_tx_reqs').where(function () {
99
- this.whereExists(k
101
+ void this.whereExists(k
100
102
  .select('*')
101
103
  .from('transactions')
102
104
  .whereRaw(`proven_tx_reqs.txid = transactions.txid and transactions.userId = ${args.userId}`));
103
105
  });
104
106
  if (args.paged != null) {
105
107
  q = q.limit(args.paged.limit);
106
- q = q.offset(args.paged.offset || 0);
108
+ q = q.offset((_a = args.paged.offset) !== null && _a !== void 0 ? _a : 0);
107
109
  }
108
110
  if (args.since != null)
109
111
  q = q.where('updated_at', '>=', this.validateDateForWhere(args.since));
@@ -115,6 +117,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
115
117
  return this.validateEntities(rs, undefined, ['notified']);
116
118
  }
117
119
  getTxLabelMapsForUserQuery(args) {
120
+ var _a;
118
121
  const k = this.toDb(args.trx);
119
122
  let q = k('tx_labels_map').whereExists(k
120
123
  .select('*')
@@ -124,7 +127,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
124
127
  q = q.where('updated_at', '>=', this.validateDateForWhere(args.since));
125
128
  if (args.paged != null) {
126
129
  q = q.limit(args.paged.limit);
127
- q = q.offset(args.paged.offset || 0);
130
+ q = q.offset((_a = args.paged.offset) !== null && _a !== void 0 ? _a : 0);
128
131
  }
129
132
  return q;
130
133
  }
@@ -134,6 +137,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
134
137
  return this.validateEntities(rs, undefined, ['isDeleted']);
135
138
  }
136
139
  getOutputTagMapsForUserQuery(args) {
140
+ var _a;
137
141
  const k = this.toDb(args.trx);
138
142
  let q = k('output_tags_map').whereExists(k
139
143
  .select('*')
@@ -143,7 +147,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
143
147
  q = q.where('updated_at', '>=', this.validateDateForWhere(args.since));
144
148
  if (args.paged != null) {
145
149
  q = q.limit(args.paged.limit);
146
- q = q.offset(args.paged.offset || 0);
150
+ q = q.offset((_a = args.paged.offset) !== null && _a !== void 0 ? _a : 0);
147
151
  }
148
152
  return q;
149
153
  }
@@ -153,12 +157,12 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
153
157
  return this.validateEntities(rs, undefined, ['isDeleted']);
154
158
  }
155
159
  async listActions(auth, vargs) {
156
- if (!auth.userId)
160
+ if (auth.userId == null)
157
161
  throw new WERR_errors_1.WERR_UNAUTHORIZED();
158
162
  return await (0, listActionsKnex_1.listActions)(this, auth, vargs);
159
163
  }
160
164
  async listOutputs(auth, vargs) {
161
- if (!auth.userId)
165
+ if (auth.userId == null)
162
166
  throw new WERR_errors_1.WERR_UNAUTHORIZED();
163
167
  return await (0, listOutputsKnex_1.listOutputs)(this, auth, vargs);
164
168
  }
@@ -187,7 +191,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
187
191
  return user.userId;
188
192
  }
189
193
  async insertCertificateAuth(auth, certificate) {
190
- if (!auth.userId || (certificate.userId && certificate.userId !== auth.userId))
194
+ if (auth.userId == null || (certificate.userId != null && certificate.userId !== 0 && certificate.userId !== auth.userId))
191
195
  throw new WERR_errors_1.WERR_UNAUTHORIZED();
192
196
  certificate.userId = auth.userId;
193
197
  return await this.insertCertificate(certificate);
@@ -196,14 +200,14 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
196
200
  const e = await this.validateEntityForInsert(certificate, trx, undefined, ['isDeleted']);
197
201
  if (e.certificateId === 0)
198
202
  delete e.certificateId;
199
- if (e.logger)
203
+ if (e.logger != null)
200
204
  delete e.logger;
201
205
  const fields = e.fields;
202
- if (e.fields)
206
+ if (e.fields != null)
203
207
  delete e.fields;
204
208
  const [id] = await this.toDb(trx)('certificates').insert(e);
205
209
  certificate.certificateId = id;
206
- if (fields) {
210
+ if (fields != null) {
207
211
  for (const field of fields) {
208
212
  field.certificateId = id;
209
213
  field.userId = certificate.userId;
@@ -241,17 +245,12 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
241
245
  return commission.commissionId;
242
246
  }
243
247
  async insertOutput(output, trx) {
244
- try {
245
- const e = await this.validateEntityForInsert(output, trx);
246
- if (e.outputId === 0)
247
- delete e.outputId;
248
- const [id] = await this.toDb(trx)('outputs').insert(e);
249
- output.outputId = id;
250
- return output.outputId;
251
- }
252
- catch (e) {
253
- throw e;
254
- }
248
+ const e = await this.validateEntityForInsert(output, trx);
249
+ if (e.outputId === 0)
250
+ delete e.outputId;
251
+ const [id] = await this.toDb(trx)('outputs').insert(e);
252
+ output.outputId = id;
253
+ return output.outputId;
255
254
  }
256
255
  async insertOutputTag(tag, trx) {
257
256
  const e = await this.validateEntityForInsert(tag, trx, undefined, ['isDeleted']);
@@ -406,12 +405,13 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
406
405
  .update(this.validatePartialForUpdate(update));
407
406
  }
408
407
  setupQuery(table, args) {
408
+ var _a;
409
409
  const q = this.toDb(args.trx)(table);
410
- if (args.partial && Object.keys(args.partial).length > 0)
411
- q.where(args.partial);
410
+ if (args.partial != null && Object.keys(args.partial).length > 0)
411
+ void q.where(args.partial);
412
412
  if (args.since != null)
413
- q.where('updated_at', '>=', this.validateDateForWhere(args.since));
414
- if (args.orderDescending) {
413
+ void q.where('updated_at', '>=', this.validateDateForWhere(args.since));
414
+ if (args.orderDescending === true) {
415
415
  let sortColumn = '';
416
416
  switch (table) {
417
417
  case 'certificates':
@@ -454,12 +454,12 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
454
454
  break;
455
455
  }
456
456
  if (sortColumn !== '') {
457
- q.orderBy(sortColumn, 'desc');
457
+ void q.orderBy(sortColumn, 'desc');
458
458
  }
459
459
  }
460
460
  if (args.paged != null) {
461
- q.limit(args.paged.limit);
462
- q.offset(args.paged.offset || 0);
461
+ void q.limit(args.paged.limit);
462
+ void q.offset((_a = args.paged.offset) !== null && _a !== void 0 ? _a : 0);
463
463
  }
464
464
  return q;
465
465
  }
@@ -469,9 +469,9 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
469
469
  findCertificatesQuery(args) {
470
470
  const q = this.setupQuery('certificates', args);
471
471
  if ((args.certifiers != null) && args.certifiers.length > 0)
472
- q.whereIn('certifier', args.certifiers);
472
+ void q.whereIn('certifier', args.certifiers);
473
473
  if ((args.types != null) && args.types.length > 0)
474
- q.whereIn('type', args.types);
474
+ void q.whereIn('type', args.types);
475
475
  return q;
476
476
  }
477
477
  findCommissionsQuery(args) {
@@ -489,18 +489,18 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
489
489
  }
490
490
  const q = this.setupQuery('outputs', args);
491
491
  if ((args.txStatus != null) && args.txStatus.length > 0) {
492
- q.whereRaw(`(select status from transactions where transactions.transactionId = outputs.transactionId) in (${args.txStatus.map(s => "'" + s + "'").join(',')})`);
492
+ void q.whereRaw(`(select status from transactions where transactions.transactionId = outputs.transactionId) in (${args.txStatus.map(s => "'" + s + "'").join(',')})`);
493
493
  }
494
- if (args.noScript && !count) {
494
+ if ((args.noScript === true) && count !== true) {
495
495
  const columns = tables_1.outputColumnsWithoutLockingScript.map(c => `outputs.${c}`);
496
- q.select(columns);
496
+ void q.select(columns);
497
497
  }
498
498
  return q;
499
499
  }
500
500
  findOutputTagMapsQuery(args) {
501
501
  const q = this.setupQuery('output_tags_map', args);
502
502
  if ((args.tagIds != null) && args.tagIds.length > 0)
503
- q.whereIn('outputTagId', args.tagIds);
503
+ void q.whereIn('outputTagId', args.tagIds);
504
504
  return q;
505
505
  }
506
506
  findOutputTagsQuery(args) {
@@ -515,11 +515,11 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
515
515
  }
516
516
  const q = this.setupQuery('proven_tx_reqs', args);
517
517
  if ((args.status != null) && args.status.length > 0)
518
- q.whereIn('status', args.status);
518
+ void q.whereIn('status', args.status);
519
519
  if (args.txids != null) {
520
520
  const txids = args.txids.filter(txid => txid !== undefined);
521
521
  if (txids.length > 0)
522
- q.whereIn('txid', txids);
522
+ void q.whereIn('txid', txids);
523
523
  }
524
524
  return q;
525
525
  }
@@ -534,10 +534,10 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
534
534
  }
535
535
  findStaleMerkleRootsQuery(args) {
536
536
  const q = this.toDb(args.trx)('proven_txs');
537
- q.where('height', '=', args.height);
538
- q.where('merkleRoot', '!=', args.merkleRoot);
539
- q.select('merkleRoot');
540
- q.distinct('merkleRoot');
537
+ void q.where('height', '=', args.height);
538
+ void q.where('merkleRoot', '!=', args.merkleRoot);
539
+ void q.select('merkleRoot');
540
+ void q.distinct('merkleRoot');
541
541
  return q;
542
542
  }
543
543
  findSyncStatesQuery(args) {
@@ -552,21 +552,21 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
552
552
  }
553
553
  const q = this.setupQuery('transactions', args);
554
554
  if ((args.status != null) && args.status.length > 0)
555
- q.whereIn('status', args.status);
555
+ void q.whereIn('status', args.status);
556
556
  if (args.from != null)
557
- q.where('created_at', '>=', this.validateDateForWhere(args.from));
557
+ void q.where('created_at', '>=', this.validateDateForWhere(args.from));
558
558
  if (args.to != null)
559
- q.where('created_at', '<', this.validateDateForWhere(args.to));
560
- if (args.noRawTx && !count) {
559
+ void q.where('created_at', '<', this.validateDateForWhere(args.to));
560
+ if ((args.noRawTx === true) && count !== true) {
561
561
  const columns = tables_1.transactionColumnsWithoutRawTx.map(c => `transactions.${c}`);
562
- q.select(columns);
562
+ void q.select(columns);
563
563
  }
564
564
  return q;
565
565
  }
566
566
  findTxLabelMapsQuery(args) {
567
567
  const q = this.setupQuery('tx_labels_map', args);
568
568
  if ((args.labelIds != null) && args.labelIds.length > 0)
569
- q.whereIn('txLabelId', args.labelIds);
569
+ void q.whereIn('txLabelId', args.labelIds);
570
570
  return q;
571
571
  }
572
572
  findTxLabelsQuery(args) {
@@ -579,19 +579,19 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
579
579
  return this.setupQuery('monitor_events', args);
580
580
  }
581
581
  async findCertificatesAuth(auth, args) {
582
- if (!auth.userId || (args.partial.userId && args.partial.userId !== auth.userId))
582
+ if (auth.userId == null || (args.partial.userId != null && args.partial.userId !== 0 && args.partial.userId !== auth.userId))
583
583
  throw new WERR_errors_1.WERR_UNAUTHORIZED();
584
584
  args.partial.userId = auth.userId;
585
585
  return await this.findCertificates(args);
586
586
  }
587
587
  async findOutputBasketsAuth(auth, args) {
588
- if (!auth.userId || (args.partial.userId && args.partial.userId !== auth.userId))
588
+ if (auth.userId == null || (args.partial.userId != null && args.partial.userId !== 0 && args.partial.userId !== auth.userId))
589
589
  throw new WERR_errors_1.WERR_UNAUTHORIZED();
590
590
  args.partial.userId = auth.userId;
591
591
  return await this.findOutputBaskets(args);
592
592
  }
593
593
  async findOutputsAuth(auth, args) {
594
- if (!auth.userId || (args.partial.userId && args.partial.userId !== auth.userId))
594
+ if (auth.userId == null || (args.partial.userId != null && args.partial.userId !== 0 && args.partial.userId !== auth.userId))
595
595
  throw new WERR_errors_1.WERR_UNAUTHORIZED();
596
596
  args.partial.userId = auth.userId;
597
597
  return await this.findOutputs(args);
@@ -603,7 +603,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
603
603
  const q = this.findCertificatesQuery(args);
604
604
  let r = await q;
605
605
  r = this.validateEntities(r, undefined, ['isDeleted']);
606
- if (args.includeFields) {
606
+ if (args.includeFields === true) {
607
607
  for (const c of r) {
608
608
  c.fields = this.validateEntities(await this.findCertificateFields({
609
609
  partial: { certificateId: c.certificateId, userId: c.userId },
@@ -626,7 +626,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
626
626
  async findOutputs(args) {
627
627
  const q = this.findOutputsQuery(args);
628
628
  const r = await q;
629
- if (!args.noScript) {
629
+ if (args.noScript !== true) {
630
630
  for (const o of r) {
631
631
  await this.validateOutputScript(o, args.trx);
632
632
  }
@@ -666,7 +666,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
666
666
  async findTransactions(args) {
667
667
  const q = this.findTransactionsQuery(args);
668
668
  const r = await q;
669
- if (!args.noRawTx) {
669
+ if (args.noRawTx !== true) {
670
670
  for (const t of r) {
671
671
  await this.validateRawTransaction(t, args.trx);
672
672
  }
@@ -708,7 +708,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
708
708
  return this.validateEntities(r, ['when'], undefined);
709
709
  }
710
710
  async getCount(q) {
711
- q.count();
711
+ void q.count();
712
712
  const r = await q;
713
713
  return r[0]['count(*)'];
714
714
  }
@@ -762,9 +762,9 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
762
762
  await ((_a = this.knex) === null || _a === void 0 ? void 0 : _a.destroy());
763
763
  }
764
764
  async migrate(storageName, storageIdentityKey) {
765
- var _a;
765
+ var _a, _b;
766
766
  // Check if this is a SQLite database by looking at the Knex client config
767
- const clientName = ((_a = this.knex.client.config) === null || _a === void 0 ? void 0 : _a.client) || '';
767
+ const clientName = (_b = (_a = this.knex.client.config) === null || _a === void 0 ? void 0 : _a.client) !== null && _b !== void 0 ? _b : '';
768
768
  const isSQLite = clientName.includes('sqlite');
769
769
  // For SQLite, disable transactions during migrations and turn off foreign keys.
770
770
  // PRAGMA foreign_keys is silently ignored inside transactions, so we must
@@ -786,11 +786,11 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
786
786
  return version;
787
787
  }
788
788
  async dropAllData() {
789
- var _a;
789
+ var _a, _b;
790
790
  // Only using migrations to migrate down, don't need valid properties for settings table.
791
791
  const migrationSource = new KnexMigrations_1.KnexMigrations('test', '', '', 1024);
792
792
  // Check if this is a SQLite database by looking at the Knex client config
793
- const clientName = ((_a = this.knex.client.config) === null || _a === void 0 ? void 0 : _a.client) || '';
793
+ const clientName = (_b = (_a = this.knex.client.config) === null || _a === void 0 ? void 0 : _a.client) !== null && _b !== void 0 ? _b : '';
794
794
  const isSQLite = clientName.includes('sqlite');
795
795
  // For SQLite, disable transactions during migrations and turn off foreign keys.
796
796
  // PRAGMA foreign_keys is silently ignored inside transactions, so we must
@@ -809,7 +809,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
809
809
  for (let i = 0; i < count; i++) {
810
810
  try {
811
811
  const r = await this.knex.migrate.down(config);
812
- if (!r) {
812
+ if (r == null) {
813
813
  console.error('Migration returned falsy result await this.knex.migrate.down(config)');
814
814
  break;
815
815
  }
@@ -838,6 +838,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
838
838
  * Convert the standard optional `TrxToken` parameter into either a direct knex database instance,
839
839
  * or a Knex.Transaction as appropriate.
840
840
  */
841
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
841
842
  toDb(trx) {
842
843
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
843
844
  const db = (trx == null) ? this.knex : trx;
@@ -846,7 +847,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
846
847
  }
847
848
  async validateRawTransaction(t, trx) {
848
849
  // if there is no txid or there is a rawTransaction return what we have.
849
- if (t.rawTx || !t.txid)
850
+ if (t.rawTx != null || t.txid == null || t.txid === '')
850
851
  return;
851
852
  // rawTransaction is missing, see if we moved it ...
852
853
  const rawTx = await this.getRawTxOfKnownValidTransaction(t.txid, undefined, undefined, trx);
@@ -894,7 +895,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
894
895
  if (dateFields == null)
895
896
  return;
896
897
  for (const df of dateFields) {
897
- if (v[df])
898
+ if (v[df] != null)
898
899
  v[df] = this.validateOptionalEntityDate(v[df]);
899
900
  }
900
901
  }
@@ -905,7 +906,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
905
906
  return;
906
907
  for (const df of booleanFields) {
907
908
  if (v[df] !== undefined)
908
- v[df] = v[df] ? 1 : 0;
909
+ v[df] = v[df] != null && v[df] !== false ? 1 : 0;
909
910
  }
910
911
  }
911
912
  /**
@@ -913,17 +914,17 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
913
914
  * Use to process the update template for entities being updated.
914
915
  */
915
916
  validatePartialForUpdate(update, dateFields, booleanFields) {
916
- if (!this.dbtype)
917
+ if (this.dbtype == null)
917
918
  throw new WERR_errors_1.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first');
918
919
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
919
920
  const v = update;
920
- if (v.created_at)
921
+ if (v.created_at != null)
921
922
  v.created_at = this.validateEntityDate(v.created_at);
922
- if (v.updated_at)
923
+ if (v.updated_at != null)
923
924
  v.updated_at = this.validateEntityDate(v.updated_at);
924
- if (!v.created_at)
925
+ if (v.created_at == null)
925
926
  delete v.created_at;
926
- if (!v.updated_at)
927
+ if (v.updated_at == null)
927
928
  v.updated_at = this.validateEntityDate(new Date());
928
929
  this.coerceDateFields(v, dateFields);
929
930
  this.coerceBooleanFields(update, booleanFields);
@@ -938,14 +939,15 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
938
939
  async validateEntityForInsert(entity, trx, dateFields, booleanFields
939
940
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
940
941
  ) {
942
+ var _a, _b;
941
943
  await this.verifyReadyForDatabaseAccess(trx);
942
944
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
943
945
  const v = { ...entity };
944
- v.created_at = this.validateOptionalEntityDate(v.created_at, true);
945
- v.updated_at = this.validateOptionalEntityDate(v.updated_at, true);
946
- if (!v.created_at)
946
+ v.created_at = (_a = this.validateOptionalEntityDate(v.created_at, true)) !== null && _a !== void 0 ? _a : new Date();
947
+ v.updated_at = (_b = this.validateOptionalEntityDate(v.updated_at, true)) !== null && _b !== void 0 ? _b : new Date();
948
+ if (v.created_at == null)
947
949
  delete v.created_at;
948
- if (!v.updated_at)
950
+ if (v.updated_at == null)
949
951
  delete v.updated_at;
950
952
  this.coerceDateFields(v, dateFields);
951
953
  this.coerceBooleanFields(entity, booleanFields);
@@ -1023,11 +1025,11 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1023
1025
  .whereIn('vout', vouts)
1024
1026
  .select('*');
1025
1027
  // Only return requested outpoints, vouts of one txid may end up matching another txid that was not requested.
1026
- const filteredRows = rows.filter(r => outpointSet.has(`${r.txid}.${r.vout}`));
1028
+ const filteredRows = rows.filter(r => outpointSet.has(`${String(r.txid)}.${String(r.vout)}`));
1027
1029
  const vrows = this.validateEntities(filteredRows, undefined, ['spendable', 'change']);
1028
1030
  for (const row of vrows) {
1029
1031
  await this.validateOutputScript(row, trx);
1030
- byOutpoint[`${row.txid}.${row.vout}`] = row;
1032
+ byOutpoint[`${String(row.txid)}.${String(row.vout)}`] = row;
1031
1033
  }
1032
1034
  return byOutpoint;
1033
1035
  }
@@ -1046,7 +1048,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1046
1048
  byName[basket.name] = basket;
1047
1049
  }
1048
1050
  for (const name of uniqueNames) {
1049
- if (!byName[name])
1051
+ if (byName[name] == null)
1050
1052
  byName[name] = await this.findOrInsertOutputBasket(userId, name, trx);
1051
1053
  }
1052
1054
  return byName;
@@ -1066,7 +1068,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1066
1068
  byTag[outputTag.tag] = outputTag;
1067
1069
  }
1068
1070
  for (const tag of uniqueTags) {
1069
- if (!byTag[tag])
1071
+ if (byTag[tag] == null)
1070
1072
  byTag[tag] = await this.findOrInsertOutputTag(userId, tag, trx);
1071
1073
  }
1072
1074
  return byTag;
@@ -1081,7 +1083,8 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1081
1083
  .whereIn('t.status', status)
1082
1084
  .sum({ totalSatoshis: 'o.satoshis' })
1083
1085
  .first();
1084
- return Number(((row != null) && row.totalSatoshis) || 0);
1086
+ const total = (row != null) ? row.totalSatoshis : undefined;
1087
+ return Number(total !== null && total !== void 0 ? total : 0);
1085
1088
  }
1086
1089
  /**
1087
1090
  * Finds closest matching available change output to use as input for new transaction.
@@ -1156,7 +1159,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1156
1159
  if (dateFields != null) {
1157
1160
  for (const df of dateFields) {
1158
1161
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1159
- if (entity[df])
1162
+ if (entity[df] != null)
1160
1163
  entity[df] = this.validateDate(entity[df]);
1161
1164
  }
1162
1165
  }
@@ -1164,7 +1167,7 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1164
1167
  for (const df of booleanFields) {
1165
1168
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1166
1169
  if (entity[df] !== undefined)
1167
- entity[df] = !!entity[df];
1170
+ entity[df] = entity[df] !== 0 && entity[df] != null && entity[df] !== false;
1168
1171
  }
1169
1172
  }
1170
1173
  this.deserialiseFromKnex(entity);
@@ -1191,79 +1194,79 @@ class StorageKnex extends StorageProvider_1.StorageProvider {
1191
1194
  }));
1192
1195
  const monitorStats = (monitorEvent != null) ? JSON.parse(monitorEvent.details) : undefined;
1193
1196
  const servicesStats = this.getServices().getServicesCallHistory(true);
1194
- const one_day_ago = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
1195
- const one_week_ago = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
1196
- const one_month_ago = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();
1197
+ const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
1198
+ const oneWeekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
1199
+ const oneMonthAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();
1197
1200
  const [[{ usersDay, usersMonth, usersWeek, usersTotal, transactionsDay, transactionsMonth, transactionsWeek, transactionsTotal, txCompletedDay, txCompletedMonth, txCompletedWeek, txCompletedTotal, txFailedDay, txFailedMonth, txFailedWeek, txFailedTotal, txAbandonedDay, txAbandonedMonth, txAbandonedWeek, txAbandonedTotal, txUnprocessedDay, txUnprocessedMonth, txUnprocessedWeek, txUnprocessedTotal, txSendingDay, txSendingMonth, txSendingWeek, txSendingTotal, txUnprovenDay, txUnprovenMonth, txUnprovenWeek, txUnprovenTotal, txUnsignedDay, txUnsignedMonth, txUnsignedWeek, txUnsignedTotal, txNosendDay, txNosendMonth, txNosendWeek, txNosendTotal, txNonfinalDay, txNonfinalMonth, txNonfinalWeek, txNonfinalTotal, txUnfailDay, txUnfailMonth, txUnfailWeek, txUnfailTotal, satoshisDefaultDay, satoshisDefaultMonth, satoshisDefaultWeek, satoshisDefaultTotal, satoshisOtherDay, satoshisOtherMonth, satoshisOtherWeek, satoshisOtherTotal, basketsDay, basketsMonth, basketsWeek, basketsTotal, labelsDay, labelsMonth, labelsWeek, labelsTotal, tagsDay, tagsMonth, tagsWeek, tagsTotal }]] = await this.knex.raw(`
1198
1201
  select
1199
- (select count(*) from users where created_at > '${one_day_ago}') as usersDay,
1200
- (select count(*) from users where created_at > '${one_week_ago}') as usersWeek,
1201
- (select count(*) from users where created_at > '${one_month_ago}') as usersMonth,
1202
- (select count(*) from users) as usersTotal,
1203
- (select count(*) from transactions where created_at > '${one_day_ago}') as transactionsDay,
1204
- (select count(*) from transactions where created_at > '${one_week_ago}') as transactionsWeek,
1205
- (select count(*) from transactions where created_at > '${one_month_ago}') as transactionsMonth,
1206
- (select count(*) from transactions) as transactionsTotal,
1207
- (select count(*) from transactions where status = 'completed' and created_at > '${one_day_ago}') as txCompletedDay,
1208
- (select count(*) from transactions where status = 'completed' and created_at > '${one_week_ago}') as txCompletedWeek,
1209
- (select count(*) from transactions where status = 'completed' and created_at > '${one_month_ago}') as txCompletedMonth,
1210
- (select count(*) from transactions where status = 'completed') as txCompletedTotal,
1211
- (select count(*) from transactions where status = 'failed' and not txid is null and created_at > '${one_day_ago}') as txFailedDay,
1212
- (select count(*) from transactions where status = 'failed' and not txid is null and created_at > '${one_week_ago}') as txFailedWeek,
1213
- (select count(*) from transactions where status = 'failed' and not txid is null and created_at > '${one_month_ago}') as txFailedMonth,
1214
- (select count(*) from transactions where status = 'failed' and not txid is null) as txFailedTotal,
1215
- (select count(*) from transactions where status = 'failed' and txid is null and created_at > '${one_day_ago}') as txAbandonedDay,
1216
- (select count(*) from transactions where status = 'failed' and txid is null and created_at > '${one_week_ago}') as txAbandonedWeek,
1217
- (select count(*) from transactions where status = 'failed' and txid is null and created_at > '${one_month_ago}') as txAbandonedMonth,
1218
- (select count(*) from transactions where status = 'failed' and txid is null) as txAbandonedTotal,
1219
- (select count(*) from transactions where status = 'unprocessed' and created_at > '${one_day_ago}') as txUnprocessedDay,
1220
- (select count(*) from transactions where status = 'unprocessed' and created_at > '${one_week_ago}') as txUnprocessedWeek,
1221
- (select count(*) from transactions where status = 'unprocessed' and created_at > '${one_month_ago}') as txUnprocessedMonth,
1222
- (select count(*) from transactions where status = 'unprocessed') as txUnprocessedTotal,
1223
- (select count(*) from transactions where status = 'sending' and created_at > '${one_day_ago}') as txSendingDay,
1224
- (select count(*) from transactions where status = 'sending' and created_at > '${one_week_ago}') as txSendingWeek,
1225
- (select count(*) from transactions where status = 'sending' and created_at > '${one_month_ago}') as txSendingMonth,
1226
- (select count(*) from transactions where status = 'sending') as txSendingTotal,
1227
- (select count(*) from transactions where status = 'unproven' and created_at > '${one_day_ago}') as txUnprovenDay,
1228
- (select count(*) from transactions where status = 'unproven' and created_at > '${one_week_ago}') as txUnprovenWeek,
1229
- (select count(*) from transactions where status = 'unproven' and created_at > '${one_month_ago}') as txUnprovenMonth,
1230
- (select count(*) from transactions where status = 'unproven') as txUnprovenTotal,
1231
- (select count(*) from transactions where status = 'unsigned' and created_at > '${one_day_ago}') as txUnsignedDay,
1232
- (select count(*) from transactions where status = 'unsigned' and created_at > '${one_week_ago}') as txUnsignedWeek,
1233
- (select count(*) from transactions where status = 'unsigned' and created_at > '${one_month_ago}') as txUnsignedMonth,
1234
- (select count(*) from transactions where status = 'unsigned') as txUnsignedTotal,
1235
- (select count(*) from transactions where status = 'nosend' and created_at > '${one_day_ago}') as txNosendDay,
1236
- (select count(*) from transactions where status = 'nosend' and created_at > '${one_week_ago}') as txNosendWeek,
1237
- (select count(*) from transactions where status = 'nosend' and created_at > '${one_month_ago}') as txNosendMonth,
1238
- (select count(*) from transactions where status = 'nosend') as txNosendTotal,
1239
- (select count(*) from transactions where status = 'nonfinal' and created_at > '${one_day_ago}') as txNonfinalDay,
1240
- (select count(*) from transactions where status = 'nonfinal' and created_at > '${one_week_ago}') as txNonfinalWeek,
1241
- (select count(*) from transactions where status = 'nonfinal' and created_at > '${one_month_ago}') as txNonfinalMonth,
1242
- (select count(*) from transactions where status = 'nonfinal') as txNonfinalTotal,
1243
- (select count(*) from transactions where status = 'unfail' and created_at > '${one_day_ago}') as txUnfailDay,
1244
- (select count(*) from transactions where status = 'unfail' and created_at > '${one_week_ago}') as txUnfailWeek,
1245
- (select count(*) from transactions where status = 'unfail' and created_at > '${one_month_ago}') as txUnfailMonth,
1246
- (select count(*) from transactions where status = 'unfail') as txUnfailTotal,
1247
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${one_day_ago}') as satoshisDefaultDay,
1248
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${one_week_ago}') as satoshisDefaultWeek,
1249
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${one_month_ago}') as satoshisDefaultMonth,
1250
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1) as satoshisDefaultTotal,
1251
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${one_day_ago}') as satoshisOtherDay,
1252
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${one_week_ago}') as satoshisOtherWeek,
1253
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${one_month_ago}') as satoshisOtherMonth,
1254
- (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null) as satoshisOtherTotal,
1255
- (select count(*) from output_baskets where created_at > '${one_day_ago}') as basketsDay,
1256
- (select count(*) from output_baskets where created_at > '${one_week_ago}') as basketsWeek,
1257
- (select count(*) from output_baskets where created_at > '${one_month_ago}') as basketsMonth,
1258
- (select count(*) from output_baskets) as basketsTotal,
1259
- (select count(*) from tx_labels where created_at > '${one_day_ago}') as labelsDay,
1260
- (select count(*) from tx_labels where created_at > '${one_week_ago}') as labelsWeek,
1261
- (select count(*) from tx_labels where created_at > '${one_month_ago}') as labelsMonth,
1262
- (select count(*) from tx_labels) as labelsTotal,
1263
- (select count(*) from output_tags where created_at > '${one_day_ago}') as tagsDay,
1264
- (select count(*) from output_tags where created_at > '${one_week_ago}') as tagsWeek,
1265
- (select count(*) from output_tags where created_at > '${one_month_ago}') as tagsMonth,
1266
- (select count(*) from output_tags) as tagsTotal
1202
+ (select count(*) from users where created_at > '${oneDayAgo}') as usersDay,
1203
+ (select count(*) from users where created_at > '${oneWeekAgo}') as usersWeek,
1204
+ (select count(*) from users where created_at > '${oneMonthAgo}') as usersMonth,
1205
+ (select count(*) from users) as usersTotal,
1206
+ (select count(*) from transactions where created_at > '${oneDayAgo}') as transactionsDay,
1207
+ (select count(*) from transactions where created_at > '${oneWeekAgo}') as transactionsWeek,
1208
+ (select count(*) from transactions where created_at > '${oneMonthAgo}') as transactionsMonth,
1209
+ (select count(*) from transactions) as transactionsTotal,
1210
+ (select count(*) from transactions where status = 'completed' and created_at > '${oneDayAgo}') as txCompletedDay,
1211
+ (select count(*) from transactions where status = 'completed' and created_at > '${oneWeekAgo}') as txCompletedWeek,
1212
+ (select count(*) from transactions where status = 'completed' and created_at > '${oneMonthAgo}') as txCompletedMonth,
1213
+ (select count(*) from transactions where status = 'completed') as txCompletedTotal,
1214
+ (select count(*) from transactions where status = 'failed' and not txid is null and created_at > '${oneDayAgo}') as txFailedDay,
1215
+ (select count(*) from transactions where status = 'failed' and not txid is null and created_at > '${oneWeekAgo}') as txFailedWeek,
1216
+ (select count(*) from transactions where status = 'failed' and not txid is null and created_at > '${oneMonthAgo}') as txFailedMonth,
1217
+ (select count(*) from transactions where status = 'failed' and not txid is null) as txFailedTotal,
1218
+ (select count(*) from transactions where status = 'failed' and txid is null and created_at > '${oneDayAgo}') as txAbandonedDay,
1219
+ (select count(*) from transactions where status = 'failed' and txid is null and created_at > '${oneWeekAgo}') as txAbandonedWeek,
1220
+ (select count(*) from transactions where status = 'failed' and txid is null and created_at > '${oneMonthAgo}') as txAbandonedMonth,
1221
+ (select count(*) from transactions where status = 'failed' and txid is null) as txAbandonedTotal,
1222
+ (select count(*) from transactions where status = 'unprocessed' and created_at > '${oneDayAgo}') as txUnprocessedDay,
1223
+ (select count(*) from transactions where status = 'unprocessed' and created_at > '${oneWeekAgo}') as txUnprocessedWeek,
1224
+ (select count(*) from transactions where status = 'unprocessed' and created_at > '${oneMonthAgo}') as txUnprocessedMonth,
1225
+ (select count(*) from transactions where status = 'unprocessed') as txUnprocessedTotal,
1226
+ (select count(*) from transactions where status = 'sending' and created_at > '${oneDayAgo}') as txSendingDay,
1227
+ (select count(*) from transactions where status = 'sending' and created_at > '${oneWeekAgo}') as txSendingWeek,
1228
+ (select count(*) from transactions where status = 'sending' and created_at > '${oneMonthAgo}') as txSendingMonth,
1229
+ (select count(*) from transactions where status = 'sending') as txSendingTotal,
1230
+ (select count(*) from transactions where status = 'unproven' and created_at > '${oneDayAgo}') as txUnprovenDay,
1231
+ (select count(*) from transactions where status = 'unproven' and created_at > '${oneWeekAgo}') as txUnprovenWeek,
1232
+ (select count(*) from transactions where status = 'unproven' and created_at > '${oneMonthAgo}') as txUnprovenMonth,
1233
+ (select count(*) from transactions where status = 'unproven') as txUnprovenTotal,
1234
+ (select count(*) from transactions where status = 'unsigned' and created_at > '${oneDayAgo}') as txUnsignedDay,
1235
+ (select count(*) from transactions where status = 'unsigned' and created_at > '${oneWeekAgo}') as txUnsignedWeek,
1236
+ (select count(*) from transactions where status = 'unsigned' and created_at > '${oneMonthAgo}') as txUnsignedMonth,
1237
+ (select count(*) from transactions where status = 'unsigned') as txUnsignedTotal,
1238
+ (select count(*) from transactions where status = 'nosend' and created_at > '${oneDayAgo}') as txNosendDay,
1239
+ (select count(*) from transactions where status = 'nosend' and created_at > '${oneWeekAgo}') as txNosendWeek,
1240
+ (select count(*) from transactions where status = 'nosend' and created_at > '${oneMonthAgo}') as txNosendMonth,
1241
+ (select count(*) from transactions where status = 'nosend') as txNosendTotal,
1242
+ (select count(*) from transactions where status = 'nonfinal' and created_at > '${oneDayAgo}') as txNonfinalDay,
1243
+ (select count(*) from transactions where status = 'nonfinal' and created_at > '${oneWeekAgo}') as txNonfinalWeek,
1244
+ (select count(*) from transactions where status = 'nonfinal' and created_at > '${oneMonthAgo}') as txNonfinalMonth,
1245
+ (select count(*) from transactions where status = 'nonfinal') as txNonfinalTotal,
1246
+ (select count(*) from transactions where status = 'unfail' and created_at > '${oneDayAgo}') as txUnfailDay,
1247
+ (select count(*) from transactions where status = 'unfail' and created_at > '${oneWeekAgo}') as txUnfailWeek,
1248
+ (select count(*) from transactions where status = 'unfail' and created_at > '${oneMonthAgo}') as txUnfailMonth,
1249
+ (select count(*) from transactions where status = 'unfail') as txUnfailTotal,
1250
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${oneDayAgo}') as satoshisDefaultDay,
1251
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${oneWeekAgo}') as satoshisDefaultWeek,
1252
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1 and o.created_at > '${oneMonthAgo}') as satoshisDefaultMonth,
1253
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 1) as satoshisDefaultTotal,
1254
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${oneDayAgo}') as satoshisOtherDay,
1255
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${oneWeekAgo}') as satoshisOtherWeek,
1256
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null and o.created_at > '${oneMonthAgo}') as satoshisOtherMonth,
1257
+ (select sum(o.satoshis) from outputs o, transactions t where o.transactionId = t.transactionId and t.status = 'completed' and o.spendable = 1 and o.change = 0 and not o.basketId is null) as satoshisOtherTotal,
1258
+ (select count(*) from output_baskets where created_at > '${oneDayAgo}') as basketsDay,
1259
+ (select count(*) from output_baskets where created_at > '${oneWeekAgo}') as basketsWeek,
1260
+ (select count(*) from output_baskets where created_at > '${oneMonthAgo}') as basketsMonth,
1261
+ (select count(*) from output_baskets) as basketsTotal,
1262
+ (select count(*) from tx_labels where created_at > '${oneDayAgo}') as labelsDay,
1263
+ (select count(*) from tx_labels where created_at > '${oneWeekAgo}') as labelsWeek,
1264
+ (select count(*) from tx_labels where created_at > '${oneMonthAgo}') as labelsMonth,
1265
+ (select count(*) from tx_labels) as labelsTotal,
1266
+ (select count(*) from output_tags where created_at > '${oneDayAgo}') as tagsDay,
1267
+ (select count(*) from output_tags where created_at > '${oneWeekAgo}') as tagsWeek,
1268
+ (select count(*) from output_tags where created_at > '${oneMonthAgo}') as tagsMonth,
1269
+ (select count(*) from output_tags) as tagsTotal
1267
1270
  `);
1268
1271
  const r = {
1269
1272
  monitorStats,