///
import * as Promise from 'bluebird';
import { Readable } from 'stream';
export declare type Maybe = T | void;
export declare type Hash = string;
export declare type Tag = string;
export declare type Trytes = string;
export declare type TransactionTrytes = string;
export declare type AttachedTransactionTrytes = string;
export interface Balance {
readonly balance: number;
}
export interface Address extends Balance {
readonly address: Hash;
readonly keyIndex: number;
readonly security: number;
}
export declare const makeAddress: (address: string, balance: number, keyIndex: number, security: number) => Address;
export interface Inputs {
readonly inputs: ReadonlyArray;
readonly totalBalance: number;
}
export interface Transfer {
readonly address: string;
readonly value: number;
readonly message?: string;
readonly tag?: string;
readonly obsoleteTag?: string;
}
export interface Transaction {
readonly hash: string;
readonly signatureMessageFragment: string;
readonly address: string;
readonly value: number;
readonly obsoleteTag: string;
readonly timestamp: number;
readonly currentIndex: number;
readonly lastIndex: number;
readonly bundle: string;
readonly trunkTransaction: string;
readonly branchTransaction: string;
readonly tag: string;
readonly attachmentTimestamp: number;
readonly attachmentTimestampLowerBound: number;
readonly attachmentTimestampUpperBound: number;
readonly nonce: string;
readonly confirmed?: boolean;
}
export interface TransactionEssence {
readonly address: Int8Array;
readonly value: Int8Array;
readonly obsoleteTag?: Int8Array;
readonly issuanceTimestamp?: Int8Array;
readonly currentIndex: Int8Array;
}
export declare type Bundle = ReadonlyArray;
export interface Neighbor {
readonly address: string;
readonly numberOfAllTransactions: number;
readonly numberOfInvalidTransactions: number;
readonly numberOfNewTransactions: number;
}
export declare type Neighbors = ReadonlyArray;
export declare enum IRICommand {
GET_NODE_INFO = "getNodeInfo",
GET_NEIGHBORS = "getNeighbors",
ADD_NEIGHBORS = "addNeighbors",
REMOVE_NEIGHBORS = "removeNeighbors",
FIND_TRANSACTIONS = "findTransactions",
GET_TRYTES = "getTrytes",
GET_INCLUSION_STATES = "getInclusionStates",
GET_BALANCES = "getBalances",
GET_TRANSACTIONS_TO_APPROVE = "getTransactionsToApprove",
ATTACH_TO_TANGLE = "attachToTangle",
INTERRUPT_ATTACHING_TO_TANGLE = "interruptAttachingToTangle",
BROADCAST_TRANSACTIONS = "broadcastTransactions",
STORE_TRANSACTIONS = "storeTransactions",
CHECK_CONSISTENCY = "checkConsistency",
WERE_ADDRESSES_SPENT_FROM = "wereAddressesSpentFrom"
}
export interface BaseCommand {
readonly command: string;
}
/** IRI Command/Response interfaces */
export interface AddNeighborsCommand extends BaseCommand {
command: IRICommand.ADD_NEIGHBORS;
readonly uris: ReadonlyArray;
}
export interface AddNeighborsResponse {
readonly addedNeighbors: number;
readonly duration: number;
}
export interface AttachToTangleCommand extends BaseCommand {
command: IRICommand.ATTACH_TO_TANGLE;
readonly trunkTransaction: Hash;
readonly branchTransaction: Hash;
readonly minWeightMagnitude: number;
readonly trytes: ReadonlyArray;
}
export interface AttachToTangleResponse {
readonly trytes: ReadonlyArray;
}
export interface BroadcastTransactionsCommand extends BaseCommand {
command: IRICommand.BROADCAST_TRANSACTIONS;
readonly trytes: ReadonlyArray;
}
export declare type BroadcastTransactionsResponse = void;
export interface CheckConsistencyCommand extends BaseCommand {
command: IRICommand.CHECK_CONSISTENCY;
readonly tails: ReadonlyArray;
}
export interface CheckConsistencyResponse {
readonly state: boolean;
readonly info: string;
}
export interface FindTransactionsQuery {
readonly addresses?: ReadonlyArray;
readonly approvees?: ReadonlyArray;
readonly bundles?: ReadonlyArray;
readonly tags?: ReadonlyArray;
}
export interface FindTransactionsCommand extends BaseCommand, FindTransactionsQuery {
readonly command: IRICommand.FIND_TRANSACTIONS;
}
export interface FindTransactionsResponse {
readonly hashes: ReadonlyArray;
}
export interface GetBalancesCommand extends BaseCommand {
readonly command: string;
readonly addresses: ReadonlyArray;
readonly tips?: ReadonlyArray;
}
export interface GetBalancesResponse {
readonly balances: ReadonlyArray;
readonly duration: number;
readonly milestone: string;
readonly milestoneIndex: number;
}
export interface Balances {
readonly balances: ReadonlyArray;
readonly milestone: string;
readonly milestoneIndex: number;
}
export interface GetInclusionStatesCommand extends BaseCommand {
readonly command: IRICommand.GET_INCLUSION_STATES;
readonly transactions: ReadonlyArray;
}
export interface GetInclusionStatesResponse {
readonly states: ReadonlyArray;
readonly duration: number;
}
export interface GetNeighborsCommand extends BaseCommand {
command: IRICommand.GET_NEIGHBORS;
}
export interface GetNeighborsResponse {
duration: number;
neighbors: Neighbors;
}
export interface GetNodeInfoCommand extends BaseCommand {
command: IRICommand.GET_NODE_INFO;
}
export interface GetNodeInfoResponse {
readonly appName: string;
readonly appVersion: string;
readonly duration: number;
readonly jreAvailableProcessors: number;
readonly jreFreeMemory: number;
readonly jreMaxMemory: number;
readonly jreTotalMemory: number;
readonly latestMilestone: Hash;
readonly latestMilestoneIndex: number;
readonly latestSolidSubtangleMilestone: Hash;
readonly latestSolidSubtangleMilestoneIndex: number;
readonly neighbors: number;
readonly packetsQueueSize: number;
readonly time: number;
readonly tips: number;
readonly transactionsToRequest: number;
}
export interface TransactionsToApprove {
readonly trunkTransaction: Hash;
readonly branchTransaction: Hash;
}
export interface GetTransactionsToApproveResponse extends TransactionsToApprove {
readonly duration: number;
}
export interface GetTransactionsToApproveCommand extends BaseCommand {
command: IRICommand.GET_TRANSACTIONS_TO_APPROVE;
readonly depth: number;
readonly reference?: Hash;
}
export interface GetTrytesCommand extends BaseCommand {
command: IRICommand.GET_TRYTES;
readonly hashes: ReadonlyArray;
}
export interface GetTrytesResponse {
readonly trytes: ReadonlyArray;
}
export interface InterruptAttachingToTangleCommand extends BaseCommand {
command: IRICommand.INTERRUPT_ATTACHING_TO_TANGLE;
}
export declare type InterruptAttachingToTangleResponse = void;
export interface RemoveNeighborsCommand extends BaseCommand {
command: IRICommand.REMOVE_NEIGHBORS;
readonly uris: ReadonlyArray;
}
export interface RemoveNeighborsResponse {
readonly removedNeighbors: number;
readonly duration: number;
}
export interface StoreTransactionsCommand extends BaseCommand {
command: IRICommand.STORE_TRANSACTIONS;
readonly trytes: ReadonlyArray;
}
export declare type StoreTransactionsResponse = void;
/** Callback */
export declare type Callback = (err: Readonly | null, res?: Readonly) => void;
/** Provider interface */
export interface Provider {
readonly send: (command: Readonly, callback?: Callback>) => Promise>;
readonly setSettings: (settings?: Readonly>) => void;
}
/** Attach to tangle */
export declare type AttachToTangle = (trunkTransaction: Hash, branchTransaction: Hash, minWeightMagnitude: number, trytes: ReadonlyArray, callback?: Callback>) => Promise>;
export declare type NativeGenerateSignatureFunction = (seed: number[], index: number, numberOfFragments: number, bundle: number[]) => Promise;
export declare const asArray: (x: T | readonly T[]) => readonly T[];
export declare const getOptionsWithDefaults: (defaults: Readonly) => (options: Readonly>) => Readonly;
export declare type CreatePersistence = (adapter: PersistenceAdapter) => Persistence;
export interface Persistence extends Readable {
readonly ready: () => Promise;
readonly increment: () => Promise;
readonly put: (key: K, value: V) => Promise;
readonly del: (key: K) => Promise;
readonly get: (key: K) => Promise;
readonly batch: (ops: PersistenceBatch) => Promise;
readonly close: () => Promise;
readonly open: () => Promise;
}
export declare type PersistenceBatch = ReadonlyArray | PersistenceDelCommand>;
export declare enum PersistenceBatchTypes {
put = "put",
del = "del"
}
export interface PersistencePutCommand {
readonly type: PersistenceBatchTypes.put;
readonly key: K;
readonly value: V;
}
export interface PersistenceDelCommand {
readonly type: PersistenceBatchTypes.del;
readonly key: K;
}
export declare type CreatePersistenceAdapter = (params: PersistenceAdapterParams) => PersistenceAdapter;
export interface PersistenceAdapterParams {
readonly persistenceID: string;
readonly persistencePath?: string;
readonly store?: any;
}
export interface PersistenceIteratorOptions {
gt?: K;
gte?: K;
lt?: K;
lte?: K;
reverse?: boolean;
limit?: number;
keys?: boolean;
values?: boolean;
keyAsBuffer?: boolean;
valueAsBuffer?: boolean;
}
export interface PersistenceAdapter {
readonly get: (key: K) => Promise;
readonly put: (key: K, value: V) => Promise;
readonly del: (key: K) => Promise;
readonly batch: (ops: PersistenceBatch) => Promise;
readonly createReadStream: (options?: PersistenceIteratorOptions) => NodeJS.ReadableStream;
readonly close: () => Promise;
readonly open: () => Promise;
}
export interface PersistenceError extends Error {
notFound?: boolean;
}