edge-currency-plugins 2.3.0 → 2.4.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.
Files changed (35) hide show
  1. package/lib/common/fees/calcMinerFeePerByte.js +4 -4
  2. package/lib/common/fees/makeFees.js +15 -22
  3. package/lib/common/plugin/types.js +30 -10
  4. package/lib/common/plugin/util/maximumFeeRateCalculator.js +23 -0
  5. package/lib/common/utxobased/engine/makeUtxoEngine.js +3 -2
  6. package/lib/common/utxobased/info/badcoin.js +1 -1
  7. package/lib/common/utxobased/info/bitcoin.js +4 -2
  8. package/lib/common/utxobased/info/bitcoincash.js +4 -2
  9. package/lib/common/utxobased/info/bitcoincashtestnet.js +1 -1
  10. package/lib/common/utxobased/info/bitcoingold.js +4 -2
  11. package/lib/common/utxobased/info/bitcoingoldtestnet.js +1 -1
  12. package/lib/common/utxobased/info/bitcoinsv.js +4 -2
  13. package/lib/common/utxobased/info/bitcointestnet.js +1 -1
  14. package/lib/common/utxobased/info/dash.js +4 -2
  15. package/lib/common/utxobased/info/digibyte.js +4 -2
  16. package/lib/common/utxobased/info/dogecoin.js +4 -2
  17. package/lib/common/utxobased/info/eboost.js +4 -2
  18. package/lib/common/utxobased/info/feathercoin.js +4 -2
  19. package/lib/common/utxobased/info/groestlcoin.js +4 -2
  20. package/lib/common/utxobased/info/litecoin.js +4 -2
  21. package/lib/common/utxobased/info/qtum.js +4 -2
  22. package/lib/common/utxobased/info/ravencoin.js +4 -2
  23. package/lib/common/utxobased/info/smartcash.js +4 -2
  24. package/lib/common/utxobased/info/ufo.js +4 -2
  25. package/lib/common/utxobased/info/vertcoin.js +4 -2
  26. package/lib/common/utxobased/info/zcoin.js +4 -2
  27. package/lib/common/utxobased/keymanager/keymanager.js +6 -2
  28. package/lib/src/common/fees/calcMinerFeePerByte.d.ts +3 -3
  29. package/lib/src/common/fees/makeFees.d.ts +2 -2
  30. package/lib/src/common/plugin/types.d.ts +9 -12
  31. package/lib/src/common/plugin/util/maximumFeeRateCalculator.d.ts +6 -0
  32. package/lib/src/common/utxobased/keymanager/keymanager.d.ts +4 -3
  33. package/package.json +1 -1
  34. package/lib/common/fees/processInfoServerFees.js +0 -16
  35. package/lib/src/common/fees/processInfoServerFees.d.ts +0 -7
@@ -8,14 +8,14 @@
8
8
  /**
9
9
  * Calculate the sat/byte mining fee given an amount to spend and a SimpleFeeSettings object
10
10
  * @param nativeAmount
11
- * @param fees
11
+ * @param feeInfo
12
12
  * @param networkFeeOption
13
13
  * @param customNetworkFee
14
14
  * @returns {string}
15
15
  */
16
16
  const calcMinerFeePerByte = (
17
17
  nativeAmount,
18
- fees,
18
+ feeInfo,
19
19
  networkFeeOption,
20
20
  customNetworkFee
21
21
  ) => {
@@ -26,8 +26,8 @@
26
26
  standardFeeHighFudgeFactor = '1',
27
27
  standardFeeLowAmount,
28
28
  standardFeeLowFudgeFactor = '1'
29
- } = fees
30
- let { highFee, lowFee, standardFeeHigh, standardFeeLow } = fees
29
+ } = feeInfo
30
+ let { highFee, lowFee, standardFeeHigh, standardFeeLow } = feeInfo
31
31
 
32
32
  highFee = _biggystring.round.call(void 0, _biggystring.mul.call(void 0, highFee, highFeeFudgeFactor), 0)
33
33
  lowFee = _biggystring.round.call(void 0, _biggystring.mul.call(void 0, lowFee, lowFeeFudgeFactor), 0)
@@ -11,13 +11,8 @@ var _memlet = require('memlet');
11
11
 
12
12
  var _filterUndefined = require('../../util/filterUndefined');
13
13
  var _constants = require('../constants');
14
-
15
-
16
-
17
-
18
14
  var _types3 = require('../plugin/types');
19
15
  var _calcMinerFeePerByte = require('./calcMinerFeePerByte');
20
- var _processInfoServerFees = require('./processInfoServerFees');
21
16
  var _processMempoolSpaceFees = require('./processMempoolSpaceFees');
22
17
 
23
18
 
@@ -43,9 +38,9 @@ var _processMempoolSpaceFees = require('./processMempoolSpaceFees');
43
38
  const { currencyInfo, engineInfo } = pluginInfo
44
39
 
45
40
  const memlet = _memlet.makeMemlet.call(void 0, disklet)
