edge-currency-plugins 1.2.1 → 1.2.3

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _biggystring = require('biggystring'); var bs = _interopRequireWildcard(_biggystring);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _biggystring = require('biggystring');
2
2
 
3
3
 
4
4
  var _memlet = require('memlet');
@@ -6,6 +6,7 @@ var _memlet = require('memlet');
6
6
  var _awaitlock = require('../utxobased/engine/await-lock'); var _awaitlock2 = _interopRequireDefault(_awaitlock);
7
7
  var _makeEngineEmitter = require('./makeEngineEmitter');
8
8
  var _types3 = require('./types');
9
+ var _utils = require('./utils');
9
10
 
10
11
  const metadataPath = `metadata.json`
11
12
 
@@ -19,6 +20,7 @@ const metadataPath = `metadata.json`
19
20
 
20
21
 
21
22
 
23
+
22
24
  const makeMetadata = async (
23
25
  config
24
26
  ) => {
@@ -27,11 +29,8 @@ const metadataPath = `metadata.json`
27
29
  const lock = new (0, _awaitlock2.default)()
28
30
 
29
31
  const instance = {
30
- get balance() {
31
- return cache.balance
32
- },
33
- get lastSeenBlockHeight() {
34
- return cache.lastSeenBlockHeight
32
+ get state() {
33
+ return cache
35
34
  },
36
35
  clear: async () => {
37
36
  await memlet.delete(metadataPath)
@@ -40,18 +39,37 @@ const metadataPath = `metadata.json`
40
39
  }
41
40
  }
42
41
 
42
+ const updateWalletBalance = async (currencyCode) => {
43
+ const cumulativeBalance = Object.values(cache.addressBalances).reduce(
44
+ (sum, addressBalance) => _biggystring.add.call(void 0, sum, addressBalance),
45
+ '0'
46
+ )
47
+ cache.balance = cumulativeBalance
48
+ await setMetadata(cache)
49
+ emitter.emit(
50
+ _makeEngineEmitter.EngineEvent.WALLET_BALANCE_CHANGED,
51
+ currencyCode,
52
+ cumulativeBalance
53
+ )
54
+ }
55
+
43
56
  emitter.on(
44
57
  _makeEngineEmitter.EngineEvent.ADDRESS_BALANCE_CHANGED,
45
- async (currencyCode, balanceDiff) => {
58
+ async (
59
+ currencyCode,
60
+ addressBalanceChanges
61
+ ) => {
46
62
  await lock.acquireAsync()
47
63
  try {
48
- cache.balance = bs.add(cache.balance, balanceDiff)
49
- emitter.emit(
50
- _makeEngineEmitter.EngineEvent.WALLET_BALANCE_CHANGED,
51
- currencyCode,
52
- cache.balance
53
- )
54
- await setMetadata(cache)
64
+ addressBalanceChanges.forEach(({ scriptPubkey, balance }) => {
65
+ if (balance === '0') {
66
+ _utils.removeItem.call(void 0, cache.addressBalances, scriptPubkey)
67
+ } else {
68
+ cache.addressBalances[scriptPubkey] = balance
69
+ }
70
+ })
71
+
72
+ await updateWalletBalance(currencyCode)
55
73
  } catch (err) {
56
74
  log.error(err)
57
75
  } finally {
@@ -83,6 +101,7 @@ const metadataPath = `metadata.json`
83
101
  const resetMetadata = async () => {
84
102
  const data = {
85
103
  balance: '0',
104
+ addressBalances: {},
86
105
  lastSeenBlockHeight: 0
87
106
  }
88
107
  await memlet.setJson(metadataPath, data)
@@ -125,6 +125,11 @@ var _cleaners = require('cleaners');
125
125
 
126
126
 
127
127
 
128
+
129
+
130
+
131
+
132
+
128
133
 
129
134
 
130
135
 
@@ -162,5 +167,7 @@ var _cleaners = require('cleaners');
162
167
 
163
168
  const asLocalWalletMetadata = _cleaners.asObject.call(void 0, {
164
169
  balance: _cleaners.asString,
170
+ // scriptPubkey -> balance
171
+ addressBalances: _cleaners.asObject.call(void 0, _cleaners.asString),
165
172
  lastSeenBlockHeight: _cleaners.asNumber
166
173
  }); exports.asLocalWalletMetadata = asLocalWalletMetadata
@@ -117,6 +117,7 @@ var _keymanager = require('../../keymanager/keymanager');
117
117
  currencyCode: currencyInfo.currencyCode,
118
118
  txid: tx.txid,
119
119
  blockHeight: tx.blockHeight,
120
+ confirmations: tx.confirmations,
120
121
  date: tx.date,
121
122
  nativeAmount: tx.ourAmount,
122
123
  networkFee: tx.fees,
@@ -124,7 +124,7 @@ var _utils = require('./utils');
124
124
  emitter.emit(
125
125
  _makeEngineEmitter.EngineEvent.WALLET_BALANCE_CHANGED,
126
126
  currencyInfo.currencyCode,
127
- metadata.balance
127
+ metadata.state.balance
128
128
  )
129
129
 
130
130
  pluginState.addEngine(engineState)
@@ -139,11 +139,11 @@ var _utils = require('./utils');
139
139
  },
140
140
 
141
141
  getBalance(_opts) {
142
- return metadata.balance
142
+ return metadata.state.balance
143
143
  },
144
144
 
145
145
  getBlockHeight() {
146
- return metadata.lastSeenBlockHeight
146
+ return metadata.state.lastSeenBlockHeight
147
147
  },
148
148
 
149
149
  async addCustomToken(_token) {
@@ -196,6 +196,7 @@ var _utils = require('./utils');
196
196
  primaryFormat,
197
197
  walletFormats
198
198
  },
199
+ metadataState: metadata.state,
199
200
  processorState: await processor.dumpData(),
200
201
  pluginState: pluginState.dumpData()
201
202
  }
@@ -644,7 +645,7 @@ var _utils = require('./utils');
644
645
  throw new Error('Private key has no funds')
645
646
  }
646
647
  const destAddress = await this.getFreshAddress({})
647
- const nativeAmount = tmpMetadata.balance
648
+ const nativeAmount = tmpMetadata.state.balance
648
649
  const options = { utxos: tmpUtxos, subtractFee: true }
649
650
  spendInfo.spendTargets = [
650
651
  { publicAddress: destAddress.publicAddress, nativeAmount }
@@ -41,6 +41,7 @@ var _keymanager = require('../keymanager/keymanager');
41
41
 
42
42
 
43
43
 
44
+
44
45
  var _BlockBookAPI = require('../network/BlockBookAPI');
45
46
  var _Deferred = require('../network/Deferred'); var _Deferred2 = _interopRequireDefault(_Deferred);
46
47
 
@@ -108,7 +109,8 @@ var _utils3 = require('./utils');
108
109
  addressUtxoCache: {},
109
110
  rawUtxoCache: {},
110
111
  processorUtxoCache: {},
111
- updateTransactionCache: {}
112
+ updateTransactionCache: {},
113
+ updateTransactionSpecificCache: {}
112
114
  }
113
115
 
114
116
  const clearTaskCache = () => {
@@ -131,6 +133,9 @@ var _utils3 = require('./utils');
131
133
  for (const key of Object.keys(taskCache.updateTransactionCache)) {
132
134
  _utils.removeItem.call(void 0, taskCache.updateTransactionCache, key)
133
135
  }
136
+ for (const key of Object.keys(taskCache.updateTransactionSpecificCache)) {
137
+ _utils.removeItem.call(void 0, taskCache.updateTransactionSpecificCache, key)
138
+ }
134
139
  }
135
140
 
136
141
  /**
@@ -253,6 +258,11 @@ var _utils3 = require('./utils');
253
258
  // processed by the processor. This happens only once before any call to
254
259
  // setLookAhead.
255
260
  const initializeAddressSubscriptions = async () => {
261
+ const addressBalanceChanges
262
+
263
+
264
+ = []
265
+
256
266
  for (const format of walletFormats) {
257
267
  const branches = _utils3.getFormatSupportedBranches.call(void 0, format)
258
268
  for (const branch of branches) {
@@ -284,6 +294,10 @@ var _utils3 = require('./utils');
284
294
  format
285
295
  })
286
296
  addressesToSubscribe.add(address)
297
+ addressBalanceChanges.push({
298
+ scriptPubkey: processorAddress.scriptPubkey,
299
+ balance: processorAddress.balance
300
+ })
287
301
  }
288
302
  addToAddressSubscribeCache(commonArgs.taskCache, addressesToSubscribe, {
289
303
  format,
@@ -291,6 +305,15 @@ var _utils3 = require('./utils');
291
305
  })
292
306
  }
293
307
  }
308
+
309
+ // Only emit address balance events after processing all initial addresses
310
+ // because we want to only propagate the wallet balance change event after
311
+ // initialization is complete.
312
+ emitter.emit(
313
+ _makeEngineEmitter.EngineEvent.ADDRESS_BALANCE_CHANGED,
314
+ pluginInfo.currencyInfo.currencyCode,
315
+ addressBalanceChanges
316
+ )
294
317
  }
295
318
 
296
319
  return {
@@ -525,6 +548,10 @@ var _utils3 = require('./utils');
525
548
 
526
549
 
527
550
 
551
+
552
+
553
+
554
+
528
555
 
529
556
 
530
557
 
@@ -669,7 +696,7 @@ const addToAddressTransactionCache = async (
669
696
  args
670
697
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
671
698
  ) => {
672
- const { taskCache, uri, serverStates } = args
699
+ const { pluginInfo, taskCache, uri, serverStates } = args
673
700
 
674
701
  const {
675
702
  addressSubscribeCache,
@@ -677,9 +704,17 @@ const addToAddressTransactionCache = async (
677
704
  rawUtxoCache,
678
705
  processorUtxoCache,
679
706
  addressTransactionCache,
680
- updateTransactionCache
707
+ updateTransactionCache,
708
+ updateTransactionSpecificCache
681
709
  } = taskCache
682
710
 
711
+ /**
712
+ * Some currencies require an additional blockbook payload 'getTransactionSpecific' in order
713
+ * to provide all relevant transaction data. Since this is currency-specific, we can limit
714
+ * the useage to currencies that require it.
715
+ **/
716
+ const needsTxSpecific = pluginInfo.engineInfo.txSpecificHandling != null
717
+
683
718
  const serverState = serverStates.getServerState(uri)
684
719
  if (serverState == null) return
685
720
 
@@ -799,6 +834,37 @@ const addToAddressTransactionCache = async (
799
834
  }
800
835
  }
801
836
 
837
+ // filled when transactions potentially changed (e.g. through new block notification)
838
+ if (Object.keys(updateTransactionSpecificCache).length > 0) {
839
+ let hasProcessedAtLeastOnce = false
840
+ for (const [txId, state] of Object.entries(
841
+ updateTransactionSpecificCache
842
+ )) {
843
+ if (!state.processing && serverStates.serverCanGetTx(uri, txId)) {
844
+ hasProcessedAtLeastOnce = true
845
+ state.processing = true
846
+ _utils.removeItem.call(void 0, updateTransactionSpecificCache, txId)
847
+ const updateTransactionSpecificTask = updateTransactionsSpecific({
848
+ ...args,
849
+ txId
850
+ })
851
+ // once resolved, add the txid to the server cache
852
+ updateTransactionSpecificTask.deferred.promise
853
+ .then(() => {
854
+ serverState.txids.add(txId)
855
+ })
856
+ .catch(err => {
857
+ updateTransactionSpecificCache[txId] = state
858
+ console.error(err)
859
+ args.log('error in updateTransactionSpecificCache:', err)
860
+ })
861
+ return updateTransactionSpecificTask
862
+ }
863
+ }
864
+ // This condition prevents infinite loops
865
+ if (hasProcessedAtLeastOnce) return true
866
+ }
867
+
802
868
  // filled when transactions potentially changed (e.g. through new block notification)
803
869
  if (Object.keys(updateTransactionCache).length > 0) {
804
870
  let hasProcessedAtLeastOnce = false
@@ -807,7 +873,11 @@ const addToAddressTransactionCache = async (
807
873
  hasProcessedAtLeastOnce = true
808
874
  state.processing = true
809
875
  _utils.removeItem.call(void 0, updateTransactionCache, txId)
810
- const updateTransactionTask = updateTransactions({ ...args, txId })
876
+ const updateTransactionTask = updateTransactions({
877
+ ...args,
878
+ txId,
879
+ needsTxSpecific
880
+ })
811
881
  // once resolved, add the txid to the server cache
812
882
  updateTransactionTask.deferred.promise
813
883
  .then(() => {
@@ -836,7 +906,8 @@ const addToAddressTransactionCache = async (
836
906
  const wsTask = await processAddressTransactions({
837
907
  ...args,
838
908
  addressTransactionState: state,
839
- address
909
+ address,
910
+ needsTxSpecific
840
911
  })
841
912
  wsTask.deferred.promise
842
913
  .then(() => {
@@ -856,11 +927,65 @@ const addToAddressTransactionCache = async (
856
927
 
857
928
 
858
929
 
859
- const updateTransactions = (
930
+ const updateTransactionsSpecific = (
860
931
  args
861
932
  ) => {
862
933
  const { emitter, walletTools, txId, pluginInfo, processor, taskCache } = args
863
934
  const deferred = new _Deferred2.default()
935
+ deferred.promise
936
+ .then(async (txResponse) => {
937
+ // Grab tx to update it
938
+ const txs = await processor.fetchTransactions({ txId })
939
+ let tx = txs[0]
940
+ if (tx == null) return
941
+
942
+ if (pluginInfo.engineInfo.txSpecificHandling != null) {
943
+ // Do coin-specific things to it
944
+ tx = pluginInfo.engineInfo.txSpecificHandling(tx, txResponse)
945
+ }
946
+
947
+ // Process and save new tx
948
+ const processedTx = await processor.saveTransaction({
949
+ tx
950
+ })
951
+
952
+ await exports.transactionChanged.call(void 0, {
953
+ emitter,
954
+ walletTools,
955
+ processor,
956
+ pluginInfo,
957
+ tx: processedTx
958
+ })
959
+ })
960
+ .catch(err => {
961
+ console.error(err)
962
+ args.log('error in updateTransactionsSpecific:', err)
963
+ taskCache.updateTransactionSpecificCache[txId] = { processing: false }
964
+ })
965
+ return {
966
+ ..._BlockBookAPI.transactionMessageSpecific.call(void 0, txId),
967
+ deferred
968
+ }
969
+ }
970
+
971
+
972
+
973
+
974
+
975
+
976
+ const updateTransactions = (
977
+ args
978
+ ) => {
979
+ const {
980
+ emitter,
981
+ walletTools,
982
+ txId,
983
+ needsTxSpecific,
984
+ pluginInfo,
985
+ processor,
986
+ taskCache
987
+ } = args
988
+ const deferred = new _Deferred2.default()
864
989
  deferred.promise
865
990
  .then(async (txResponse) => {
866
991
  // check if raw tx is still not confirmed, if so, don't change anything
@@ -885,6 +1010,7 @@ const updateTransactions = (
885
1010
  const processedTx = await processor.saveTransaction({
886
1011
  tx
887
1012
  })
1013
+
888
1014
  await exports.transactionChanged.call(void 0, {
889
1015
  emitter,
890
1016
  walletTools,
@@ -892,6 +1018,13 @@ const updateTransactions = (
892
1018
  pluginInfo,
893
1019
  tx: processedTx
894
1020
  })
1021
+
1022
+ if (needsTxSpecific) {
1023
+ // Add task to grab transactionSpecific payload
1024
+ taskCache.updateTransactionSpecificCache[txId] = {
1025
+ processing: false
1026
+ }
1027
+ }
895
1028
  })
896
1029
  .catch(err => {
897
1030
  console.error(err)
@@ -1002,6 +1135,7 @@ const internalGetFreshAddress = async (
1002
1135
 
1003
1136
 
1004
1137
 
1138
+
1005
1139
  const processAddressTransactions = async (
1006
1140
  args
1007
1141
  ) => {
@@ -1009,6 +1143,7 @@ const processAddressTransactions = async (
1009
1143
  address,
1010
1144
  addressTransactionState,
1011
1145
  emitter,
1146
+ needsTxSpecific,
1012
1147
  pluginInfo,
1013
1148
  processor,
1014
1149
  walletTools,
@@ -1055,6 +1190,13 @@ const processAddressTransactions = async (
1055
1190
  pluginInfo,
1056
1191
  tx: processedTx
1057
1192
  })
1193
+
1194
+ if (needsTxSpecific) {
1195
+ // Add task to grab transactionSpecific payload
1196
+ taskCache.updateTransactionSpecificCache[tx.txid] = {
1197
+ processing: false
1198
+ }
1199
+ }
1058
1200
  }
1059
1201
 
1060
1202
  // Halt on finishing the processing of address transaction until
@@ -1292,13 +1434,17 @@ const processProcessorUtxos = async (
1292
1434
  //
1293
1435
 
1294
1436
  // Address balance and emit address balance change event
1295
- const diff = _biggystring.sub.call(void 0, newBalance, oldBalance)
1296
- if (diff !== '0') {
1297
- log('balance changed:', { scriptPubkey, diff })
1437
+ if (newBalance !== oldBalance) {
1438
+ log('address balance changed:', { scriptPubkey, oldBalance, newBalance })
1298
1439
  emitter.emit(
1299
1440
  _makeEngineEmitter.EngineEvent.ADDRESS_BALANCE_CHANGED,
1300
1441
  currencyInfo.currencyCode,
1301
- diff
1442
+ [
1443
+ {
1444
+ scriptPubkey,
1445
+ balance: newBalance
1446
+ }
1447
+ ]
1302
1448
  )
1303
1449
 
1304
1450
  // Update balances for address that have this scriptPubkey
@@ -1,4 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _cleaners = require('cleaners');
2
+
3
+
2
4
 
3
5
 
4
6
 
@@ -52,6 +54,21 @@ const engineInfo = {
52
54
  standardFeeHigh: '200',
53
55
  standardFeeLowAmount: '20000000',
54
56
  standardFeeHighAmount: '981000000'
57
+ },
58
+ txSpecificHandling: (
59
+ tx,
60
+ txSpecific
61
+ ) => {
62
+ const asDashTransactionSpecific = _cleaners.asObject.call(void 0, {
63
+ instantlock: _cleaners.asOptional.call(void 0, _cleaners.asBoolean)
64
+ })
65
+ const cleanedTxSpecific = _cleaners.asMaybe.call(void 0, asDashTransactionSpecific)(txSpecific)
66
+
67
+ if (_optionalChain([cleanedTxSpecific, 'optionalAccess', _ => _.instantlock]) === true) {
68
+ tx.confirmations = 'confirmed'
69
+ }
70
+
71
+ return tx
55
72
  }
56
73
  }
57
74
 
@@ -8,6 +8,7 @@
8
8
 
9
9
 
10
10
 
11
+
11
12
  var _cleaners = require('cleaners');
12
13
 
13
14
 
@@ -211,6 +212,17 @@ var _cleaners = require('cleaners');
211
212
 
212
213
  const asTransactionResponse = exports.asBlockbookTransaction; exports.asTransactionResponse = asTransactionResponse
213
214
 
215
+ /**
216
+ * Get Transaction Specific
217
+ */
218
+ const transactionMessageSpecific = (
219
+ hash
220
+ ) => ({
221
+ method: 'getTransactionSpecific',
222
+ params: { txid: hash },
223
+ cleaner: exports.asBlockbookResponse.call(void 0, _cleaners.asUnknown)
224
+ }); exports.transactionMessageSpecific = transactionMessageSpecific
225
+
214
226
  /**
215
227
  * Send Transaction
216
228
  */
@@ -3,8 +3,14 @@ import { EdgeCurrencyEngineCallbacks, EdgeTransaction, EdgeTxidMap } from 'edge-
3
3
  import { EventEmitter } from 'events';
4
4
  import { SubscribeAddressResponse } from '../utxobased/network/BlockBookAPI';
5
5
  export declare interface EngineEmitter {
6
- emit: ((event: EngineEvent.TRANSACTIONS_CHANGED, transactions: EdgeTransaction[]) => boolean) & ((event: EngineEvent.ADDRESS_BALANCE_CHANGED, currencyCode: string, nativeDiff: string) => boolean) & ((event: EngineEvent.WALLET_BALANCE_CHANGED, currencyCode: string, nativeBalance: string) => boolean) & ((event: EngineEvent.BLOCK_HEIGHT_CHANGED, uri: string, blockHeight: number) => boolean) & ((event: EngineEvent.NEW_ADDRESS_TRANSACTION, uri: string, newTx: SubscribeAddressResponse) => boolean) & ((event: EngineEvent.ADDRESSES_CHECKED, progressRatio: number) => boolean) & ((event: EngineEvent.TXIDS_CHANGED, txids: EdgeTxidMap) => boolean);
7
- on: ((event: EngineEvent.TRANSACTIONS_CHANGED, listener: (transactions: EdgeTransaction[]) => Promise<void> | void) => this) & ((event: EngineEvent.ADDRESS_BALANCE_CHANGED, listener: (currencyCode: string, nativeDiff: string) => Promise<void> | void) => this) & ((event: EngineEvent.WALLET_BALANCE_CHANGED, listener: (currencyCode: string, nativeBalance: string) => Promise<void> | void) => this) & ((event: EngineEvent.BLOCK_HEIGHT_CHANGED, listener: (uri: string, blockHeight: number) => Promise<void> | void) => this) & ((event: EngineEvent.NEW_ADDRESS_TRANSACTION, listener: (uri: string, newTx: SubscribeAddressResponse) => Promise<void> | void) => this) & ((event: EngineEvent.ADDRESSES_CHECKED, listener: (progressRatio: number) => Promise<void> | void) => this) & ((event: EngineEvent.TXIDS_CHANGED, listener: (txids: EdgeTxidMap) => Promise<void> | void) => this);
6
+ emit: ((event: EngineEvent.TRANSACTIONS_CHANGED, transactions: EdgeTransaction[]) => boolean) & ((event: EngineEvent.ADDRESS_BALANCE_CHANGED, currencyCode: string, addressBalanceChanges: Array<{
7
+ scriptPubkey: string;
8
+ balance: string;
9
+ }>) => boolean) & ((event: EngineEvent.WALLET_BALANCE_CHANGED, currencyCode: string, nativeBalance: string) => boolean) & ((event: EngineEvent.BLOCK_HEIGHT_CHANGED, uri: string, blockHeight: number) => boolean) & ((event: EngineEvent.NEW_ADDRESS_TRANSACTION, uri: string, newTx: SubscribeAddressResponse) => boolean) & ((event: EngineEvent.ADDRESSES_CHECKED, progressRatio: number) => boolean) & ((event: EngineEvent.TXIDS_CHANGED, txids: EdgeTxidMap) => boolean);
10
+ on: ((event: EngineEvent.TRANSACTIONS_CHANGED, listener: (transactions: EdgeTransaction[]) => Promise<void> | void) => this) & ((event: EngineEvent.ADDRESS_BALANCE_CHANGED, listener: (currencyCode: string, addressBalanceChanges: Array<{
11
+ scriptPubkey: string;
12
+ balance: string;
13
+ }>) => Promise<void> | void) => this) & ((event: EngineEvent.WALLET_BALANCE_CHANGED, listener: (currencyCode: string, nativeBalance: string) => Promise<void> | void) => this) & ((event: EngineEvent.BLOCK_HEIGHT_CHANGED, listener: (uri: string, blockHeight: number) => Promise<void> | void) => this) & ((event: EngineEvent.NEW_ADDRESS_TRANSACTION, listener: (uri: string, newTx: SubscribeAddressResponse) => Promise<void> | void) => this) & ((event: EngineEvent.ADDRESSES_CHECKED, listener: (progressRatio: number) => Promise<void> | void) => this) & ((event: EngineEvent.TXIDS_CHANGED, listener: (txids: EdgeTxidMap) => Promise<void> | void) => this);
8
14
  }
9
15
  export declare class EngineEmitter extends EventEmitter {
10
16
  }
@@ -7,7 +7,8 @@ interface MetadataConfig {
7
7
  emitter: EngineEmitter;
8
8
  log: EdgeLog;
9
9
  }
10
- export interface Metadata extends LocalWalletMetadata {
10
+ export interface Metadata {
11
+ state: LocalWalletMetadata;
11
12
  clear: () => Promise<void>;
12
13
  }
13
14
  export declare const makeMetadata: (config: MetadataConfig) => Promise<Metadata>;
@@ -3,7 +3,7 @@ import { bip32 } from 'altcoin-js';
3
3
  import { Cleaner } from 'cleaners';
4
4
  import { Disklet } from 'disklet';
5
5
  import { EdgeCurrencyEngineOptions, EdgeCurrencyInfo, EdgeCurrencyTools, EdgeIo, EdgeParsedUri, EdgeWalletInfo } from 'edge-core-js/types';
6
- import { IUTXO } from '../utxobased/db/types';
6
+ import { IProcessorTransaction, IUTXO } from '../utxobased/db/types';
7
7
  import { ScriptTemplates } from '../utxobased/info/scriptTemplates/types';
8
8
  import { UtxoPicker } from '../utxobased/keymanager/utxopicker';
9
9
  import { EngineEmitter } from './makeEngineEmitter';
@@ -41,6 +41,7 @@ export interface EngineInfo {
41
41
  simpleFeeSettings: SimpleFeeSettings;
42
42
  scriptTemplates?: ScriptTemplates;
43
43
  asBlockbookAddress?: Cleaner<string>;
44
+ txSpecificHandling?: (tx: IProcessorTransaction, specialTx: unknown) => IProcessorTransaction;
44
45
  }
45
46
  /**
46
47
  * Coin Info
@@ -129,6 +130,9 @@ export interface EngineOptions extends EdgeCurrencyEngineOptions {
129
130
  export declare type LocalWalletMetadata = ReturnType<typeof asLocalWalletMetadata>;
130
131
  export declare const asLocalWalletMetadata: import("cleaners").ObjectCleaner<{
131
132
  balance: string;
133
+ addressBalances: {
134
+ [keys: string]: string;
135
+ };
132
136
  lastSeenBlockHeight: number;
133
137
  }>;
134
138
  export {};
@@ -28,6 +28,7 @@ export interface IProcessorTransaction {
28
28
  txid: string;
29
29
  hex: string;
30
30
  blockHeight: number;
31
+ confirmations?: 'confirmed' | 'unconfirmed' | 'dropped' | number;
31
32
  date: number;
32
33
  fees: string;
33
34
  inputs: ITransactionInput[];
@@ -52,12 +52,18 @@ interface TaskCache {
52
52
  readonly processorUtxoCache: ProcessorUtxoCache;
53
53
  readonly addressTransactionCache: AddressTransactionCache;
54
54
  readonly updateTransactionCache: UpdateTransactionCache;
55
+ readonly updateTransactionSpecificCache: UpdateTransactionSpecificCache;
55
56
  }
56
57
  interface UpdateTransactionCache {
57
58
  [key: string]: {
58
59
  processing: boolean;
59
60
  };
60
61
  }
62
+ interface UpdateTransactionSpecificCache {
63
+ [key: string]: {
64
+ processing: boolean;
65
+ };
66
+ }
61
67
  interface AddressSubscribeCache {
62
68
  [key: string]: {
63
69
  processing: boolean;
@@ -96,6 +96,10 @@ export declare const asAddressUtxosResponse: (asAddress?: Cleaner<string>) => Cl
96
96
  export declare const transactionMessage: (hash: string, asAddress?: Cleaner<string>) => BlockbookTask<TransactionResponse>;
97
97
  export declare type TransactionResponse = BlockbookTransaction;
98
98
  export declare const asTransactionResponse: (asAddress?: Cleaner<string>) => Cleaner<BlockbookTransaction>;
99
+ /**
100
+ * Get Transaction Specific
101
+ */
102
+ export declare const transactionMessageSpecific: (hash: string) => BlockbookTask<unknown>;
99
103
  /**
100
104
  * Send Transaction
101
105
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
5
5
  "repository": "https://github.com/EdgeApp/edge-currency-plugins",
6
6
  "license": "MIT",