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.
- package/README.md +10 -0
- package/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +35 -35
- package/lib/common/plugin/CurrencyTools.js +4 -4
- package/lib/common/plugin/types.js +154 -0
- package/lib/common/plugin/utils.js +2 -3
- package/lib/common/utxobased/db/Models/ProcessorTransaction.js +1 -0
- package/lib/common/utxobased/db/types.js +4 -0
- package/lib/common/utxobased/engine/UtxoEngine.js +14 -14
- package/lib/common/utxobased/engine/UtxoEngineState.js +2 -1
- package/lib/common/utxobased/engine/types.js +1 -0
- package/lib/common/utxobased/info/badcoin.js +0 -1
- package/lib/common/utxobased/info/bitcoin.js +0 -1
- package/lib/common/utxobased/info/bitcoincash.js +0 -1
- package/lib/common/utxobased/info/bitcoincashtestnet.js +0 -1
- package/lib/common/utxobased/info/bitcoingold.js +0 -1
- package/lib/common/utxobased/info/bitcoingoldtestnet.js +0 -1
- package/lib/common/utxobased/info/bitcoinsv.js +0 -1
- package/lib/common/utxobased/info/bitcointestnet.js +0 -1
- package/lib/common/utxobased/info/dash.js +0 -1
- package/lib/common/utxobased/info/digibyte.js +0 -1
- package/lib/common/utxobased/info/dogecoin.js +0 -1
- package/lib/common/utxobased/info/eboost.js +0 -1
- package/lib/common/utxobased/info/feathercoin.js +0 -1
- package/lib/common/utxobased/info/groestlcoin.js +0 -1
- package/lib/common/utxobased/info/litecoin.js +0 -1
- package/lib/common/utxobased/info/qtum.js +0 -1
- package/lib/common/utxobased/info/ravencoin.js +0 -1
- package/lib/common/utxobased/info/smartcash.js +0 -1
- package/lib/common/utxobased/info/ufo.js +0 -1
- package/lib/common/utxobased/info/vertcoin.js +0 -1
- package/lib/common/utxobased/info/zcoin.js +0 -1
- package/lib/common/utxobased/keymanager/cleaners.js +2 -2
- package/lib/common/utxobased/network/blockbookApi.js +8 -2
- package/lib/src/common/plugin/types.d.ts +141 -2
- package/lib/src/common/utxobased/db/types.d.ts +7 -3
- package/lib/src/common/utxobased/keymanager/utxopicker/types.d.ts +1 -1
- package/lib/src/common/utxobased/network/blockbookApi.d.ts +1 -1
- 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]), () => (
|
|
67
|
-
coinType: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
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',
|
|
94
|
-
coinType: _nullishCoalesce(_nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
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)
|
|
@@ -137,6 +137,160 @@ var _types3 = require('../utxobased/db/types');
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
140
294
|
|
|
141
295
|
|
|
142
296
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
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
|
|
@@ -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
|
-
//
|
|
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,
|
|
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'),
|
|
@@ -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: {
|
|
@@ -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: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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,
|