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,328 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// Typescript translation from original code in edge-currency-bitcoin
|
|
2
|
+
|
|
3
|
+
var _cleaners = require('cleaners');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const asServerInfo = _cleaners.asObject.call(void 0, {
|
|
8
|
+
serverUrl: _cleaners.asString,
|
|
9
|
+
serverScore: _cleaners.asNumber,
|
|
10
|
+
responseTime: _cleaners.asNumber,
|
|
11
|
+
numResponseTimes: _cleaners.asNumber
|
|
12
|
+
}); exports.asServerInfo = asServerInfo
|
|
13
|
+
|
|
14
|
+
const asServerList = _cleaners.asObject.call(void 0, exports.asServerInfo); exports.asServerList = asServerList
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const asServerCache = _cleaners.asObject.call(void 0, {
|
|
18
|
+
customServers: exports.asServerList,
|
|
19
|
+
internalServers: exports.asServerList
|
|
20
|
+
}); exports.asServerCache = asServerCache
|
|
21
|
+
|
|
22
|
+
const RESPONSE_TIME_UNINITIALIZED = 999999999
|
|
23
|
+
const MAX_SCORE = 500
|
|
24
|
+
const MIN_SCORE = -100
|
|
25
|
+
const DROPPED_SERVER_SCORE = -100
|
|
26
|
+
const RE_ADDED_SERVER_SCORE = -10
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ServerScores {
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
constructor(options) {
|
|
40
|
+
const { log, onDirtyServer = () => {} } = options
|
|
41
|
+
this.log = log
|
|
42
|
+
this.scoresLastLoaded = Date.now()
|
|
43
|
+
this.lastScoreUpTime = Date.now()
|
|
44
|
+
this.onDirtyServer = onDirtyServer
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Loads the server scores with new and old servers, mutates the passed in
|
|
49
|
+
* list of known servers.
|
|
50
|
+
* @param knownServers: Map of ServerInfo objects by serverUrl. This should come from disk
|
|
51
|
+
* @param newServers: Array<string> of new servers downloaded from the info server
|
|
52
|
+
*/
|
|
53
|
+
serverScoresLoad(knownServers, newServers = []) {
|
|
54
|
+
//
|
|
55
|
+
// Add any new servers coming out of the info server
|
|
56
|
+
//
|
|
57
|
+
for (const newServer of newServers) {
|
|
58
|
+
if (knownServers[newServer] === undefined) {
|
|
59
|
+
const serverScoreObj = {
|
|
60
|
+
serverUrl: newServer,
|
|
61
|
+
serverScore: 0,
|
|
62
|
+
responseTime: RESPONSE_TIME_UNINITIALIZED,
|
|
63
|
+
numResponseTimes: 0
|
|
64
|
+
}
|
|
65
|
+
knownServers[newServer] = serverScoreObj
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//
|
|
70
|
+
// If there is a known server that is not on the newServers array, then
|
|
71
|
+
// reduce it's score to reduce chances of using it.
|
|
72
|
+
//
|
|
73
|
+
for (const knownServerUrl in knownServers) {
|
|
74
|
+
const knownServer = knownServers[knownServerUrl]
|
|
75
|
+
let match = false
|
|
76
|
+
for (const newServerUrl of newServers) {
|
|
77
|
+
if (newServerUrl === knownServerUrl) {
|
|
78
|
+
match = true
|
|
79
|
+
break
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let serverScore = knownServer.serverScore
|
|
84
|
+
if (!match) {
|
|
85
|
+
if (serverScore > DROPPED_SERVER_SCORE) {
|
|
86
|
+
serverScore = DROPPED_SERVER_SCORE
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
if (serverScore < RE_ADDED_SERVER_SCORE) {
|
|
90
|
+
serverScore = RE_ADDED_SERVER_SCORE
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (this.scoresLastLoaded === 0) {
|
|
95
|
+
serverScore = Math.min(serverScore, MAX_SCORE - 100)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (knownServerUrl.startsWith('ws') && serverScore > 0) {
|
|
99
|
+
serverScore = 0
|
|
100
|
+
knownServer.responseTime = RESPONSE_TIME_UNINITIALIZED
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
knownServer.serverScore = serverScore
|
|
104
|
+
this.onDirtyServer(knownServerUrl)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
clearServerScoreTimes() {
|
|
109
|
+
this.scoresLastLoaded = Date.now()
|
|
110
|
+
this.lastScoreUpTime = Date.now()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
printServers(servers) {
|
|
114
|
+
this.log('**** printServers ****')
|
|
115
|
+
const serverInfos = []
|
|
116
|
+
for (const s in servers) {
|
|
117
|
+
serverInfos.push(servers[s])
|
|
118
|
+
}
|
|
119
|
+
// Sort by score
|
|
120
|
+
serverInfos.sort((a, b) => {
|
|
121
|
+
return b.serverScore - a.serverScore
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
for (const s of serverInfos) {
|
|
125
|
+
const score = s.serverScore.toString()
|
|
126
|
+
const response = s.responseTime.toString()
|
|
127
|
+
const numResponse = s.numResponseTimes.toString()
|
|
128
|
+
const url = s.serverUrl
|
|
129
|
+
this.log(`ServerInfo ${score} ${response}ms ${numResponse} ${url}`)
|
|
130
|
+
}
|
|
131
|
+
this.log('**************************')
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
serverScoreUp(
|
|
135
|
+
servers,
|
|
136
|
+
serverUrl,
|
|
137
|
+
responseTimeMilliseconds,
|
|
138
|
+
changeScore = 1
|
|
139
|
+
) {
|
|
140
|
+
const serverInfo = servers[serverUrl]
|
|
141
|
+
|
|
142
|
+
serverInfo.serverScore += changeScore
|
|
143
|
+
if (serverInfo.serverScore > MAX_SCORE) {
|
|
144
|
+
serverInfo.serverScore = MAX_SCORE
|
|
145
|
+
}
|
|
146
|
+
this.lastScoreUpTime = Date.now()
|
|
147
|
+
|
|
148
|
+
if (responseTimeMilliseconds !== 0) {
|
|
149
|
+
this.setResponseTime(servers, serverUrl, responseTimeMilliseconds)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.log(
|
|
153
|
+
`${serverUrl}: score UP to ${serverInfo.serverScore} ${responseTimeMilliseconds}ms`
|
|
154
|
+
)
|
|
155
|
+
this.onDirtyServer(serverUrl)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
serverScoreDown(
|
|
159
|
+
servers,
|
|
160
|
+
serverUrl,
|
|
161
|
+
changeScore = 10
|
|
162
|
+
) {
|
|
163
|
+
const currentTime = Date.now()
|
|
164
|
+
if (currentTime - this.lastScoreUpTime > 60000) {
|
|
165
|
+
// It has been over 1 minute since we got an up-vote for any server.
|
|
166
|
+
// Assume the network is down and don't penalize anyone for now
|
|
167
|
+
this.log(`${serverUrl}: score DOWN cancelled`)
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
const serverInfo = servers[serverUrl]
|
|
171
|
+
serverInfo.serverScore -= changeScore
|
|
172
|
+
if (serverInfo.serverScore < MIN_SCORE) {
|
|
173
|
+
serverInfo.serverScore = MIN_SCORE
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (serverInfo.numResponseTimes === 0) {
|
|
177
|
+
this.setResponseTime(servers, serverUrl, 9999)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.log(`${serverUrl}: score DOWN to ${serverInfo.serverScore}`)
|
|
181
|
+
this.onDirtyServer(serverUrl)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setResponseTime(
|
|
185
|
+
servers,
|
|
186
|
+
serverUrl,
|
|
187
|
+
responseTimeMilliseconds
|
|
188
|
+
) {
|
|
189
|
+
const serverInfo = servers[serverUrl]
|
|
190
|
+
serverInfo.numResponseTimes++
|
|
191
|
+
|
|
192
|
+
const oldTime = serverInfo.responseTime
|
|
193
|
+
let newTime = 0
|
|
194
|
+
if (RESPONSE_TIME_UNINITIALIZED === oldTime) {
|
|
195
|
+
newTime = responseTimeMilliseconds
|
|
196
|
+
} else {
|
|
197
|
+
// Every 10th setting of response time, decrease effect of prior values by 5x
|
|
198
|
+
if (serverInfo.numResponseTimes % 10 === 0) {
|
|
199
|
+
newTime = (oldTime + responseTimeMilliseconds * 4) / 5
|
|
200
|
+
} else {
|
|
201
|
+
newTime = (oldTime + responseTimeMilliseconds) / 2
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
serverInfo.responseTime = newTime
|
|
205
|
+
this.onDirtyServer(serverUrl)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
getServers(
|
|
209
|
+
servers,
|
|
210
|
+
numServersWanted,
|
|
211
|
+
includePatterns = []
|
|
212
|
+
) {
|
|
213
|
+
if (servers == null || Object.keys(servers).length === 0) {
|
|
214
|
+
return []
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let serverInfos = []
|
|
218
|
+
let newServerInfos = []
|
|
219
|
+
//
|
|
220
|
+
// Find new servers from the passed in servers
|
|
221
|
+
//
|
|
222
|
+
for (const s in servers) {
|
|
223
|
+
const server = servers[s]
|
|
224
|
+
serverInfos.push(server)
|
|
225
|
+
if (
|
|
226
|
+
server.responseTime === RESPONSE_TIME_UNINITIALIZED &&
|
|
227
|
+
server.serverScore === 0
|
|
228
|
+
) {
|
|
229
|
+
newServerInfos.push(server)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (serverInfos.length === 0) {
|
|
233
|
+
return []
|
|
234
|
+
}
|
|
235
|
+
if (includePatterns.length > 0) {
|
|
236
|
+
const filter = (server) => {
|
|
237
|
+
for (const pattern of includePatterns) {
|
|
238
|
+
// make sure that the server URL starts with the required pattern
|
|
239
|
+
if (server.serverUrl.indexOf(pattern) === 0) return true
|
|
240
|
+
}
|
|
241
|
+
return false
|
|
242
|
+
}
|
|
243
|
+
serverInfos = serverInfos.filter(filter)
|
|
244
|
+
newServerInfos = newServerInfos.filter(filter)
|
|
245
|
+
}
|
|
246
|
+
// Sort by score
|
|
247
|
+
serverInfos.sort((a, b) => {
|
|
248
|
+
return b.serverScore - a.serverScore
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
//
|
|
252
|
+
// Take the top 50% of servers that have
|
|
253
|
+
// 1. A score within 100 points of the highest score
|
|
254
|
+
// 2. And a positive score of at least 5
|
|
255
|
+
// 3. And a response time that is not RESPONSE_TIME_UNINITIALIZED
|
|
256
|
+
//
|
|
257
|
+
// Then sort those top servers by response time from lowest to highest
|
|
258
|
+
//
|
|
259
|
+
|
|
260
|
+
const startServerInfo = serverInfos[0]
|
|
261
|
+
let numServerPass = 0
|
|
262
|
+
let serverEnd = 0
|
|
263
|
+
for (let i = 0; i < serverInfos.length; i++) {
|
|
264
|
+
const serverInfo = serverInfos[i]
|
|
265
|
+
if (serverInfo.serverScore < startServerInfo.serverScore - 100) {
|
|
266
|
+
continue
|
|
267
|
+
}
|
|
268
|
+
if (serverInfo.serverScore < 5) {
|
|
269
|
+
continue
|
|
270
|
+
}
|
|
271
|
+
if (serverInfo.responseTime >= RESPONSE_TIME_UNINITIALIZED) {
|
|
272
|
+
continue
|
|
273
|
+
}
|
|
274
|
+
numServerPass++
|
|
275
|
+
if (numServerPass < numServersWanted) {
|
|
276
|
+
continue
|
|
277
|
+
}
|
|
278
|
+
if (numServerPass >= serverInfos.length / 2) {
|
|
279
|
+
continue
|
|
280
|
+
}
|
|
281
|
+
serverEnd = i
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
let topServerInfos = serverInfos.slice(0, serverEnd)
|
|
285
|
+
topServerInfos.sort((a, b) => {
|
|
286
|
+
return a.responseTime - b.responseTime
|
|
287
|
+
})
|
|
288
|
+
topServerInfos = topServerInfos.concat(serverInfos.slice(serverEnd))
|
|
289
|
+
|
|
290
|
+
const selectedServers = []
|
|
291
|
+
let numServers = 0
|
|
292
|
+
let numNewServers = 0
|
|
293
|
+
for (const serverInfo of topServerInfos) {
|
|
294
|
+
numServers++
|
|
295
|
+
selectedServers.push(serverInfo.serverUrl)
|
|
296
|
+
if (
|
|
297
|
+
serverInfo.responseTime === RESPONSE_TIME_UNINITIALIZED &&
|
|
298
|
+
serverInfo.serverScore === 0
|
|
299
|
+
) {
|
|
300
|
+
numNewServers++
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (numServers >= numServersWanted) {
|
|
304
|
+
break
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (numServers >= numServersWanted / 2 && numNewServers === 0) {
|
|
308
|
+
if (newServerInfos.length >= numServersWanted - numServers) {
|
|
309
|
+
break
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// If this list does not have a new server in it, try to add one as we always want to give new
|
|
315
|
+
// servers a try.
|
|
316
|
+
if (numNewServers === 0) {
|
|
317
|
+
for (const serverInfo of newServerInfos) {
|
|
318
|
+
selectedServers.unshift(serverInfo.serverUrl)
|
|
319
|
+
numServers++
|
|
320
|
+
if (numServers >= numServersWanted) {
|
|
321
|
+
break
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return selectedServers
|
|
327
|
+
}
|
|
328
|
+
} exports.ServerScores = ServerScores;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
var _cleaners = require('cleaners');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const asCurrencyFormat = _cleaners.asValue.call(void 0, 'bip32', 'bip44', 'bip49', 'bip84'); exports.asCurrencyFormat = asCurrencyFormat
|
|
22
|
+
|
|
23
|
+
// Path up to changeIndex
|
|
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
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
const asFeeRates = _cleaners.asObject.call(void 0, {
|
|
142
|
+
lowFee: _cleaners.asString,
|
|
143
|
+
standardFeeLow: _cleaners.asString,
|
|
144
|
+
standardFeeHigh: _cleaners.asString,
|
|
145
|
+
highFee: _cleaners.asString
|
|
146
|
+
}); exports.asFeeRates = asFeeRates
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
const asSimpleFeeSettings = _cleaners.asObject.call(void 0, {
|
|
150
|
+
...exports.asFeeRates.shape,
|
|
151
|
+
standardFeeLowAmount: _cleaners.asString,
|
|
152
|
+
standardFeeHighAmount: _cleaners.asString
|
|
153
|
+
}); exports.asSimpleFeeSettings = asSimpleFeeSettings
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
const asLocalWalletMetadata = _cleaners.asObject.call(void 0, {
|
|
171
|
+
balance: _cleaners.asString,
|
|
172
|
+
lastSeenBlockHeight: _cleaners.asNumber
|
|
173
|
+
}); exports.asLocalWalletMetadata = asLocalWalletMetadata
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _all = require('../utxobased/info/all');
|
|
2
|
+
|
|
3
|
+
const getFormatsForNetwork = (coinName) => {
|
|
4
|
+
for (const plugin of _all.all) {
|
|
5
|
+
if (plugin.coinInfo.name === coinName)
|
|
6
|
+
return _nullishCoalesce(plugin.engineInfo.formats, () => ( []))
|
|
7
|
+
}
|
|
8
|
+
return []
|
|
9
|
+
}; exports.getFormatsForNetwork = getFormatsForNetwork
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const removeItem = (obj, key) => {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
17
|
+
delete obj[key]
|
|
18
|
+
}; exports.removeItem = removeItem
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _defaultValidateConfirmations = require('../../engine/util/defaultValidateConfirmations');
|
|
7
|
+
var _keymanager = require('../../keymanager/keymanager');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const fromEdgeTransaction = (
|
|
12
|
+
tx
|
|
13
|
+
) => {
|
|
14
|
+
const otherParams = tx.otherParams
|
|
15
|
+
if (otherParams == null) throw new Error('Invalid transaction data')
|
|
16
|
+
if (otherParams.psbt == null)
|
|
17
|
+
throw new Error('Missing PSBT in edge transaction data')
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* [1]: Buffer.from is necessary because Buffers are converted to Uint8Arrays
|
|
21
|
+
* after through passing the bridge.
|
|
22
|
+
*/
|
|
23
|
+
const inputs = otherParams.psbt.inputs.map((input, n) => ({
|
|
24
|
+
amount: input.value.toString(),
|
|
25
|
+
scriptPubkey: Buffer.from(input.scriptPubkey).toString('hex'), // [1]
|
|
26
|
+
n,
|
|
27
|
+
txId: Buffer.from(input.hash).reverse().toString('hex'), // [1]
|
|
28
|
+
outputIndex: input.index
|
|
29
|
+
}))
|
|
30
|
+
const outputs = otherParams.psbt.outputs.map((output, n) => ({
|
|
31
|
+
amount: output.value.toString(),
|
|
32
|
+
scriptPubkey: Buffer.from(output.scriptPubkey).toString('hex'), // [1]
|
|
33
|
+
n
|
|
34
|
+
}))
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
txid: tx.txid,
|
|
38
|
+
hex: tx.signedTx,
|
|
39
|
+
blockHeight: tx.blockHeight,
|
|
40
|
+
date: tx.date,
|
|
41
|
+
fees: tx.networkFee,
|
|
42
|
+
inputs: inputs,
|
|
43
|
+
outputs: outputs,
|
|
44
|
+
// We can leave ourIns/ourOuts blank because they'll be updated by the
|
|
45
|
+
// processor when receiving the transaction from blockbook.
|
|
46
|
+
// We may want to calculate these preemptively, but for now this will work.
|
|
47
|
+
ourIns: [],
|
|
48
|
+
ourOuts: [],
|
|
49
|
+
ourAmount: _nullishCoalesce(tx.nativeAmount, () => ( '0'))
|
|
50
|
+
}
|
|
51
|
+
}; exports.fromEdgeTransaction = fromEdgeTransaction
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const toEdgeTransaction = async (
|
|
63
|
+
args
|
|
64
|
+
) => {
|
|
65
|
+
const { tx, processor, walletBlockHeight, walletTools, pluginInfo } = args
|
|
66
|
+
const { currencyInfo, engineInfo } = pluginInfo
|
|
67
|
+
const { validateConfirmations = _defaultValidateConfirmations.defaultValidateConfirmations } = engineInfo
|
|
68
|
+
const { requiredConfirmations } = currencyInfo
|
|
69
|
+
|
|
70
|
+
const ourReceiveAddresses = []
|
|
71
|
+
for (const out of tx.ourOuts) {
|
|
72
|
+
const { scriptPubkey } = tx.outputs[parseInt(out)]
|
|
73
|
+
const address = await processor.fetchAddress(scriptPubkey)
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
Hack to set replay protection tx to the correct script type through the
|
|
77
|
+
address format.
|
|
78
|
+
|
|
79
|
+
We use a function which can determine whether the derivationLevelScriptHash
|
|
80
|
+
was used for the path's change index in order to detect whether an address
|
|
81
|
+
is used for replay protection. We need to detect this because we must treat
|
|
82
|
+
the address format as bip49 because the script is P2SH even though the
|
|
83
|
+
address is on the bip44 derivation chain.
|
|
84
|
+
*/
|
|
85
|
+
const scriptTemplate = _optionalChain([engineInfo, 'access', _ => _.scriptTemplates, 'optionalAccess', _2 => _2.replayProtection])
|
|
86
|
+
if (
|
|
87
|
+
scriptTemplate != null &&
|
|
88
|
+
_optionalChain([address, 'optionalAccess', _3 => _3.path]) != null &&
|
|
89
|
+
_keymanager.isPathUsingDerivationLevelScriptHash.call(void 0, scriptTemplate, address.path)
|
|
90
|
+
) {
|
|
91
|
+
address.path.format = 'bip49'
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (_optionalChain([address, 'optionalAccess', _4 => _4.path]) != null) {
|
|
95
|
+
const { address: addrStr } = walletTools.scriptPubkeyToAddress({
|
|
96
|
+
scriptPubkey,
|
|
97
|
+
format: address.path.format
|
|
98
|
+
})
|
|
99
|
+
ourReceiveAddresses.push(addrStr)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const confirmations = validateConfirmations(
|
|
104
|
+
tx,
|
|
105
|
+
walletBlockHeight,
|
|
106
|
+
requiredConfirmations
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const edgeTx = {
|
|
110
|
+
currencyCode: args.currencyCode,
|
|
111
|
+
txid: args.tx.txid,
|
|
112
|
+
confirmations,
|
|
113
|
+
blockHeight: args.tx.blockHeight,
|
|
114
|
+
date: args.tx.date,
|
|
115
|
+
nativeAmount: args.tx.ourAmount,
|
|
116
|
+
networkFee: args.tx.fees,
|
|
117
|
+
signedTx: args.tx.hex,
|
|
118
|
+
ourReceiveAddresses
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return edgeTx
|
|
122
|
+
}; exports.toEdgeTransaction = toEdgeTransaction
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const addressPathToPrefix = (path) =>
|
|
14
|
+
`${path.format}_${path.changeIndex}`; exports.addressPathToPrefix = addressPathToPrefix
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const scriptPubkeyByPathOptions = {
|
|
18
|
+
name: 'scriptPubkeyByPath',
|
|
19
|
+
bucketSize: 50
|
|
20
|
+
}; exports.scriptPubkeyByPathOptions = scriptPubkeyByPathOptions
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const addressByScriptPubkeyOptions = {
|
|
24
|
+
name: 'addressByScriptPubkey',
|
|
25
|
+
prefixSize: 4
|
|
26
|
+
}; exports.addressByScriptPubkeyOptions = addressByScriptPubkeyOptions
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const lastUsedByFormatPathOptions = {
|
|
30
|
+
name: 'lastUsedByFormatPath',
|
|
31
|
+
prefixSize: 2
|
|
32
|
+
}; exports.lastUsedByFormatPathOptions = lastUsedByFormatPathOptions
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const txIdsByBlockHeightOptions
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
= {
|
|
47
|
+
name: 'txIdByBlockHeight',
|
|
48
|
+
bucketSize: 100000,
|
|
49
|
+
rangeKey: 'blockHeight',
|
|
50
|
+
idKey: 'txid'
|
|
51
|
+
}; exports.txIdsByBlockHeightOptions = txIdsByBlockHeightOptions
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const txByIdOptions = {
|
|
55
|
+
name: 'txById',
|
|
56
|
+
prefixSize: 2
|
|
57
|
+
}; exports.txByIdOptions = txByIdOptions
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
const txIdsByDateOptions = {
|
|
65
|
+
name: 'txIdsByDate',
|
|
66
|
+
bucketSize: 30 * 24 * 60 * 60, // 30 days
|
|
67
|
+
rangeKey: 'date',
|
|
68
|
+
idKey: 'txid'
|
|
69
|
+
}; exports.txIdsByDateOptions = txIdsByDateOptions
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const utxoByIdOptions = {
|
|
73
|
+
name: 'utxoById',
|
|
74
|
+
prefixSize: 2
|
|
75
|
+
}; exports.utxoByIdOptions = utxoByIdOptions
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const utxoIdsByScriptPubkeyOptions = {
|
|
79
|
+
name: 'utxoIdsByScriptPubkey',
|
|
80
|
+
prefixSize: 4
|
|
81
|
+
}; exports.utxoIdsByScriptPubkeyOptions = utxoIdsByScriptPubkeyOptions
|