edge-currency-plugins 3.15.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +51 -49
- package/lib/common/plugin/EngineEmitter.js +10 -0
- package/lib/common/plugin/PluginState.js +87 -1
- package/lib/common/plugin/types.js +11 -0
- package/lib/common/utxobased/engine/ServerStates.js +257 -9
- package/lib/common/utxobased/engine/UtxoEngineProcessor.js +147 -22
- package/lib/common/utxobased/info/all.js +6 -0
- package/lib/common/utxobased/info/bitcoin.js +1 -1
- package/lib/common/utxobased/info/ecashbitcoin.js +90 -0
- package/lib/common/utxobased/info/ecashbitcoinbetanet.js +91 -0
- package/lib/common/utxobased/keymanager/keymanager.js +6 -1
- package/lib/common/utxobased/network/Blockbook.js +9 -2
- package/lib/common/utxobased/network/BlockbookElectrum.js +243 -77
- package/lib/common/utxobased/network/Socket.js +34 -22
- package/lib/common/utxobased/network/electrumApi.js +49 -1
- package/lib/src/common/plugin/EngineEmitter.d.ts +7 -2
- package/lib/src/common/plugin/PluginState.d.ts +30 -0
- package/lib/src/common/plugin/types.d.ts +10 -0
- package/lib/src/common/utxobased/engine/ServerStates.d.ts +32 -0
- package/lib/src/common/utxobased/engine/UtxoEngineProcessor.d.ts +5 -1
- package/lib/src/common/utxobased/info/all.d.ts +2 -0
- package/lib/src/common/utxobased/info/ecashbitcoin.d.ts +3 -0
- package/lib/src/common/utxobased/info/ecashbitcoinbetanet.d.ts +3 -0
- package/lib/src/common/utxobased/network/Blockbook.d.ts +6 -1
- package/lib/src/common/utxobased/network/BlockbookElectrum.d.ts +2 -0
- package/lib/src/common/utxobased/network/Socket.d.ts +4 -0
- package/lib/src/common/utxobased/network/electrumApi.d.ts +21 -0
- package/lib/test/common/plugin/PluginState.spec.d.ts +1 -0
- package/lib/test/common/utxobased/engine/AddressRepair.spec.d.ts +1 -0
- package/lib/test/common/utxobased/engine/UtxoEngineProcessor.spec.d.ts +1 -0
- package/lib/test/common/utxobased/keymanager/coins/ecashbitcointransactiontest.spec.d.ts +1 -0
- package/lib/test/common/utxobased/network/BlockbookElectrum.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8,10 +8,20 @@ import { AddressResponse, AddressUtxosResponse, BlockbookTransaction } from '../
|
|
|
8
8
|
import Deferred from '../network/Deferred';
|
|
9
9
|
import { WsTask, WsTaskGenerator } from '../network/Socket';
|
|
10
10
|
import { UtxoInitOptions } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* What the last REST health probe said about a connected server:
|
|
13
|
+
* - `pending`: the probe has not answered yet.
|
|
14
|
+
* - `healthy`: Blockbook reported `inSync: true`.
|
|
15
|
+
* - `unhealthy`: Blockbook reported `inSync: false`.
|
|
16
|
+
* - `unknown`: the server has no HTTP twin to probe, or the probe failed
|
|
17
|
+
* (network error, non-200, unparseable body). Never treated as unhealthy.
|
|
18
|
+
*/
|
|
19
|
+
export declare type ServerHealth = 'pending' | 'healthy' | 'unhealthy' | 'unknown';
|
|
11
20
|
export interface ServerState {
|
|
12
21
|
blockbook: Blockbook;
|
|
13
22
|
blockSubscriptionStatus: 'unsubscribed' | 'subscribing' | 'subscribed';
|
|
14
23
|
blockHeight: number;
|
|
24
|
+
health: ServerHealth;
|
|
15
25
|
txids: Set<string>;
|
|
16
26
|
addresses: Set<string>;
|
|
17
27
|
}
|
|
@@ -28,12 +38,21 @@ interface ServerStateConfig {
|
|
|
28
38
|
* seconds the socket layer uses for a request. Exposed for tests.
|
|
29
39
|
*/
|
|
30
40
|
broadcastTimeoutMs?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Timing overrides so tests can drive the keepalive probe cycle in
|
|
43
|
+
* milliseconds rather than minutes. Production uses the defaults.
|
|
44
|
+
*/
|
|
45
|
+
healthProbeMinIntervalMs?: number;
|
|
46
|
+
healthProbeTimeoutMs?: number;
|
|
47
|
+
keepAliveMs?: number;
|
|
48
|
+
wakeUpMs?: number;
|
|
31
49
|
}
|
|
32
50
|
export interface ServerStates {
|
|
33
51
|
setPickNextTaskCB: (callback: (uri: string) => AsyncGenerator<WsTask<unknown> | boolean>) => void;
|
|
34
52
|
stop: () => void;
|
|
35
53
|
serverCanGetTx: (uri: string, txid: string) => boolean;
|
|
36
54
|
serverCanGetAddress: (uri: string, address: string) => boolean;
|
|
55
|
+
serverCanGetAddressHistory: (uri: string, address: string) => boolean;
|
|
37
56
|
serverIsAwareOfAddress: (uri: string, address: string) => boolean;
|
|
38
57
|
getServerState: (uri: string) => ServerState | undefined;
|
|
39
58
|
refillServers: () => void;
|
|
@@ -43,6 +62,7 @@ export interface ServerStates {
|
|
|
43
62
|
watchAddresses: (uri: string, addresses: string[], deferredAddressSub?: Deferred<unknown>) => void;
|
|
44
63
|
watchBlocks: (uri: string) => void;
|
|
45
64
|
getBlockHeight: (uri: string) => number;
|
|
65
|
+
getServerHealth: (uri: string) => ServerHealth | undefined;
|
|
46
66
|
addressQueryTask: (serverUri: string, address: string, params: {
|
|
47
67
|
lastQueriedBlockHeight: number;
|
|
48
68
|
page: number;
|
|
@@ -67,5 +87,17 @@ export declare const NOWNODES_BROADCAST_DELAY_MS = 2000;
|
|
|
67
87
|
* open. This mirrors the socket figure.
|
|
68
88
|
*/
|
|
69
89
|
export declare const BROADCAST_ATTEMPT_TIMEOUT_MS = 30000;
|
|
90
|
+
/**
|
|
91
|
+
* Upper bound on a REST health probe. The probe runs off the socket keepalive
|
|
92
|
+
* and must never hold the connection's timer for long.
|
|
93
|
+
*/
|
|
94
|
+
export declare const HEALTH_PROBE_TIMEOUT_MS = 10000;
|
|
95
|
+
/**
|
|
96
|
+
* Probes of one server closer together than this share a single request,
|
|
97
|
+
* across every wallet of the plugin. The connect path and the first
|
|
98
|
+
* keepalive can land within milliseconds of each other, and N wallets each
|
|
99
|
+
* run their own keepalive; one answer serves them all.
|
|
100
|
+
*/
|
|
101
|
+
export declare const HEALTH_PROBE_MIN_INTERVAL_MS = 10000;
|
|
70
102
|
export declare function makeServerStates(config: ServerStateConfig): ServerStates;
|
|
71
103
|
export {};
|
|
@@ -42,7 +42,9 @@ interface CommonParams {
|
|
|
42
42
|
emitter: EngineEmitter;
|
|
43
43
|
taskCache: TaskCache;
|
|
44
44
|
pendingTimeouts: Set<NodeJS.Timeout>;
|
|
45
|
-
|
|
45
|
+
electrumHistoryAddresses: Set<string>;
|
|
46
|
+
reopenAddresses: (addresses: Iterable<string>) => number;
|
|
47
|
+
updateProgressRatio: (scriptPubkey: string, process: AddressProcess) => Promise<void>;
|
|
46
48
|
updateSeenTxCheckpoint: () => void;
|
|
47
49
|
io: EdgeIo;
|
|
48
50
|
log: EdgeLog;
|
|
@@ -75,6 +77,8 @@ interface AddressForUtxosCache {
|
|
|
75
77
|
path: ChangePath;
|
|
76
78
|
};
|
|
77
79
|
}
|
|
80
|
+
/** The two per-address jobs that make up the sync progress ratio. */
|
|
81
|
+
declare type AddressProcess = 'txs' | 'utxos';
|
|
78
82
|
interface AddressSubscribeCache {
|
|
79
83
|
[key: string]: {
|
|
80
84
|
processing: boolean;
|
|
@@ -12,6 +12,8 @@ export { info as digibyte } from './digibyte';
|
|
|
12
12
|
export { info as dogecoin } from './dogecoin';
|
|
13
13
|
export { info as eboost } from './eboost';
|
|
14
14
|
export { info as ecash } from './ecash';
|
|
15
|
+
export { info as ecashbitcoin } from './ecashbitcoin';
|
|
16
|
+
export { info as ecashbitcoinbetanet } from './ecashbitcoinbetanet';
|
|
15
17
|
export { info as feathercoin } from './feathercoin';
|
|
16
18
|
export { info as groestlcoin } from './groestlcoin';
|
|
17
19
|
export { info as litecoin } from './litecoin';
|
|
@@ -2,7 +2,7 @@ import { Cleaner } from 'cleaners';
|
|
|
2
2
|
import { EdgeLog, EdgeTransaction } from 'edge-core-js/types';
|
|
3
3
|
import { EngineEmitter } from '../../plugin/EngineEmitter';
|
|
4
4
|
import { UtxoInitOptions } from '../engine/types';
|
|
5
|
-
import { AddressResponse, AddresssMessageParams, AddressUtxosResponse, BlockbookTask, BlockbookTransaction, BroadcastTxResponse, InfoResponse, SubscribeAddressResponse, TransactionResponse } from './blockbookApi';
|
|
5
|
+
import { AddressResponse, AddresssMessageParams, AddressUtxosResponse, BlockbookTask, BlockbookTransaction, BroadcastTxResponse, InfoResponse, SubscribeAddressResponse, SubscribeNewBlockResponse, TransactionResponse } from './blockbookApi';
|
|
6
6
|
import Deferred from './Deferred';
|
|
7
7
|
import { TaskGeneratorFn, WsResponse, WsTaskGenerator } from './Socket';
|
|
8
8
|
import { SocketEmitter } from './SocketEmitter';
|
|
@@ -40,8 +40,13 @@ interface BlockbookConfig {
|
|
|
40
40
|
log: EdgeLog;
|
|
41
41
|
taskGeneratorFn: TaskGeneratorFn;
|
|
42
42
|
ping?: () => Promise<void>;
|
|
43
|
+
/** The new-block subscription, for servers that are not Blockbook. */
|
|
44
|
+
subscribeNewBlockMessage?: () => BlockbookTask<SubscribeNewBlockResponse>;
|
|
43
45
|
socketEmitter: SocketEmitter;
|
|
44
46
|
walletId: string;
|
|
47
|
+
/** Socket timing overrides, for tests. */
|
|
48
|
+
keepAliveMs?: number;
|
|
49
|
+
wakeUpMs?: number;
|
|
45
50
|
}
|
|
46
51
|
export declare function makeBlockbook(config: BlockbookConfig): Blockbook;
|
|
47
52
|
export {};
|
|
@@ -25,3 +25,5 @@ export interface ElectrumResponseMessage {
|
|
|
25
25
|
} | undefined;
|
|
26
26
|
}
|
|
27
27
|
export declare function makeBlockbookElectrum(config: BlockbookElectrumConfig): Blockbook;
|
|
28
|
+
/** True for the URIs of Electrum servers, as opposed to Blockbook servers. */
|
|
29
|
+
export declare const isElectrumUri: (uri: string) => boolean;
|
|
@@ -39,6 +39,10 @@ interface SocketConfig {
|
|
|
39
39
|
taskGeneratorFn: TaskGeneratorFn;
|
|
40
40
|
timeout?: number;
|
|
41
41
|
walletId: string;
|
|
42
|
+
/** Keepalive interval override, for tests. Defaults to KEEP_ALIVE_MS. */
|
|
43
|
+
keepAliveMs?: number;
|
|
44
|
+
/** Timer wake-up interval override, for tests. Defaults to WAKE_UP_MS. */
|
|
45
|
+
wakeUpMs?: number;
|
|
42
46
|
}
|
|
43
47
|
export declare type WsResponse = WsResponseMessage[];
|
|
44
48
|
export interface WsResponseMessage {
|
|
@@ -67,6 +67,15 @@ export declare const asElectrumResponse: <T>(asT: Cleaner<T>) => Cleaner<T>;
|
|
|
67
67
|
export declare const pingMessage: () => ElectrumTask<PingResponse>;
|
|
68
68
|
export declare type PingResponse = ReturnType<typeof asPingResponse>;
|
|
69
69
|
export declare const asPingResponse: Cleaner<undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Subscribe to Headers (Get Block Height)
|
|
72
|
+
*/
|
|
73
|
+
export declare const headersSubscribeMessage: () => ElectrumTask<HeadersSubscribeResponse>;
|
|
74
|
+
export declare type HeadersSubscribeResponse = ReturnType<typeof asHeadersSubscribeResponse>;
|
|
75
|
+
export declare const asHeadersSubscribeResponse: import("cleaners").ObjectCleaner<{
|
|
76
|
+
height: number;
|
|
77
|
+
hex: string;
|
|
78
|
+
}>;
|
|
70
79
|
/**
|
|
71
80
|
* List Unspent (Get UTXOs)
|
|
72
81
|
*/
|
|
@@ -88,3 +97,15 @@ export declare const asAddressTransactionsResponse: Cleaner<{
|
|
|
88
97
|
export declare const transactionMessage: (txHash: string, asAddress?: Cleaner<string>) => ElectrumTask<TransactionResponse>;
|
|
89
98
|
export declare type TransactionResponse = ElectrumTransaction;
|
|
90
99
|
export declare const asTransactionResponse: (asAddress?: Cleaner<string>) => Cleaner<ElectrumTransaction>;
|
|
100
|
+
/**
|
|
101
|
+
* Get Raw Transaction
|
|
102
|
+
*/
|
|
103
|
+
export declare const rawTransactionMessage: (txHash: string) => ElectrumTask<RawTransactionResponse>;
|
|
104
|
+
export declare type RawTransactionResponse = ReturnType<typeof asRawTransactionResponse>;
|
|
105
|
+
export declare const asRawTransactionResponse: Cleaner<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Broadcast Transaction
|
|
108
|
+
*/
|
|
109
|
+
export declare const broadcastTransactionMessage: (rawTx: string) => ElectrumTask<BroadcastTransactionResponse>;
|
|
110
|
+
export declare type BroadcastTransactionResponse = ReturnType<typeof asBroadcastTransactionResponse>;
|
|
111
|
+
export declare const asBroadcastTransactionResponse: Cleaner<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
|
|
5
5
|
"homepage": "https://edge.app/",
|
|
6
6
|
"repository": "https://github.com/EdgeApp/edge-currency-plugins",
|