edge-currency-plugins 1.3.7 → 2.0.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.
@@ -38,7 +38,7 @@ var _utils3 = require('./utils');
38
38
 
39
39
  const asCurrencyPrivateKey = _cleaners3.asPrivateKey.call(void 0, coinInfo.name, coinInfo.coinType)
40
40
  const wasCurrencyPrivateKey = _cleaners.uncleaner.call(void 0, asCurrencyPrivateKey)
41
- const asCurrencyNumbWalletInfo = _cleaners3.asNumbWalletInfo.call(void 0, pluginInfo)
41
+ const asCurrencySafeWalletInfo = _cleaners3.asSafeWalletInfo.call(void 0, pluginInfo)
42
42
 
43
43
  const fns = {
44
44
  async checkPublicKey(publicKeyData) {
@@ -102,9 +102,13 @@ var _utils3 = require('./utils');
102
102
  return _utils.validateMemo.call(void 0, memo)
103
103
  },
104
104
 
105
- async derivePublicKey(walletInfo) {
106
- const numbWalletInfo = asCurrencyNumbWalletInfo(walletInfo)
107
- return numbWalletInfo.keys.publicKey
105
+ async derivePublicKey(
106
+ unsafeWalletInfo
107
+ ) {
108
+ // Use the safety cleaner to derive the public keys from the
109
+ // unsafeWalletInfo which contains the private key.
110
+ const safeWalletInfo = asCurrencySafeWalletInfo(unsafeWalletInfo)
111
+ return safeWalletInfo.keys.publicKey
108
112
  },
109
113
 
110
114
  async parseUri(uri) {
@@ -14,7 +14,8 @@ var _disklet = require('disklet');
14
14
 
15
15
 
16
16
 
17
- var _types = require('edge-core-js/types');
17
+
18
+ var _edgecorejs = require('edge-core-js');
18
19
 
19
20
  var _filterUndefined = require('../../../util/filterUndefined');
20
21
  var _unixTime = require('../../../util/unixTime');
@@ -42,7 +43,11 @@ var _keymanager = require('../keymanager/keymanager');
42
43
  var _makeUtxoEngineState = require('./makeUtxoEngineState');
43
44
  var _makeUtxoWalletTools = require('./makeUtxoWalletTools');
44
45
  var _paymentRequest = require('./paymentRequest');
45
- var _types7 = require('./types');
46
+
47
+
48
+
49
+
50
+ var _types5 = require('./types');
46
51
  var _getOwnUtxosFromTx = require('./util/getOwnUtxosFromTx');
47
52
  var _utils = require('./utils');
48
53
 
@@ -53,7 +58,6 @@ var _utils = require('./utils');
53
58
  pluginInfo,
54
59
  pluginDisklet,
55
60
  // Rename to make it explicit that this is sensitive memory
56
- walletInfo: sensitiveWalletInfo,
57
61
  options,
58
62
  io,
59
63
  pluginState
@@ -65,7 +69,7 @@ var _utils = require('./utils');
65
69
  log
66
70
  } = options
67
71
  const { currencyInfo, engineInfo, coinInfo } = pluginInfo
68
- const userSettings = _types7.asUtxoUserSettings.call(void 0, options.userSettings)
72
+ const userSettings = _types5.asUtxoUserSettings.call(void 0, options.userSettings)
69
73
 
70
74
  // We should move the active server list to the engine state,
71
75
  // since multiple accounts can be logged in at once,
@@ -77,10 +81,12 @@ var _utils = require('./utils');
77
81
  })
78
82
 
79
83
  const asCurrencyPrivateKey = _cleaners3.asPrivateKey.call(void 0, coinInfo.name, coinInfo.coinType)
80
- // Private key may be missing for watch-only wallets
84
+ // Private key may be missing for read-only wallets
81
85
  const asMaybeCurrencyPrivateKey = _cleaners.asMaybe.call(void 0, asCurrencyPrivateKey)