46
- const fees = await fetchCachedFees(
41
+ const feeInfo = await fetchCachedFees(
47
42
  memlet,
48
- engineInfo.simpleFeeSettings
43
+ engineInfo.defaultFeeInfo
49
44
  )
50
45
  // The last time the fees were updated
51
46
  let timestamp = 0
@@ -59,10 +54,10 @@ var _processMempoolSpaceFees = require('./processMempoolSpaceFees');
59
54
  mempoolSpaceFeeInfoServer: engineInfo.mempoolSpaceFeeInfoServer
60
55
  })
61
56
  const cleanedVendorFees = _filterUndefined.removeUndefined.call(void 0, _nullishCoalesce(vendorFees, () => ( {})))
62
- Object.assign(fees, cleanedVendorFees)
57
+ Object.assign(feeInfo, cleanedVendorFees)
63
58
  timestamp = Date.now()
64
59
 
65
- await cacheFees(memlet, fees)
60
+ await cacheFees(memlet, feeInfo)
66
61
  }
67
62
 
68
63
  return {
@@ -70,9 +65,9 @@ var _processMempoolSpaceFees = require('./processMempoolSpaceFees');
70
65
  const edgeFees = await fetchFees({
71
66
  ...common,
72
67
  uri: `${_constants.INFO_SERVER_URI}/v1/networkFees/${currencyInfo.pluginId}`,
73
- processor: _processInfoServerFees.processInfoServerFees
68
+ cleaner: _cleaners.asMaybe.call(void 0, _types3.asFeeInfo.call(void 0, feeInfo), null)
74
69
  })
75
- Object.assign(fees, edgeFees)
70
+ Object.assign(feeInfo, edgeFees)
76
71
  await updateVendorFees()
77
72
  vendorIntervalId = setInterval(
78
73
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
@@ -109,15 +104,15 @@ var _processMempoolSpaceFees = require('./processMempoolSpaceFees');
109
104
 
110
105
  const rate = _calcMinerFeePerByte.calcMinerFeePerByte.call(void 0,
111
106
  sumSpendTargets(spendTargets),
112
- fees,
107
+ feeInfo,
113
108
  networkFeeOption,
114
109
  customNetworkFee[customFeeTemplate.key]
115
110
  )
116
111
  return rate
117
112
  },
118
113
 
119
- get fees() {
120
- return fees
114
+ get feeInfo() {
115
+ return feeInfo
121
116
  }
122
117
  }
123
118
  }; exports.makeFees = makeFees
@@ -127,14 +122,12 @@ const fetchCachedFees = async (
127
122
  fallback
128
123
  ) => {
129
124
  const data = await memlet.getJson(_constants.FEES_PATH).catch(() => undefined)
130
- const feeSettings = _cleaners.asMaybe.call(void 0, _types3.asSimpleFeeSettings, fallback)(data)
125
+ const feeSettings = _cleaners.asMaybe.call(void 0, _types3.asFeeInfo.call(void 0, fallback), fallback)(data)
131
126
  return feeSettings
132
127
  }
133
128
 
134
- const cacheFees = async (
135
- memlet,
136
- fees
137
- ) => await memlet.setJson(_constants.FEES_PATH, fees)
129
+ const cacheFees = async (memlet, feeInfo) =>
130
+ await memlet.setJson(_constants.FEES_PATH, feeInfo)
138
131
 
139
132
  const sumSpendTargets = (spendTargets) =>
