edge-currency-plugins 3.0.1 → 3.1.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 (38) hide show
  1. package/README.md +10 -0
  2. package/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +35 -35
  3. package/lib/common/plugin/CurrencyTools.js +4 -4
  4. package/lib/common/plugin/types.js +154 -0
  5. package/lib/common/plugin/utils.js +2 -3
  6. package/lib/common/utxobased/db/Models/ProcessorTransaction.js +1 -0
  7. package/lib/common/utxobased/db/types.js +4 -0
  8. package/lib/common/utxobased/engine/UtxoEngine.js +14 -14
  9. package/lib/common/utxobased/engine/UtxoEngineState.js +2 -1
  10. package/lib/common/utxobased/engine/types.js +1 -0
  11. package/lib/common/utxobased/info/badcoin.js +0 -1
  12. package/lib/common/utxobased/info/bitcoin.js +0 -1
  13. package/lib/common/utxobased/info/bitcoincash.js +0 -1
  14. package/lib/common/utxobased/info/bitcoincashtestnet.js +0 -1
  15. package/lib/common/utxobased/info/bitcoingold.js +0 -1
  16. package/lib/common/utxobased/info/bitcoingoldtestnet.js +0 -1
  17. package/lib/common/utxobased/info/bitcoinsv.js +0 -1
  18. package/lib/common/utxobased/info/bitcointestnet.js +0 -1
  19. package/lib/common/utxobased/info/dash.js +0 -1
  20. package/lib/common/utxobased/info/digibyte.js +0 -1
  21. package/lib/common/utxobased/info/dogecoin.js +0 -1
  22. package/lib/common/utxobased/info/eboost.js +0 -1
  23. package/lib/common/utxobased/info/feathercoin.js +0 -1
  24. package/lib/common/utxobased/info/groestlcoin.js +0 -1
  25. package/lib/common/utxobased/info/litecoin.js +0 -1
  26. package/lib/common/utxobased/info/qtum.js +0 -1
  27. package/lib/common/utxobased/info/ravencoin.js +0 -1
  28. package/lib/common/utxobased/info/smartcash.js +0 -1
  29. package/lib/common/utxobased/info/ufo.js +0 -1
  30. package/lib/common/utxobased/info/vertcoin.js +0 -1
  31. package/lib/common/utxobased/info/zcoin.js +0 -1
  32. package/lib/common/utxobased/keymanager/cleaners.js +2 -2
  33. package/lib/common/utxobased/network/blockbookApi.js +8 -2
  34. package/lib/src/common/plugin/types.d.ts +141 -2
  35. package/lib/src/common/utxobased/db/types.d.ts +7 -3
  36. package/lib/src/common/utxobased/keymanager/utxopicker/types.d.ts +1 -1
  37. package/lib/src/common/utxobased/network/blockbookApi.d.ts +1 -1
  38. package/package.json +2 -2
@@ -63,8 +63,8 @@ var _utils3 = require('./utils');
63
63
  const privateKey = {
64
64
  imported: false,
65
65
  seed: mnemonic,
66
- format: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _ => _.format]), () => ( _optionalChain([engineInfo, 'access', _2 => _2.formats, 'optionalAccess', _3 => _3[0]]))), () => ( 'bip44')),
67
- coinType: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _4 => _4.coinType]), () => ( coinInfo.coinType)), () => ( 0))
66
+ format: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _ => _.format]), () => ( engineInfo.formats[0])), () => ( 'bip44')),
67
+ coinType: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _2 => _2.coinType]), () => ( coinInfo.coinType)), () => ( 0))
68
68
  }
69
69
 
70
70
  return wasCurrencyPrivateKey(privateKey)
@@ -90,8 +90,8 @@ var _utils3 = require('./utils');
90
90
  const privateKey = {
91
91
  imported: true,
92
92
  seed: entropy,
93
- format: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _5 => _5.format]), () => ( _optionalChain([engineInfo, 'access', _6 => _6.formats, 'optionalAccess', _7 => _7[0]]))), () => ( 'bip44')),
94
- coinType: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _8 => _8.coinType]), () => ( coinInfo.coinType)), () => ( 0))
93
+ format: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _3 => _3.format]), () => ( _optionalChain([engineInfo, 'access', _4 => _4.formats, 'optionalAccess', _5 => _5[0]]))), () => ( 'bip44')),
94
+ coinType: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess', _6 => _6.coinType]), () => ( coinInfo.coinType)), () => ( 0))
95
95
  }