82
- // This walletInfo is desensitized (numb) and should be passed around over the original walletInfo
83
- const walletInfo = _cleaners3.asNumbWalletInfo.call(void 0, pluginInfo)(sensitiveWalletInfo)
86
+
87
+ // This walletInfo will not contain private keys and should only contain the
88
+ // public keys and so can be passed around the plugin safely.
89
+ const walletInfo = _cleaners3.asSafeWalletInfo.call(void 0, pluginInfo)(config.walletInfo)
84
90
  const { privateKeyFormat, publicKey, walletFormats } = walletInfo.keys
85
91
 
86
92
  if (
@@ -120,7 +126,7 @@ var _utils = require('./utils');
120
126
  pluginState
121
127
  })
122
128
 
123
- const fns = {
129
+ const engine = {
124
130
  async startEngine() {
125
131
  emitter.emit(
126
132
  _makeEngineEmitter.EngineEvent.WALLET_BALANCE_CHANGED,
@@ -180,7 +186,7 @@ var _utils = require('./utils');
180
186
  },
181
187
 
182
188
  async changeUserSettings(userSettings) {
183
- await pluginState.updateServers(_types7.asUtxoUserSettings.call(void 0, userSettings))
189
+ await pluginState.updateServers(_types5.asUtxoUserSettings.call(void 0, userSettings))
184
190
  },
185
191
 
186
192
  async disableTokens(_tokens) {
@@ -208,8 +214,8 @@ var _utils = require('./utils');
208
214
  return await Promise.resolve(undefined)
209
215
  },
210
216
 
211
- getDisplayPrivateSeed() {
212
- const privateKey = asMaybeCurrencyPrivateKey(sensitiveWalletInfo.keys)
217
+ getDisplayPrivateSeed(privateKeys) {
218
+ const privateKey = asMaybeCurrencyPrivateKey(privateKeys)
213
219
  if (privateKey == null) return null
214
220
  return privateKey.format === 'bip32'
215
221
  ? Buffer.from(privateKey.seed, 'base64').toString('hex')
@@ -279,11 +285,10 @@ var _utils = require('./utils');
279
285
  return addressData.used
280
286
  },
281
287
 
282
- async makeSpend(
283
- edgeSpendInfo,
284
- options
285
- ) {
288
+ async makeSpend(edgeSpendInfo) {
286
289
  const { spendTargets } = edgeSpendInfo
290
+ const txOptions =
291
+ _optionalChain([edgeSpendInfo, 'access', _5 => _5.otherParams, 'optionalAccess', _6 => _6.txOptions])
287
292
  const { outputSort = 'bip69', utxoSourceAddress, forceChangeAddress } =
288
293
  _nullishCoalesce(edgeSpendInfo.otherParams, () => ( {}))
289
294
 
@@ -292,7 +297,7 @@ var _utils = require('./utils');
292
297
  utxoScriptPubkey = walletTools.addressToScriptPubkey(utxoSourceAddress)
293
298
  }
294
299
 
295
- if (_optionalChain([options, 'optionalAccess', _5 => _5.CPFP]) == null && spendTargets.length < 1) {
300
+ if (_optionalChain([txOptions, 'optionalAccess', _7 => _7.CPFP]) == null && spendTargets.length < 1) {
296
301
  throw new Error('Need to provide Spend Targets')
297
302
  }
298
303
  // Calculate the total amount to send
@@ -301,7 +306,7 @@ var _utils = require('./utils');
301
306
  '0'
302
307
  )
303
308
  const utxos =
304
- await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _6 => _6.utxos]), async () => (
309
+ await _asyncNullishCoalesce(await _asyncOptionalChain([txOptions, 'optionalAccess', async _8 => _8.utxos]), async () => (
305
310
  _filterUndefined.filterUndefined.call(void 0,
306
311
  (await processor.fetchUtxos({
307
312
  scriptPubkey: utxoScriptPubkey,
@@ -313,7 +318,7 @@ var _utils = require('./utils');
313
318
  bs.gt(totalAmountToSend, `${_utils.sumUtxos.call(void 0, utxos)}`) ||
314
319
  utxos.length === 0
315
320
  ) {
316
- throw new (0, _types.InsufficientFundsError)(currencyInfo.currencyCode)
321
+ throw new (0, _edgecorejs.InsufficientFundsError)(currencyInfo.currencyCode)
317
322
  }
318
323
 
319
324
  let targets = []
@@ -327,7 +332,7 @@ var _utils = require('./utils');
327
332
  }
328
333
 
329
334
  // if script exists construct address from script
330
- if (_optionalChain([target, 'access', _7 => _7.otherParams, 'optionalAccess', _8 => _8.script]) != null) {
335
+ if (_optionalChain([target, 'access', _9 => _9.otherParams, 'optionalAccess', _10 => _10.script]) != null) {
331
336
  const { script } = target.otherParams
332
337
  if (script.type === 'replayProtection') {
333
338
  // construct a replay protection p2sh address
@@ -373,7 +378,7 @@ var _utils = require('./utils');
373
378
  freshAddress.segwitAddress)), () => (
374
379
  freshAddress.publicAddress))
375
380
 
376
- const setRBF = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.setRBF]), () => ( false))
381
+ const setRBF = _nullishCoalesce(_optionalChain([txOptions, 'optionalAccess', _11 => _11.setRBF]), () => ( false))
377
382
  const rbfTxid = edgeSpendInfo.rbfTxid
378
383
  let maxUtxo
379
384
  let feeRate = parseInt(await fees.getRate(edgeSpendInfo))
@@ -395,9 +400,9 @@ var _utils = require('./utils');
395
400
  )
396
401
  }
397
402
  }
398
- if (_optionalChain([options, 'optionalAccess', _10 => _10.CPFP]) != null) {
403
+ if (_optionalChain([txOptions, 'optionalAccess', _12 => _12.CPFP]) != null) {
399
404
  const [childTx] = await processor.fetchTransactions({
400
- txId: _optionalChain([options, 'optionalAccess', _11 => _11.CPFP])
405
+ txId: _optionalChain([txOptions, 'optionalAccess', _13 => _13.CPFP])
401
406
  })
402
407
  if (childTx == null) throw new Error('transaction not found')
403
408
  const utxos = []
@@ -411,7 +416,7 @@ var _utils = require('./utils');
411
416
  }
412
417
  log.warn(`spend: Using fee rate ${feeRate} sat/B`)
413
418
  const subtractFee =
414
- _optionalChain([options, 'optionalAccess', _12 => _12.subtractFee]) != null ? options.subtractFee : false
419
+ _optionalChain([txOptions, 'optionalAccess', _14 => _14.subtractFee]) != null ? txOptions.subtractFee : false
415
420
  const tx = _keymanager.makeTx.call(void 0, {
416
421
  utxos,
417
422
  forceUseUtxo: maxUtxo != null ? [maxUtxo] : [],
@@ -480,7 +485,7 @@ var _utils = require('./utils');
480
485
 
481
486
  async resyncBlockchain() {
482
487
  // Stops the engine
483
- await fns.killEngine()
488
+ await engine.killEngine()
484
489
 
485
490
  // Clear cache and state
486
491
  await processor.clearAll()
@@ -492,7 +497,7 @@ var _utils = require('./utils');
492
497
  await pluginState.refreshServers()
493
498
 
494
499
  // Restart the engine
495
- await fns.startEngine()
500
+ await engine.startEngine()
496
501
  },
497
502
 
498
503
  async saveTx(edgeTx) {
@@ -507,7 +512,7 @@ var _utils = require('./utils');
507
512
  })
508
513
  await processor.saveTransaction({
509
514
  tx,
510
- scriptPubkeys: _optionalChain([edgeTx, 'access', _13 => _13.otherParams, 'optionalAccess', _14 => _14.ourScriptPubkeys])
515
+ scriptPubkeys: _optionalChain([edgeTx, 'access', _15 => _15.otherParams, 'optionalAccess', _16 => _16.ourScriptPubkeys])
511
516
  })
512
517
 
513
518
  /*
@@ -517,7 +522,42 @@ var _utils = require('./utils');
517
522
  await engineState.processUtxos(ownUtxos)
518
523
  },
519
524
 
520
- async signTx(transaction) {
525
+ async signMessage(
526
+ message,
527
+ privateKeys,
528
+ opts
529
+ ) {
530
+ const otherParams = _types5.asUtxoSignMessageOtherParams.call(void 0, opts.otherParams)
531
+ const { publicAddress } = otherParams
532
+ const scriptPubkey = walletTools.addressToScriptPubkey(publicAddress)
533
+ const processorAddress = await processor.fetchAddress(scriptPubkey)
534
+ if (_optionalChain([processorAddress, 'optionalAccess', _17 => _17.path]) == null) {
535
+ throw new Error('Missing address to sign with')
536
+ }
537
+ const privateKey = asMaybeCurrencyPrivateKey(privateKeys)
538
+
539
+ if (privateKey == null)
540
+ throw new Error('Cannot sign a message for a read-only wallet')
541
+
542
+ // Derive the xprivs on the fly, since we do not persist them
543
+ const xprivKeys = await _utils.fetchOrDeriveXprivFromKeys.call(void 0, {
544
+ privateKey,
545
+ walletLocalEncryptedDisklet,
546
+ coin: coinInfo.name
547
+ })
548
+
549
+ const signature = await walletTools.signMessageBase64({
550
+ path: _optionalChain([processorAddress, 'optionalAccess', _18 => _18.path]),
551
+ message,
552
+ xprivKeys
553
+ })
554
+ return signature
555
+ },
556
+
557
+ async signTx(
558
+ transaction,
559
+ privateKeys
560
+ ) {
521
561
  const otherParams = transaction.otherParams
522
562
  if (otherParams == null) throw new Error('Invalid transaction data')
523
563
 
@@ -525,7 +565,7 @@ var _utils = require('./utils');
525
565
  if (psbt == null || edgeSpendInfo == null)
526
566
  throw new Error('Invalid transaction data')
527
567
 
528
- const privateKey = asMaybeCurrencyPrivateKey(sensitiveWalletInfo.keys)
568
+ const privateKey = asMaybeCurrencyPrivateKey(privateKeys)
529
569
 
530
570
  if (privateKey == null)
531
571
  throw new Error('Cannot sign a transaction for a read-only wallet')
@@ -587,7 +627,7 @@ var _utils = require('./utils');
587
627
  transaction.signedTx = signedTx.hex
588
628
 
589
629
  const { paymentProtocolInfo } =
590
- _nullishCoalesce(_optionalChain([transaction, 'access', _15 => _15.otherParams, 'optionalAccess', _16 => _16.edgeSpendInfo, 'optionalAccess', _17 => _17.otherParams]), () => ( {}))
630
+ _nullishCoalesce(_optionalChain([transaction, 'access', _19 => _19.otherParams, 'optionalAccess', _20 => _20.edgeSpendInfo, 'optionalAccess', _21 => _21.otherParams]), () => ( {}))
591
631
  if (paymentProtocolInfo != null) {
592
632
  const payment = _paymentRequest.createPayment.call(void 0,
593
633
  transaction.signedTx,
@@ -672,12 +712,15 @@ var _utils = require('./utils');
672
712
  }
673
713
  const destAddress = await this.getFreshAddress({})
674
714
  const nativeAmount = tmpMetadata.state.balance
675
- const options = { utxos: tmpUtxos, subtractFee: true }
715
+ const txOptions = { utxos: tmpUtxos, subtractFee: true }
676
716
  spendInfo.spendTargets = [
677
717
  { publicAddress: destAddress.publicAddress, nativeAmount }
678
718
  ]
679
- // @ts-expect-error TODO: TheCharlatan - add option to makeSpend declaration in edge-core-js
680
- const tx = await this.makeSpend(spendInfo, options)
719
+ spendInfo.otherParams = {
720
+ ...spendInfo.otherParams,
721
+ txOptions
722
+ }
723
+ const tx = await this.makeSpend(spendInfo)
681
724
  success(tx)
682
725
  } catch (e) {
683
726
  failure(e)
@@ -711,37 +754,8 @@ var _utils = require('./utils');
711
754
  return await end
712
755
  },
713
756
 
714
- otherMethods: {
715
- signMessageBase64: async (
716
- message,
717
- address
718
- ) => {
719
- const scriptPubkey = walletTools.addressToScriptPubkey(address)
720
- const processorAddress = await processor.fetchAddress(scriptPubkey)
721
- if (_optionalChain([processorAddress, 'optionalAccess', _18 => _18.path]) == null) {
722
- throw new Error('Missing address to sign with')
723
- }
724
- const privateKey = asMaybeCurrencyPrivateKey(sensitiveWalletInfo.keys)
725
-
726
- if (privateKey == null)
727
- throw new Error('Cannot sign a message for a read-only wallet')
728
-
729
- // Derive the xprivs on the fly, since we do not persist them
730
- const xprivKeys = await _utils.fetchOrDeriveXprivFromKeys.call(void 0, {
731
- privateKey,
732
- walletLocalEncryptedDisklet,
733
- coin: coinInfo.name
734
- })
735
-
736
- const signature = await walletTools.signMessageBase64({
737
- path: _optionalChain([processorAddress, 'optionalAccess', _19 => _19.path]),
738
- message,
739
- xprivKeys
740
- })
741
- return signature
742
- }
743
- }
757
+ otherMethods: {}
744
758
  }
745
759
 
746
- return fns
760
+ return engine
747
761
  } exports.makeUtxoEngine = makeUtxoEngine;
@@ -19,3 +19,10 @@
19
19
 
20
20
 
21
21
 
22
+
23
+
24
+
25
+
26
+ const asUtxoSignMessageOtherParams = _cleaners.asObject.call(void 0, {
27
+ publicAddress: _cleaners.asString
28
+ }); exports.asUtxoSignMessageOtherParams = asUtxoSignMessageOtherParams
@@ -52,14 +52,6 @@ var _keymanager = require('../keymanager/keymanager');
52
52
  return result
53
53
  }; exports.validateMemo = validateMemo
54
54
 
55
- const getAddressTypeFromKeys = (
56
- privateKey
57
- ) => {
58
- return exports.getAddressTypeFromPurposeType.call(void 0,
59
- exports.currencyFormatToPurposeType.call(void 0, privateKey.format)
60
- )
61
- }; exports.getAddressTypeFromKeys = getAddressTypeFromKeys
62
-
63
55
  const getAddressTypeFromPurposeType = (
64
56
  purpose
65
57
  ) => {
@@ -239,32 +231,22 @@ var _keymanager = require('../keymanager/keymanager');
239
231
  ) => {
240
232
  const { engineInfo, privateKey, coin } = args
241
233
  const xpubs = {}
242
- for (const format of _cleaners.getSupportedFormats.call(void 0,
243
- engineInfo,
244
- args.privateKey.format
245
- )) {
246
- xpubs[format] = exports.deriveXpub.call(void 0, {
247
- privateKey,
234
+ for (const format of _cleaners.getSupportedFormats.call(void 0, engineInfo, privateKey.format)) {
235
+ const xpriv = exports.deriveXprivFromKeys.call(void 0, {
248
236
  coin,
249
- type: exports.currencyFormatToPurposeType.call(void 0, format)
237
+ privateKey
238
+ })[format]
239
+ if (xpriv == null)
240
+ throw new Error('Cannot derive xpub: no private key exists')
241
+ xpubs[format] = _keymanager.xprivToXPub.call(void 0, {
242
+ coin,
243
+ type: exports.currencyFormatToPurposeType.call(void 0, format),
244
+ xpriv
250
245
  })
251
246
  }
252
247
  return xpubs
253
248
  }; exports.deriveXpubsFromKeys = deriveXpubsFromKeys
254
249
 
255
- const deriveXpub = (args
256
-
257
-
258
-
259
- ) => {
260
- const xpriv = exports.deriveXprivFromKeys.call(void 0, args)[
261
- exports.getCurrencyFormatFromPurposeType.call(void 0, args.type)
262
- ]
263
- if (xpriv == null)
264
- throw new Error('Cannot derive xpub: no private key exists')
265
- return _keymanager.xprivToXPub.call(void 0, { ...args, xpriv })
266
- }; exports.deriveXpub = deriveXpub
267
-
268
250
  const parsePathname = (args
269
251
 
270
252
 
@@ -27,6 +27,10 @@ const asOptionalPrivateKeyFormat = _cleaners.asOptional.call(void 0, asPrivateKe
27
27
 
28
28
  /**
29
29
  * A cleaner for the private key format following the key-formats specification.
30
+ * It _includes_ the private key.
31
+ *
32
+ * **It is not considered safe memory, and it should be deallocated
33
+ * (thrown away) after use**.
30
34
  *
31
35
  * (spec: https://github.com/EdgeApp/edge-core-js/blob/master/docs/key-formats.md)
32
36
  */
@@ -123,9 +127,12 @@ const asOptionalPrivateKeyFormat = _cleaners.asOptional.call(void 0, asPrivateKe
123
127
  }; exports.inferPrivateKeyFormat = inferPrivateKeyFormat
124
128
 
125
129
  /**
126
- * A cleaner that desensitizes the walletInfo object, excluding sensitive
130
+ * A cleaner that desensitizes an unsafeWalletInfo object, excluding sensitive
127
131
  * keys (seed/mnemonic, sync key, data key, etc). By using this object type
128
- * internally within the plugin, we can minimize risk of leaking sensitive data.
132
+ * internally within the plugin, we can minimize risk of leaking sensitive data
133
+ * when deriving public keys from walletInfo which only contains private keys.
134
+ * It may also be used on a safeWalletInfo object which only contains the
135
+ * wallet's public keys.
129
136
  *
130
137
  * It also includes internal derived data (publicKey, format, walletFormats, etc).
131
138
  * This derived data is to be used internally within the plugin and saved to disk (publicKey).
@@ -147,7 +154,7 @@ const asOptionalPrivateKeyFormat = _cleaners.asOptional.call(void 0, asPrivateKe
147
154
 
148
155
 
149
156
 
150
- const asNumbWalletInfo = (
157
+ const asSafeWalletInfo = (
151
158
  pluginInfo
152
159
  ) => {
153
160
  return (walletInfo) => {
@@ -209,4 +216,4 @@ const asOptionalPrivateKeyFormat = _cleaners.asOptional.call(void 0, asPrivateKe
209
216
  // If we get here, nothing matched:
210
217
  throw new Error('Either a public or private key are required')
211
218
  }
212
- }; exports.asNumbWalletInfo = asNumbWalletInfo
219
+ }; exports.asSafeWalletInfo = asSafeWalletInfo
@@ -2,7 +2,7 @@ import { EdgeLog, EdgeTransaction } from 'edge-core-js/types';
2
2
  import { EngineEmitter } from '../../plugin/makeEngineEmitter';
3
3
  import { PluginState } from '../../plugin/pluginState';
4
4
  import { PluginInfo } from '../../plugin/types';
5
- import { NumbWalletInfo } from '../keymanager/cleaners';
5
+ import { SafeWalletInfo } from '../keymanager/cleaners';
6
6
  import { BlockBook } from '../network/BlockBook';
7
7
  import Deferred from '../network/Deferred';
8
8
  import { WsTask } from '../network/Socket';
@@ -18,7 +18,7 @@ interface ServerStateConfig {
18
18
  log: EdgeLog;
19
19
  pluginInfo: PluginInfo;
20
20
  pluginState: PluginState;
21
- walletInfo: NumbWalletInfo;
21
+ walletInfo: SafeWalletInfo;
22
22
  }
23
23
  export interface ServerStates {
24
24
  setPickNextTaskCB: (callback: (uri: string) => Promise<boolean | WsTask<any> | undefined>) => void;
@@ -1,3 +1,3 @@
1
- import { EdgeCurrencyEngine } from 'edge-core-js/types';
1
+ import { EdgeCurrencyEngine } from 'edge-core-js';
2
2
  import { EngineConfig } from '../../plugin/types';
3
3
  export declare function makeUtxoEngine(config: EngineConfig): Promise<EdgeCurrencyEngine>;
@@ -4,7 +4,7 @@ import { PluginState } from '../../plugin/pluginState';
4
4
  import { ChangePath, CurrencyFormat, EngineConfig, PluginInfo } from '../../plugin/types';
5
5
  import { Processor } from '../db/makeProcessor';
6
6
  import { IAddress, IProcessorTransaction, IUTXO } from '../db/types';
7
- import { NumbWalletInfo } from '../keymanager/cleaners';
7
+ import { SafeWalletInfo } from '../keymanager/cleaners';
8
8
  import { BlockbookAccountUtxo } from '../network/BlockBookAPI';
9
9
  import { WsTask } from '../network/Socket';
10
10
  import AwaitLock from './await-lock';
@@ -29,13 +29,13 @@ export interface UtxoEngineState {
29
29
  }
30
30
  export interface UtxoEngineStateConfig extends EngineConfig {
31
31
  walletTools: UTXOPluginWalletTools;
32
- walletInfo: NumbWalletInfo;
32
+ walletInfo: SafeWalletInfo;
33
33
  processor: Processor;
34
34
  }
35
35
  export declare function makeUtxoEngineState(config: UtxoEngineStateConfig): UtxoEngineState;
36
36
  interface CommonArgs {
37
37
  pluginInfo: PluginInfo;
38
- walletInfo: NumbWalletInfo;
38
+ walletInfo: SafeWalletInfo;
39
39
  walletTools: UTXOPluginWalletTools;
40
40
  processor: Processor;
41
41
  emitter: EngineEmitter;
@@ -15,3 +15,7 @@ export interface UtxoTxOtherParams {
15
15
  edgeSpendInfo?: EdgeSpendInfo;
16
16
  ourScriptPubkeys: string[];
17
17
  }
18
+ export declare type UtxoSignMessageOtherParams = ReturnType<typeof asUtxoSignMessageOtherParams>;
19
+ export declare const asUtxoSignMessageOtherParams: import("cleaners").ObjectCleaner<{
20
+ publicAddress: string;
21
+ }>;
@@ -7,7 +7,6 @@ import { PrivateKey } from '../keymanager/cleaners';
7
7
  import { AddressTypeEnum, BIP43PurposeTypeEnum, ScriptTypeEnum } from '../keymanager/keymanager';
8
8
  export declare const getCurrencyFormatFromPurposeType: (purpose: BIP43PurposeTypeEnum) => CurrencyFormat;
9
9
  export declare const validateMemo: (memo: string) => EdgeMemoRules;
10
- export declare const getAddressTypeFromKeys: (privateKey: PrivateKey) => AddressTypeEnum;
11
10
  export declare const getAddressTypeFromPurposeType: (purpose: BIP43PurposeTypeEnum) => AddressTypeEnum;
12
11
  export declare const getScriptTypeFromPurposeType: (purpose: BIP43PurposeTypeEnum) => ScriptTypeEnum;
13
12
  export declare const validScriptPubkeyFromAddress: (args: {
@@ -53,11 +52,6 @@ export declare const deriveXpubsFromKeys: (args: {
53
52
  privateKey: PrivateKey;
54
53
  coin: string;
55
54
  }) => CurrencyFormatKeys;
56
- export declare const deriveXpub: (args: {
57
- privateKey: PrivateKey;
58
- coin: string;
59
- type: BIP43PurposeTypeEnum;
60
- }) => string;
61
55
  export declare const parsePathname: (args: {
62
56
  pathname: string;
63
57
  coin: string;
@@ -4,6 +4,10 @@ declare type PrivateKeyFormat = ReturnType<typeof asPrivateKeyFormat>;
4
4
  declare const asPrivateKeyFormat: Cleaner<"bip32" | "bip44" | "bip49">;
5
5
  /**
6
6
  * A cleaner for the private key format following the key-formats specification.
7
+ * It _includes_ the private key.
8
+ *
9
+ * **It is not considered safe memory, and it should be deallocated
10
+ * (thrown away) after use**.
7
11
  *
8
12
  * (spec: https://github.com/EdgeApp/edge-core-js/blob/master/docs/key-formats.md)
9
13
  */
@@ -35,9 +39,12 @@ export declare const getSupportedFormats: (engineInfo: EngineInfo, privateKeyFor
35
39
  */
36
40
  export declare const inferPrivateKeyFormat: (publicKey: PublicKey) => PrivateKeyFormat;
37
41
  /**
38
- * A cleaner that desensitizes the walletInfo object, excluding sensitive
42
+ * A cleaner that desensitizes an unsafeWalletInfo object, excluding sensitive
39
43
  * keys (seed/mnemonic, sync key, data key, etc). By using this object type
40
- * internally within the plugin, we can minimize risk of leaking sensitive data.
44
+ * internally within the plugin, we can minimize risk of leaking sensitive data
45
+ * when deriving public keys from walletInfo which only contains private keys.
46
+ * It may also be used on a safeWalletInfo object which only contains the
47
+ * wallet's public keys.
41
48
  *
42
49
  * It also includes internal derived data (publicKey, format, walletFormats, etc).
43
50
  * This derived data is to be used internally within the plugin and saved to disk (publicKey).
@@ -49,7 +56,7 @@ export declare const inferPrivateKeyFormat: (publicKey: PublicKey) => PrivateKey
49
56
  * useful for determining the "kind of wallet", or more precisely how the public
50
57
  * key (xpubs) formats were derived.
51
58
  */
52
- export interface NumbWalletInfo {
59
+ export interface SafeWalletInfo {
53
60
  id: string;
54
61
  type: string;
55
62
  keys: {
@@ -59,5 +66,5 @@ export interface NumbWalletInfo {
59
66
  walletFormats: CurrencyFormat[];
60
67
  };
61
68
  }
62
- export declare const asNumbWalletInfo: (pluginInfo: PluginInfo) => Cleaner<NumbWalletInfo>;
69
+ export declare const asSafeWalletInfo: (pluginInfo: PluginInfo) => Cleaner<SafeWalletInfo>;
63
70
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "1.3.7",
3
+ "version": "2.0.1",
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",
@@ -48,7 +48,7 @@
48
48
  "bs58smartcheck": "^2.0.4",
49
49
  "cleaners": "^0.3.12",
50
50
  "disklet": "^0.4.5",
51
- "edge-core-js": "^0.19.37",
51
+ "edge-core-js": "^0.19.48",
52
52
  "edge-sync-client": "^0.2.7",
53
53
  "memlet": "^0.1.7",
54
54
  "uri-js": "^4.4.0",