@berrywallet/core
Version:
Berrywallet main Core for work with common cryptocurrencies like Bitcoin, Ethereum, Dash, Litecoin
41 lines (40 loc) • 2.23 kB
TypeScript
import { Coin, Wallet, Debug } from '../';
import * as Networking from './';
import { Destructable } from '../utils';
export declare type ClientUnit = {
options: Networking.Api.TAdapterOption;
client: Networking.Clients.INetworkClient;
banned: boolean;
};
export interface INetworkProvider {
getClient(index: number): Networking.Clients.INetworkClient;
broadCastTransaction(transaction: Coin.Transaction.Transaction): Promise<string>;
getAddressTxs(address: string): Promise<Wallet.Entity.WalletTransaction[]>;
getTx(txid: string): Promise<Wallet.Entity.WalletTransaction | undefined>;
getTracker(): Networking.Clients.Tracker.ITrackerClient;
onNewBlock(callback: Networking.Events.NewBlockCallback): void;
onAddrsTx(address: string[], callback: Networking.Events.NewTxCallback): void;
onTransactionConfirm(txid: string, callback: Networking.Events.NewTxCallback): void;
getLastBlock(): Promise<Wallet.Entity.Block>;
}
export declare class NetworkProvider implements INetworkProvider, Destructable {
protected readonly coin: Coin.CoinInterface;
protected clientList: ClientUnit[];
protected currentClientIndex: number;
protected debug: Debug.BerryDebug;
constructor(coin: Coin.CoinInterface);
protected getClientCount(): number;
protected rotateClient(depth?: number): Networking.Clients.INetworkClient;
getAddressTxs(address: string): Promise<Wallet.Entity.WalletTransaction[]>;
getBulkAddrTxs(addrs: string[]): Promise<Wallet.Entity.WalletTransaction[]>;
getTx(txid: string): Promise<Wallet.Entity.WalletTransaction | undefined>;
getTracker(): Networking.Clients.Tracker.ITrackerClient;
onNewBlock(callback: Networking.Events.NewBlockCallback): void;
onTransactionConfirm(txid: string, callback: Networking.Events.NewTxCallback): void;
onAddrsTx(addrs: string[], callback: Networking.Events.NewTxCallback): void;
getClient(index?: number): Networking.Clients.INetworkClient;
broadCastTransaction(transaction: Coin.Transaction.Transaction): Promise<string>;
getLastBlock(): Promise<Wallet.Entity.Block>;
destruct(): void;
protected catchError: (method: string, client: any) => (error: Error) => never;
}