edge-currency-plugins 1.0.0-rc.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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/lib/bch.js +15 -0
- package/lib/bsv.js +15 -0
- package/lib/btc.js +15 -0
- package/lib/common/constants.js +11 -0
- package/lib/common/fees/calcMinerFeePerByte.js +62 -0
- package/lib/common/fees/makeFees.js +182 -0
- package/lib/common/fees/processInfoServerFees.js +30 -0
- package/lib/common/fees/processMempoolSpaceFees.js +38 -0
- package/lib/common/plugin/makeCurrencyPlugin.js +66 -0
- package/lib/common/plugin/makeCurrencyTools.js +211 -0
- package/lib/common/plugin/makeEngineEmitter.js +102 -0
- package/lib/common/plugin/makeMetadata.js +99 -0
- package/lib/common/plugin/pluginState.js +253 -0
- package/lib/common/plugin/serverScores.js +328 -0
- package/lib/common/plugin/types.js +173 -0
- package/lib/common/plugin/utils.js +18 -0
- package/lib/common/utxobased/db/Models/ProcessorTransaction.js +122 -0
- package/lib/common/utxobased/db/Models/baselet.js +81 -0
- package/lib/common/utxobased/db/makeBaselets.js +123 -0
- package/lib/common/utxobased/db/makeMutex.js +17 -0
- package/lib/common/utxobased/db/makeProcessor.js +554 -0
- package/lib/common/utxobased/db/types.js +67 -0
- package/lib/common/utxobased/engine/await-lock.js +65 -0
- package/lib/common/utxobased/engine/constants.js +7 -0
- package/lib/common/utxobased/engine/makeServerStates.js +394 -0
- package/lib/common/utxobased/engine/makeUtxoEngine.js +690 -0
- package/lib/common/utxobased/engine/makeUtxoEngineState.js +1443 -0
- package/lib/common/utxobased/engine/makeUtxoWalletTools.js +216 -0
- package/lib/common/utxobased/engine/paymentRequest.js +102 -0
- package/lib/common/utxobased/engine/types.js +21 -0
- package/lib/common/utxobased/engine/util/defaultValidateConfirmations.js +19 -0
- package/lib/common/utxobased/engine/util/getOwnUtxosFromTx.js +54 -0
- package/lib/common/utxobased/engine/utils.js +239 -0
- package/lib/common/utxobased/info/all.js +67 -0
- package/lib/common/utxobased/info/badcoin.js +73 -0
- package/lib/common/utxobased/info/bitcoin.js +91 -0
- package/lib/common/utxobased/info/bitcoincash.js +93 -0
- package/lib/common/utxobased/info/bitcoincashtestnet.js +72 -0
- package/lib/common/utxobased/info/bitcoingold.js +85 -0
- package/lib/common/utxobased/info/bitcoingoldtestnet.js +71 -0
- package/lib/common/utxobased/info/bitcoinsv.js +76 -0
- package/lib/common/utxobased/info/bitcointestnet.js +81 -0
- package/lib/common/utxobased/info/dash.js +76 -0
- package/lib/common/utxobased/info/digibyte.js +76 -0
- package/lib/common/utxobased/info/dogecoin.js +76 -0
- package/lib/common/utxobased/info/eboost.js +70 -0
- package/lib/common/utxobased/info/feathercoin.js +76 -0
- package/lib/common/utxobased/info/groestlcoin.js +88 -0
- package/lib/common/utxobased/info/litecoin.js +82 -0
- package/lib/common/utxobased/info/qtum.js +67 -0
- package/lib/common/utxobased/info/ravencoin.js +70 -0
- package/lib/common/utxobased/info/scriptTemplates/bitcoincashScriptTemplates.js +56 -0
- package/lib/common/utxobased/info/scriptTemplates/types.js +14 -0
- package/lib/common/utxobased/info/smartcash.js +78 -0
- package/lib/common/utxobased/info/ufo.js +75 -0
- package/lib/common/utxobased/info/utxoPickers/dogeUtxoPicker.js +34 -0
- package/lib/common/utxobased/info/vertcoin.js +82 -0
- package/lib/common/utxobased/info/zcoin.js +72 -0
- package/lib/common/utxobased/keymanager/base.js +60 -0
- package/lib/common/utxobased/keymanager/bip69.js +31 -0
- package/lib/common/utxobased/keymanager/bitcoincashUtils/base32.js +88 -0
- package/lib/common/utxobased/keymanager/bitcoincashUtils/bn.js +210 -0
- package/lib/common/utxobased/keymanager/bitcoincashUtils/cashAddress.js +282 -0
- package/lib/common/utxobased/keymanager/cleaners.js +198 -0
- package/lib/common/utxobased/keymanager/coinmapper.js +12 -0
- package/lib/common/utxobased/keymanager/declarations/base58grscheck.d.js +1 -0
- package/lib/common/utxobased/keymanager/declarations/blake-hash.d.js +1 -0
- package/lib/common/utxobased/keymanager/declarations/bn.d.js +1 -0
- package/lib/common/utxobased/keymanager/declarations/bs58smartcheck.d.js +1 -0
- package/lib/common/utxobased/keymanager/declarations/wif-smart.d.js +1 -0
- package/lib/common/utxobased/keymanager/declarations/wifgrs.d.js +1 -0
- package/lib/common/utxobased/keymanager/keymanager.js +1214 -0
- package/lib/common/utxobased/keymanager/utxopicker/accumulative.js +52 -0
- package/lib/common/utxobased/keymanager/utxopicker/forceUseUtxo.js +59 -0
- package/lib/common/utxobased/keymanager/utxopicker/subtractFee.js +17 -0
- package/lib/common/utxobased/keymanager/utxopicker/types.js +42 -0
- package/lib/common/utxobased/keymanager/utxopicker/utils.js +159 -0
- package/lib/common/utxobased/keymanager/utxopicker.js +17 -0
- package/lib/common/utxobased/network/BlockBook.js +200 -0
- package/lib/common/utxobased/network/BlockBookAPI.js +335 -0
- package/lib/common/utxobased/network/Deferred.js +29 -0
- package/lib/common/utxobased/network/MakeSocketEmitter.js +35 -0
- package/lib/common/utxobased/network/Socket.js +362 -0
- package/lib/common/utxobased/network/nodejsWS.js +59 -0
- package/lib/common/utxobased/network/socketQueue.js +60 -0
- package/lib/common/utxobased/network/types.js +19 -0
- package/lib/common/utxobased/network/windowWS.js +54 -0
- package/lib/firo.js +15 -0
- package/lib/ftc.js +15 -0
- package/lib/index.js +19 -0
- package/lib/ltc.js +15 -0
- package/lib/src/bch.d.ts +3 -0
- package/lib/src/bsv.d.ts +3 -0
- package/lib/src/btc.d.ts +3 -0
- package/lib/src/common/constants.d.ts +9 -0
- package/lib/src/common/fees/calcMinerFeePerByte.d.ts +13 -0
- package/lib/src/common/fees/makeFees.d.ts +20 -0
- package/lib/src/common/fees/processInfoServerFees.d.ts +7 -0
- package/lib/src/common/fees/processMempoolSpaceFees.d.ts +13 -0
- package/lib/src/common/plugin/makeCurrencyPlugin.d.ts +3 -0
- package/lib/src/common/plugin/makeCurrencyTools.d.ts +8 -0
- package/lib/src/common/plugin/makeEngineEmitter.d.ts +23 -0
- package/lib/src/common/plugin/makeMetadata.d.ts +14 -0
- package/lib/src/common/plugin/pluginState.d.ts +34 -0
- package/lib/src/common/plugin/serverScores.d.ts +61 -0
- package/lib/src/common/plugin/types.d.ts +135 -0
- package/lib/src/common/plugin/utils.d.ts +6 -0
- package/lib/src/common/utxobased/db/Models/ProcessorTransaction.d.ts +16 -0
- package/lib/src/common/utxobased/db/Models/baselet.d.ts +28 -0
- package/lib/src/common/utxobased/db/makeBaselets.d.ts +33 -0
- package/lib/src/common/utxobased/db/makeMutex.d.ts +3 -0
- package/lib/src/common/utxobased/db/makeProcessor.d.ts +42 -0
- package/lib/src/common/utxobased/db/types.d.ts +47 -0
- package/lib/src/common/utxobased/engine/await-lock.d.ts +29 -0
- package/lib/src/common/utxobased/engine/constants.d.ts +4 -0
- package/lib/src/common/utxobased/engine/makeServerStates.d.ts +37 -0
- package/lib/src/common/utxobased/engine/makeUtxoEngine.d.ts +3 -0
- package/lib/src/common/utxobased/engine/makeUtxoEngineState.d.ts +108 -0
- package/lib/src/common/utxobased/engine/makeUtxoWalletTools.d.ts +52 -0
- package/lib/src/common/utxobased/engine/paymentRequest.d.ts +18 -0
- package/lib/src/common/utxobased/engine/types.d.ts +19 -0
- package/lib/src/common/utxobased/engine/util/defaultValidateConfirmations.d.ts +3 -0
- package/lib/src/common/utxobased/engine/util/getOwnUtxosFromTx.d.ts +4 -0
- package/lib/src/common/utxobased/engine/utils.d.ts +43 -0
- package/lib/src/common/utxobased/info/all.d.ts +22 -0
- package/lib/src/common/utxobased/info/badcoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcoincash.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcoincashtestnet.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcoingold.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcoingoldtestnet.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcoinsv.d.ts +3 -0
- package/lib/src/common/utxobased/info/bitcointestnet.d.ts +6 -0
- package/lib/src/common/utxobased/info/dash.d.ts +3 -0
- package/lib/src/common/utxobased/info/digibyte.d.ts +3 -0
- package/lib/src/common/utxobased/info/dogecoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/eboost.d.ts +3 -0
- package/lib/src/common/utxobased/info/feathercoin.d.ts +6 -0
- package/lib/src/common/utxobased/info/groestlcoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/litecoin.d.ts +6 -0
- package/lib/src/common/utxobased/info/qtum.d.ts +3 -0
- package/lib/src/common/utxobased/info/ravencoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/scriptTemplates/bitcoincashScriptTemplates.d.ts +2 -0
- package/lib/src/common/utxobased/info/scriptTemplates/types.d.ts +9 -0
- package/lib/src/common/utxobased/info/smartcash.d.ts +3 -0
- package/lib/src/common/utxobased/info/ufo.d.ts +3 -0
- package/lib/src/common/utxobased/info/utxoPickers/dogeUtxoPicker.d.ts +2 -0
- package/lib/src/common/utxobased/info/vertcoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/zcoin.d.ts +6 -0
- package/lib/src/common/utxobased/keymanager/base.d.ts +9 -0
- package/lib/src/common/utxobased/keymanager/bip69.d.ts +19 -0
- package/lib/src/common/utxobased/keymanager/bitcoincashUtils/base32.d.ts +19 -0
- package/lib/src/common/utxobased/keymanager/bitcoincashUtils/bn.d.ts +2 -0
- package/lib/src/common/utxobased/keymanager/bitcoincashUtils/cashAddress.d.ts +12 -0
- package/lib/src/common/utxobased/keymanager/cleaners.d.ts +55 -0
- package/lib/src/common/utxobased/keymanager/coinmapper.d.ts +2 -0
- package/lib/src/common/utxobased/keymanager/keymanager.d.ts +198 -0
- package/lib/src/common/utxobased/keymanager/utxopicker/accumulative.d.ts +2 -0
- package/lib/src/common/utxobased/keymanager/utxopicker/forceUseUtxo.d.ts +2 -0
- package/lib/src/common/utxobased/keymanager/utxopicker/subtractFee.d.ts +2 -0
- package/lib/src/common/utxobased/keymanager/utxopicker/types.d.ts +36 -0
- package/lib/src/common/utxobased/keymanager/utxopicker/utils.d.ts +15 -0
- package/lib/src/common/utxobased/keymanager/utxopicker.d.ts +8 -0
- package/lib/src/common/utxobased/network/BlockBook.d.ts +33 -0
- package/lib/src/common/utxobased/network/BlockBookAPI.d.ts +163 -0
- package/lib/src/common/utxobased/network/Deferred.d.ts +8 -0
- package/lib/src/common/utxobased/network/MakeSocketEmitter.d.ts +13 -0
- package/lib/src/common/utxobased/network/Socket.d.ts +41 -0
- package/lib/src/common/utxobased/network/nodejsWS.d.ts +2 -0
- package/lib/src/common/utxobased/network/socketQueue.d.ts +8 -0
- package/lib/src/common/utxobased/network/types.d.ts +17 -0
- package/lib/src/common/utxobased/network/windowWS.d.ts +2 -0
- package/lib/src/firo.d.ts +3 -0
- package/lib/src/ftc.d.ts +3 -0
- package/lib/src/index.d.ts +4 -0
- package/lib/src/ltc.d.ts +3 -0
- package/lib/src/tbch.d.ts +3 -0
- package/lib/src/tbtc.d.ts +3 -0
- package/lib/src/tbtg.d.ts +3 -0
- package/lib/src/types.d.ts +6 -0
- package/lib/src/util/delay.d.ts +1 -0
- package/lib/src/util/filterUndefined.d.ts +1 -0
- package/lib/src/util/indexAtProtected.d.ts +5 -0
- package/lib/src/util/typeUtil.d.ts +8 -0
- package/lib/src/util/undefinedIfEmptyString.d.ts +1 -0
- package/lib/src/util/unixTime.d.ts +1 -0
- package/lib/tbch.js +15 -0
- package/lib/tbtc.js +15 -0
- package/lib/tbtg.js +15 -0
- package/lib/test/common/fees/calcMinerFeePerByte.spec.d.ts +1 -0
- package/lib/test/common/fees/fees.spec.d.ts +1 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/common.d.ts +29 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/bitcoin.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/bitcoincash.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/bitcoinsv.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/digibyte.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/feathercoin.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/groestlcoin.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/litecoin.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/smartcash.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/currencies/zcoin.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.fixtures/index.d.ts +2 -0
- package/lib/test/common/plugin/currencyPlugin.spec.d.ts +1 -0
- package/lib/test/common/plugin/makeMetadata.spec.d.ts +1 -0
- package/lib/test/common/plugin/serverScores.spec.d.ts +1 -0
- package/lib/test/common/utxobased/addressFormat/addressFormatIndex/addressFormat.spec.d.ts +1 -0
- package/lib/test/common/utxobased/db/Processor.spec.d.ts +1 -0
- package/lib/test/common/utxobased/engine/PaymentRequest.spec.d.ts +1 -0
- package/lib/test/common/utxobased/engine/UtxoWalletTools.spec.d.ts +1 -0
- package/lib/test/common/utxobased/engine/engine.fixtures/bitcoinTestnet/tests.d.ts +70 -0
- package/lib/test/common/utxobased/engine/engine.fixtures/index.d.ts +65 -0
- package/lib/test/common/utxobased/engine/engine.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/altcointestfixtures.d.ts +54 -0
- package/lib/test/common/utxobased/keymanager/coins/bitcoincashtransactiontest.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/bitcointransactiontest.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/cashaddr.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/checkdatasig.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/groestlcointransactiontest.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/keymanagertest.spec.d.ts +1 -0
- package/lib/test/common/utxobased/network/BlockBook.spec.d.ts +1 -0
- package/lib/test/util/objectKeys.d.ts +8 -0
- package/lib/test/util/testLog.d.ts +3 -0
- package/lib/test/utils.d.ts +10 -0
- package/lib/types.js +7 -0
- package/lib/util/delay.js +4 -0
- package/lib/util/filterUndefined.js +4 -0
- package/lib/util/indexAtProtected.js +9 -0
- package/lib/util/typeUtil.js +9 -0
- package/lib/util/undefinedIfEmptyString.js +2 -0
- package/lib/util/unixTime.js +2 -0
- package/package.json +101 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _keymanager = require('../keymanager/keymanager');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _utils = require('./utils');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
function makeUtxoWalletTools(
|
|
90
|
+
config
|
|
91
|
+
) {
|
|
92
|
+
const { coin, publicKey } = config
|
|
93
|
+
|
|
94
|
+
const xpubKeys = publicKey.publicKeys
|
|
95
|
+
|
|
96
|
+
const fns = {
|
|
97
|
+
getPubkey(args) {
|
|
98
|
+
if (xpubKeys[args.format] == null) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`wallet tools: xpub with format ${args.format} does not exist`
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return _keymanager.xpubToPubkey.call(void 0, {
|
|
104
|
+
xpub: _nullishCoalesce(xpubKeys[args.format], () => ( '')),
|
|
105
|
+
coin,
|
|
106
|
+
type: _utils.currencyFormatToPurposeType.call(void 0, args.format),
|
|
107
|
+
bip44ChangeIndex: args.changeIndex,
|
|
108
|
+
bip44AddressIndex: args.addressIndex
|
|
109
|
+
})
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
getScriptPubkey(args) {
|
|
113
|
+
const purposeType = _utils.currencyFormatToPurposeType.call(void 0, args.format)
|
|
114
|
+
const scriptType = _utils.getScriptTypeFromPurposeType.call(void 0, purposeType)
|
|
115
|
+
return _keymanager.pubkeyToScriptPubkey.call(void 0, {
|
|
116
|
+
pubkey: fns.getPubkey(args),
|
|
117
|
+
scriptType
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
// Used specifically for sweeping private keys (WIFs)
|
|
122
|
+
getScriptPubkeyFromWif(
|
|
123
|
+
wifKey,
|
|
124
|
+
format
|
|
125
|
+
) {
|
|
126
|
+
const purposeType = _utils.currencyFormatToPurposeType.call(void 0, format)
|
|
127
|
+
const scriptType = _utils.getScriptTypeFromPurposeType.call(void 0, purposeType)
|
|
128
|
+
const pubkey = _keymanager.privateKeyToPubkey.call(void 0,
|
|
129
|
+
_keymanager.wifToPrivateKey.call(void 0, {
|
|
130
|
+
wifKey,
|
|
131
|
+
coin
|
|
132
|
+
})
|
|
133
|
+
)
|
|
134
|
+
return _keymanager.pubkeyToScriptPubkey.call(void 0, {
|
|
135
|
+
pubkey: pubkey,
|
|
136
|
+
scriptType
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
getAddress(args) {
|
|
141
|
+
const purposeType = _utils.currencyFormatToPurposeType.call(void 0, args.format)
|
|
142
|
+
const { scriptPubkey } = fns.getScriptPubkey(args)
|
|
143
|
+
const addressType = _utils.getAddressTypeFromPurposeType.call(void 0, purposeType)
|
|
144
|
+
return _keymanager.scriptPubkeyToAddress.call(void 0, {
|
|
145
|
+
scriptPubkey,
|
|
146
|
+
addressType,
|
|
147
|
+
coin
|
|
148
|
+
})
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
addressToScriptPubkey(address) {
|
|
152
|
+
return _keymanager.addressToScriptPubkey.call(void 0, { address, coin })
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
scriptPubkeyToAddress(args) {
|
|
156
|
+
const purposeType = _utils.currencyFormatToPurposeType.call(void 0, args.format)
|
|
157
|
+
const addressType = _utils.getAddressTypeFromPurposeType.call(void 0, purposeType)
|
|
158
|
+
return _keymanager.scriptPubkeyToAddress.call(void 0, {
|
|
159
|
+
scriptPubkey: args.scriptPubkey,
|
|
160
|
+
addressType,
|
|
161
|
+
coin
|
|
162
|
+
})
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
getPrivateKey(args) {
|
|
166
|
+
const { path, xprivKeys } = args
|
|
167
|
+
const xpriv = xprivKeys[path.format]
|
|
168
|
+
if (xpriv == null) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`wallet tools: xpriv with format ${path.format} does not exist`
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
return _keymanager.xprivToPrivateKey.call(void 0, {
|
|
174
|
+
xpriv: xpriv,
|
|
175
|
+
type: _utils.currencyFormatToPurposeType.call(void 0, path.format),
|
|
176
|
+
coin,
|
|
177
|
+
bip44ChangeIndex: path.changeIndex,
|
|
178
|
+
bip44AddressIndex: path.addressIndex
|
|
179
|
+
})
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
getPrivateKeyFromWif(wifKey) {
|
|
183
|
+
return _keymanager.wifToPrivateKey.call(void 0, {
|
|
184
|
+
wifKey,
|
|
185
|
+
coin
|
|
186
|
+
})
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
getScriptAddress({
|
|
190
|
+
path,
|
|
191
|
+
scriptTemplate
|
|
192
|
+
}) {
|
|
193
|
+
// get the replay protection script from the templates and wrap it in p2sh
|
|
194
|
+
const publicKey = fns.getPubkey(path)
|
|
195
|
+
const script = scriptTemplate(publicKey)
|
|
196
|
+
const { address, scriptPubkey, redeemScript } = _keymanager.scriptPubkeyToP2SH.call(void 0, {
|
|
197
|
+
coin,
|
|
198
|
+
scriptPubkey: script
|
|
199
|
+
})
|
|
200
|
+
if (address == null) {
|
|
201
|
+
throw new Error('Failed to derive address for script')
|
|
202
|
+
}
|
|
203
|
+
return { address, scriptPubkey, redeemScript }
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
signMessageBase64({ path, message, xprivKeys }) {
|
|
207
|
+
const privKey = fns.getPrivateKey({
|
|
208
|
+
path,
|
|
209
|
+
xprivKeys
|
|
210
|
+
})
|
|
211
|
+
return _keymanager.signMessageBase64.call(void 0, message, privKey)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return fns
|
|
216
|
+
} exports.makeUtxoWalletTools = makeUtxoWalletTools;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _urlparse = require('url-parse'); var _urlparse2 = _interopRequireDefault(_urlparse);
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function getSpendTargets(
|
|
19
|
+
outputs
|
|
20
|
+
) {
|
|
21
|
+
let nativeAmount = 0
|
|
22
|
+
const spendTargets = []
|
|
23
|
+
for (const output of outputs) {
|
|
24
|
+
nativeAmount += output.amount
|
|
25
|
+
spendTargets.push({
|
|
26
|
+
publicAddress: output.address,
|
|
27
|
+
nativeAmount: `${output.amount}`
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
return { nativeAmount, spendTargets }
|
|
31
|
+
} exports.getSpendTargets = getSpendTargets;
|
|
32
|
+
|
|
33
|
+
async function getPaymentDetails(
|
|
34
|
+
paymentProtocolURL,
|
|
35
|
+
currencyCode,
|
|
36
|
+
fetch
|
|
37
|
+
) {
|
|
38
|
+
const headers = {
|
|
39
|
+
Accept: 'application/payment-request',
|
|
40
|
+
'x-currency': currencyCode
|
|
41
|
+
}
|
|
42
|
+
const result = await fetch(paymentProtocolURL, { headers })
|
|
43
|
+
if (result.status !== 200) {
|
|
44
|
+
const error = await result.text()
|
|
45
|
+
throw new Error(error)
|
|
46
|
+
}
|
|
47
|
+
const paymentRequest = await result.json()
|
|
48
|
+
const {
|
|
49
|
+
outputs,
|
|
50
|
+
memo,
|
|
51
|
+
paymentUrl,
|
|
52
|
+
paymentId,
|
|
53
|
+
requiredFeeRate
|
|
54
|
+
} = paymentRequest
|
|
55
|
+
|
|
56
|
+
const { nativeAmount, spendTargets } = getSpendTargets(outputs)
|
|
57
|
+
const domain = _urlparse2.default.call(void 0, paymentUrl, {}).hostname
|
|
58
|
+
|
|
59
|
+
const edgePaymentProtocolInfo = {
|
|
60
|
+
nativeAmount: `${nativeAmount}`,
|
|
61
|
+
merchant: `{ ${JSON.stringify(paymentId)}, ${JSON.stringify(
|
|
62
|
+
requiredFeeRate
|
|
63
|
+
)} }`,
|
|
64
|
+
memo,
|
|
65
|
+
domain,
|
|
66
|
+
spendTargets
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return edgePaymentProtocolInfo
|
|
70
|
+
} exports.getPaymentDetails = getPaymentDetails;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function createPayment(
|
|
78
|
+
tx,
|
|
79
|
+
currencyCode
|
|
80
|
+
) {
|
|
81
|
+
return { currency: currencyCode, transactions: [tx] }
|
|
82
|
+
} exports.createPayment = createPayment;
|
|
83
|
+
|
|
84
|
+
async function sendPayment(
|
|
85
|
+
fetch,
|
|
86
|
+
paymentUrl,
|
|
87
|
+
payment
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
) {
|
|
90
|
+
const headers = { 'Content-Type': 'application/payment' }
|
|
91
|
+
const result = await fetch(paymentUrl, {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers,
|
|
94
|
+
body: JSON.stringify(payment)
|
|
95
|
+
})
|
|
96
|
+
if (result.status !== 200) {
|
|
97
|
+
const error = await result.text()
|
|
98
|
+
throw new Error(error)
|
|
99
|
+
}
|
|
100
|
+
const paymentACK = await result.json()
|
|
101
|
+
return paymentACK
|
|
102
|
+
} exports.sendPayment = sendPayment;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _cleaners = require('cleaners');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const asUtxoUserSettings = _cleaners.asObject.call(void 0, {
|
|
7
|
+
blockbookServers: _cleaners.asMaybe.call(void 0, _cleaners.asArray.call(void 0, _cleaners.asString), []),
|
|
8
|
+
enableCustomServers: _cleaners.asMaybe.call(void 0, _cleaners.asBoolean, false)
|
|
9
|
+
}); exports.asUtxoUserSettings = asUtxoUserSettings
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const defaultValidateConfirmations = (
|
|
6
|
+
tx,
|
|
7
|
+
blockHeight,
|
|
8
|
+
requiredConfirmations = 1
|
|
9
|
+
) => {
|
|
10
|
+
const blockConfirmations =
|
|
11
|
+
tx.blockHeight === 0 ? 0 : 1 + blockHeight - tx.blockHeight
|
|
12
|
+
const confirmations =
|
|
13
|
+
blockConfirmations >= requiredConfirmations
|
|
14
|
+
? 'confirmed'
|
|
15
|
+
: blockConfirmations <= 0
|
|
16
|
+
? 'unconfirmed'
|
|
17
|
+
: blockConfirmations
|
|
18
|
+
return confirmations
|
|
19
|
+
}; exports.defaultValidateConfirmations = defaultValidateConfirmations
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _keymanager = require('../../keymanager/keymanager');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _utils = require('../utils');
|
|
9
|
+
|
|
10
|
+
const getOwnUtxosFromTx = async (
|
|
11
|
+
engineInfo,
|
|
12
|
+
processor,
|
|
13
|
+
tx
|
|
14
|
+
) => {
|
|
15
|
+
const utxos = []
|
|
16
|
+
for (const output of tx.outputs) {
|
|
17
|
+
const scriptPubkey = output.scriptPubkey
|
|
18
|
+
const address = await processor.fetchAddress(scriptPubkey)
|
|
19
|
+
if (address != null) {
|
|
20
|
+
const id = `${tx.txid}_${output.n}`
|
|
21
|
+
const path = address.path
|
|
22
|
+
if (path != null) {
|
|
23
|
+
const redeemScript = address.redeemScript
|
|
24
|
+
const purposeType = _utils.currencyFormatToPurposeType.call(void 0, path.format)
|
|
25
|
+
|
|
26
|
+
const isAirbitzOrLegacy = [
|
|
27
|
+
_keymanager.BIP43PurposeTypeEnum.Airbitz,
|
|
28
|
+
_keymanager.BIP43PurposeTypeEnum.Legacy
|
|
29
|
+
].includes(purposeType)
|
|
30
|
+
|
|
31
|
+
const scriptType = _utils.getScriptTypeFromPurposeType.call(void 0,
|
|
32
|
+
purposeType,
|
|
33
|
+
redeemScript,
|
|
34
|
+
engineInfo.scriptTemplates
|
|
35
|
+
)
|
|
36
|
+
const script = isAirbitzOrLegacy ? tx.hex : address.scriptPubkey
|
|
37
|
+
const utxo = {
|
|
38
|
+
id,
|
|
39
|
+
txid: tx.txid,
|
|
40
|
+
vout: output.n,
|
|
41
|
+
value: output.amount,
|
|
42
|
+
scriptPubkey,
|
|
43
|
+
script,
|
|
44
|
+
redeemScript,
|
|
45
|
+
scriptType,
|
|
46
|
+
blockHeight: tx.blockHeight,
|
|
47
|
+
spent: false
|
|
48
|
+
}
|
|
49
|
+
utxos.push(utxo)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return utxos
|
|
54
|
+
}; exports.getOwnUtxosFromTx = getOwnUtxosFromTx
|
|
@@ -0,0 +1,239 @@
|
|
|
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; }var _biggystring = require('biggystring'); var bs = _interopRequireWildcard(_biggystring);
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _cleaners = require('../keymanager/cleaners');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _keymanager = require('../keymanager/keymanager');
|
|
22
|
+
|
|
23
|
+
const getCurrencyFormatFromPurposeType = (
|
|
24
|
+
purpose
|
|
25
|
+
) => {
|
|
26
|
+
switch (purpose) {
|
|
27
|
+
case _keymanager.BIP43PurposeTypeEnum.Airbitz:
|
|
28
|
+
return 'bip32'
|
|
29
|
+
case _keymanager.BIP43PurposeTypeEnum.Legacy:
|
|
30
|
+
return 'bip44'
|
|
31
|
+
case _keymanager.BIP43PurposeTypeEnum.WrappedSegwit:
|
|
32
|
+
return 'bip49'
|
|
33
|
+
case _keymanager.BIP43PurposeTypeEnum.Segwit:
|
|
34
|
+
return 'bip84'
|
|
35
|
+
}
|
|
36
|
+
}; exports.getCurrencyFormatFromPurposeType = getCurrencyFormatFromPurposeType
|
|
37
|
+
|
|
38
|
+
const getAddressTypeFromKeys = (
|
|
39
|
+
privateKey
|
|
40
|
+
) => {
|
|
41
|
+
return exports.getAddressTypeFromPurposeType.call(void 0,
|
|
42
|
+
exports.currencyFormatToPurposeType.call(void 0, privateKey.format)
|
|
43
|
+
)
|
|
44
|
+
}; exports.getAddressTypeFromKeys = getAddressTypeFromKeys
|
|
45
|
+
|
|
46
|
+
const getAddressTypeFromPurposeType = (
|
|
47
|
+
purpose
|
|
48
|
+
) => {
|
|
49
|
+
switch (purpose) {
|
|
50
|
+
case _keymanager.BIP43PurposeTypeEnum.Airbitz:
|
|
51
|
+
case _keymanager.BIP43PurposeTypeEnum.Legacy:
|
|
52
|
+
return _keymanager.AddressTypeEnum.p2pkh
|
|
53
|
+
|
|
54
|
+
case _keymanager.BIP43PurposeTypeEnum.WrappedSegwit:
|
|
55
|
+
return _keymanager.AddressTypeEnum.p2sh
|
|
56
|
+
|
|
57
|
+
case _keymanager.BIP43PurposeTypeEnum.Segwit:
|
|
58
|
+
return _keymanager.AddressTypeEnum.p2wpkh
|
|
59
|
+
}
|
|
60
|
+
}; exports.getAddressTypeFromPurposeType = getAddressTypeFromPurposeType
|
|
61
|
+
|
|
62
|
+
const getScriptTypeFromPurposeType = (
|
|
63
|
+
purpose,
|
|
64
|
+
redeemScript,
|
|
65
|
+
scriptTemplates
|
|
66
|
+
) => {
|
|
67
|
+
switch (purpose) {
|
|
68
|
+
case _keymanager.BIP43PurposeTypeEnum.Airbitz:
|
|
69
|
+
case _keymanager.BIP43PurposeTypeEnum.Legacy:
|
|
70
|
+
if (redeemScript != null) {
|
|
71
|
+
if (_optionalChain([scriptTemplates, 'optionalAccess', _ => _.replayProtection]) != null) {
|
|
72
|
+
const replayProtectionPartialScript = scriptTemplates
|
|
73
|
+
.replayProtection('')
|
|
74
|
+
.slice(0, -4)
|
|
75
|
+
if (redeemScript.indexOf(replayProtectionPartialScript) === 0) {
|
|
76
|
+
return _keymanager.ScriptTypeEnum.replayProtection
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return _keymanager.ScriptTypeEnum.p2pkh
|
|
81
|
+
|
|
82
|
+
case _keymanager.BIP43PurposeTypeEnum.WrappedSegwit:
|
|
83
|
+
return _keymanager.ScriptTypeEnum.p2wpkhp2sh
|
|
84
|
+
|
|
85
|
+
case _keymanager.BIP43PurposeTypeEnum.Segwit:
|
|
86
|
+
return _keymanager.ScriptTypeEnum.p2wpkh
|
|
87
|
+
}
|
|
88
|
+
}; exports.getScriptTypeFromPurposeType = getScriptTypeFromPurposeType
|
|
89
|
+
|
|
90
|
+
const validScriptPubkeyFromAddress = (args
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
) =>
|
|
94
|
+
_keymanager.addressToScriptPubkey.call(void 0, {
|
|
95
|
+
...args
|
|
96
|
+
}); exports.validScriptPubkeyFromAddress = validScriptPubkeyFromAddress
|
|
97
|
+
|
|
98
|
+
const getFormatSupportedBranches = (
|
|
99
|
+
format
|
|
100
|
+
) => {
|
|
101
|
+
const branches = [0]
|
|
102
|
+
if (exports.currencyFormatToPurposeType.call(void 0, format) !== _keymanager.BIP43PurposeTypeEnum.Airbitz) {
|
|
103
|
+
branches.push(1)
|
|
104
|
+
}
|
|
105
|
+
return branches
|
|
106
|
+
}; exports.getFormatSupportedBranches = getFormatSupportedBranches
|
|
107
|
+
|
|
108
|
+
const currencyFormatToPurposeType = (
|
|
109
|
+
format
|
|
110
|
+
) =>
|
|
111
|
+
_keymanager.bip43PurposeNumberToTypeEnum.call(void 0, parseInt(format.replace('bip', ''))); exports.currencyFormatToPurposeType = currencyFormatToPurposeType
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
const fetchOrDeriveXprivFromKeys = async (args
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
) => {
|
|
122
|
+
const filename = 'walletKeys.json'
|
|
123
|
+
let keys
|
|
124
|
+
try {
|
|
125
|
+
const data = await args.walletLocalEncryptedDisklet.getText(filename)
|
|
126
|
+
keys = JSON.parse(data)
|
|
127
|
+
} catch (e) {
|
|
128
|
+
keys = exports.deriveXprivFromKeys.call(void 0, args)
|
|
129
|
+
await args.walletLocalEncryptedDisklet.setText(
|
|
130
|
+
filename,
|
|
131
|
+
JSON.stringify(keys)
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
return keys
|
|
135
|
+
}; exports.fetchOrDeriveXprivFromKeys = fetchOrDeriveXprivFromKeys
|
|
136
|
+
|
|
137
|
+
const deriveXprivFromKeys = (args
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
) => {
|
|
141
|
+
const keys = {}
|
|
142
|
+
const xprivArgs = {
|
|
143
|
+
seed: args.privateKey.seed,
|
|
144
|
+
coinType: args.privateKey.coinType,
|
|
145
|
+
coin: args.coin
|
|
146
|
+
}
|
|
147
|
+
const walletPurpose = exports.currencyFormatToPurposeType.call(void 0, args.privateKey.format)
|
|
148
|
+
if (
|
|
149
|
+
walletPurpose === _keymanager.BIP43PurposeTypeEnum.Segwit ||
|
|
150
|
+
walletPurpose === _keymanager.BIP43PurposeTypeEnum.WrappedSegwit
|
|
151
|
+
) {
|
|
152
|
+
keys[
|
|
153
|
+
exports.getCurrencyFormatFromPurposeType.call(void 0, _keymanager.BIP43PurposeTypeEnum.Segwit)
|
|
154
|
+
] = _keymanager.seedOrMnemonicToXPriv.call(void 0, {
|
|
155
|
+
...xprivArgs,
|
|
156
|
+
type: _keymanager.BIP43PurposeTypeEnum.Segwit
|
|
157
|
+
})
|
|
158
|
+
keys[
|
|
159
|
+
exports.getCurrencyFormatFromPurposeType.call(void 0, _keymanager.BIP43PurposeTypeEnum.WrappedSegwit)
|
|
160
|
+
] = _keymanager.seedOrMnemonicToXPriv.call(void 0, {
|
|
161
|
+
...xprivArgs,
|
|
162
|
+
type: _keymanager.BIP43PurposeTypeEnum.WrappedSegwit
|
|
163
|
+
})
|
|
164
|
+
} else {
|
|
165
|
+
keys[
|
|
166
|
+
exports.getCurrencyFormatFromPurposeType.call(void 0, walletPurpose)
|
|
167
|
+
] = _keymanager.seedOrMnemonicToXPriv.call(void 0, {
|
|
168
|
+
...xprivArgs,
|
|
169
|
+
type: walletPurpose
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return keys
|
|
174
|
+
}; exports.deriveXprivFromKeys = deriveXprivFromKeys
|
|
175
|
+
|
|
176
|
+
const deriveXpubsFromKeys = (args
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
) => {
|
|
180
|
+
const xpubs = {}
|
|
181
|
+
for (const format of _cleaners.getSupportedFormats.call(void 0, args.privateKey.format)) {
|
|
182
|
+
xpubs[format] = exports.deriveXpub.call(void 0, {
|
|
183
|
+
...args,
|
|
184
|
+
type: exports.currencyFormatToPurposeType.call(void 0, format)
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
return xpubs
|
|
188
|
+
}; exports.deriveXpubsFromKeys = deriveXpubsFromKeys
|
|
189
|
+
|
|
190
|
+
const deriveXpub = (args
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
) => {
|
|
195
|
+
const xpriv = exports.deriveXprivFromKeys.call(void 0, args)[
|
|
196
|
+
exports.getCurrencyFormatFromPurposeType.call(void 0, args.type)
|
|
197
|
+
]
|
|
198
|
+
if (xpriv == null)
|
|
199
|
+
throw new Error('Cannot derive xpub: no private key exists')
|
|
200
|
+
return _keymanager.xprivToXPub.call(void 0, { ...args, xpriv })
|
|
201
|
+
}; exports.deriveXpub = deriveXpub
|
|
202
|
+
|
|
203
|
+
const parsePathname = (args
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
) => {
|
|
207
|
+
const edgeParsedUri = {}
|
|
208
|
+
|
|
209
|
+
// Check if the pathname type is a wif
|
|
210
|
+
try {
|
|
211
|
+
_keymanager.wifToPrivateKey.call(void 0, {
|
|
212
|
+
wifKey: args.pathname,
|
|
213
|
+
coin: args.coin
|
|
214
|
+
})
|
|
215
|
+
edgeParsedUri.privateKeys = [args.pathname]
|
|
216
|
+
} catch (e) {
|
|
217
|
+
// If the pathname is non of the above, then assume it's an address and check for validity
|
|
218
|
+
const addressFormat = _keymanager.verifyAddress.call(void 0, {
|
|
219
|
+
address: args.pathname,
|
|
220
|
+
coin: args.coin
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
// Throw if address format failed
|
|
224
|
+
if (addressFormat === _keymanager.VerifyAddressEnum.bad)
|
|
225
|
+
throw new Error('InvalidPublicAddressError')
|
|
226
|
+
|
|
227
|
+
// Format publicAddress to the latest format from the provided address
|
|
228
|
+
edgeParsedUri.publicAddress = _keymanager.toNewFormat.call(void 0, args.pathname, args.coin)
|
|
229
|
+
|
|
230
|
+
// Include a legacyAddress if the provided format is a legacy format
|
|
231
|
+
if (addressFormat === _keymanager.VerifyAddressEnum.legacy)
|
|
232
|
+
edgeParsedUri.legacyAddress = args.pathname
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return edgeParsedUri
|
|
236
|
+
}; exports.parsePathname = parsePathname
|
|
237
|
+
|
|
238
|
+
const sumUtxos = (utxos) =>
|
|
239
|
+
utxos.reduce((sum, { value }) => bs.add(sum, value), '0'); exports.sumUtxos = sumUtxos
|