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,13 @@
|
|
|
1
|
+
import { FeeRates } from '../plugin/types';
|
|
2
|
+
export declare const asMempoolSpaceFees: import("cleaners").ObjectCleaner<{
|
|
3
|
+
fastestFee: number;
|
|
4
|
+
halfHourFee: number;
|
|
5
|
+
hourFee: number;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the FeeRates object from MempoolSpace
|
|
9
|
+
* Sets the minimum of LOW_FEE on all fee levels
|
|
10
|
+
* @param fees
|
|
11
|
+
* @returns Partial<FeeRates>
|
|
12
|
+
*/
|
|
13
|
+
export declare const processMempoolSpaceFees: (fees: unknown) => FeeRates | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EdgeCurrencyTools, EdgeIo } from 'edge-core-js/types';
|
|
2
|
+
import { PluginInfo } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The core currency plugin.
|
|
5
|
+
* Provides information about the currency,
|
|
6
|
+
* as well as generic (non-wallet) functionality.
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeCurrencyTools(io: EdgeIo, pluginInfo: PluginInfo): EdgeCurrencyTools;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EdgeCurrencyEngineCallbacks, EdgeTransaction, EdgeTxidMap } from 'edge-core-js/types';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import { SubscribeAddressResponse } from '../utxobased/network/BlockBookAPI';
|
|
5
|
+
export declare interface EngineEmitter {
|
|
6
|
+
emit: ((event: EngineEvent.TRANSACTIONS_CHANGED, transactions: EdgeTransaction[]) => boolean) & ((event: EngineEvent.ADDRESS_BALANCE_CHANGED, currencyCode: string, nativeDiff: string) => boolean) & ((event: EngineEvent.WALLET_BALANCE_CHANGED, currencyCode: string, nativeBalance: string) => boolean) & ((event: EngineEvent.BLOCK_HEIGHT_CHANGED, uri: string, blockHeight: number) => boolean) & ((event: EngineEvent.NEW_ADDRESS_TRANSACTION, uri: string, newTx: SubscribeAddressResponse) => boolean) & ((event: EngineEvent.ADDRESSES_CHECKED, progressRatio: number) => boolean) & ((event: EngineEvent.TXIDS_CHANGED, txids: EdgeTxidMap) => boolean);
|
|
7
|
+
on: ((event: EngineEvent.TRANSACTIONS_CHANGED, listener: (transactions: EdgeTransaction[]) => Promise<void> | void) => this) & ((event: EngineEvent.ADDRESS_BALANCE_CHANGED, listener: (currencyCode: string, nativeDiff: string) => Promise<void> | void) => this) & ((event: EngineEvent.WALLET_BALANCE_CHANGED, listener: (currencyCode: string, nativeBalance: string) => Promise<void> | void) => this) & ((event: EngineEvent.BLOCK_HEIGHT_CHANGED, listener: (uri: string, blockHeight: number) => Promise<void> | void) => this) & ((event: EngineEvent.NEW_ADDRESS_TRANSACTION, listener: (uri: string, newTx: SubscribeAddressResponse) => Promise<void> | void) => this) & ((event: EngineEvent.ADDRESSES_CHECKED, listener: (progressRatio: number) => Promise<void> | void) => this) & ((event: EngineEvent.TXIDS_CHANGED, listener: (txids: EdgeTxidMap) => Promise<void> | void) => this);
|
|
8
|
+
}
|
|
9
|
+
export declare class EngineEmitter extends EventEmitter {
|
|
10
|
+
}
|
|
11
|
+
export declare enum EngineEvent {
|
|
12
|
+
TRANSACTIONS_CHANGED = "transactions:changed",
|
|
13
|
+
WALLET_BALANCE_CHANGED = "wallet:balance:changed",
|
|
14
|
+
ADDRESS_BALANCE_CHANGED = "address:balance:changed",
|
|
15
|
+
BLOCK_HEIGHT_CHANGED = "block:height:changed",
|
|
16
|
+
NEW_ADDRESS_TRANSACTION = "address:transaction:changed",
|
|
17
|
+
ADDRESSES_CHECKED = "addresses:checked",
|
|
18
|
+
TXIDS_CHANGED = "txids:changed",
|
|
19
|
+
CONNECTION_OPEN = "connection:open",
|
|
20
|
+
CONNECTION_CLOSE = "connection:close",
|
|
21
|
+
CONNECTION_TIMER = "connection:timer"
|
|
22
|
+
}
|
|
23
|
+
export declare const makeEngineEmitter: (callbacks: EdgeCurrencyEngineCallbacks) => EngineEmitter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Disklet } from 'disklet';
|
|
2
|
+
import { EdgeLog } from 'edge-core-js/types';
|
|
3
|
+
import { EngineEmitter } from './makeEngineEmitter';
|
|
4
|
+
import { LocalWalletMetadata } from './types';
|
|
5
|
+
interface MetadataConfig {
|
|
6
|
+
disklet: Disklet;
|
|
7
|
+
emitter: EngineEmitter;
|
|
8
|
+
log: EdgeLog;
|
|
9
|
+
}
|
|
10
|
+
export interface Metadata extends LocalWalletMetadata {
|
|
11
|
+
clear: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const makeMetadata: (config: MetadataConfig) => Promise<Metadata>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Disklet } from 'disklet';
|
|
2
|
+
import { EdgeIo, EdgeLog } from 'edge-core-js/types';
|
|
3
|
+
import { UtxoEngineState } from '../utxobased/engine/makeUtxoEngineState';
|
|
4
|
+
import { UtxoUserSettings } from '../utxobased/engine/types';
|
|
5
|
+
/** A JSON object (as opposed to an array or primitive). */
|
|
6
|
+
interface JsonObject {
|
|
7
|
+
[name: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* This object holds the plugin-wide per-currency caches.
|
|
11
|
+
* Engine plugins are responsible for keeping it up to date.
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginStateSettings {
|
|
14
|
+
io: EdgeIo;
|
|
15
|
+
defaultSettings: UtxoUserSettings;
|
|
16
|
+
currencyCode: string;
|
|
17
|
+
pluginId: string;
|
|
18
|
+
pluginDisklet: Disklet;
|
|
19
|
+
log: EdgeLog;
|
|
20
|
+
}
|
|
21
|
+
export interface PluginState {
|
|
22
|
+
addEngine: (engineState: UtxoEngineState) => void;
|
|
23
|
+
removeEngine: (engineState: UtxoEngineState) => void;
|
|
24
|
+
dumpData: () => JsonObject;
|
|
25
|
+
load: () => Promise<PluginState>;
|
|
26
|
+
serverScoreDown: (uri: string) => void;
|
|
27
|
+
serverScoreUp: (uri: string, score: number) => void;
|
|
28
|
+
clearCache: () => Promise<void>;
|
|
29
|
+
getLocalServers: (numServersWanted: number, includePatterns: string[]) => string[];
|
|
30
|
+
refreshServers: () => Promise<void>;
|
|
31
|
+
updateServers: (settings: UtxoUserSettings) => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare function makePluginState(settings: PluginStateSettings): PluginState;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EdgeLog } from 'edge-core-js/types';
|
|
2
|
+
export declare type ServerInfo = ReturnType<typeof asServerInfo>;
|
|
3
|
+
export declare const asServerInfo: import("cleaners").ObjectCleaner<{
|
|
4
|
+
serverUrl: string;
|
|
5
|
+
serverScore: number;
|
|
6
|
+
responseTime: number;
|
|
7
|
+
numResponseTimes: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare type ServerList = ReturnType<typeof asServerList>;
|
|
10
|
+
export declare const asServerList: import("cleaners").Cleaner<{
|
|
11
|
+
[keys: string]: {
|
|
12
|
+
serverUrl: string;
|
|
13
|
+
serverScore: number;
|
|
14
|
+
responseTime: number;
|
|
15
|
+
numResponseTimes: number;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
export declare type ServerCache = ReturnType<typeof asServerCache>;
|
|
19
|
+
export declare const asServerCache: import("cleaners").ObjectCleaner<{
|
|
20
|
+
customServers: {
|
|
21
|
+
[keys: string]: {
|
|
22
|
+
serverUrl: any;
|
|
23
|
+
serverScore: any;
|
|
24
|
+
responseTime: any;
|
|
25
|
+
numResponseTimes: any;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
internalServers: {
|
|
29
|
+
[keys: string]: {
|
|
30
|
+
serverUrl: any;
|
|
31
|
+
serverScore: any;
|
|
32
|
+
responseTime: any;
|
|
33
|
+
numResponseTimes: any;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
interface ServerScoresOptions {
|
|
38
|
+
log: EdgeLog;
|
|
39
|
+
onDirtyServer?: (serverUrl: string) => void;
|
|
40
|
+
}
|
|
41
|
+
export declare class ServerScores {
|
|
42
|
+
scoresLastLoaded: number;
|
|
43
|
+
log: EdgeLog;
|
|
44
|
+
lastScoreUpTime: number;
|
|
45
|
+
onDirtyServer: (serverUrl: string) => void;
|
|
46
|
+
constructor(options: ServerScoresOptions);
|
|
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: ServerList, newServers?: string[]): void;
|
|
54
|
+
clearServerScoreTimes(): void;
|
|
55
|
+
printServers(servers: ServerList): void;
|
|
56
|
+
serverScoreUp(servers: ServerList, serverUrl: string, responseTimeMilliseconds: number, changeScore?: number): void;
|
|
57
|
+
serverScoreDown(servers: ServerList, serverUrl: string, changeScore?: number): void;
|
|
58
|
+
setResponseTime(servers: ServerList, serverUrl: string, responseTimeMilliseconds: number): void;
|
|
59
|
+
getServers(servers: ServerList, numServersWanted: number, includePatterns?: string[]): string[];
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { bip32 } from 'altcoin-js';
|
|
3
|
+
import { Cleaner } from 'cleaners';
|
|
4
|
+
import { Disklet } from 'disklet';
|
|
5
|
+
import { EdgeCurrencyEngineOptions, EdgeCurrencyInfo, EdgeCurrencyTools, EdgeIo, EdgeParsedUri, EdgeTransaction, EdgeWalletInfo } from 'edge-core-js/types';
|
|
6
|
+
import { IProcessorTransaction, IUTXO } from '../utxobased/db/types';
|
|
7
|
+
import { ScriptTemplates } from '../utxobased/info/scriptTemplates/types';
|
|
8
|
+
import { UtxoPicker } from '../utxobased/keymanager/utxopicker';
|
|
9
|
+
import { EngineEmitter } from './makeEngineEmitter';
|
|
10
|
+
import { PluginState } from './pluginState';
|
|
11
|
+
export declare type CurrencyFormat = ReturnType<typeof asCurrencyFormat>;
|
|
12
|
+
export declare const asCurrencyFormat: Cleaner<"bip32" | "bip44" | "bip49" | "bip84">;
|
|
13
|
+
export interface ChangePath {
|
|
14
|
+
format: CurrencyFormat;
|
|
15
|
+
changeIndex: number;
|
|
16
|
+
}
|
|
17
|
+
export interface AddressPath {
|
|
18
|
+
format: CurrencyFormat;
|
|
19
|
+
changeIndex: number;
|
|
20
|
+
addressIndex: number;
|
|
21
|
+
}
|
|
22
|
+
export interface TxOptions {
|
|
23
|
+
utxos?: IUTXO[];
|
|
24
|
+
subtractFee?: boolean;
|
|
25
|
+
setRBF?: boolean;
|
|
26
|
+
CPFP?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface PluginInfo {
|
|
29
|
+
currencyInfo: EdgeCurrencyInfo;
|
|
30
|
+
engineInfo: EngineInfo;
|
|
31
|
+
coinInfo: CoinInfo;
|
|
32
|
+
}
|
|
33
|
+
export interface EngineInfo {
|
|
34
|
+
formats?: CurrencyFormat[];
|
|
35
|
+
forks?: string[];
|
|
36
|
+
uriPrefix?: string;
|
|
37
|
+
gapLimit: number;
|
|
38
|
+
defaultFee: number;
|
|
39
|
+
feeUpdateInterval: number;
|
|
40
|
+
mempoolSpaceFeeInfoServer?: string;
|
|
41
|
+
simpleFeeSettings: SimpleFeeSettings;
|
|
42
|
+
scriptTemplates?: ScriptTemplates;
|
|
43
|
+
asBlockbookAddress?: Cleaner<string>;
|
|
44
|
+
validateConfirmations?: (txResponse: IProcessorTransaction, blockHeight: number, requiredConfirmations: number | undefined) => EdgeTransaction['confirmations'];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Coin Info
|
|
48
|
+
*/
|
|
49
|
+
export interface CoinInfo {
|
|
50
|
+
name: string;
|
|
51
|
+
segwit: boolean;
|
|
52
|
+
coinType: number;
|
|
53
|
+
sighash?: number;
|
|
54
|
+
sighashFunction?: (Hash: Buffer) => Buffer;
|
|
55
|
+
txHashFunction?: (Hash: Buffer) => Buffer;
|
|
56
|
+
bs58DecodeFunc?: (payload: string | undefined) => Buffer;
|
|
57
|
+
bs58EncodeFunc?: (payload: any) => string;
|
|
58
|
+
wifEncodeFunc?: (prefix: unknown, key: unknown, compressed: unknown) => string;
|
|
59
|
+
bip32FromBase58Func?: (xKey: string, network: BitcoinJSNetwork) => bip32.BIP32Interface;
|
|
60
|
+
bip32FromSeedFunc?: (seed: Buffer) => bip32.BIP32Interface;
|
|
61
|
+
utxoPicker?: UtxoPicker;
|
|
62
|
+
prefixes: CoinPrefixes;
|
|
63
|
+
}
|
|
64
|
+
export interface CoinPrefixes {
|
|
65
|
+
messagePrefix: string[];
|
|
66
|
+
wif: number[];
|
|
67
|
+
legacyXPriv: number[];
|
|
68
|
+
legacyXPub: number[];
|
|
69
|
+
wrappedSegwitXPriv?: number[];
|
|
70
|
+
wrappedSegwitXPub?: number[];
|
|
71
|
+
segwitXPriv?: number[];
|
|
72
|
+
segwitXPub?: number[];
|
|
73
|
+
pubkeyHash: number[];
|
|
74
|
+
scriptHash: number[];
|
|
75
|
+
bech32?: string[];
|
|
76
|
+
cashaddr?: string[];
|
|
77
|
+
}
|
|
78
|
+
interface BitcoinJSNetwork {
|
|
79
|
+
wif: number;
|
|
80
|
+
bip32: Bip32;
|
|
81
|
+
messagePrefix: string;
|
|
82
|
+
bech32: string;
|
|
83
|
+
pubKeyHash: number;
|
|
84
|
+
scriptHash: number;
|
|
85
|
+
}
|
|
86
|
+
interface Bip32 {
|
|
87
|
+
public: number;
|
|
88
|
+
private: number;
|
|
89
|
+
}
|
|
90
|
+
export interface ExtendedParseUri extends EdgeParsedUri {
|
|
91
|
+
metadata?: EdgeParsedUri['metadata'] & {
|
|
92
|
+
gateway?: boolean;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export interface EncodeUriMetadata {
|
|
96
|
+
metadata?: {
|
|
97
|
+
name?: string;
|
|
98
|
+
notes?: string;
|
|
99
|
+
gateway?: boolean;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export declare type FeeRates = ReturnType<typeof asFeeRates>;
|
|
103
|
+
export declare const asFeeRates: import("cleaners").ObjectCleaner<{
|
|
104
|
+
lowFee: string;
|
|
105
|
+
standardFeeLow: string;
|
|
106
|
+
standardFeeHigh: string;
|
|
107
|
+
highFee: string;
|
|
108
|
+
}>;
|
|
109
|
+
export declare type SimpleFeeSettings = ReturnType<typeof asSimpleFeeSettings>;
|
|
110
|
+
export declare const asSimpleFeeSettings: import("cleaners").ObjectCleaner<{
|
|
111
|
+
standardFeeLowAmount: string;
|
|
112
|
+
standardFeeHighAmount: string;
|
|
113
|
+
lowFee: string;
|
|
114
|
+
standardFeeLow: string;
|
|
115
|
+
standardFeeHigh: string;
|
|
116
|
+
highFee: string;
|
|
117
|
+
}>;
|
|
118
|
+
export interface EngineConfig {
|
|
119
|
+
walletInfo: EdgeWalletInfo;
|
|
120
|
+
pluginInfo: PluginInfo;
|
|
121
|
+
pluginDisklet: Disklet;
|
|
122
|
+
currencyTools: EdgeCurrencyTools;
|
|
123
|
+
options: EngineOptions;
|
|
124
|
+
io: EdgeIo;
|
|
125
|
+
pluginState: PluginState;
|
|
126
|
+
}
|
|
127
|
+
export interface EngineOptions extends EdgeCurrencyEngineOptions {
|
|
128
|
+
emitter: EngineEmitter;
|
|
129
|
+
}
|
|
130
|
+
export declare type LocalWalletMetadata = ReturnType<typeof asLocalWalletMetadata>;
|
|
131
|
+
export declare const asLocalWalletMetadata: import("cleaners").ObjectCleaner<{
|
|
132
|
+
balance: string;
|
|
133
|
+
lastSeenBlockHeight: number;
|
|
134
|
+
}>;
|
|
135
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EdgeTransaction } from 'edge-core-js/types';
|
|
2
|
+
import { PluginInfo } from '../../../plugin/types';
|
|
3
|
+
import { UTXOPluginWalletTools } from '../../engine/makeUtxoWalletTools';
|
|
4
|
+
import { Processor } from '../makeProcessor';
|
|
5
|
+
import { IProcessorTransaction } from '../types';
|
|
6
|
+
export declare const fromEdgeTransaction: (tx: EdgeTransaction) => IProcessorTransaction;
|
|
7
|
+
interface ToEdgeTransactionArgs {
|
|
8
|
+
tx: IProcessorTransaction;
|
|
9
|
+
currencyCode: string;
|
|
10
|
+
pluginInfo: PluginInfo;
|
|
11
|
+
processor: Processor;
|
|
12
|
+
walletBlockHeight: number;
|
|
13
|
+
walletTools: UTXOPluginWalletTools;
|
|
14
|
+
}
|
|
15
|
+
export declare const toEdgeTransaction: (args: ToEdgeTransactionArgs) => Promise<EdgeTransaction>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CountBase, CountBaseOptions, HashBase, HashBaseOptions, RangeBase, RangeBaseOptions } from 'baselet';
|
|
2
|
+
import { ChangePath } from '../../../plugin/types';
|
|
3
|
+
import { IAddress, IProcessorTransaction, IUTXO } from '../types';
|
|
4
|
+
export declare const addressPathToPrefix: (path: ChangePath) => string;
|
|
5
|
+
export declare type ScriptPubkeyByPathBaselet = CountBase<string>;
|
|
6
|
+
export declare const scriptPubkeyByPathOptions: CountBaseOptions;
|
|
7
|
+
export declare type AddressByScriptPubkeyBaselet = HashBase<IAddress>;
|
|
8
|
+
export declare const addressByScriptPubkeyOptions: HashBaseOptions;
|
|
9
|
+
export declare type LastUsedByFormatPathBaselet = HashBase<number>;
|
|
10
|
+
export declare const lastUsedByFormatPathOptions: HashBaseOptions;
|
|
11
|
+
export interface TxIdByBlockHeight {
|
|
12
|
+
txid: string;
|
|
13
|
+
blockHeight: number;
|
|
14
|
+
}
|
|
15
|
+
export declare type TxIdByBlockHeightBaselet = RangeBase<TxIdByBlockHeight, 'blockHeight', 'txid'>;
|
|
16
|
+
export declare const txIdsByBlockHeightOptions: RangeBaseOptions<'blockHeight', 'txid'>;
|
|
17
|
+
export declare type TxByIdBaselet = HashBase<IProcessorTransaction>;
|
|
18
|
+
export declare const txByIdOptions: HashBaseOptions;
|
|
19
|
+
export interface TxIdByDate {
|
|
20
|
+
txid: string;
|
|
21
|
+
date: number;
|
|
22
|
+
}
|
|
23
|
+
export declare type TxIdByDateBaselet = RangeBase<TxIdByDate, 'date', 'txid'>;
|
|
24
|
+
export declare const txIdsByDateOptions: RangeBaseOptions<'date', 'txid'>;
|
|
25
|
+
export declare type UtxoByIdBaselet = HashBase<IUTXO>;
|
|
26
|
+
export declare const utxoByIdOptions: HashBaseOptions;
|
|
27
|
+
export declare type UtxoIdsByScriptPubkeyBaselet = HashBase<string[]>;
|
|
28
|
+
export declare const utxoIdsByScriptPubkeyOptions: HashBaseOptions;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Disklet } from 'disklet';
|
|
2
|
+
import { AddressByScriptPubkeyBaselet, LastUsedByFormatPathBaselet, ScriptPubkeyByPathBaselet, TxByIdBaselet, TxIdByBlockHeightBaselet, TxIdByDateBaselet, UtxoByIdBaselet, UtxoIdsByScriptPubkeyBaselet } from './Models/baselet';
|
|
3
|
+
interface MakeBaseletsConfig {
|
|
4
|
+
disklet: Disklet;
|
|
5
|
+
}
|
|
6
|
+
declare type Executor<BaseletName extends keyof AllBaselets> = (tables: AllBaselets[BaseletName]) => Promise<unknown>;
|
|
7
|
+
interface AllBaselets {
|
|
8
|
+
address: AddressBaselets;
|
|
9
|
+
tx: TransactionBaselets;
|
|
10
|
+
utxo: UtxoBaselets;
|
|
11
|
+
}
|
|
12
|
+
interface AddressBaselets {
|
|
13
|
+
addressByScriptPubkey: AddressByScriptPubkeyBaselet;
|
|
14
|
+
scriptPubkeyByPath: ScriptPubkeyByPathBaselet;
|
|
15
|
+
lastUsedByFormatPath: LastUsedByFormatPathBaselet;
|
|
16
|
+
}
|
|
17
|
+
interface TransactionBaselets {
|
|
18
|
+
txById: TxByIdBaselet;
|
|
19
|
+
txIdsByBlockHeight: TxIdByBlockHeightBaselet;
|
|
20
|
+
txIdsByDate: TxIdByDateBaselet;
|
|
21
|
+
}
|
|
22
|
+
interface UtxoBaselets {
|
|
23
|
+
utxoById: UtxoByIdBaselet;
|
|
24
|
+
utxoIdsByScriptPubkey: UtxoIdsByScriptPubkeyBaselet;
|
|
25
|
+
}
|
|
26
|
+
export interface Baselets {
|
|
27
|
+
address: <E extends Executor<'address'>>(fn: E) => Promise<ReturnType<E>>;
|
|
28
|
+
tx: <E extends Executor<'tx'>>(fn: E) => Promise<ReturnType<E>>;
|
|
29
|
+
utxo: <E extends Executor<'utxo'>>(fn: E) => Promise<ReturnType<E>>;
|
|
30
|
+
all: AddressBaselets & TransactionBaselets & UtxoBaselets;
|
|
31
|
+
}
|
|
32
|
+
export declare const makeBaselets: (config: MakeBaseletsConfig) => Promise<Baselets>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Disklet } from 'disklet';
|
|
2
|
+
import { EdgeGetTransactionsOptions } from 'edge-core-js/types';
|
|
3
|
+
import { AddressPath, ChangePath } from '../../plugin/types';
|
|
4
|
+
import { IAddress, IProcessorTransaction, IUTXO } from './types';
|
|
5
|
+
interface ProcessorConfig {
|
|
6
|
+
disklet: Disklet;
|
|
7
|
+
}
|
|
8
|
+
interface SaveTransactionArgs {
|
|
9
|
+
tx: IProcessorTransaction;
|
|
10
|
+
scriptPubkeys?: string[];
|
|
11
|
+
}
|
|
12
|
+
interface FetchTransactionArgs {
|
|
13
|
+
blockHeight?: number;
|
|
14
|
+
blockHeightMax?: number;
|
|
15
|
+
txId?: string;
|
|
16
|
+
options?: EdgeGetTransactionsOptions;
|
|
17
|
+
}
|
|
18
|
+
interface FetchUtxosArgs {
|
|
19
|
+
utxoIds?: string[];
|
|
20
|
+
scriptPubkey?: string;
|
|
21
|
+
}
|
|
22
|
+
interface DumpDataReturn {
|
|
23
|
+
databaseName: string;
|
|
24
|
+
data: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface Processor {
|
|
27
|
+
clearAll: () => Promise<void>;
|
|
28
|
+
dumpData: () => Promise<DumpDataReturn[]>;
|
|
29
|
+
saveUtxo: (utxo: IUTXO) => Promise<void>;
|
|
30
|
+
removeUtxos: (utxoIds: string[]) => Promise<void>;
|
|
31
|
+
fetchUtxos: (args: FetchUtxosArgs) => Promise<Array<IUTXO | undefined>>;
|
|
32
|
+
saveTransaction: (args: SaveTransactionArgs) => Promise<IProcessorTransaction>;
|
|
33
|
+
numTransactions: () => number;
|
|
34
|
+
removeTransaction: (txId: string) => Promise<void>;
|
|
35
|
+
fetchTransactions: (args: FetchTransactionArgs) => Promise<Array<IProcessorTransaction | undefined>>;
|
|
36
|
+
saveAddress: (args: IAddress) => Promise<void>;
|
|
37
|
+
numAddressesByFormatPath: (path: ChangePath) => number;
|
|
38
|
+
lastUsedIndexByFormatPath: (path: ChangePath) => Promise<number>;
|
|
39
|
+
fetchAddress: (args: AddressPath | string) => Promise<IAddress | undefined>;
|
|
40
|
+
}
|
|
41
|
+
export declare function makeProcessor(config: ProcessorConfig): Promise<Processor>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SoftPick } from '../../../util/typeUtil';
|
|
2
|
+
import { AddressPath } from '../../plugin/types';
|
|
3
|
+
import { ScriptTypeEnum } from '../keymanager/keymanager';
|
|
4
|
+
export interface IAddress {
|
|
5
|
+
scriptPubkey: string;
|
|
6
|
+
redeemScript?: string;
|
|
7
|
+
lastQueriedBlockHeight: number;
|
|
8
|
+
path?: AddressPath;
|
|
9
|
+
lastQuery: number;
|
|
10
|
+
lastTouched: number;
|
|
11
|
+
used: boolean;
|
|
12
|
+
balance: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const makeIAddress: (addressFields: SoftPick<IAddress, 'scriptPubkey'>) => IAddress;
|
|
15
|
+
export interface IUTXO {
|
|
16
|
+
id: string;
|
|
17
|
+
txid: string;
|
|
18
|
+
vout: number;
|
|
19
|
+
value: string;
|
|
20
|
+
scriptPubkey: string;
|
|
21
|
+
script: string;
|
|
22
|
+
redeemScript?: string;
|
|
23
|
+
scriptType: ScriptTypeEnum;
|
|
24
|
+
blockHeight: number;
|
|
25
|
+
spent: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface IProcessorTransaction {
|
|
28
|
+
txid: string;
|
|
29
|
+
hex: string;
|
|
30
|
+
blockHeight: number;
|
|
31
|
+
date: number;
|
|
32
|
+
fees: string;
|
|
33
|
+
inputs: ITransactionInput[];
|
|
34
|
+
outputs: ITransactionOutput[];
|
|
35
|
+
ourIns: string[];
|
|
36
|
+
ourOuts: string[];
|
|
37
|
+
ourAmount: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ITransactionOutput {
|
|
40
|
+
amount: string;
|
|
41
|
+
scriptPubkey: string;
|
|
42
|
+
n: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ITransactionInput extends ITransactionOutput {
|
|
45
|
+
txId: string;
|
|
46
|
+
outputIndex: number;
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A mutex lock for coordination across async functions
|
|
3
|
+
*/
|
|
4
|
+
export default class AwaitLock {
|
|
5
|
+
private _acquired;
|
|
6
|
+
private readonly _waitingResolvers;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the lock is currently acquired or not. Accessing this property does not affect the
|
|
9
|
+
* status of the lock.
|
|
10
|
+
*/
|
|
11
|
+
get acquired(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Acquires the lock, waiting if necessary for it to become free if it is already locked. The
|
|
14
|
+
* returned promise is fulfilled once the lock is acquired.
|
|
15
|
+
*
|
|
16
|
+
* After acquiring the lock, you **must** call `release` when you are done with it.
|
|
17
|
+
*/
|
|
18
|
+
acquireAsync(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Acquires the lock if it is free and otherwise returns immediately without waiting. Returns
|
|
21
|
+
* `true` if the lock was free and is now acquired, and `false` otherwise,
|
|
22
|
+
*/
|
|
23
|
+
tryAcquire(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Releases the lock and gives it to the next waiting acquirer, if there is one. Each acquirer
|
|
26
|
+
* must release the lock exactly once.
|
|
27
|
+
*/
|
|
28
|
+
release(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EdgeLog, EdgeTransaction } from 'edge-core-js/types';
|
|
2
|
+
import { EngineEmitter } from '../../plugin/makeEngineEmitter';
|
|
3
|
+
import { PluginState } from '../../plugin/pluginState';
|
|
4
|
+
import { PluginInfo } from '../../plugin/types';
|
|
5
|
+
import { NumbWalletInfo } from '../keymanager/cleaners';
|
|
6
|
+
import Deferred from '../network/Deferred';
|
|
7
|
+
import { WsTask } from '../network/Socket';
|
|
8
|
+
interface ServerState {
|
|
9
|
+
blockSubscriptionStatus: 'unsubscribed' | 'subscribing' | 'subscribed';
|
|
10
|
+
blockHeight: number;
|
|
11
|
+
txids: Set<string>;
|
|
12
|
+
addresses: Set<string>;
|
|
13
|
+
}
|
|
14
|
+
interface ServerStateConfig {
|
|
15
|
+
engineEmitter: EngineEmitter;
|
|
16
|
+
log: EdgeLog;
|
|
17
|
+
pluginInfo: PluginInfo;
|
|
18
|
+
pluginState: PluginState;
|
|
19
|
+
walletInfo: NumbWalletInfo;
|
|
20
|
+
}
|
|
21
|
+
export interface ServerStates {
|
|
22
|
+
setPickNextTaskCB: (callback: (uri: string) => Promise<boolean | WsTask<any> | undefined>) => void;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
serverCanGetTx: (uri: string, txid: string) => boolean;
|
|
25
|
+
serverCanGetAddress: (uri: string, address: string) => boolean;
|
|
26
|
+
serverScoreUp: (uri: string, score: number) => void;
|
|
27
|
+
getServerState: (uri: string) => ServerState | undefined;
|
|
28
|
+
refillServers: () => void;
|
|
29
|
+
getServerList: () => string[];
|
|
30
|
+
setServerList: (updatedServerList: string[]) => void;
|
|
31
|
+
broadcastTx: (transaction: EdgeTransaction) => Promise<string>;
|
|
32
|
+
watchAddresses: (uri: string, addresses: string[], deferredAddressSub: Deferred<unknown>) => void;
|
|
33
|
+
watchBlocks: (uri: string) => void;
|
|
34
|
+
getBlockHeight: (uri: string) => number;
|
|
35
|
+
}
|
|
36
|
+
export declare function makeServerStates(config: ServerStateConfig): ServerStates;
|
|
37
|
+
export {};
|