96
96
 
97
97
  return wasCurrencyPrivateKey(privateKey)
@@ -1,9 +1,8 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _all = require('../utxobased/info/all');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _all = require('../utxobased/info/all');
2
2
 
3
3
  const getFormatsForNetwork = (coinName) => {
4
4
  for (const plugin of _all.all) {
5
- if (plugin.coinInfo.name === coinName)
6
- return _nullishCoalesce(plugin.engineInfo.formats, () => ( []))
5
+ if (plugin.coinInfo.name === coinName) return plugin.engineInfo.formats
7
6
  }
8
7
  return []
9
8
  }; exports.getFormatsForNetwork = getFormatsForNetwork
@@ -24,6 +24,7 @@ var _bnjs = require('bn.js'); var _bnjs2 = _interopRequireDefault(_bnjs);
24
24
  const inputs = otherParams.psbt.inputs.map((input, n) => ({
25
25
  amount: input.value.toString(),
26
26
  scriptPubkey: Buffer.from(input.scriptPubkey).toString('hex'), // [1]
27
+ sequence: input.sequence,
27
28
  n,
28
29
  txId: Buffer.from(input.hash).reverse().toString('hex'), // [1]
29
30
  outputIndex: input.index
@@ -74,6 +74,10 @@ var _keymanager = require('../keymanager/keymanager');
74
74
 
75
75
 
76
76
 
77
+
78
+
79
+
80
+
77
81
 
78
82
 
79
83
 
@@ -102,10 +102,7 @@ var _UtxoWalletTools = require('./UtxoWalletTools');
102
102
  const walletInfo = _cleaners3.asSafeWalletInfo.call(void 0, pluginInfo)(config.walletInfo)
103
103
  const { privateKeyFormat, publicKey, walletFormats } = walletInfo.keys
104
104
 
105
- if (
106
- engineInfo.formats == null ||
107
- !engineInfo.formats.includes(privateKeyFormat)
108
- ) {
105
+ if (!engineInfo.formats.includes(privateKeyFormat)) {
109
106
  const message = `Wallet format is not supported: ${privateKeyFormat}`
110
107
  log.error(message)
111
108
  throw new Error(message)
@@ -155,8 +152,12 @@ var _UtxoWalletTools = require('./UtxoWalletTools');
155
152
  })
156
153
 
157
154
  // Transaction checks:
158
- // The transaction must be found and not confirmed or dropped.
155
+ // Must be found
159
156
  if (replacedTx == null) return null
157
+ // Must have at least one input with the sequence enabling RBF policy
158
+ if (replacedTx.inputs.every(input => input.sequence > 0xfffffffd))
159
+ return null
160
+ // Must not be confirmed or dropped.
160
161
  if (replacedTx.blockHeight !== 0) return null
161
162
 
162
163
  // Double the fee used for the RBF transaction:
@@ -616,6 +617,13 @@ var _UtxoWalletTools = require('./UtxoWalletTools');
616
617
  targets = []
617
618
  }
618
619
 
620
+ // Determine whether the transaction should enable RBF given that the
621
+ // currency supports RBF.
622
+ const enableRbf =
623
+ currencyInfo.canReplaceByFee === true
624
+ ? _nullishCoalesce(_nullishCoalesce(edgeSpendInfo.enableRbf, () => ( spendInfoOtherParams.enableRbf)), () => ( true))
625
+ : false
626
+
619
627
  log.warn(`spend: Using fee rate ${feeRate} sat/B`)
620
628
  const subtractFee =
621
629
  txOptions.subtractFee != null ? txOptions.subtractFee : false
@@ -627,10 +635,7 @@ var _UtxoWalletTools = require('./UtxoWalletTools');
627
635
  feeRate,
628
636
  coin: coinInfo.name,
629
637
  currencyCode: currencyInfo.currencyCode,
630
- enableRbf:
631
- _nullishCoalesce(_nullishCoalesce(spendInfoOtherParams.enableRbf, () => (
632
- currencyInfo.canReplaceByFee)), () => (
633
- false)),
638
+ enableRbf,
634
639
  freshChangeAddress,
635
640
  subtractFee,
636
641
  log,
@@ -900,11 +905,6 @@ var _UtxoWalletTools = require('./UtxoWalletTools');
900
905
 
901
906
  // The temporary wallet info should include all formats for the currency
902
907
  const allFormats = engineInfo.formats
903
- if (allFormats == null) {
904
- throw new Error(
905
- `Missing formats for wallet type ${currencyInfo.walletType}`
906
- )
907
- }
908
908
 
909
909
  const tmpWalletInfo = {
910
910
  id: walletInfo.id,
@@ -1332,9 +1332,10 @@ const processTransactionResponse = (
1332
1332
  })
1333
1333
  return {
1334
1334
  txId: vin.txid,
1335
- outputIndex: vin.vout, // case for tx `fefac8c22ba1178df5d7c90b78cc1c203d1a9f5f5506f7b8f6f469fa821c2674` no `vout` for input
1335
+ outputIndex: vin.vout,
1336
1336
  n: vin.n,
1337
1337
  scriptPubkey,
1338
+ sequence: vin.sequence,
1338
1339
  amount: vin.value
1339
1340
  }
1340
1341
  })
