UNPKG

@bsv/wallet-toolbox-client

Version:
130 lines 4.69 kB
import { BEEF, CreateActionOptions, CreateActionOutput, CreateActionResult, KeyDeriverApi, LockingScript, PrivateKey, ScriptTemplateUnlock, WalletInterface } from '@bsv/sdk'; import { KeyPairAddress, SetupClientWalletArgs, SetupWallet, SetupWalletClient } from './SetupWallet'; import { StorageIdb } from './storage/StorageIdb'; import { WalletStorageManager } from './storage/WalletStorageManager'; import { Services } from './services/Services'; import { Monitor } from './monitor/Monitor'; import { Wallet } from './Wallet'; import { Chain } from './sdk/types'; /** * The 'Setup` class provides static setup functions to construct BRC-100 compatible * wallets in a variety of configurations. * * It serves as a starting point for experimentation and customization. */ export declare abstract class SetupClient { /** * Create a `Wallet`. Storage can optionally be provided or configured later. * * The following components are configured: KeyDeriver, WalletStorageManager, WalletService, WalletStorage. * Optionally, PrivilegedKeyManager is also configured. * * @publicbody */ static createWallet(args: SetupClientWalletArgs): Promise<SetupWallet>; /** * Setup a new `Wallet` without requiring a .env file. * * @param args.chain - 'main' or 'test' * @param args.rootKeyHex - Root private key for wallet's key deriver. * @param args.storageUrl - Optional. `StorageClient` and `chain` compatible endpoint URL. * @param args.privilegedKeyGetter - Optional. Method that will return the privileged `PrivateKey`, on demand. */ static createWalletClientNoEnv(args: { chain: Chain; rootKeyHex: string; storageUrl?: string; privilegedKeyGetter?: () => Promise<PrivateKey>; }): Promise<Wallet>; /** * @publicbody */ static createWalletClient(args: SetupClientWalletClientArgs): Promise<SetupWalletClient>; /** * @publicbody */ static getKeyPair(priv?: string | PrivateKey): KeyPairAddress; /** * @publicbody */ static getLockP2PKH(address: string): LockingScript; /** * @publicbody */ static getUnlockP2PKH(priv: PrivateKey, satoshis: number): ScriptTemplateUnlock; /** * @publicbody */ static createP2PKHOutputs(outputs: { address: string; satoshis: number; outputDescription?: string; basket?: string; tags?: string[]; }[]): CreateActionOutput[]; /** * @publicbody */ static createP2PKHOutputsAction(wallet: WalletInterface, outputs: { address: string; satoshis: number; outputDescription?: string; basket?: string; tags?: string[]; }[], options?: CreateActionOptions): Promise<{ cr: CreateActionResult; outpoints: string[] | undefined; }>; /** * @publicbody */ static fundWalletFromP2PKHOutpoints(wallet: WalletInterface, outpoints: string[], p2pkhKey: KeyPairAddress, inputBEEF?: BEEF): Promise<void>; /** * Adds `indexedDB` based storage to a `Wallet` configured by `SetupClient.createWalletOnly` * * @param args.databaseName Name for this storage. For MySQL, the schema name within the MySQL instance. * @param args.chain Which chain this wallet is on: 'main' or 'test'. Defaults to 'test'. * @param args.rootKeyHex * * @publicbody */ static createWalletIdb(args: SetupWalletIdbArgs): Promise<SetupWalletIdb>; /** * @returns {StorageIdb} - `Knex` based storage provider for a wallet. May be used for either active storage or backup storage. */ static createStorageIdb(args: SetupWalletIdbArgs): Promise<StorageIdb>; } /** * */ export interface SetupWalletIdbArgs extends SetupClientWalletArgs { databaseName: string; } /** * */ export interface SetupWalletIdb extends SetupWallet { activeStorage: StorageIdb; userId: number; rootKey: PrivateKey; identityKey: string; keyDeriver: KeyDeriverApi; chain: Chain; storage: WalletStorageManager; services: Services; monitor: Monitor; wallet: Wallet; } /** * Extension `SetupWalletClientArgs` of `SetupWalletArgs` is used by `createWalletClient` * to construct a `SetupWalletClient`. */ export interface SetupClientWalletClientArgs extends SetupClientWalletArgs { /** * The endpoint URL of a service hosting the `StorageServer` JSON-RPC service to * which a `StorageClient` instance should connect to function as * the active storage provider of the newly created wallet. */ endpointUrl?: string; } //# sourceMappingURL=SetupClient.d.ts.map