140
133
  spendTargets.reduce((amount, { nativeAmount }) => {
@@ -148,14 +141,14 @@ const sumSpendTargets = (spendTargets) =>
148
141
 
149
142
 
150
143
  const fetchFees = async ( args) => {
151
- const { uri, processor, io, log } = args
144
+ const { uri, cleaner, io, log } = args
152
145
 
153
146
  try {
154
147
  const response = await io.fetch(uri)
155
148
  if (!response.ok) throw new Error(`Error fetching fees from ${uri}`)
156
149
 
157
150
  const fees = await response.json()
158
- return processor(fees)
151
+ return cleaner(fees)
159
152
  } catch (err) {
160
153
  log(err.message)
161
154
  return null
@@ -173,7 +166,7 @@ const fetchFeesFromVendor = async (
173
166
  const mempoolFees = await fetchFees({
174
167
  ...args,
175
168
  uri: args.mempoolSpaceFeeInfoServer,
176
- processor: _processMempoolSpaceFees.processMempoolSpaceFees
169
+ cleaner: _processMempoolSpaceFees.processMempoolSpaceFees
177
170
  })
178
171
  if (mempoolFees != null) {
179
172
  return mempoolFees
@@ -1,4 +1,5 @@
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; } }
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 _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; }
2
+
2
3
 
3
4
 
4
5
 
@@ -152,17 +153,36 @@ var _cleaners = require('cleaners');
152
153
  }); exports.asFeeRates = asFeeRates
153
154
 
154
155
 
155
- const asSimpleFeeSettings = _cleaners.asObject.call(void 0, {
156
- ...exports.asFeeRates.shape,
157
156
 
158
- lowFeeFudgeFactor: _cleaners.asMaybe.call(void 0, _cleaners.asString),
159
- standardFeeLowFudgeFactor: _cleaners.asMaybe.call(void 0, _cleaners.asString),
160
- standardFeeHighFudgeFactor: _cleaners.asMaybe.call(void 0, _cleaners.asString),
161
- highFeeFudgeFactor: _cleaners.asMaybe.call(void 0, _cleaners.asString),
162
157
 
163
- standardFeeLowAmount: _cleaners.asString,
164
- standardFeeHighAmount: _cleaners.asString
165
- }); exports.asSimpleFeeSettings = asSimpleFeeSettings
158
+
159
+
160
+
161
+
162
+
163
+
164
+ const asFeeInfo = (fallback) =>
165
+ _cleaners.asObject({
166
+ ...exports.asFeeRates.shape,
167
+
168
+ lowFeeFudgeFactor: _cleaners.asMaybe.call(void 0, _cleaners.asString, _optionalChain([fallback, 'optionalAccess', _ => _.lowFeeFudgeFactor])),
169
+ standardFeeLowFudgeFactor: _cleaners.asMaybe.call(void 0,
170
+ _cleaners.asString,
171
+ _optionalChain([fallback, 'optionalAccess', _2 => _2.standardFeeLowFudgeFactor])
172
+ ),
173
+ standardFeeHighFudgeFactor: _cleaners.asMaybe.call(void 0,
174
+ _cleaners.asString,
175
+ _optionalChain([fallback, 'optionalAccess', _3 => _3.standardFeeHighFudgeFactor])
176
+ ),
177
+ highFeeFudgeFactor: _cleaners.asMaybe.call(void 0, _cleaners.asString, _optionalChain([fallback, 'optionalAccess', _4 => _4.highFeeFudgeFactor])),
178
+
179
+ // The amount of satoshis which will be charged the standardFeeLow
180
+ standardFeeLowAmount: _cleaners.asString,
181
+ // The amount of satoshis which will be charged the standardFeeHigh
182
+ standardFeeHighAmount: _cleaners.asString,
183
+ // A safe-guard for any potential software bugs:
184
+ maximumFeeRate: _cleaners.asOptional.call(void 0, _cleaners.asString, _optionalChain([fallback, 'optionalAccess', _5 => _5.maximumFeeRate]))
185
+ }).withRest; exports.asFeeInfo = asFeeInfo
166
186
 
167
187
 
168
188
 
@@ -0,0 +1,23 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _biggystring = require('biggystring');
2
+
3
+
4
+ /**
5
+ * Calculates a maximum fee rate of 1 USD per vByte given a USD exchange rate
6
+ * (usdPrice).
7
+ */
8
+ const maximumFeeRateCalculator = (
9
+ currencyInfo,
10
+ usdPrice
11
+ ) => {
12
+ const { currencyCode, denominations } = currencyInfo
13
+ const primaryDenomination = denominations.find(
14
+ denom => denom.name === currencyCode
15
+ )
16
+ if (primaryDenomination == null)
17
+ throw new Error(`Missing primary currency denomination for ${currencyCode}`)
18
+
19
+ return _biggystring.round.call(void 0,
20
+ _biggystring.mul.call(void 0, _biggystring.div.call(void 0, '1', String(usdPrice), 16), primaryDenomination.multiplier),
21
+ 0
22
+ )
23
+ }; exports.maximumFeeRateCalculator = maximumFeeRateCalculator
@@ -625,9 +625,10 @@ var _utils = require('./utils');
625
625
  }
626
626
  })()
627
627
  const signedTx = await _keymanager.signTx.call(void 0, {
628
- psbtBase64: psbt.base64,
629
628
  coin: coinInfo.name,
630
- privateKeyEncodings: privateKeyEncodings
629
+ feeInfo: fees.feeInfo,
630
+ privateKeyEncodings: privateKeyEncodings,
631
+ psbtBase64: psbt.base64
631
632
  })
632
633
  transaction.txid = signedTx.id
633
634
  transaction.signedTx = signedTx.hex
