edge-currency-plugins 3.2.1 → 3.3.1
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/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +41 -41
- package/lib/common/plugin/PluginState.js +4 -4
- package/lib/common/plugin/ServerScores.js +10 -0
- package/lib/common/plugin/types.js +1 -1
- package/lib/common/utxobased/db/{Processor.js → DataLayer.js} +15 -11
- package/lib/common/utxobased/db/Models/{ProcessorTransaction.js → TransactionData.js} +4 -6
- package/lib/common/utxobased/db/types.js +4 -4
- package/lib/common/utxobased/db/util/utxo.js +8 -8
- package/lib/common/utxobased/engine/ServerStates.js +137 -98
- package/lib/common/utxobased/engine/UtxoEngine.js +58 -55
- package/lib/common/utxobased/engine/{UtxoEngineState.js → UtxoEngineProcessor.js} +650 -714
- package/lib/common/utxobased/engine/types.js +4 -2
- package/lib/common/utxobased/engine/util/getOwnUtxosFromTx.js +4 -4
- package/lib/common/utxobased/info/bitcoin.js +2 -1
- package/lib/common/utxobased/info/bitcoincash.js +2 -1
- package/lib/common/utxobased/info/dash.js +2 -1
- package/lib/common/utxobased/info/digibyte.js +5 -1
- package/lib/common/utxobased/info/dogecoin.js +2 -1
- package/lib/common/utxobased/info/groestlcoin.js +5 -2
- package/lib/common/utxobased/info/litecoin.js +2 -1
- package/lib/common/utxobased/info/zcoin.js +4 -1
- package/lib/common/utxobased/network/Blockbook.js +33 -30
- package/lib/common/utxobased/network/BlockbookElectrum.js +79 -77
- package/lib/common/utxobased/network/Socket.js +79 -49
- package/lib/common/utxobased/network/nodejsWS.js +2 -2
- package/lib/common/utxobased/network/types.js +5 -0
- package/lib/common/utxobased/network/windowWS.js +2 -2
- package/lib/src/common/plugin/PluginState.d.ts +3 -3
- package/lib/src/common/plugin/types.d.ts +4 -4
- package/lib/src/common/utxobased/db/{Processor.d.ts → DataLayer.d.ts} +17 -11
- package/lib/src/common/utxobased/db/Models/{ProcessorTransaction.d.ts → TransactionData.d.ts} +5 -5
- package/lib/src/common/utxobased/db/Models/baselet.d.ts +4 -4
- package/lib/src/common/utxobased/db/types.d.ts +9 -9
- package/lib/src/common/utxobased/db/util/utxo.d.ts +3 -3
- package/lib/src/common/utxobased/engine/ServerStates.d.ts +7 -7
- package/lib/src/common/utxobased/engine/{UtxoEngineState.d.ts → UtxoEngineProcessor.d.ts} +44 -42
- package/lib/src/common/utxobased/engine/types.d.ts +4 -4
- package/lib/src/common/utxobased/engine/util/getOwnUtxosFromTx.d.ts +3 -3
- package/lib/src/common/utxobased/engine/utils.d.ts +2 -2
- package/lib/src/common/utxobased/keymanager/keymanager.d.ts +3 -3
- package/lib/src/common/utxobased/network/Blockbook.d.ts +8 -7
- package/lib/src/common/utxobased/network/BlockbookElectrum.d.ts +4 -2
- package/lib/src/common/utxobased/network/Socket.d.ts +10 -8
- package/lib/src/common/utxobased/network/types.d.ts +6 -2
- package/lib/src/util/uriKeyParams.d.ts +4 -0
- package/lib/util/uriKeyParams.js +20 -0
- package/package.json +2 -2
- /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
|
|
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
|
|
@@ -131,7 +139,7 @@ const asResponseDefault = (raw) => [
|
|
|
131
139
|
|
|
132
140
|
const handleError = (e) => {
|
|
133
141
|
if (trackedError == null) trackedError = e
|
|
134
|
-
if (connected && socket != null && socket.readyState ===
|
|
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)
|
|
@@ -145,31 +153,29 @@ const asResponseDefault = (raw) => [
|
|
|
145
153
|
_socketQueue.removeIdFromQueue.call(void 0, socketQueueId)
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
const onSocketClose = () => {
|
|
156
|
+
const onSocketClose = (code) => {
|
|
149
157
|
const errObj =
|
|
150
|
-
trackedError
|
|
151
|
-
?
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
: new Error(
|
|
155
|
-
log.warn(`onSocketClose with server ${uri}: ${errObj.message}`)
|
|
158
|
+
trackedError == null
|
|
159
|
+
? new Error('Socket closed without error')
|
|
160
|
+
: trackedError instanceof Error
|
|
161
|
+
? trackedError
|
|
162
|
+
: new Error(String(trackedError))
|
|
163
|
+
log.warn(`onSocketClose with server ${uri}: ${code} ${errObj.message}`)
|
|
156
164
|
clearTimeout(timer)
|
|
157
165
|
connected = false
|
|
158
166
|
socket = null
|
|
159
167
|
cancelConnect = false
|
|
160
168
|
trackedError = undefined
|
|
161
169
|
for (const request of Object.values(pendingRequests)) {
|
|
162
|
-
|
|
163
|
-
request.task.deferred.reject(errObj)
|
|
164
|
-
} catch (e) {
|
|
170
|
+
request.generator.throw(errObj).catch(e => {
|
|
165
171
|
log.error(e.message)
|
|
166
|
-
}
|
|
172
|
+
})
|
|
167
173
|
}
|
|
168
174
|
pendingRequests = {}
|
|
169
175
|
try {
|
|
170
176
|
emitter.emit(_SocketEmitter.SocketEvent.CONNECTION_CLOSE, uri, errObj)
|
|
171
177
|
} catch (e) {
|
|
172
|
-
log.error(e
|
|
178
|
+
log.error(String(e))
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
|
|
@@ -211,20 +217,21 @@ const asResponseDefault = (raw) => [
|
|
|
211
217
|
lastWakeUp = Date.now()
|
|
212
218
|
if (connected && version != null) {
|
|
213
219
|
while (Object.keys(pendingRequests).length < queueSize) {
|
|
214
|
-
const
|
|
215
|
-
|
|
220
|
+
const generator = await config.taskGeneratorFn(uri)
|
|
221
|
+
const result = await generator.next()
|
|
222
|
+
const task = result.value
|
|
216
223
|
if (typeof task === 'boolean') {
|
|
217
224
|
if (task) continue
|
|
218
|
-
break
|
|
225
|
+
else break
|
|
219
226
|
}
|
|
220
|
-
submitTask(task)
|
|
227
|
+
instance.submitTask(task, generator)
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
// add any exception, since the passed in template parameter needs to be re-assigned
|
|
226
233
|
const subscribe = (subscription) => {
|
|
227
|
-
if (socket != null && socket.readyState ===
|
|
234
|
+
if (socket != null && socket.readyState === _types5.ReadyState.OPEN && connected) {
|
|
228
235
|
const id = subscription.method
|
|
229
236
|
const message = {
|
|
230
237
|
id,
|
|
@@ -236,19 +243,11 @@ const asResponseDefault = (raw) => [
|
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
245
|
|
|
239
|
-
// add any exception, since the passed in template parameter needs to be re-assigned
|
|
240
|
-
const submitTask = (task) => {
|
|
241
|
-
const id = (nextId++).toString()
|
|
242
|
-
const request = { task, startTime: Date.now() }
|
|
243
|
-
pendingRequests[id] = request
|
|
244
|
-
transmitRequest(id, request)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
246
|
const transmitRequest = (id, request) => {
|
|
248
247
|
const now = Date.now()
|
|
249
248
|
if (
|
|
250
249
|
socket != null &&
|
|
251
|
-
socket.readyState ===
|
|
250
|
+
socket.readyState === _types5.ReadyState.OPEN &&
|
|
252
251
|
connected &&
|
|
253
252
|
!cancelConnect
|
|
254
253
|
) {
|
|
@@ -278,11 +277,11 @@ const asResponseDefault = (raw) => [
|
|
|
278
277
|
|
|
279
278
|
for (const [id, request] of Object.entries(pendingRequests)) {
|
|
280
279
|
if (request.startTime + timeout < now) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
280
|
+
request.generator
|
|
281
|
+
.throw(new Error(`Timeout for request ${id}`))
|
|
282
|
+
.catch(e => {
|
|
283
|
+
log.error(e.message)
|
|
284
|
+
})
|
|
286
285
|
_utils.removeItem.call(void 0, pendingRequests, id)
|
|
287
286
|
}
|
|
288
287
|
}
|
|
@@ -347,16 +346,29 @@ const asResponseDefault = (raw) => [
|
|
|
347
346
|
'message' in error ? error.message : error.connected
|
|
348
347
|
throw new Error(errorMessage)
|
|
349
348
|
}
|
|
349
|
+
let nextValue
|
|
350
350
|
if (request.task.cleaner != null) {
|
|
351
|
-
request.task.
|
|
352
|
-
request.task.cleaner(responseMessage.data)
|
|
353
|
-
)
|
|
351
|
+
nextValue = request.task.cleaner(responseMessage.data)
|
|
354
352
|
} else {
|
|
355
|
-
|
|
353
|
+
nextValue = responseMessage.data
|
|
356
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
|
+
})
|
|
357
367
|
} catch (error) {
|
|
358
368
|
console.log({ uri, error, response: responseMessage, request })
|
|
359
|
-
request.
|
|
369
|
+
request.generator.throw(error).catch(e => {
|
|
370
|
+
log.error(e.message)
|
|
371
|
+
})
|
|
360
372
|
}
|
|
361
373
|
continue
|
|
362
374
|
}
|
|
@@ -375,9 +387,9 @@ const asResponseDefault = (raw) => [
|
|
|
375
387
|
setupTimer()
|
|
376
388
|
|
|
377
389
|
// return a Socket
|
|
378
|
-
|
|
390
|
+
const instance = {
|
|
379
391
|
get readyState() {
|
|
380
|
-
return _nullishCoalesce(_optionalChain([socket, 'optionalAccess', _2 => _2.readyState]), () => (
|
|
392
|
+
return _nullishCoalesce(_optionalChain([socket, 'optionalAccess', _2 => _2.readyState]), () => ( _types5.ReadyState.CLOSED))
|
|
381
393
|
},
|
|
382
394
|
|
|
383
395
|
async connect() {
|
|
@@ -391,16 +403,28 @@ const asResponseDefault = (raw) => [
|
|
|
391
403
|
},
|
|
392
404
|
onMessage: onMessage,
|
|
393
405
|
onError: err => {
|
|
394
|
-
trackedError =
|
|
406
|
+
trackedError = err
|
|
395
407
|
},
|
|
396
408
|
onClose: onSocketClose
|
|
397
409
|
}
|
|
398
410
|
|
|
399
|
-
// Append "/websocket" if
|
|
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.
|
|
400
414
|
let fullUri = uri
|
|
401
415
|
if (uri.startsWith('wss:') || uri.startsWith('ws:')) {
|
|
402
|
-
|
|
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
|
+
}
|
|
403
423
|
}
|
|
424
|
+
|
|
425
|
+
// Replace any "key params" in the URIs (e.g. `%{nowNodesApiKey}`)
|
|
426
|
+
fullUri = _uriKeyParams.replaceKeyParams.call(void 0, fullUri, config.initOptions)
|
|
427
|
+
|
|
404
428
|
if (uri.startsWith('electrumwss:')) {
|
|
405
429
|
fullUri = uri.replace(/^electrumwss:/, 'wss:')
|
|
406
430
|
}
|
|
@@ -423,15 +447,21 @@ const asResponseDefault = (raw) => [
|
|
|
423
447
|
},
|
|
424
448
|
|
|
425
449
|
isConnected() {
|
|
426
|
-
return _optionalChain([socket, 'optionalAccess', _7 => _7.readyState]) ===
|
|
450
|
+
return _optionalChain([socket, 'optionalAccess', _7 => _7.readyState]) === _types5.ReadyState.OPEN
|
|
427
451
|
},
|
|
428
452
|
|
|
429
|
-
submitTask
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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)
|
|
433
461
|
},
|
|
434
462
|
|
|
435
463
|
subscribe
|
|
436
464
|
}
|
|
465
|
+
|
|
466
|
+
return instance
|
|
437
467
|
} exports.makeSocket = makeSocket;
|
|
@@ -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 {
|
|
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,8 +19,8 @@ export interface PluginStateSettings {
|
|
|
19
19
|
log: EdgeLog;
|
|
20
20
|
}
|
|
21
21
|
export interface PluginState {
|
|
22
|
-
addEngine: (
|
|
23
|
-
removeEngine: (
|
|
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;
|
|
@@ -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 {
|
|
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?:
|
|
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 `
|
|
113
|
+
* data from the Blockbook endpoint with the `TransactionData` object
|
|
114
114
|
* which is stored to disk.
|
|
115
115
|
**/
|
|
116
|
-
txSpecificHandling?: (tx:
|
|
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 {
|
|
5
|
-
interface
|
|
4
|
+
import { AddressData, TransactionData, UtxoData } from './types';
|
|
5
|
+
interface DataLayerConfig {
|
|
6
6
|
disklet: Disklet;
|
|
7
7
|
}
|
|
8
8
|
interface SaveTransactionArgs {
|
|
9
|
-
tx:
|
|
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
|
-
|
|
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:
|
|
40
|
+
saveUtxo: (utxo: UtxoData) => Promise<void>;
|
|
35
41
|
removeUtxos: (utxoIds: string[]) => Promise<void>;
|
|
36
|
-
fetchUtxos: (args: FetchUtxosArgs) => Promise<Array<
|
|
37
|
-
saveTransaction: (args: SaveTransactionArgs) => Promise<
|
|
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<
|
|
41
|
-
saveAddress: (args:
|
|
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<
|
|
50
|
+
fetchAddress: (args: AddressPath | string) => Promise<AddressData | undefined>;
|
|
45
51
|
}
|
|
46
|
-
export declare function
|
|
52
|
+
export declare function makeDataLayer(config: DataLayerConfig): Promise<DataLayer>;
|
|
47
53
|
export {};
|
package/lib/src/common/utxobased/db/Models/{ProcessorTransaction.d.ts → TransactionData.d.ts}
RENAMED
|
@@ -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 {
|
|
5
|
-
import {
|
|
6
|
-
export declare const fromEdgeTransaction: (tx: EdgeTransaction) =>
|
|
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:
|
|
9
|
+
tx: TransactionData;
|
|
10
10
|
walletTools: UtxoWalletTools;
|
|
11
|
-
|
|
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 {
|
|
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<
|
|
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<
|
|
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<
|
|
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
|
|
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
|
|
15
|
-
export interface
|
|
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
|
|
28
|
-
export interface
|
|
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:
|
|
36
|
-
outputs:
|
|
35
|
+
inputs: TransactionDataInput[];
|
|
36
|
+
outputs: TransactionDataOutput[];
|
|
37
37
|
ourIns: string[];
|
|
38
38
|
ourOuts: string[];
|
|
39
39
|
ourAmount: string;
|
|
40
40
|
}
|
|
41
|
-
export interface
|
|
41
|
+
export interface TransactionDataOutput {
|
|
42
42
|
amount: string;
|
|
43
43
|
n: number;
|
|
44
44
|
scriptPubkey: string;
|
|
45
45
|
}
|
|
46
|
-
export interface
|
|
46
|
+
export interface TransactionDataInput {
|
|
47
47
|
amount: string;
|
|
48
48
|
n: number;
|
|
49
49
|
outputIndex: number;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
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) =>
|
|
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
|
-
}
|
|
45
|
-
transactionQueryTask: (serverUri: string, txId: string
|
|
46
|
-
transactionSpecialQueryTask: (serverUri: string, txId: string
|
|
47
|
-
utxoListQueryTask: (serverUri: string, address: string
|
|
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 {};
|