edge-currency-plugins 3.2.0 → 3.3.0

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 (47) hide show
  1. package/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +41 -41
  2. package/lib/common/plugin/PluginState.js +73 -43
  3. package/lib/common/plugin/ServerScores.js +11 -0
  4. package/lib/common/plugin/types.js +1 -1
  5. package/lib/common/utxobased/db/{Processor.js → DataLayer.js} +15 -11
  6. package/lib/common/utxobased/db/Models/{ProcessorTransaction.js → TransactionData.js} +4 -6
  7. package/lib/common/utxobased/db/types.js +4 -4
  8. package/lib/common/utxobased/db/util/utxo.js +8 -8
  9. package/lib/common/utxobased/engine/ServerStates.js +324 -298
  10. package/lib/common/utxobased/engine/UtxoEngine.js +58 -55
  11. package/lib/common/utxobased/engine/{UtxoEngineState.js → UtxoEngineProcessor.js} +650 -714
  12. package/lib/common/utxobased/engine/types.js +4 -2
  13. package/lib/common/utxobased/engine/util/getOwnUtxosFromTx.js +4 -4
  14. package/lib/common/utxobased/info/bitcoin.js +2 -1
  15. package/lib/common/utxobased/info/bitcoincash.js +2 -1
  16. package/lib/common/utxobased/info/dash.js +2 -1
  17. package/lib/common/utxobased/info/digibyte.js +5 -1
  18. package/lib/common/utxobased/info/dogecoin.js +2 -1
  19. package/lib/common/utxobased/info/groestlcoin.js +4 -1
  20. package/lib/common/utxobased/info/litecoin.js +2 -1
  21. package/lib/common/utxobased/info/zcoin.js +4 -1
  22. package/lib/common/utxobased/network/Blockbook.js +33 -30
  23. package/lib/common/utxobased/network/BlockbookElectrum.js +79 -77
  24. package/lib/common/utxobased/network/Socket.js +84 -48
  25. package/lib/common/utxobased/network/windowWS.js +2 -2
  26. package/lib/src/common/plugin/PluginState.d.ts +4 -4
  27. package/lib/src/common/plugin/ServerScores.d.ts +1 -0
  28. package/lib/src/common/plugin/types.d.ts +4 -4
  29. package/lib/src/common/utxobased/db/{Processor.d.ts → DataLayer.d.ts} +17 -11
  30. package/lib/src/common/utxobased/db/Models/{ProcessorTransaction.d.ts → TransactionData.d.ts} +5 -5
  31. package/lib/src/common/utxobased/db/Models/baselet.d.ts +4 -4
  32. package/lib/src/common/utxobased/db/types.d.ts +9 -9
  33. package/lib/src/common/utxobased/db/util/utxo.d.ts +3 -3
  34. package/lib/src/common/utxobased/engine/ServerStates.d.ts +7 -7
  35. package/lib/src/common/utxobased/engine/{UtxoEngineState.d.ts → UtxoEngineProcessor.d.ts} +44 -42
  36. package/lib/src/common/utxobased/engine/types.d.ts +4 -4
  37. package/lib/src/common/utxobased/engine/util/getOwnUtxosFromTx.d.ts +3 -3
  38. package/lib/src/common/utxobased/engine/utils.d.ts +2 -2
  39. package/lib/src/common/utxobased/keymanager/keymanager.d.ts +3 -3
  40. package/lib/src/common/utxobased/network/Blockbook.d.ts +8 -7
  41. package/lib/src/common/utxobased/network/BlockbookElectrum.d.ts +4 -2
  42. package/lib/src/common/utxobased/network/Socket.d.ts +10 -8
  43. package/lib/src/common/utxobased/network/types.d.ts +1 -1
  44. package/lib/src/util/uriKeyParams.d.ts +4 -0
  45. package/lib/util/uriKeyParams.js +20 -0
  46. package/package.json +1 -1
  47. /package/lib/test/common/utxobased/db/{Processor.spec.d.ts → DataLayer.spec.d.ts} +0 -0
