edge-currency-plugins 3.4.2 → 3.4.4
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/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/assets/edge-currency-plugins/669.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +76 -0
- package/android/src/main/java/app/edge/reactnative/currencyplugins/EdgeCurrencyPluginsModule.java +26 -0
- package/android/src/main/java/app/edge/reactnative/currencyplugins/EdgeCurrencyPluginsPackage.java +24 -0
- package/lib/common/utxobased/db/util/utxo.js +6 -9
- package/lib/common/utxobased/engine/ServerStates.js +16 -5
- package/lib/common/utxobased/engine/UtxoEngineProcessor.js +33 -16
- package/lib/common/utxobased/network/blockbookApi.js +40 -16
- package/lib/src/common/utxobased/network/blockbookApi.d.ts +11 -6
- package/package.json +2 -2
package/android/src/main/java/app/edge/reactnative/currencyplugins/EdgeCurrencyPluginsModule.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package app.edge.reactnative.currencyplugins;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
5
|
+
import java.util.HashMap;
|
|
6
|
+
import java.util.Map;
|
|
7
|
+
|
|
8
|
+
public class EdgeCurrencyPluginsModule extends ReactContextBaseJavaModule {
|
|
9
|
+
EdgeCurrencyPluginsModule(ReactApplicationContext context) {
|
|
10
|
+
super(context);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public Map<String, Object> getConstants() {
|
|
15
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
16
|
+
constants.put(
|
|
17
|
+
"sourceUri",
|
|
18
|
+
"file:///android_asset/edge-currency-plugins/edge-currency-plugins.js");
|
|
19
|
+
return constants;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Override
|
|
23
|
+
public String getName() {
|
|
24
|
+
return "EdgeCurrencyPluginsModule";
|
|
25
|
+
}
|
|
26
|
+
}
|
package/android/src/main/java/app/edge/reactnative/currencyplugins/EdgeCurrencyPluginsPackage.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package app.edge.reactnative.currencyplugins;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import com.facebook.react.ReactPackage;
|
|
5
|
+
import com.facebook.react.bridge.NativeModule;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
8
|
+
import java.util.Collections;
|
|
9
|
+
import java.util.List;
|
|
10
|
+
|
|
11
|
+
public class EdgeCurrencyPluginsPackage implements ReactPackage {
|
|
12
|
+
@NonNull
|
|
13
|
+
@Override
|
|
14
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
15
|
+
return Collections.<NativeModule>singletonList(
|
|
16
|
+
new EdgeCurrencyPluginsModule(reactContext));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@NonNull
|
|
20
|
+
@Override
|
|
21
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
22
|
+
return Collections.emptyList();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -12,11 +12,10 @@ var _keymanager = require('../../keymanager/keymanager');
|
|
|
12
12
|
inputIndex
|
|
13
13
|
) => {
|
|
14
14
|
const input = transactionData.inputs[inputIndex]
|
|
15
|
-
const
|
|
16
|
-
const address = await dataLayer.fetchAddress(scriptPubkey)
|
|
15
|
+
const address = await dataLayer.fetchAddress(input.scriptPubkey)
|
|
17
16
|
|
|
18
17
|
if (address == null)
|
|
19
|
-
throw new Error(`Cannot find address for ${scriptPubkey}`)
|
|
18
|
+
throw new Error(`Cannot find address for ${input.scriptPubkey}`)
|
|
20
19
|
if (address.path == null)
|
|
21
20
|
throw new Error(`Address has no derivation path information`)
|
|
22
21
|
|
|
@@ -25,8 +24,6 @@ var _keymanager = require('../../keymanager/keymanager');
|
|
|
25
24
|
|
|
26
25
|
const purposeType = _utils.currencyFormatToPurposeType.call(void 0, address.path.format)
|
|
27
26
|
const getScripts = async (
|
|
28
|
-
scriptPubkey
|
|
29
|
-
|
|
30
27
|
|
|
31
28
|
|
|
32
29
|
) => {
|
|
@@ -41,26 +38,26 @@ var _keymanager = require('../../keymanager/keymanager');
|
|
|
41
38
|
}
|
|
42
39
|
case _keymanager.BIP43PurposeTypeEnum.WrappedSegwit:
|
|
43
40
|
return {
|
|
44
|
-
script: scriptPubkey,
|
|
41
|
+
script: input.scriptPubkey,
|
|
45
42
|
scriptType: _keymanager.ScriptTypeEnum.p2wpkhp2sh
|
|
46
43
|
}
|
|
47
44
|
case _keymanager.BIP43PurposeTypeEnum.Segwit:
|
|
48
45
|
return {
|
|
49
|
-
script: scriptPubkey,
|
|
46
|
+
script: input.scriptPubkey,
|
|
50
47
|
scriptType: _keymanager.ScriptTypeEnum.p2wpkh
|
|
51
48
|
}
|
|
52
49
|
default:
|
|
53
50
|
throw new Error(`Unknown purpose type ${purposeType}`)
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
|
-
const { script, scriptType } = await getScripts(
|
|
53
|
+
const { script, scriptType } = await getScripts()
|
|
57
54
|
|
|
58
55
|
return {
|
|
59
56
|
id: `${input.txId}_${input.outputIndex}`,
|
|
60
57
|
txid: input.txId,
|
|
61
58
|
vout: input.outputIndex,
|
|
62
59
|
value: input.amount,
|
|
63
|
-
scriptPubkey,
|
|
60
|
+
scriptPubkey: input.scriptPubkey,
|
|
64
61
|
script,
|
|
65
62
|
redeemScript,
|
|
66
63
|
scriptType,
|
|
@@ -231,13 +231,13 @@ var _constants = require('./constants');
|
|
|
231
231
|
if (uri == null || !(uri in serverStatesCache)) return false
|
|
232
232
|
|
|
233
233
|
const generator = pickNextTaskCB(uri)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const result
|
|
234
|
+
|
|
235
|
+
let result
|
|
237
236
|
|
|
238
237
|
|
|
239
|
-
= await generator.next(
|
|
238
|
+
= await generator.next()
|
|
240
239
|
|
|
240
|
+
while (true) {
|
|
241
241
|
if (_optionalChain([result, 'optionalAccess', _ => _.done]) === true) {
|
|
242
242
|
return result.value
|
|
243
243
|
}
|
|
@@ -250,7 +250,18 @@ var _constants = require('./constants');
|
|
|
250
250
|
)}`
|
|
251
251
|
log(`${uri} nextTask: ${taskMessage}`)
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
try {
|
|
254
|
+
const nextValue = yield task
|
|
255
|
+
result = await generator.next(nextValue)
|
|
256
|
+
} catch (error) {
|
|
257
|
+
// Delegate the error handling to the task generator:
|
|
258
|
+
result = await generator.throw(error).catch(error => {
|
|
259
|
+
// If unhandled, log the error up to the core:
|
|
260
|
+
log.error(error)
|
|
261
|
+
// End the task generator routine (task threw unhandled error)
|
|
262
|
+
return { done: true, value: false }
|
|
263
|
+
})
|
|
264
|
+
}
|
|
254
265
|
}
|
|
255
266
|
}
|
|
256
267
|
|
|
@@ -1257,7 +1257,39 @@ const processTransactionResponse = (
|
|
|
1257
1257
|
args
|
|
1258
1258
|
) => {
|
|
1259
1259
|
const { txResponse } = args
|
|
1260
|
+
|
|
1261
|
+
let outputTotalValue = '0'
|
|
1262
|
+
const outputs = txResponse.vout.map(vout => {
|
|
1263
|
+
const scriptPubkey =
|
|
1264
|
+
_nullishCoalesce(vout.hex, () => (
|
|
1265
|
+
_cleaners.asMaybe.call(void 0,
|
|
1266
|
+
raw => _utils3.validScriptPubkeyFromAddress.call(void 0, raw),
|
|
1267
|
+
'unknown'
|
|
1268
|
+
)({
|
|
1269
|
+
address: vout.addresses[0],
|
|
1270
|
+
coin: common.pluginInfo.coinInfo.name
|
|
1271
|
+
})))
|
|
1272
|
+
outputTotalValue = _biggystring.add.call(void 0, outputTotalValue, vout.value)
|
|
1273
|
+
return {
|
|
1274
|
+
n: vout.n,
|
|
1275
|
+
scriptPubkey,
|
|
1276
|
+
amount: vout.value
|
|
1277
|
+
}
|
|
1278
|
+
})
|
|
1279
|
+
|
|
1260
1280
|
const inputs = txResponse.vin.map(vin => {
|
|
1281
|
+
// Handle coinbase input
|
|
1282
|
+
if (!vin.isAddress) {
|
|
1283
|
+
return {
|
|
1284
|
+
amount: outputTotalValue,
|
|
1285
|
+
n: 0,
|
|
1286
|
+
outputIndex: 4294967295,
|
|
1287
|
+
scriptPubkey: '', // Maybe there's a bogus scriptPubkey we can use here?
|
|
1288
|
+
sequence: vin.sequence,
|
|
1289
|
+
txId: '0000000000000000000000000000000000000000000000000000000000000000'
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1261
1293
|
const scriptPubkey =
|
|
1262
1294
|
// Note: Blockbook has empirically not sent a hex value as the
|
|
1263
1295
|
// scriptPubkey for vins. If we discover this to be changed for some
|
|
@@ -1278,22 +1310,7 @@ const processTransactionResponse = (
|
|
|
1278
1310
|
amount: vin.value
|
|
1279
1311
|
}
|
|
1280
1312
|
})
|
|
1281
|
-
|
|
1282
|
-
const scriptPubkey =
|
|
1283
|
-
_nullishCoalesce(vout.hex, () => (
|
|
1284
|
-
_cleaners.asMaybe.call(void 0,
|
|
1285
|
-
raw => _utils3.validScriptPubkeyFromAddress.call(void 0, raw),
|
|
1286
|
-
'unknown'
|
|
1287
|
-
)({
|
|
1288
|
-
address: vout.addresses[0],
|
|
1289
|
-
coin: common.pluginInfo.coinInfo.name
|
|
1290
|
-
})))
|
|
1291
|
-
return {
|
|
1292
|
-
n: vout.n,
|
|
1293
|
-
scriptPubkey,
|
|
1294
|
-
amount: vout.value
|
|
1295
|
-
}
|
|
1296
|
-
})
|
|
1313
|
+
|
|
1297
1314
|
return {
|
|
1298
1315
|
txid: txResponse.txid,
|
|
1299
1316
|
hex: txResponse.hex,
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
|
|
13
|
+
|
|
12
14
|
var _cleaners = require('cleaners');
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -65,6 +67,14 @@ var _cleaners = require('cleaners');
|
|
|
65
67
|
|
|
66
68
|
|
|
67
69
|
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
68
78
|
|
|
69
79
|
|
|
70
80
|
|
|
@@ -85,22 +95,36 @@ var _cleaners = require('cleaners');
|
|
|
85
95
|
blockTime: _cleaners.asNumber,
|
|
86
96
|
fees: _cleaners.asString,
|
|
87
97
|
vin: _cleaners.asArray.call(void 0,
|
|
88
|
-
_cleaners.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
_cleaners.asEither.call(void 0,
|
|
99
|
+
// Address input:
|
|
100
|
+
_cleaners.asObject.call(void 0, {
|
|
101
|
+
addresses: _cleaners.asArray.call(void 0, asAddress),
|
|
102
|
+
// `isAddress` is a boolean flag that indicates whether the input is an address.
|
|
103
|
+
// And therefore has `addresses` field. If `isAddress` is false, then the input is likely a coinbase input.
|
|
104
|
+
isAddress: _cleaners.asValue.call(void 0, true),
|
|
105
|
+
// This is the index of the input. Not to be confused with the index of the previous output (vout).
|
|
106
|
+
n: _cleaners.asNumber,
|
|
107
|
+
// Empirically observed omitted sequence is possible for when sequence is zero.
|
|
108
|
+
// Is the case for tx `19ecc679cfc7e71ad616a22bbee96fd5abe8616e4f408f1f5daaf137400ae091`.
|
|
109
|
+
sequence: _cleaners.asOptional.call(void 0, _cleaners.asNumber, 0),
|
|
110
|
+
txid: _cleaners.asString,
|
|
111
|
+
value: _cleaners.asString,
|
|
112
|
+
// If Blockbook doesn't provide vout, assume 0. Empirically observed
|
|
113
|
+
// case for tx `fefac8c22ba1178df5d7c90b78cc1c203d1a9f5f5506f7b8f6f469fa821c2674`
|
|
114
|
+
// which has no `vout` for input in WebSocket response payload but block
|
|
115
|
+
// will show the input's vout value to be `0`.
|
|
116
|
+
vout: _cleaners.asOptional.call(void 0, _cleaners.asNumber, 0),
|
|
117
|
+
hex: _cleaners.asOptional.call(void 0, _cleaners.asString)
|
|
118
|
+
}),
|
|
119
|
+
// Coinbase input:
|
|
120
|
+
_cleaners.asObject.call(void 0, {
|
|
121
|
+
// Coinbase input is a string of hex data (see example c6e617656b7b6d9fdcf8800fb5370479e5aceea4b6fe2fd74bd7bb0f3f2c64db)
|
|
122
|
+
coinbase: _cleaners.asString,
|
|
123
|
+
isAddress: _cleaners.asValue.call(void 0, false),
|
|
124
|
+
n: _cleaners.asNumber,
|
|
125
|
+
sequence: _cleaners.asNumber
|
|
126
|
+
})
|
|
127
|
+
)
|
|
104
128
|
),
|
|
105
129
|
vout: _cleaners.asArray.call(void 0,
|
|
106
130
|
_cleaners.asObject.call(void 0, {
|
|
@@ -27,14 +27,19 @@ export interface BlockbookTransaction {
|
|
|
27
27
|
blockTime: number;
|
|
28
28
|
fees: string;
|
|
29
29
|
vin: Array<{
|
|
30
|
-
txid: string;
|
|
31
|
-
sequence: number;
|
|
32
|
-
n: number;
|
|
33
|
-
vout: number;
|
|
34
30
|
addresses: string[];
|
|
35
|
-
isAddress: boolean;
|
|
36
|
-
value: string;
|
|
37
31
|
hex?: string;
|
|
32
|
+
isAddress: true;
|
|
33
|
+
n: number;
|
|
34
|
+
sequence: number;
|
|
35
|
+
txid: string;
|
|
36
|
+
value: string;
|
|
37
|
+
vout: number;
|
|
38
|
+
} | {
|
|
39
|
+
coinbase: string;
|
|
40
|
+
isAddress: false;
|
|
41
|
+
n: number;
|
|
42
|
+
sequence: number;
|
|
38
43
|
}>;
|
|
39
44
|
vout: Array<{
|
|
40
45
|
n: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.4",
|
|
4
4
|
"description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
|
|
5
5
|
"homepage": "https://edge.app/",
|
|
6
6
|
"repository": "https://github.com/EdgeApp/edge-currency-plugins",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"bs58": "^4.0.1",
|
|
55
55
|
"bs58grscheck": "^2.1.2",
|
|
56
56
|
"bs58smartcheck": "^2.0.4",
|
|
57
|
-
"cleaners": "^0.3.
|
|
57
|
+
"cleaners": "^0.3.17",
|
|
58
58
|
"disklet": "^0.4.5",
|
|
59
59
|
"ecpair": "https://github.com/EdgeApp/ecpair.git#b193eb8ea2ec0c93b528f4b0223a605407ff43e4",
|
|
60
60
|
"edge-sync-client": "^0.2.7",
|