@@ -43,7 +43,7 @@ const engineInfo = {
43
43
  gapLimit: 10,
44
44
  defaultFee: 500000,
45
45
  feeUpdateInterval: 60000,
46
- simpleFeeSettings: {
46
+ defaultFeeInfo: {
47
47
  lowFeeFudgeFactor: undefined,
48
48
  standardFeeLowFudgeFactor: undefined,
49
49
  standardFeeHighFudgeFactor: undefined,
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _constants = require('../../constants');
4
4
 
5
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
5
6
  var _commonInfo = require('./commonInfo');
6
7
 
7
8
  const currencyInfo = {
@@ -59,7 +60,7 @@ const engineInfo = {
59
60
  defaultFee: 1000,
60
61
  feeUpdateInterval: 60000,
61
62
  mempoolSpaceFeeInfoServer: 'https://mempool.space/api/v1/fees/recommended',
62
- simpleFeeSettings: {
63
+ defaultFeeInfo: {
63
64
  lowFeeFudgeFactor: undefined,
64
65
  standardFeeLowFudgeFactor: undefined,
65
66
  standardFeeHighFudgeFactor: undefined,
@@ -70,7 +71,8 @@ const engineInfo = {
70
71
  standardFeeLow: '50',
71
72
  standardFeeHigh: '100',
72
73
  standardFeeLowAmount: '173200',
73
- standardFeeHighAmount: '8670000'
74
+ standardFeeHighAmount: '8670000',
75
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 27460.65)
74
76
  }
75
77
  }
76
78
 
@@ -4,6 +4,7 @@ var _cleaners = require('cleaners');
4
4
 
5
5
  var _constants = require('../../constants');
6
6
 
7
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
7
8
  var _commonInfo = require('./commonInfo');
8
9
  var _bitcoincashScriptTemplates = require('./scriptTemplates/bitcoincashScriptTemplates');
9
10
 
@@ -60,7 +61,7 @@ const engineInfo = {
60
61
  gapLimit: 10,
61
62
  defaultFee: 10000,
62
63
  feeUpdateInterval: 60000,
63
- simpleFeeSettings: {
64
+ defaultFeeInfo: {
64
65
  lowFeeFudgeFactor: undefined,
65
66
  standardFeeLowFudgeFactor: undefined,
66
67
  standardFeeHighFudgeFactor: undefined,
@@ -71,7 +72,8 @@ const engineInfo = {
71
72
  standardFeeLow: '5',
72
73
  standardFeeHigh: '10',
73
74
  standardFeeLowAmount: '1000000',
74
- standardFeeHighAmount: '65000000'
75
+ standardFeeHighAmount: '65000000',
76
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 212.86)
75
77
  },
76
78
  scriptTemplates: _bitcoincashScriptTemplates.scriptTemplates,
77
79
  asBlockbookAddress: _cleaners.asCodec.call(void 0,
@@ -45,7 +45,7 @@ const engineInfo = {
45
45
  gapLimit: 10,
46
46
  defaultFee: 10000,
47
47
  feeUpdateInterval: 60000,
48
- simpleFeeSettings: {
48
+ defaultFeeInfo: {
49
49
  lowFeeFudgeFactor: undefined,
50
50
  standardFeeLowFudgeFactor: undefined,
51
51
  standardFeeHighFudgeFactor: undefined,
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
 
5
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
5
6
  var _commonInfo = require('./commonInfo');
6
7
 
7
8
  const currencyInfo = {
@@ -51,7 +52,7 @@ const engineInfo = {
51
52
  gapLimit: 10,
52
53
  defaultFee: 1000,
53
54
  feeUpdateInterval: 60000,
54
- simpleFeeSettings: {
55
+ defaultFeeInfo: {
55
56
  lowFeeFudgeFactor: undefined,
56
57
  standardFeeLowFudgeFactor: undefined,
57
58
  standardFeeHighFudgeFactor: undefined,
@@ -62,7 +63,8 @@ const engineInfo = {
62
63
  standardFeeLow: '15',
63
64
  standardFeeHigh: '140',
64
65
  standardFeeLowAmount: '17320',
65
- standardFeeHighAmount: '86700000'
66
+ standardFeeHighAmount: '86700000',
67
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 12.62)
66
68
  }
67
69
  }
68
70
 
@@ -37,7 +37,7 @@ const engineInfo = {
37
37
  gapLimit: 10,
38
38
  defaultFee: 1000,
39
39
  feeUpdateInterval: 60000,
40
- simpleFeeSettings: {
40
+ defaultFeeInfo: {
41
41
  lowFeeFudgeFactor: undefined,
42
42
  standardFeeLowFudgeFactor: undefined,
43
43
  standardFeeHighFudgeFactor: undefined,
@@ -4,6 +4,7 @@ var _cleaners = require('cleaners');
4
4
 
5
5
  var _constants = require('../../constants');
6
6
 
7
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
7
8
 
8
9
 
9
10
 
@@ -57,7 +58,7 @@ const engineInfo = {
57
58
  gapLimit: 10,
58
59
  defaultFee: 10000,
59
60
  feeUpdateInterval: 60000,
60
- simpleFeeSettings: {
61
+ defaultFeeInfo: {
61
62
  lowFeeFudgeFactor: undefined,
62
63
  standardFeeLowFudgeFactor: undefined,
63
64
  standardFeeHighFudgeFactor: undefined,
@@ -68,7 +69,8 @@ const engineInfo = {
68
69
  standardFeeLow: '5',
69
70
  standardFeeHigh: '10',
70
71
  standardFeeLowAmount: '1000000',
71
- standardFeeHighAmount: '65000000'
72
+ standardFeeHighAmount: '65000000',
73
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 33.61)
72
74
  },
73
75
  /*
74
76
  This is to support cashaddr and 1-addresses coming from the network.
@@ -53,7 +53,7 @@ var _commonInfo = require('./commonInfo');
53
53
  defaultFee: 1000,
54
54
  feeUpdateInterval: 60000,
55
55
  mempoolSpaceFeeInfoServer: 'https://mempool.space/api/v1/fees/recommended',
56
- simpleFeeSettings: {
56
+ defaultFeeInfo: {
57
57
  lowFeeFudgeFactor: undefined,
58
58
  standardFeeLowFudgeFactor: undefined,
59
59
  standardFeeHighFudgeFactor: undefined,
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
 
5
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
5
6
 
6
7
  var _commonInfo = require('./commonInfo');
7
8
 
@@ -52,7 +53,7 @@ const engineInfo = {
52
53
  gapLimit: 10,
53
54
  defaultFee: 10000,
54
55
  feeUpdateInterval: 60000,
55
- simpleFeeSettings: {
56
+ defaultFeeInfo: {
56
57
  lowFeeFudgeFactor: undefined,
57
58
  standardFeeLowFudgeFactor: undefined,
58
59
  standardFeeHighFudgeFactor: undefined,
@@ -63,7 +64,8 @@ const engineInfo = {
63
64
  standardFeeLow: '150',
64
65
  standardFeeHigh: '200',
65
66
  standardFeeLowAmount: '20000000',
66
- standardFeeHighAmount: '981000000'
67
+ standardFeeHighAmount: '981000000',
68
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 25.8)
67
69
  },
68
70
  txSpecificHandling: (
69
71
  tx,
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
 
6
7
  const currencyInfo = {
@@ -44,7 +45,7 @@ const engineInfo = {
44
45
  gapLimit: 10,
45
46
  defaultFee: 1000,
46
47
  feeUpdateInterval: 60000,
47
- simpleFeeSettings: {
48
+ defaultFeeInfo: {
48
49
  lowFeeFudgeFactor: undefined,
49
50
  standardFeeLowFudgeFactor: undefined,
50
51
  standardFeeHighFudgeFactor: undefined,
@@ -55,7 +56,8 @@ const engineInfo = {
55
56
  standardFeeLow: '50',
56
57
  standardFeeHigh: '100',
57
58
  standardFeeLowAmount: '173200',
58
- standardFeeHighAmount: '8670000'
59
+ standardFeeHighAmount: '8670000',
60
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.006176)
59
61
  }
60
62
  }
61
63
 
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
  var _dogeUtxoPicker = require('./utxoPickers/dogeUtxoPicker');
6
7
 
@@ -48,7 +49,7 @@ const engineInfo = {
48
49
  gapLimit: 10,
49
50
  defaultFee: 1000,
50
51
  feeUpdateInterval: 10000,
51
- simpleFeeSettings: {
52
+ defaultFeeInfo: {
52
53
  lowFeeFudgeFactor: undefined,
53
54
  standardFeeLowFudgeFactor: undefined,
54
55
  standardFeeHighFudgeFactor: undefined,
@@ -59,7 +60,8 @@ const engineInfo = {
59
60
  standardFeeLow: '526316',
60
61
  standardFeeHigh: '526316',
61
62
  standardFeeLowAmount: '2000000000',
62
- standardFeeHighAmount: '98100000000'
63
+ standardFeeHighAmount: '98100000000',
64
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.05938)
63
65
  }
64
66
  }
65
67
 
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
 
6
7
  const currencyInfo = {
@@ -43,7 +44,7 @@ const engineInfo = {
43
44
  gapLimit: 10,
44
45
  defaultFee: 500000,
45
46
  feeUpdateInterval: 60000,
46
- simpleFeeSettings: {
47
+ defaultFeeInfo: {
47
48
  lowFeeFudgeFactor: undefined,
48
49
  standardFeeLowFudgeFactor: undefined,
49
50
  standardFeeHighFudgeFactor: undefined,
@@ -54,7 +55,8 @@ const engineInfo = {
54
55
  standardFeeLow: '150',
55
56
  standardFeeHigh: '200',
56
57
  standardFeeLowAmount: '20000000',
57
- standardFeeHighAmount: '981000000'
58
+ standardFeeHighAmount: '981000000',
59
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.0033)
58
60
  }
59
61
  }
60
62
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _constants = require('../../constants');
4
4
 
5
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
5
6
  var _commonInfo = require('./commonInfo');
6
7
 
7
8
  const currencyInfo = {
@@ -48,7 +49,7 @@ var _commonInfo = require('./commonInfo');
48
49
  gapLimit: 10,
49
50
  defaultFee: 1000,
50
51
  feeUpdateInterval: 60000,
51
- simpleFeeSettings: {
52
+ defaultFeeInfo: {
52
53
  lowFeeFudgeFactor: undefined,
53
54
  standardFeeLowFudgeFactor: undefined,
54
55
  standardFeeHighFudgeFactor: undefined,
@@ -59,7 +60,8 @@ var _commonInfo = require('./commonInfo');
59
60
  standardFeeLow: '600',
60
61
  standardFeeHigh: '800',
61
62
  standardFeeLowAmount: '2000000000',
62
- standardFeeHighAmount: '98100000000'
63
+ standardFeeHighAmount: '98100000000',
64
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, exports.currencyInfo, 0.002275)
63
65
  }
64
66
  }; exports.engineInfo = engineInfo
65
67
 
@@ -5,6 +5,7 @@ var _bs58grscheck = require('bs58grscheck'); var base58grs = _interopRequireWild
5
5
  var _wifgrs = require('wifgrs'); var wifgrs = _interopRequireWildcard(_wifgrs);
6
6
 
7
7
 
8
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
8
9
  var _commonInfo = require('./commonInfo');
9
10
 
10
11
  const currencyInfo = {
@@ -49,7 +50,7 @@ const engineInfo = {
49
50
  gapLimit: 10,
50
51
  defaultFee: 100000,
51
52
  feeUpdateInterval: 60000,
52
- simpleFeeSettings: {
53
+ defaultFeeInfo: {
53
54
  lowFeeFudgeFactor: undefined,
54
55
  standardFeeLowFudgeFactor: undefined,
55
56
  standardFeeHighFudgeFactor: undefined,
@@ -60,7 +61,8 @@ const engineInfo = {
60
61
  standardFeeLow: '50',
61
62
  standardFeeHigh: '100',
62
63
  standardFeeLowAmount: '173200',
63
- standardFeeHighAmount: '8670000'
64
+ standardFeeHighAmount: '8670000',
65
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.4705)
64
66
  }
65
67
  }
66
68
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _constants = require('../../constants');
4
4
 
5
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
5
6
  var _commonInfo = require('./commonInfo');
6
7
 
7
8
  const currencyInfo = {
@@ -55,7 +56,7 @@ var _commonInfo = require('./commonInfo');
55
56
  gapLimit: 10,
56
57
  defaultFee: 50000,
57
58
  feeUpdateInterval: 60000,
58
- simpleFeeSettings: {
59
+ defaultFeeInfo: {
59
60
  lowFeeFudgeFactor: undefined,
60
61
  standardFeeLowFudgeFactor: undefined,
61
62
  standardFeeHighFudgeFactor: undefined,
@@ -66,7 +67,8 @@ var _commonInfo = require('./commonInfo');
66
67
  standardFeeLow: '150',
67
68
  standardFeeHigh: '200',
68
69
  standardFeeLowAmount: '20000000',
69
- standardFeeHighAmount: '981000000'
70
+ standardFeeHighAmount: '981000000',
71
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, exports.currencyInfo, 63.64)
70
72
  }
71
73
  }; exports.engineInfo = engineInfo
72
74
 
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
 
6
7
  const currencyInfo = {
@@ -40,7 +41,7 @@ const engineInfo = {
40
41
  gapLimit: 10,
41
42
  defaultFee: 1000,
42
43
  feeUpdateInterval: 60000,
43
- simpleFeeSettings: {
44
+ defaultFeeInfo: {
44
45
  lowFeeFudgeFactor: undefined,
45
46
  standardFeeLowFudgeFactor: undefined,
46
47
  standardFeeHighFudgeFactor: undefined,
@@ -51,7 +52,8 @@ const engineInfo = {
51
52
  standardFeeLow: '450',
52
53
  standardFeeHigh: '700',
53
54
  standardFeeLowAmount: '20000000',
54
- standardFeeHighAmount: '981000000'
55
+ standardFeeHighAmount: '981000000',
56
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 2.13)
55
57
  }
56
58
  }
57
59
 
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
 
6
7
  const currencyInfo = {
@@ -40,7 +41,7 @@ const engineInfo = {
40
41
  gapLimit: 10,
41
42
  defaultFee: 1000,
42
43
  feeUpdateInterval: 60000,
43
- simpleFeeSettings: {
44
+ defaultFeeInfo: {
44
45
  lowFeeFudgeFactor: undefined,
45
46
  standardFeeLowFudgeFactor: undefined,
46
47
  standardFeeHighFudgeFactor: undefined,
@@ -51,7 +52,8 @@ const engineInfo = {
51
52
  standardFeeLow: '50',
52
53
  standardFeeHigh: '100',
53
54
  standardFeeLowAmount: '173200',
54
- standardFeeHighAmount: '8670000'
55
+ standardFeeHighAmount: '8670000',
56
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.01419)
55
57
  }
56
58
  }
57
59
 
@@ -4,6 +4,7 @@ var _bs58smartcheck = require('bs58smartcheck'); var base58smart = _interopRequi
4
4
  var _wifsmart = require('wif-smart'); var wifsmart = _interopRequireWildcard(_wifsmart);
5
5
 
6
6
 
7
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
7
8
  var _commonInfo = require('./commonInfo');
8
9
 
9
10
  const currencyInfo = {
@@ -46,7 +47,7 @@ const engineInfo = {
46
47
  gapLimit: 10,
47
48
  defaultFee: 100000,
48
49
  feeUpdateInterval: 60000,
49
- simpleFeeSettings: {
50
+ defaultFeeInfo: {
50
51
  lowFeeFudgeFactor: undefined,
51
52
  standardFeeLowFudgeFactor: undefined,
52
53
  standardFeeHighFudgeFactor: undefined,
@@ -57,7 +58,8 @@ const engineInfo = {
57
58
  standardFeeLow: '500',
58
59
  standardFeeHigh: '1000',
59
60
  standardFeeLowAmount: '1732000',
60
- standardFeeHighAmount: '86700000'
61
+ standardFeeHighAmount: '86700000',
62
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.0002171)
61
63
  }
62
64
  }
63
65
 
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
 
6
7
  const currencyInfo = {
@@ -43,7 +44,7 @@ const engineInfo = {
43
44
  gapLimit: 10,
44
45
  defaultFee: 50000,
45
46
  feeUpdateInterval: 60000,
46
- simpleFeeSettings: {
47
+ defaultFeeInfo: {
47
48
  lowFeeFudgeFactor: undefined,
48
49
  standardFeeLowFudgeFactor: undefined,
49
50
  standardFeeHighFudgeFactor: undefined,
@@ -54,7 +55,8 @@ const engineInfo = {
54
55
  standardFeeLow: '1100',
55
56
  standardFeeHigh: '2000',
56
57
  standardFeeLowAmount: '51282051282051',
57
- standardFeeHighAmount: '5128205128205100'
58
+ standardFeeHighAmount: '5128205128205100',
59
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.000137)
58
60
  }
59
61
  }
60
62
 
@@ -1,6 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
4
5
  var _commonInfo = require('./commonInfo');
5
6
 
6
7
  const currencyInfo = {
@@ -50,7 +51,7 @@ const engineInfo = {
50
51
  gapLimit: 10,
51
52
  defaultFee: 1000,
52
53
  feeUpdateInterval: 60000,
53
- simpleFeeSettings: {
54
+ defaultFeeInfo: {
54
55
  lowFeeFudgeFactor: undefined,
55
56
  standardFeeLowFudgeFactor: undefined,
56
57
  standardFeeHighFudgeFactor: undefined,
@@ -61,7 +62,8 @@ const engineInfo = {
61
62
  standardFeeLow: '50',
62
63
  standardFeeHigh: '100',
63
64
  standardFeeLowAmount: '173200',
64
- standardFeeHighAmount: '8670000'
65
+ standardFeeHighAmount: '8670000',
66
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, currencyInfo, 0.04662)
65
67
  }
66
68
  }
67
69
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _constants = require('../../constants');
4
4
 
5
+ var _maximumFeeRateCalculator = require('../../plugin/util/maximumFeeRateCalculator');
5
6
  var _commonInfo = require('./commonInfo');
6
7
 
7
8
  const currencyInfo = {
@@ -49,7 +50,7 @@ var _commonInfo = require('./commonInfo');
49
50
  gapLimit: 10,
50
51
  defaultFee: 1000,
51
52
  feeUpdateInterval: 60000,
52
- simpleFeeSettings: {
53
+ defaultFeeInfo: {
53
54
  lowFeeFudgeFactor: undefined,
54
55
  standardFeeLowFudgeFactor: undefined,
55
56
  standardFeeHighFudgeFactor: undefined,
@@ -60,7 +61,8 @@ var _commonInfo = require('./commonInfo');
60
61
  standardFeeLow: '50',
61
62
  standardFeeHigh: '100',
62
63
  standardFeeLowAmount: '173200',
63
- standardFeeHighAmount: '8670000'
64
+ standardFeeHighAmount: '8670000',
65
+ maximumFeeRate: _maximumFeeRateCalculator.maximumFeeRateCalculator.call(void 0, exports.currencyInfo, 1.39)
64
66
  }
65
67
  }; exports.engineInfo = engineInfo
66
68
 
@@ -256,6 +256,7 @@ var VerifyAddressEnum; (function (VerifyAddressEnum) {
256
256
 
257
257
 
258
258
 
259
+
259
260
 
260
261
 
261
262
  function bip43PurposeNumberToTypeEnum(
@@ -1084,7 +1085,10 @@ const wifToPrivateKeyEncodingInternal = (
1084
1085
  } exports.makeTx = makeTx;
1085
1086
 
1086
1087
  async function signTx(args) {
1087
- const psbt = _altcoinjs.Psbt.fromBase64(args.psbtBase64)
1088
+ const { maximumFeeRate } = args.feeInfo
1089
+ const opts =
1090
+ maximumFeeRate != null ? { maximumFeeRate: parseInt(maximumFeeRate) } : {}
1091
+ const psbt = _altcoinjs.Psbt.fromBase64(args.psbtBase64, opts)
1088
1092
  const coin = _coinmapper.getCoinFromString.call(void 0, args.coin)
1089
1093
 
1090
1094
  const validator = (
@@ -1107,7 +1111,7 @@ const wifToPrivateKeyEncodingInternal = (
1107
1111
  psbt.validateSignaturesOfInput(i, validator)
1108
1112
  psbt.finalizeInput(i)
1109
1113
  }
1110
- const tx = psbt.extractTransaction(true)
1114
+ const tx = psbt.extractTransaction()
1111
1115
  return {
1112
1116
  id: tx.getId(coin.txHashFunction),
1113
1117
  hex: tx.toHex()
@@ -1,13 +1,13 @@
1
1
  import { EdgeSpendInfo } from 'edge-core-js/types';
2
- import { SimpleFeeSettings } from '../plugin/types';
2
+ import { FeeInfo } from '../plugin/types';
3
3
  declare type NetworkFeeOption = EdgeSpendInfo['networkFeeOption'];
4
4
  /**
5
5
  * Calculate the sat/byte mining fee given an amount to spend and a SimpleFeeSettings object
6
6
  * @param nativeAmount
7
- * @param fees
7
+ * @param feeInfo
8
8
  * @param networkFeeOption
9
9
  * @param customNetworkFee
10
10
  * @returns {string}
11
11
  */
12
- export declare const calcMinerFeePerByte: (nativeAmount: string, fees: SimpleFeeSettings, networkFeeOption?: NetworkFeeOption, customNetworkFee?: string | undefined) => string;
12
+ export declare const calcMinerFeePerByte: (nativeAmount: string, feeInfo: FeeInfo, networkFeeOption?: NetworkFeeOption, customNetworkFee?: string | undefined) => string;
13
13
  export {};
@@ -1,6 +1,6 @@
1
1
  import { Disklet } from 'disklet';
2
2
  import { EdgeIo, EdgeLog, EdgeSpendInfo } from 'edge-core-js/types';
3
- import { PluginInfo, SimpleFeeSettings } from '../plugin/types';
3
+ import { FeeInfo, PluginInfo } from '../plugin/types';
4
4
  interface MakeFeesConfig extends Common {
5
5
  disklet: Disklet;
6
6
  pluginInfo: PluginInfo;
@@ -14,7 +14,7 @@ export interface Fees {
14
14
  stop: () => void;
15
15
  clearCache: () => Promise<void>;
16
16
  getRate: (edgeSpendInfo: EdgeSpendInfo) => Promise<string>;
17
- fees: SimpleFeeSettings;
17
+ feeInfo: FeeInfo;
18
18
  }
19
19
  export declare const makeFees: (config: MakeFeesConfig) => Promise<Fees>;
20
20
  export {};
@@ -40,7 +40,7 @@ export interface EngineInfo {
40
40
  defaultFee: number;
41
41
  feeUpdateInterval: number;
42
42
  mempoolSpaceFeeInfoServer?: string;
43
- simpleFeeSettings: SimpleFeeSettings;
43
+ defaultFeeInfo: FeeInfo;
44
44
  scriptTemplates?: ScriptTemplates;
45
45
  asBlockbookAddress?: Cleaner<string>;
46
46
  txSpecificHandling?: (tx: IProcessorTransaction, specialTx: unknown) => IProcessorTransaction;
@@ -108,19 +108,16 @@ export declare const asFeeRates: import("cleaners").ObjectCleaner<{
108
108
  standardFeeHigh: string;
109
109
  highFee: string;
110
110
  }>;
111
- export declare type SimpleFeeSettings = ReturnType<typeof asSimpleFeeSettings>;
112
- export declare const asSimpleFeeSettings: import("cleaners").ObjectCleaner<{
113
- lowFeeFudgeFactor: string | undefined;
114
- standardFeeLowFudgeFactor: string | undefined;
115
- standardFeeHighFudgeFactor: string | undefined;
116
- highFeeFudgeFactor: string | undefined;
111
+ export declare type FeeInfo = FeeRates & {
112
+ lowFeeFudgeFactor?: string;
113
+ standardFeeLowFudgeFactor?: string;
114
+ standardFeeHighFudgeFactor?: string;
115
+ highFeeFudgeFactor?: string;
117
116
  standardFeeLowAmount: string;
118
117
  standardFeeHighAmount: string;
119
- lowFee: string;
120
- standardFeeLow: string;
121
- standardFeeHigh: string;
122
- highFee: string;
123
- }>;
118
+ maximumFeeRate?: string;
119
+ };
120
+ export declare const asFeeInfo: (fallback?: FeeInfo | undefined) => Cleaner<FeeInfo>;
124
121
  export interface EngineConfig {
125
122
  walletInfo: EdgeWalletInfo;
126
123
  pluginInfo: PluginInfo;
@@ -0,0 +1,6 @@
1
+ import { EdgeCurrencyInfo } from 'edge-core-js/types';
2
+ /**
3
+ * Calculates a maximum fee rate of 1 USD per vByte given a USD exchange rate
4
+ * (usdPrice).
5
+ */
6
+ export declare const maximumFeeRateCalculator: (currencyInfo: EdgeCurrencyInfo, usdPrice: number) => string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { EdgeLog, EdgeMemo } from 'edge-core-js/types';
2
- import { ChangePath } from '../../plugin/types';
2
+ import { ChangePath, FeeInfo } from '../../plugin/types';
3
3
  import { IUTXO } from '../db/types';
4
4
  import { ScriptTemplate, ScriptTemplates } from '../info/scriptTemplates/types';
5
5
  import * as utxopicker from './utxopicker';
@@ -153,9 +153,10 @@ interface MakeTxReturn extends Required<utxopicker.UtxoPickerResult> {
153
153
  psbtBase64: string;
154
154
  }
155
155
  export interface SignTxArgs {
156
- privateKeyEncodings: PrivateKeyEncoding[];
157
- psbtBase64: string;
158
156
  coin: string;
157
+ feeInfo: FeeInfo;
158
+ psbtBase64: string;
159
+ privateKeyEncodings: PrivateKeyEncoding[];
159
160
  }
160
161
  interface SignTxReturn {
161
162
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "2.3.0",
3
+ "version": "2.4.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",
@@ -1,16 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _types = require('../plugin/types');
2
-
3
- /**
4
- * Processes the fee object from Edge Info Server
5
- * @param fees
6
- * @returns {SimpleFeeSettings}
7
- */
8
- const processInfoServerFees = (
9
- fees
10
- ) => {
11
- try {
12
- return _types.asSimpleFeeSettings.call(void 0, fees)
13
- } catch (e) {
14
- return null
15
- }
16
- }; exports.processInfoServerFees = processInfoServerFees
@@ -1,7 +0,0 @@
1
- import { SimpleFeeSettings } from '../plugin/types';
2
- /**
3
- * Processes the fee object from Edge Info Server
4
- * @param fees
5
- * @returns {SimpleFeeSettings}
6
- */
7
- export declare const processInfoServerFees: (fees: unknown) => SimpleFeeSettings | null;