edge-currency-plugins 3.8.6 → 3.8.8
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.
|
@@ -115,6 +115,17 @@ var _utils3 = require('./utils');
|
|
|
115
115
|
transactionUpdateCache: {}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// Track pending timeouts so they can be cleared on stop
|
|
119
|
+
const pendingTimeouts = new Set()
|
|
120
|
+
|
|
121
|
+
// Clear all pending timeouts
|
|
122
|
+
const clearPendingTimeouts = () => {
|
|
123
|
+
for (const timeoutId of pendingTimeouts) {
|
|
124
|
+
clearTimeout(timeoutId)
|
|
125
|
+
}
|
|
126
|
+
pendingTimeouts.clear()
|
|
127
|
+
}
|
|
128
|
+
|
|
118
129
|
const clearTaskCache = () => {
|
|
119
130
|
for (const key of Object.keys(taskCache.addressForTransactionsCache)) {
|
|
120
131
|
_utils.removeItem.call(void 0, taskCache.addressForTransactionsCache, key)
|
|
@@ -212,6 +223,7 @@ var _utils3 = require('./utils');
|
|
|
212
223
|
dataLayer,
|
|
213
224
|
emitter,
|
|
214
225
|
taskCache,
|
|
226
|
+
pendingTimeouts,
|
|
215
227
|
updateProgressRatio,
|
|
216
228
|
updateSeenTxCheckpoint,
|
|
217
229
|
io,
|
|
@@ -358,6 +370,7 @@ var _utils3 = require('./utils');
|
|
|
358
370
|
async stop() {
|
|
359
371
|
serverStates.stop()
|
|
360
372
|
clearTaskCache()
|
|
373
|
+
clearPendingTimeouts()
|
|
361
374
|
running = false
|
|
362
375
|
},
|
|
363
376
|
|
|
@@ -685,6 +698,7 @@ const internalGetFreshAddress = async (
|
|
|
685
698
|
|
|
686
699
|
|
|
687
700
|
|
|
701
|
+
|
|
688
702
|
|
|
689
703
|
|
|
690
704
|
const setLookAhead = async (common) => {
|
|
@@ -1154,9 +1168,18 @@ async function* processCheckTransactionConfirmation(
|
|
|
1154
1168
|
} catch (err) {
|
|
1155
1169
|
console.error(err)
|
|
1156
1170
|
common.log('error while processing transaction update:', err)
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1171
|
+
// Delay putting the transaction back into the cache to avoid thrashing
|
|
1172
|
+
// on dropped transactions. 10 seconds is a reasonable compromise between
|
|
1173
|
+
// thrashing and not waiting too long.
|
|
1174
|
+
addPendingTimeout(
|
|
1175
|
+
common,
|
|
1176
|
+
() => {
|
|
1177
|
+
common.taskCache.transactionUpdateCache[txId] = {
|
|
1178
|
+
processing: false
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
10000
|
|
1182
|
+
)
|
|
1160
1183
|
return false
|
|
1161
1184
|
}
|
|
1162
1185
|
}
|
|
@@ -1331,30 +1354,44 @@ const processTransactionResponse = (
|
|
|
1331
1354
|
return {
|
|
1332
1355
|
amount: outputTotalValue,
|
|
1333
1356
|
n: 0,
|
|
1334
|
-
|
|
1357
|
+
// UINT32_MAX value, as a coinbase has no previous outpoint
|
|
1358
|
+
outputIndex: 0xffffffff,
|
|
1335
1359
|
scriptPubkey: '', // Maybe there's a bogus scriptPubkey we can use here?
|
|
1336
1360
|
sequence: vin.sequence,
|
|
1337
1361
|
txId: '0000000000000000000000000000000000000000000000000000000000000000'
|
|
1338
1362
|
}
|
|
1339
1363
|
}
|
|
1340
1364
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
const scriptPubkey =
|
|
1365
|
+
let scriptPubkey = 'unknown'
|
|
1366
|
+
try {
|
|
1346
1367
|
// Note: Blockbook has empirically not sent a hex value as the
|
|
1347
1368
|
// scriptPubkey for vins. If we discover this to be changed for some
|
|
1348
1369
|
// cases, we may want to use the `hex` field as an optimization.
|
|
1349
|
-
|
|
1350
|
-
raw => _utils3.validScriptPubkeyFromAddress.call(void 0, raw),
|
|
1351
|
-
'unknown'
|
|
1352
|
-
)({
|
|
1370
|
+
scriptPubkey = _utils3.validScriptPubkeyFromAddress.call(void 0, {
|
|
1353
1371
|
address: vin.addresses[0],
|
|
1354
1372
|
coin: common.pluginInfo.coinInfo.name
|
|
1355
1373
|
})
|
|
1374
|
+
} catch (error) {
|
|
1375
|
+
common.log.warn(
|
|
1376
|
+
`failed to get scriptPubkey from address ${vin.addresses[0]}: `,
|
|
1377
|
+
error
|
|
1378
|
+
)
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
// Some inputs may not have a txid in addition to coinbase inputs, such as
|
|
1382
|
+
// private transaction inputs from privacy chains (e.g. SparkSpend inputs in FIRO).
|
|
1383
|
+
// Warning: Because the engine doesn't support private transactions, or any
|
|
1384
|
+
// transaction outputs that wouldn't have a txid as their input in the spend transaction,
|
|
1385
|
+
// we can safely assume an all-zero txid for these inputs.
|
|
1386
|
+
// If we're to ever support private transaction spends, then this wouldn't
|
|
1387
|
+
// be safe to assume as "our own input" because it wouldn't remove the UTXO
|
|
1388
|
+
// from the DataLayer properly.
|
|
1389
|
+
const txId =
|
|
1390
|
+
_nullishCoalesce(vin.txid, () => (
|
|
1391
|
+
'0000000000000000000000000000000000000000000000000000000000000000'))
|
|
1392
|
+
|
|
1356
1393
|
return {
|
|
1357
|
-
txId
|
|
1394
|
+
txId,
|
|
1358
1395
|
outputIndex: vin.vout,
|
|
1359
1396
|
n: vin.n,
|
|
1360
1397
|
scriptPubkey,
|
|
@@ -1681,3 +1718,22 @@ const addToDataLayerUtxoCache = (
|
|
|
1681
1718
|
dataLayerUtxoCache[scriptPubkey] = dataLayerUtxos
|
|
1682
1719
|
dataLayerUtxos.full = dataLayerUtxos.utxos.length >= requiredCount
|
|
1683
1720
|
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* This adds a pending timeout to the common.pendingTimeouts set.
|
|
1724
|
+
* It will call the callback after the timeout.
|
|
1725
|
+
*
|
|
1726
|
+
* This utility is a safe way to add pending timeouts for the processor because
|
|
1727
|
+
* it will clear the timeout when the processor stops.
|
|
1728
|
+
*/
|
|
1729
|
+
const addPendingTimeout = (
|
|
1730
|
+
common,
|
|
1731
|
+
callback,
|
|
1732
|
+
timeout
|
|
1733
|
+
) => {
|
|
1734
|
+
const timeoutId = setTimeout(() => {
|
|
1735
|
+
common.pendingTimeouts.delete(timeoutId)
|
|
1736
|
+
callback()
|
|
1737
|
+
}, timeout)
|
|
1738
|
+
common.pendingTimeouts.add(timeoutId)
|
|
1739
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { EdgeFreshAddress, EdgeIo, EdgeLog, EdgeTransaction } from 'edge-core-js/types';
|
|
2
3
|
import { EngineEmitter } from '../../plugin/EngineEmitter';
|
|
3
4
|
import { ChangePath, CurrencyFormat, EngineConfig, PluginInfo } from '../../plugin/types';
|
|
@@ -40,6 +41,7 @@ interface CommonParams {
|
|
|
40
41
|
dataLayer: DataLayer;
|
|
41
42
|
emitter: EngineEmitter;
|
|
42
43
|
taskCache: TaskCache;
|
|
44
|
+
pendingTimeouts: Set<NodeJS.Timeout>;
|
|
43
45
|
updateProgressRatio: () => void;
|
|
44
46
|
updateSeenTxCheckpoint: () => void;
|
|
45
47
|
io: EdgeIo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.8",
|
|
4
4
|
"description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
|
|
5
5
|
"homepage": "https://edge.app/",
|
|
6
6
|
"repository": "https://github.com/EdgeApp/edge-currency-plugins",
|