@@ -10,13 +10,16 @@
10
10
 
11
11
  var _cleaners = require('cleaners');
12
12
 
13
+ var _urlparse = require('url-parse'); var _urlparse2 = _interopRequireDefault(_urlparse);
13
14
 
15
+ var _uriKeyParams = require('../../../util/uriKeyParams');
14
16
  var _utils = require('../../plugin/utils');
15
17
 
18
+
16
19
  var _nodejsWS = require('./nodejsWS');
17
20
  var _SocketEmitter = require('./SocketEmitter');
18
21
  var _socketQueue = require('./socketQueue');
19
- var _types3 = require('./types');
22
+ var _types5 = require('./types');
20
23
  var _windowWS = require('./windowWS');
21
24
 
22
25
  const TIMER_SLACK = 500
@@ -76,6 +79,12 @@ const WAKE_UP_MS = 5000 // interval at which we wakeUp and potentially onQueueSp
76
79
 
77
80
 
78
81
 
82
+
83
+
84
+
85
+
86
+
87
+
79
88
 
80
89
 
81
90
 
@@ -118,7 +127,6 @@ const asResponseDefault = (raw) => [
118
127
  const version = ''
119
128
  const socketQueueId = walletId + '==' + uri
120
129
  const subscriptions = {}
121
- let onQueueSpace = config.onQueueSpaceCB
122
130
  let pendingRequests = {}
123
131
  let nextId = 0
124
132
  let lastKeepAlive = 0
@@ -126,12 +134,12 @@ const asResponseDefault = (raw) => [
126
134
  let connected = false
127
135
  let cancelConnect = false
128
136
  const timeout = 1000 * (_nullishCoalesce(config.timeout, () => ( 30)))
129
- let error
137
+ let trackedError
130
138
  let timer
131
139
 
132
140
  const handleError = (e) => {
133
- if (error == null) error = e
134
- if (connected && socket != null && socket.readyState === _types3.ReadyState.OPEN)
141
+ if (trackedError == null) trackedError = e
142
+ if (connected && socket != null && socket.readyState === _types5.ReadyState.OPEN)
135
143
  disconnect()
136
144
  else cancelConnect = true
137
145
  log.error('handled error!', e)
@@ -146,22 +154,26 @@ const asResponseDefault = (raw) => [
146
154
  }
147
155
 
148
156
  const onSocketClose = () => {
149
- const err = _nullishCoalesce(error, () => ( new Error('Socket close')))
150
- log.warn(`onSocketClose due to ${err.message} with server ${uri}`)
157
+ const errObj =
158
+ trackedError != null
159
+ ? trackedError instanceof Error
160
+ ? trackedError
161
+ : new Error(String(trackedError))
162
+ : new Error('Socket closed without error')
163
+ log.warn(`onSocketClose with server ${uri}: ${errObj.message}`)
151
164
  clearTimeout(timer)
152
165
  connected = false
153
166
  socket = null
154
167
  cancelConnect = false
168
+ trackedError = undefined
155
169
  for (const request of Object.values(pendingRequests)) {
156
- try {
157
- request.task.deferred.reject(err)
158
- } catch (e) {
170
+ request.generator.throw(errObj).catch(e => {
159
171
  log.error(e.message)
160
- }
172
+ })
161
173
  }
162
174
  pendingRequests = {}
163
175
  try {
164
- emitter.emit(_SocketEmitter.SocketEvent.CONNECTION_CLOSE, uri, err)
176
+ emitter.emit(_SocketEmitter.SocketEvent.CONNECTION_CLOSE, uri, errObj)
165
177
  } catch (e) {
166
178
  log.error(e.message)
167
179
  }
@@ -205,20 +217,21 @@ const asResponseDefault = (raw) => [
205
217
  lastWakeUp = Date.now()
206
218
  if (connected && version != null) {
207
219
  while (Object.keys(pendingRequests).length < queueSize) {
208
- const task = await onQueueSpace(uri)
209
- if (task == null) break
220
+ const generator = await config.taskGeneratorFn(uri)
221
+ const result = await generator.next()
222
+ const task = result.value
210
223
  if (typeof task === 'boolean') {
211
224
  if (task) continue
212
- break
225
+ else break
213
226
  }
214
- submitTask(task)
227
+ instance.submitTask(task, generator)
215
228
  }
216
229
  }
217
230
  }
218
231
 
219
232
  // add any exception, since the passed in template parameter needs to be re-assigned
220
233
  const subscribe = (subscription) => {
221
- if (socket != null && socket.readyState === _types3.ReadyState.OPEN && connected) {
234
+ if (socket != null && socket.readyState === _types5.ReadyState.OPEN && connected) {
222
235
  const id = subscription.method
223
236
  const message = {
224
237
  id,
@@ -230,19 +243,11 @@ const asResponseDefault = (raw) => [
230
243
  }
231
244
  }
232
245
 
233
- // add any exception, since the passed in template parameter needs to be re-assigned
234
- const submitTask = (task) => {
235
- const id = (nextId++).toString()
236
- const request = { task, startTime: Date.now() }
237
- pendingRequests[id] = request
238
- transmitRequest(id, request)
239
- }
240
-
241
246
  const transmitRequest = (id, request) => {
242
247
  const now = Date.now()
243
248
  if (
244
249
  socket != null &&
245
- socket.readyState === _types3.ReadyState.OPEN &&
250
+ socket.readyState === _types5.ReadyState.OPEN &&
246
251
  connected &&
247
252
  !cancelConnect
248
253
  ) {
@@ -267,16 +272,16 @@ const asResponseDefault = (raw) => [
267
272
  .then(() => {
268
273
  emitter.emit(_SocketEmitter.SocketEvent.CONNECTION_TIMER, uri, now)
269
274
  })
270
- .catch((e) => handleError(e))
275
+ .catch(e => handleError(e))
271
276
  }
272
277
 
273
278
  for (const [id, request] of Object.entries(pendingRequests)) {
274
279
  if (request.startTime + timeout < now) {
275
- try {
276
- request.task.deferred.reject(new Error(`Timeout for request ${id}`))
277
- } catch (e) {
278
- log.error(e.message)
279
- }
280
+ request.generator
281
+ .throw(new Error(`Timeout for request ${id}`))
282
+ .catch(e => {
283
+ log.error(e.message)
284
+ })
280
285
  _utils.removeItem.call(void 0, pendingRequests, id)
281
286
  }
282
287
  }
@@ -341,16 +346,29 @@ const asResponseDefault = (raw) => [
341
346
  'message' in error ? error.message : error.connected
342
347
  throw new Error(errorMessage)
343
348
  }
349
+ let nextValue
344
350
  if (request.task.cleaner != null) {
345
- request.task.deferred.resolve(
346
- request.task.cleaner(responseMessage.data)
347
- )
351
+ nextValue = request.task.cleaner(responseMessage.data)
348
352
  } else {
349
- request.task.deferred.resolve(responseMessage.data)
353
+ nextValue = responseMessage.data
350
354
  }
355
+ request.generator
356
+ .next(nextValue)
357
+ .then(result => {
358
+ const task = result.value
359
+ if (typeof task === 'boolean') {
360
+ return
361
+ }
362
+ instance.submitTask(task, request.generator)
363
+ })
364
+ .catch(e => {
365
+ log.error(e.message)
366
+ })
351
367
  } catch (error) {
352
368
  console.log({ uri, error, response: responseMessage, request })
353
- request.task.deferred.reject(error)
369
+ request.generator.throw(error).catch(e => {
370
+ log.error(e.message)
371
+ })
354
372
  }
355
373
  continue
356
374
  }
@@ -369,9 +387,9 @@ const asResponseDefault = (raw) => [
369
387
  setupTimer()
370
388
 
371
389
  // return a Socket
372
- return {
390
+ const instance = {
373
391
  get readyState() {
374
- return _nullishCoalesce(_optionalChain([socket, 'optionalAccess', _2 => _2.readyState]), () => ( _types3.ReadyState.CLOSED))
392
+ return _nullishCoalesce(_optionalChain([socket, 'optionalAccess', _2 => _2.readyState]), () => ( _types5.ReadyState.CLOSED))
375
393
  },
376
394
 
377
395
  async connect() {
@@ -384,17 +402,29 @@ const asResponseDefault = (raw) => [
384
402
  resolve()
385
403
  },
386
404
  onMessage: onMessage,
387
- onError: event => {
388
- error = new Error(JSON.stringify(event))
405
+ onError: err => {
406
+ trackedError = new Error(String(err))
389
407
  },
390
408
  onClose: onSocketClose
391
409
  }
392
410
 
393
- // Append "/websocket" if needed:
411
+ // Append "/websocket" if the uri has no explicit path:
412
+ // We treat URIs with any path or a single trailing slash as having
413
+ // an explicit path.
394
414
  let fullUri = uri
395
415
  if (uri.startsWith('wss:') || uri.startsWith('ws:')) {
396
- fullUri = uri.replace(/\/websocket\/?$/, '') + '/websocket'
416
+ // There is no path and the uri has no trailing slash
417
+ const pathIsExplicitlyEmpty =
418
+ !uri.endsWith('/') && _urlparse2.default.call(void 0, uri).pathname === '/'
419
+ // If path is explicitly empty, then append /websocket
420
+ if (pathIsExplicitlyEmpty) {
421
+ fullUri = uri + '/websocket'
422
+ }
397
423
  }
424
+
425
+ // Replace any "key params" in the URIs (e.g. `%{nowNodesApiKey}`)
426
+ fullUri = _uriKeyParams.replaceKeyParams.call(void 0, fullUri, config.initOptions)
427
+
398
428
  if (uri.startsWith('electrumwss:')) {
399
429
  fullUri = uri.replace(/^electrumwss:/, 'wss:')
400
430
  }
@@ -417,15 +447,21 @@ const asResponseDefault = (raw) => [
417
447
  },
418
448
 
419
449
  isConnected() {
420
- return _optionalChain([socket, 'optionalAccess', _7 => _7.readyState]) === _types3.ReadyState.OPEN
450
+ return _optionalChain([socket, 'optionalAccess', _7 => _7.readyState]) === _types5.ReadyState.OPEN
421
451
  },
422
452
 
423
- submitTask,
424
-
425
- onQueueSpace(cb) {
426
- onQueueSpace = cb
453
+ submitTask: (
454
+ task,
455
+ generator
456
+ ) => {
457
+ const id = (nextId++).toString()
458
+ const request = { task, startTime: Date.now(), generator }
459
+ pendingRequests[id] = request
460
+ transmitRequest(id, request)
427
461
  },
428
462
 
429
463
  subscribe
430
464
  }
465
+
466
+ return instance
431
467
  } exports.makeSocket = makeSocket;
@@ -14,8 +14,8 @@
14
14
  socket.onmessage = (message) => {
15
15
  callbacks.onMessage(message.data.toString())
16
16
  }
17
- socket.onerror = () => {
18
- callbacks.onError()
17
+ socket.onerror = event => {
18
+ callbacks.onError(event)
19
19
  }
20
20
  socket.onclose = () => {
21
21
  callbacks.onClose()
@@ -1,7 +1,7 @@
1
1
  import { Disklet } from 'disklet';
2
2
  import { EdgeIo, EdgeLog } from 'edge-core-js/types';
3
3
  import { UtxoUserSettings } from '../utxobased/engine/types';
4
- import { UtxoEngineState } from '../utxobased/engine/UtxoEngineState';
4
+ import { UtxoEngineProcessor } from '../utxobased/engine/UtxoEngineProcessor';
5
5
  /** A JSON object (as opposed to an array or primitive). */
6
6
  interface JsonObject {
7
7
  [name: string]: unknown;
@@ -19,15 +19,15 @@ export interface PluginStateSettings {
19
19
  log: EdgeLog;
20
20
  }
21
21
  export interface PluginState {
22
- addEngine: (engineState: UtxoEngineState) => void;
23
- removeEngine: (engineState: UtxoEngineState) => void;
22
+ addEngine: (engineProcessor: UtxoEngineProcessor) => void;
23
+ removeEngine: (engineProcessor: UtxoEngineProcessor) => void;
24
24
  dumpData: () => JsonObject;
25
25
  load: () => Promise<PluginState>;
26
26
  serverScoreDown: (uri: string) => void;
27
27
  serverScoreUp: (uri: string, score: number) => void;
28
28
  clearCache: () => Promise<void>;
29
29
  getLocalServers: (numServersWanted: number, includePatterns?: Array<string | RegExp>) => string[];
30
- refreshServers: () => Promise<void>;
30
+ refreshServers: (updatedCustomServers?: string[]) => Promise<void>;
31
31
  updateServers: (settings: UtxoUserSettings) => Promise<void>;
32
32
  }
33
33
  export declare function makePluginState(settings: PluginStateSettings): PluginState;
@@ -25,6 +25,7 @@ export declare const asServerCache: import("cleaners").ObjectCleaner<{
25
25
  numResponseTimes: any;
26
26
  };
27
27
  };
28
+ enableCustomServers: boolean;
28
29
  internalServers: {
29
30
  [keys: string]: {
30
31
  serverUrl: any;
@@ -5,7 +5,7 @@ import { Cleaner } from 'cleaners';
5
5
  import { Disklet } from 'disklet';
6
6
  import { EdgeCurrencyEngineOptions, EdgeCurrencyInfo, EdgeCurrencyTools, EdgeIo, EdgeParsedUri, EdgeWalletInfo } from 'edge-core-js/types';
7
7
  import * as wif from 'wif';
8
- import { IProcessorTransaction, IUTXO } from '../utxobased/db/types';
8
+ import { TransactionData, UtxoData } from '../utxobased/db/types';
9
9
  import { UtxoInitOptions } from '../utxobased/engine/types';
10
10
  import { ScriptTemplates } from '../utxobased/info/scriptTemplates/types';
11
11
  import { UtxoPicker } from '../utxobased/keymanager/utxopicker';
@@ -23,7 +23,7 @@ export interface AddressPath {
23
23
  addressIndex: number;
24
24
  }
25
25
  export interface TxOptions {
26
- utxos?: IUTXO[];
26
+ utxos?: UtxoData[];
27
27
  subtractFee?: boolean;
28
28
  CPFP?: string;
29
29
  }
@@ -110,10 +110,10 @@ export interface EngineInfo {
110
110
  * Some currencies require an additional blockbook payload
111
111
  * 'getTransactionSpecific' in order to provide all relevant transaction
112
112
  * data. If this function is defined, it should merge the unknown `specialTx`
113
- * data from the Blockbook endpoint with the `IProcessorTransaction` object
113
+ * data from the Blockbook endpoint with the `TransactionData` object
114
114
  * which is stored to disk.
115
115
  **/
116
- txSpecificHandling?: (tx: IProcessorTransaction, specialTx: unknown) => IProcessorTransaction;
116
+ txSpecificHandling?: (tx: TransactionData, specialTx: unknown) => TransactionData;
117
117
  }
118
118
  export interface ServerConfig {
119
119
  type: 'blockbook-nownode';
@@ -1,12 +1,12 @@
1
1
  import { Disklet } from 'disklet';
2
2
  import { EdgeGetTransactionsOptions } from 'edge-core-js/types';
3
3
  import { AddressPath, ChangePath } from '../../plugin/types';
4
- import { IAddress, IProcessorTransaction, IUTXO } from './types';
5
- interface ProcessorConfig {
4
+ import { AddressData, TransactionData, UtxoData } from './types';
5
+ interface DataLayerConfig {
6
6
  disklet: Disklet;
7
7
  }
8
8
  interface SaveTransactionArgs {
9
- tx: IProcessorTransaction;
9
+ tx: TransactionData;
10
10
  scriptPubkeys?: string[];
11
11
  }
12
12
  interface FetchTransactionArgs {
@@ -28,20 +28,26 @@ interface DumpDataReturn {
28
28
  databaseName: string;
29
29
  data: unknown;
30
30
  }
31
- export interface Processor {
31
+ /**
32
+ * The Data Access Layer for the UTXO-based wallet engine.
33
+ *
34
+ * It provides all the methods necessary to interact with underlying
35
+ * database/storage mechanism.
36
+ */
37
+ export interface DataLayer {
32
38
  clearAll: () => Promise<void>;
33
39
  dumpData: () => Promise<DumpDataReturn[]>;
34
- saveUtxo: (utxo: IUTXO) => Promise<void>;
40
+ saveUtxo: (utxo: UtxoData) => Promise<void>;
35
41
  removeUtxos: (utxoIds: string[]) => Promise<void>;
36
- fetchUtxos: (args: FetchUtxosArgs) => Promise<Array<IUTXO | undefined>>;
37
- saveTransaction: (args: SaveTransactionArgs) => Promise<IProcessorTransaction>;
42
+ fetchUtxos: (args: FetchUtxosArgs) => Promise<Array<UtxoData | undefined>>;
43
+ saveTransaction: (args: SaveTransactionArgs) => Promise<TransactionData>;
38
44
  numTransactions: () => number;
39
45
  removeTransaction: (txId: string) => Promise<void>;
40
- fetchTransactions: (args: FetchTransactionArgs) => Promise<Array<IProcessorTransaction | undefined>>;
41
- saveAddress: (args: IAddress) => Promise<void>;
46
+ fetchTransactions: (args: FetchTransactionArgs) => Promise<Array<TransactionData | undefined>>;
47
+ saveAddress: (args: AddressData) => Promise<void>;
42
48
  numAddressesByFormatPath: (path: ChangePath) => number;
43
49
  lastUsedIndexByFormatPath: (path: ChangePath) => Promise<number>;
44
- fetchAddress: (args: AddressPath | string) => Promise<IAddress | undefined>;
50
+ fetchAddress: (args: AddressPath | string) => Promise<AddressData | undefined>;
45
51
  }
46
- export declare function makeProcessor(config: ProcessorConfig): Promise<Processor>;
52
+ export declare function makeDataLayer(config: DataLayerConfig): Promise<DataLayer>;
47
53
  export {};
@@ -1,14 +1,14 @@
1
1
  import { EdgeTransaction } from 'edge-core-js/types';
2
2
  import { PluginInfo } from '../../../plugin/types';
3
3
  import { UtxoWalletTools } from '../../engine/UtxoWalletTools';
4
- import { Processor } from '../Processor';
5
- import { IProcessorTransaction } from '../types';
6
- export declare const fromEdgeTransaction: (tx: EdgeTransaction) => IProcessorTransaction;
4
+ import { DataLayer } from '../DataLayer';
5
+ import { TransactionData } from '../types';
6
+ export declare const fromEdgeTransaction: (tx: EdgeTransaction) => TransactionData;
7
7
  interface ToEdgeTransactionArgs {
8
8
  walletId: string;
9
- tx: IProcessorTransaction;
9
+ tx: TransactionData;
10
10
  walletTools: UtxoWalletTools;
11
- processor: Processor;
11
+ dataLayer: DataLayer;
12
12
  pluginInfo: PluginInfo;
13
13
  }
14
14
  export declare const toEdgeTransaction: (args: ToEdgeTransactionArgs) => Promise<EdgeTransaction>;
@@ -1,10 +1,10 @@
1
1
  import { CountBase, CountBaseOptions, HashBase, HashBaseOptions, RangeBase, RangeBaseOptions } from 'baselet';
2
2
  import { ChangePath } from '../../../plugin/types';
3
- import { IAddress, IProcessorTransaction, IUTXO } from '../types';
3
+ import { AddressData, TransactionData, UtxoData } from '../types';
4
4
  export declare const addressPathToPrefix: (path: ChangePath) => string;
5
5
  export declare type ScriptPubkeyByPathBaselet = CountBase<string>;
6
6
  export declare const scriptPubkeyByPathOptions: CountBaseOptions;
7
- export declare type AddressByScriptPubkeyBaselet = HashBase<IAddress>;
7
+ export declare type AddressByScriptPubkeyBaselet = HashBase<AddressData>;
8
8
  export declare const addressByScriptPubkeyOptions: HashBaseOptions;
9
9
  export declare type LastUsedByFormatPathBaselet = HashBase<number>;
10
10
  export declare const lastUsedByFormatPathOptions: HashBaseOptions;
@@ -14,7 +14,7 @@ export interface TxIdByBlockHeight {
14
14
  }
15
15
  export declare type TxIdByBlockHeightBaselet = RangeBase<TxIdByBlockHeight, 'blockHeight', 'txid'>;
16
16
  export declare const txIdsByBlockHeightOptions: RangeBaseOptions<'blockHeight', 'txid'>;
17
- export declare type TxByIdBaselet = HashBase<IProcessorTransaction>;
17
+ export declare type TxByIdBaselet = HashBase<TransactionData>;
18
18
  export declare const txByIdOptions: HashBaseOptions;
19
19
  export interface TxIdByDate {
20
20
  txid: string;
@@ -22,7 +22,7 @@ export interface TxIdByDate {
22
22
  }
23
23
  export declare type TxIdByDateBaselet = RangeBase<TxIdByDate, 'date', 'txid'>;
24
24
  export declare const txIdsByDateOptions: RangeBaseOptions<'date', 'txid'>;
25
- export declare type UtxoByIdBaselet = HashBase<IUTXO>;
25
+ export declare type UtxoByIdBaselet = HashBase<UtxoData>;
26
26
  export declare const utxoByIdOptions: HashBaseOptions;
27
27
  export declare type UtxoIdsByScriptPubkeyBaselet = HashBase<string[]>;
28
28
  export declare const utxoIdsByScriptPubkeyOptions: HashBaseOptions;
@@ -1,7 +1,7 @@
1
1
  import { SoftPick } from '../../../util/typeUtil';
2
2
  import { AddressPath } from '../../plugin/types';
3
3
  import { ScriptTypeEnum } from '../keymanager/keymanager';
4
- export interface IAddress {
4
+ export interface AddressData {
5
5
  scriptPubkey: string;
6
6
  redeemScript?: string;
7
7
  lastQueriedBlockHeight: number;
@@ -11,8 +11,8 @@ export interface IAddress {
11
11
  used: boolean;
12
12
  balance?: string;
13
13
  }
14
- export declare const makeIAddress: (addressFields: SoftPick<IAddress, 'scriptPubkey'>) => IAddress;
15
- export interface IUTXO {
14
+ export declare const makeAddressData: (addressFields: SoftPick<AddressData, 'scriptPubkey'>) => AddressData;
15
+ export interface UtxoData {
16
16
  id: string;
17
17
  txid: string;
18
18
  vout: number;
@@ -24,26 +24,26 @@ export interface IUTXO {
24
24
  blockHeight: number;
25
25
  spent: boolean;
26
26
  }
27
- export declare const asIUTXO: import("cleaners").ObjectCleaner<IUTXO>;
28
- export interface IProcessorTransaction {
27
+ export declare const asUtxoData: import("cleaners").ObjectCleaner<UtxoData>;
28
+ export interface TransactionData {
29
29
  txid: string;
30
30
  hex: string;
31
31
  blockHeight: number;
32
32
  confirmations?: 'confirmed' | 'unconfirmed' | 'dropped' | number;
33
33
  date: number;
34
34
  fees: string;
35
- inputs: ITransactionInput[];
36
- outputs: ITransactionOutput[];
35
+ inputs: TransactionDataInput[];
36
+ outputs: TransactionDataOutput[];
37
37
  ourIns: string[];
38
38
  ourOuts: string[];
39
39
  ourAmount: string;
40
40
  }
41
- export interface ITransactionOutput {
41
+ export interface TransactionDataOutput {
42
42
  amount: string;
43
43
  n: number;
44
44
  scriptPubkey: string;
45
45
  }
46
- export interface ITransactionInput {
46
+ export interface TransactionDataInput {
47
47
  amount: string;
48
48
  n: number;
49
49
  outputIndex: number;
@@ -1,3 +1,3 @@
1
- import { Processor } from '../Processor';
2
- import { IProcessorTransaction, IUTXO } from '../types';
3
- export declare const utxoFromProcessorTransactionInput: (processor: Processor, processorTransaction: IProcessorTransaction, inputIndex: number) => Promise<IUTXO>;
1
+ import { DataLayer } from '../DataLayer';
2
+ import { TransactionData, UtxoData } from '../types';
3
+ export declare const utxoFromTransactionDataInput: (dataLayer: DataLayer, transactionData: TransactionData, inputIndex: number) => Promise<UtxoData>;
@@ -6,9 +6,9 @@ import { SafeWalletInfo } from '../keymanager/cleaners';
6
6
  import { Blockbook } from '../network/Blockbook';
7
7
  import { AddressResponse, AddressUtxosResponse, BlockbookTransaction } from '../network/blockbookApi';
8
8
  import Deferred from '../network/Deferred';
9
- import { WsTask } from '../network/Socket';
9
+ import { WsTask, WsTaskGenerator } from '../network/Socket';
10
10
  import { UtxoInitOptions } from './types';
11
- interface ServerState {
11
+ export interface ServerState {
12
12
  blockbook: Blockbook;
13
13
  blockSubscriptionStatus: 'unsubscribed' | 'subscribing' | 'subscribed';
14
14
  blockHeight: number;
@@ -25,7 +25,7 @@ interface ServerStateConfig {
25
25
  walletInfo: SafeWalletInfo;
26
26
  }
27
27
  export interface ServerStates {
28
- setPickNextTaskCB: (callback: (uri: string) => Promise<boolean | WsTask<any> | undefined>) => void;
28
+ setPickNextTaskCB: (callback: (uri: string) => AsyncGenerator<WsTask<unknown> | boolean>) => void;
29
29
  stop: () => void;
30
30
  serverCanGetTx: (uri: string, txid: string) => boolean;
31
31
  serverCanGetAddress: (uri: string, address: string) => boolean;
@@ -41,10 +41,10 @@ export interface ServerStates {
41
41
  addressQueryTask: (serverUri: string, address: string, params: {
42
42
  lastQueriedBlockHeight: number;
43
43
  page: number;
44
- }, deferred: Deferred<AddressResponse>) => WsTask<AddressResponse>;
45
- transactionQueryTask: (serverUri: string, txId: string, deferred: Deferred<BlockbookTransaction>) => WsTask<BlockbookTransaction>;
46
- transactionSpecialQueryTask: (serverUri: string, txId: string, deferred: Deferred<unknown>) => WsTask<unknown>;
47
- utxoListQueryTask: (serverUri: string, address: string, deferred: Deferred<AddressUtxosResponse>) => WsTask<AddressUtxosResponse>;
44
+ }) => WsTaskGenerator<AddressResponse>;
45
+ transactionQueryTask: (serverUri: string, txId: string) => WsTaskGenerator<BlockbookTransaction>;
46
+ transactionSpecialQueryTask: (serverUri: string, txId: string) => WsTaskGenerator<unknown>;
47
+ utxoListQueryTask: (serverUri: string, address: string) => WsTaskGenerator<AddressUtxosResponse>;
48
48
  }
49
49
  export declare function makeServerStates(config: ServerStateConfig): ServerStates;
50
50
  export {};