-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathRecoveryProvider.ts
More file actions
41 lines (35 loc) · 1.07 KB
/
RecoveryProvider.ts
File metadata and controls
41 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { BlockchairApi, AddressInfo, TransactionIO } from '@bitgo/blockapis';
import type { Unspent } from '../unspent';
import { ApiNotImplementedError } from './baseApi';
/**
* An account with bear minimum information required for recoveries.
*/
export interface RecoveryAccountData {
txCount: number;
totalBalance: number;
}
/**
* Factory for AddressApi & UtxoApi
*/
export interface RecoveryProvider<TNumber extends number | bigint = number> {
getUnspentsForAddresses(addresses: string[]): Promise<Unspent<TNumber>[]>;
getAddressInfo(address: string): Promise<AddressInfo>;
getTransactionHex(txid: string): Promise<string>;
getTransactionIO(txid: string): Promise<TransactionIO>;
}
export function forCoin(coinName: string, apiToken?: string): RecoveryProvider<number> {
switch (coinName) {
case 'btc':
case 'tbtc':
case 'bch':
case 'bcha':
case 'bsv':
case 'btg':
case 'dash':
case 'doge':
case 'ltc':
case 'zec':
return BlockchairApi.forCoin(coinName, { apiToken });
}
throw new ApiNotImplementedError(coinName);
}