@@ -48,6 +48,7 @@ const asOutputSort = _cleaners.asValue.call(void 0, 'bip69', 'targets')
48
48
 
49
49
 
50
50
  const asUtxoSpendInfoOtherParams = _cleaners.asObject.call(void 0, {
51
+ /** @deprecated use `EdgeSpendInfo['enableRbf']` */
51
52
  enableRbf: _cleaners.asOptional.call(void 0, _cleaners.asBoolean),
52
53
  forceChangeAddress: _cleaners.asOptional.call(void 0, _cleaners.asString),
53
54
  outputSort: _cleaners.asOptional.call(void 0, asOutputSort, 'bip69'),
@@ -38,7 +38,6 @@ const currencyInfo = {
38
38
  const engineInfo = {
39
39
  formats: ['bip49', 'bip44', 'bip32'],
40
40
  gapLimit: 10,
41
- defaultFee: 500000,
42
41
  feeUpdateInterval: 60000,
43
42
  defaultFeeInfo: {
44
43
  lowFeeFudgeFactor: undefined,
@@ -55,7 +55,6 @@ const engineInfo = {
55
55
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
56
56
  forks: ['bitcoincash', 'bitcoingold'],
57
57
  gapLimit: 25,
58
- defaultFee: 1000,
59
58
  feeUpdateInterval: 60000,
60
59
  mempoolSpaceFeeInfoServer: 'https://mempool.space/api/v1/fees/recommended',
61
60
  defaultFeeInfo: {
@@ -57,7 +57,6 @@ const engineInfo = {
57
57
  formats: ['bip44', 'bip32'],
58
58
  forks: [], // 'bitcoinsv' is currently disabled, so not included in the forks
59
59
  gapLimit: 10,
60
- defaultFee: 10000,
61
60
  feeUpdateInterval: 60000,
62
61
  defaultFeeInfo: {
63
62
  lowFeeFudgeFactor: undefined,
@@ -43,7 +43,6 @@ const engineInfo = {
43
43
  formats: ['bip44', 'bip32'],
44
44
  forks: ['bitcoinsv'],
45
45
  gapLimit: 10,
46
- defaultFee: 10000,
47
46
  feeUpdateInterval: 60000,
48
47
  defaultFeeInfo: {
49
48
  lowFeeFudgeFactor: undefined,
@@ -47,7 +47,6 @@ const currencyInfo = {
47
47
  const engineInfo = {
48
48
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
49
49
  gapLimit: 10,
50
- defaultFee: 1000,
51
50
  feeUpdateInterval: 60000,
52
51
  defaultFeeInfo: {
53
52
  lowFeeFudgeFactor: undefined,
@@ -40,7 +40,6 @@ const currencyInfo = {
40
40
  const engineInfo = {
41
41
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
42
42
  gapLimit: 10,
43
- defaultFee: 1000,
44
43
  feeUpdateInterval: 60000,
45
44
  defaultFeeInfo: {
46
45
  lowFeeFudgeFactor: undefined,
@@ -48,7 +48,6 @@ const engineInfo = {
48
48
  formats: ['bip44', 'bip32'],
49
49
  uriPrefix: 'bitcoin',
50
50
  gapLimit: 10,
51
- defaultFee: 10000,
52
51
  feeUpdateInterval: 60000,
53
52
  defaultFeeInfo: {
54
53
  lowFeeFudgeFactor: undefined,
@@ -42,7 +42,6 @@ var _commonInfo = require('./commonInfo');
42
42
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
43
43
  forks: ['bitcoincash', 'bitcoingold'],
44
44
  gapLimit: 25,
45
- defaultFee: 1000,
46
45
  feeUpdateInterval: 60000,
47
46
  mempoolSpaceFeeInfoServer: 'https://mempool.space/api/v1/fees/recommended',
48
47
  defaultFeeInfo: {
@@ -54,7 +54,6 @@ const engineInfo = {
54
54
  ],
55
55
  formats: ['bip44', 'bip32'],
56
56
  gapLimit: 10,
57
- defaultFee: 10000,
58
57
  feeUpdateInterval: 60000,
59
58
  defaultFeeInfo: {
60
59
  lowFeeFudgeFactor: undefined,
@@ -46,7 +46,6 @@ const engineInfo = {
46
46
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
47
47
  forks: [],
48
48
  gapLimit: 10,
49
- defaultFee: 1000,
50
49
  feeUpdateInterval: 60000,
51
50
  defaultFeeInfo: {
52
51
  lowFeeFudgeFactor: undefined,
@@ -50,7 +50,6 @@ const engineInfo = {
50
50
  ],
51
51
  formats: ['bip44', 'bip32'],
52
52
  gapLimit: 10,
53
- defaultFee: 1000,
54
53
  feeUpdateInterval: 10000,
55
54
  defaultFeeInfo: {
56
55
  lowFeeFudgeFactor: undefined,
@@ -39,7 +39,6 @@ const currencyInfo = {
39
39
  const engineInfo = {
40
40
  formats: ['bip44', 'bip32'],
41
41
  gapLimit: 10,
42
- defaultFee: 500000,
43
42
  feeUpdateInterval: 60000,
44
43
  defaultFeeInfo: {
45
44
  lowFeeFudgeFactor: undefined,
@@ -39,7 +39,6 @@ var _commonInfo = require('./commonInfo');
39
39
  const engineInfo = {
40
40
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
41
41
  gapLimit: 10,
42
- defaultFee: 1000,
43
42
  feeUpdateInterval: 60000,
44
43
  defaultFeeInfo: {
45
44
  lowFeeFudgeFactor: undefined,
@@ -51,7 +51,6 @@ const engineInfo = {
51
51
  ],
52
52
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
53
53
  gapLimit: 10,
54
- defaultFee: 100000,
55
54
  feeUpdateInterval: 60000,
56
55
  defaultFeeInfo: {
57
56
  lowFeeFudgeFactor: undefined,
@@ -52,7 +52,6 @@ var _commonInfo = require('./commonInfo');
52
52
  ],
53
53
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
54
54
  gapLimit: 10,
55
- defaultFee: 50000,
56
55
  feeUpdateInterval: 60000,
57
56
  defaultFeeInfo: {
58
57
  lowFeeFudgeFactor: undefined,
@@ -36,7 +36,6 @@ const currencyInfo = {
36
36
  const engineInfo = {
37
37
  formats: ['bip44', 'bip32'],
38
38
  gapLimit: 10,
39
- defaultFee: 1000,
40
39
  feeUpdateInterval: 60000,
41
40
  defaultFeeInfo: {
42
41
  lowFeeFudgeFactor: undefined,
@@ -36,7 +36,6 @@ const currencyInfo = {
36
36
  const engineInfo = {
37
37
  formats: ['bip44', 'bip32'],
38
38
  gapLimit: 10,
39
- defaultFee: 1000,
40
39
  feeUpdateInterval: 60000,
41
40
  defaultFeeInfo: {
42
41
  lowFeeFudgeFactor: undefined,
@@ -42,7 +42,6 @@ const currencyInfo = {
42
42
  const engineInfo = {
43
43
  formats: ['bip44', 'bip32'],
44
44
  gapLimit: 10,
45
- defaultFee: 100000,
46
45
  feeUpdateInterval: 60000,
47
46
  defaultFeeInfo: {
48
47
  lowFeeFudgeFactor: undefined,
@@ -39,7 +39,6 @@ const currencyInfo = {
39
39
  const engineInfo = {
40
40
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
41
41
  gapLimit: 10,
42
- defaultFee: 50000,
43
42
  feeUpdateInterval: 60000,
44
43
  defaultFeeInfo: {
45
44
  lowFeeFudgeFactor: undefined,
@@ -46,7 +46,6 @@ const engineInfo = {
46
46
  formats: ['bip49', 'bip84', 'bip44', 'bip32'],
47
47
  forks: [],
48
48
  gapLimit: 10,
49
- defaultFee: 1000,
50
49
  feeUpdateInterval: 60000,
51
50
  defaultFeeInfo: {
52
51
  lowFeeFudgeFactor: undefined,
@@ -46,7 +46,6 @@ var _commonInfo = require('./commonInfo');
46
46
  formats: ['bip44', 'bip32'],
47
47
  uriPrefix: 'firo',
48
48
  gapLimit: 10,
49
- defaultFee: 1000,
50
49
  feeUpdateInterval: 60000,
51
50
  defaultFeeInfo: {
52
51
  lowFeeFudgeFactor: undefined,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
4
 
@@ -105,7 +105,7 @@ const asOptionalPrivateKeyFormat = _cleaners.asOptional.call(void 0, asPrivateKe
105
105
  return ['bip49', 'bip84']
106
106
  }
107
107
  })()
108
- const engineInfoFormats = _nullishCoalesce(engineInfo.formats, () => ( ['bip44', 'bip32']))
108
+ const engineInfoFormats = engineInfo.formats
109
109
  return formats.filter(format => engineInfoFormats.includes(format))
110
110
  }; exports.getSupportedFormats = getSupportedFormats
111
111
 
@@ -87,9 +87,15 @@ var _cleaners = require('cleaners');
87
87
  vin: _cleaners.asArray.call(void 0,
88
88
  _cleaners.asObject.call(void 0, {
89
89
  txid: _cleaners.asString,
90
- sequence: _cleaners.asOptional.call(void 0, _cleaners.asNumber),
90
+ // Empirically observed omitted sequence is possible for when sequence is zero.
91
+ // Is the case for tx `19ecc679cfc7e71ad616a22bbee96fd5abe8616e4f408f1f5daaf137400ae091`.
92
+ sequence: _cleaners.asOptional.call(void 0, _cleaners.asNumber, 0),
91
93
  n: _cleaners.asNumber,
92
- vout: _cleaners.asOptional.call(void 0, _cleaners.asNumber, 0), // If Blockbook doesn't provide vout, assume 0 (empirically observed)
94
+ // If Blockbook doesn't provide vout, assume 0. Empirically observed
95
+ // case for tx `fefac8c22ba1178df5d7c90b78cc1c203d1a9f5f5506f7b8f6f469fa821c2674`
96
+ // which has no `vout` for input in WebSocket response payload but block
97
+ // will show the input's vout value to be `0`.
98
+ vout: _cleaners.asOptional.call(void 0, _cleaners.asNumber, 0),
93
99
  addresses: _cleaners.asArray.call(void 0, asAddress),
94
100
  isAddress: _cleaners.asBoolean,
95
101
  value: _cleaners.asString,