import { ClientConfig, RequestConfig, AlkanesBalance, UTXO, AddressAlkanesTokenSummary, AlkanesCollection, AlkanesInfo, UserToSignInput, WalletConfig, AddressSummary, BitcoinBalance, BitcoinBalanceV2, FeeSummary, DecodedPsbt, UtxoAssets, TokenBalance, AddressTokenSummary, TokenTransfer, BRC20HistoryItem, TickPriceItem, InscribeOrder, CAT20Balance, CAT721CollectionInfo, AppSummary, VersionDetail, CoinPrice, UTXO_Detail, Inscription, InscriptionSummary, RuneBalance, AddressRunesTokenSummary, AppExtra, Announcement } from './types.mjs';
import { CAT_VERSION, UserToSignInput as UserToSignInput$1, NotificationListItem } from '@unisat/wallet-shared';
import { ProxyStorageAdapter } from '@unisat/wallet-storage';
import '@unisat/wallet-types';
/**
* HTTP client for UniSat API
*/
///
/**
* HTTP request options
*/
interface RequestOptions extends RequestConfig {
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
body?: any;
query?: Record;
}
interface BaseHttpClient {
get(url: string, options?: RequestOptions): Promise;
post(url: string, body?: any, options?: RequestOptions): Promise;
setBaseURL(baseURL: string): void;
setHeaders(headers: Record): void;
}
/**
* HTTP client implementation
*/
declare class HttpClient implements BaseHttpClient {
private readonly baseURL;
private readonly defaultConfig;
private readonly defaultHeaders;
constructor(config?: ClientConfig);
/**
* Make an HTTP request
*/
request(path: string, options?: RequestOptions): Promise;
/**
* Make a GET request
*/
get(path: string, options?: Omit): Promise;
/**
* Make a POST request
*/
post(path: string, body?: any, options?: Omit): Promise;
/**
* Make a PUT request
*/
put(path: string, body?: any, options?: Omit): Promise;
/**
* Make a DELETE request
*/
delete(path: string, options?: Omit): Promise;
/**
* Build URL with query parameters
*/
private buildUrl;
/**
* Make the actual HTTP request
*/
private makeRequest;
/**
* Handle HTTP response
*/
private handleResponse;
/**
* Check if response is in API format
*/
private isApiResponse;
/**
* Sleep utility for retries
*/
private sleep;
/**
* Update base URL
*/
setBaseURL(baseURL: string): void;
/**
* Update default headers
*/
setHeaders(headers: Record): void;
/**
* Remove a header
*/
removeHeader(name: string): void;
}
/**
* Alkanes-related API methods - Fully compatible with openapi.ts
*/
declare class AlkanesService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get address Alkanes list
*/
getAlkanesList(address: string, cursor: number, size: number): Promise<{
list: AlkanesBalance[];
total: number;
}>;
/**
* Get Alkanes UTXO
*/
getAlkanesUtxos(address: string, alkaneid: string): Promise;
getAddressAlkanesTokenSummary(address: string, alkaneid: string, fetchAvailable?: boolean): Promise;
getAlkanesCollectionList(address: string, cursor: number, size: number): Promise<{
list: AlkanesCollection[];
total: number;
}>;
getAlkanesCollectionItems(address: string, collectionId: string, cursor: number, size: number): Promise<{
list: AlkanesInfo[];
total: number;
}>;
createAlkanesSendTx({ userAddress, userPubkey, receiver, alkaneid, amount, feeRate, enableRBF, }: {
userAddress: string;
userPubkey: string;
receiver: string;
alkaneid: string;
amount: string;
feeRate: number;
enableRBF?: boolean;
}): Promise<{
orderId: string;
psbtHex: string;
toSignInputs: UserToSignInput[];
}>;
}
/**
* Bitcoin-related API methods - Fully compatible with openapi.ts
*/
declare class BitcoinService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get wallet configuration
*/
getWalletConfig(): Promise;
/**
* Get address summary
*/
getAddressSummary(address: string): Promise;
/**
* Get address balance
*/
getAddressBalance(address: string): Promise;
/**
* Get address balance V2
*/
getAddressBalanceV2(address: string): Promise;
/**
* Get multi-address assets
*/
getMultiAddressAssets(addresses: string): Promise;
/**
* Get fee summary
*/
getFeeSummary(): Promise;
getLowFeeSummary(): Promise;
/**
* Get available UTXOs (deprecated)
*/
getAvailableUtxos(address: string): Promise;
/**
* Get unavailable UTXOs (deprecated)
*/
getUnavailableUtxos(address: string): Promise;
/**
* Get BTC UTXOs
*/
getBTCUtxos(address: string): Promise;
/**
* Broadcast transaction
*/
pushTx(rawtx: string): Promise;
/**
* Decode PSBT
*/
decodePsbt(psbtHex: string, website: string): Promise;
/**
* Get address recent history
*/
getAddressRecentHistory(params: {
address: string;
start: number;
limit: number;
}): Promise;
/**
* Create send BTC transaction, bypassing head offsets
*/
createSendCoinBypassHeadOffsets(address: string, pubkey: string, tos: {
address: string;
satoshis: number;
}[], feeRate: number, enableRBF?: boolean): Promise;
/**
* Find group assets
*/
findGroupAssets(groups: {
type: number;
address_arr: string[];
}[]): Promise<{
type: number;
address_arr: string[];
satoshis_arr: number[];
}[]>;
/**
* Decode contracts
*/
decodeContracts(contracts: any[], account: any): Promise;
/**
* Batch fetch inscription/rune/alkane assets for a list of outpoints (txid:vout).
* Much smaller payload than sending full PSBT hex.
*/
getUtxoAssetsByOutpoints(outpoints: string[]): Promise;
}
/**
* BRC20-related API methods - Fully compatible with openapi.ts
*/
declare class BRC20Service {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
private resolveTicker;
/**
* Get address BRC20 token list
*/
getBRC20List({ address, cursor, size, }: {
address: string;
cursor: number;
size: number;
}): Promise<{
list: TokenBalance[];
total: number;
}>;
/**
* Get address specific token summary
*/
getAddressTokenSummary({ address, ticker, tickerHex, }: {
address: string;
ticker: string;
tickerHex?: string;
}): Promise;
/**
* Get address token history list
*/
getAddressTokenHistoryList({ address, ticker, tickerHex, cursor, size, }: {
address: string;
ticker: string;
tickerHex?: string;
cursor: number;
size: number;
}): Promise<{
list: TokenTransfer[];
total: number;
}>;
/**
* Get BRC20 recent history
*/
getBRC20RecentHistory(address: string, ticker: string): Promise;
/**
* Get token price
*/
getTickPrice(ticker: string): Promise;
/**
* Inscribe BRC20 transfer
*/
inscribeBRC20Transfer(address: string, tick: string, amount: string, feeRate: number, outputValue?: number): Promise;
/**
* Get inscription result
*/
getInscribeResult(orderId: string): Promise;
getTokenTransferableList({ address, ticker, tickerHex, cursor, size, }: {
address: string;
ticker: string;
tickerHex?: string;
cursor: number;
size: number;
}): Promise<{
list: TokenTransfer[];
total: number;
}>;
/**
* Single step transfer BRC20 - Step 1
*/
singleStepTransferBRC20Step1({ userAddress, userPubkey, receiver, ticker, amount, feeRate, }: {
userAddress: string;
userPubkey: string;
receiver: string;
ticker: string;
amount: string;
feeRate: number;
}): Promise<{
orderId: string;
psbtHex: string;
toSignInputs: UserToSignInput[];
}>;
singleStepTransferBRC20Step2({ orderId, psbt, }: {
orderId: string;
psbt: string;
}): Promise<{
psbtHex: string;
toSignInputs: UserToSignInput[];
}>;
/**
* Single step transfer BRC20 - Step 3
*/
singleStepTransferBRC20Step3(params: {
orderId: string;
psbt: string;
}): Promise<{
txid: string;
}>;
getBRC20ProgList({ address, cursor, size, }: {
address: string;
cursor: number;
size: number;
}): Promise<{
list: TokenBalance[];
total: number;
}>;
}
/**
* CAT20/CAT721-related API methods - Fully compatible with openapi.ts
*/
declare class CATService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
getCAT20List(version: CAT_VERSION, address: string, cursor: number, size: number): Promise<{
list: CAT20Balance[];
total: number;
}>;
getAddressCAT20TokenSummary(version: CAT_VERSION, address: string, tokenId: string): Promise;
getAddressCAT20UtxoSummary(version: CAT_VERSION, address: string, tokenId: string): Promise;
transferCAT20Step1(version: CAT_VERSION, address: string, pubkey: string, to: string, tokenId: string, amount: string, feeRate: number): Promise<{
id: string;
commitTx: string;
toSignInputs: UserToSignInput$1[];
feeRate: number;
}>;
transferCAT20Step2(version: CAT_VERSION, transferId: string, signedPsbt: string): Promise<{
revealTx: string;
toSignInputs: UserToSignInput$1[];
}>;
transferCAT20Step3(version: CAT_VERSION, transferId: string, signedPsbt: string): Promise<{
txid: string;
}>;
transferCAT20Step1ByMerge(version: CAT_VERSION, mergeId: string): Promise<{
id: string;
commitTx: string;
toSignInputs: UserToSignInput$1[];
feeRate: number;
}>;
mergeCAT20Prepare(version: CAT_VERSION, address: string, pubkey: string, tokenId: string, utxoCount: number, feeRate: number): Promise<{
id: string;
senderAddress: string;
senderPubkey: string;
tokenId: string;
feeRate: number;
batchIndex: number;
batchCount: number;
ct: number;
version?: string;
}>;
getMergeCAT20Status(version: CAT_VERSION, mergeId: string): Promise<{
id: string;
senderAddress: string;
senderPubkey: string;
tokenId: string;
feeRate: number;
batchIndex: number;
batchCount: number;
ct: number;
version?: string;
}>;
getCAT721CollectionList(version: CAT_VERSION, address: string, cursor: number, size: number): Promise<{
list: CAT721CollectionInfo[];
total: number;
}>;
getAddressCAT721CollectionSummary(version: CAT_VERSION, address: string, collectionId: string): Promise;
transferCAT721Step1(version: CAT_VERSION, address: string, pubkey: string, to: string, collectionId: string, localId: string, feeRate: number): Promise<{
id: string;
commitTx: string;
toSignInputs: UserToSignInput$1[];
feeRate: number;
}>;
transferCAT721Step2(version: CAT_VERSION, transferId: string, signedPsbt: string): Promise<{
revealTx: string;
toSignInputs: UserToSignInput$1[];
}>;
transferCAT721Step3(version: CAT_VERSION, transferId: string, signedPsbt: string): Promise<{
txid: string;
}>;
}
/**
* Configuration and utility API methods
*/
declare class ConfigService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get wallet configuration
*/
getWalletConfig(): Promise;
/**
* Get application list
*/
getAppList(): Promise<{
apps: AppSummary[];
featured: AppSummary[];
categories: Array<{
id: string;
name: string;
apps: AppSummary[];
}>;
}>;
/**
* Get banner list
*/
getBannerList(): Promise>;
/**
* Get block activity information
*/
getBlockActiveInfo(): Promise<{
allTransactions: number;
allAddrs: number;
currentHeight: number;
recentBlocks: Array<{
height: number;
timestamp: number;
txCount: number;
}>;
}>;
/**
* Get version details
*/
getVersionDetail(version: string): Promise;
/**
* Get Bitcoin price
*/
getBitcoinPrice(): Promise;
/**
* Get tick prices
*/
getTickPrices(ticks: string[]): Promise;
/**
* Get Babylon configuration
*/
getBabylonConfig(): Promise;
}
/**
* Inscriptions-related API methods - Fully compatible with openapi.ts
*/
declare class InscriptionsService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get inscription UTXO
*/
getInscriptionUtxo(inscriptionId: string): Promise;
/**
* Get inscription UTXO details
*/
getInscriptionUtxoDetail(inscriptionId: string): Promise;
/**
* Get UTXOs for multiple inscriptions
*/
getInscriptionUtxos(inscriptionIds: string[]): Promise;
/**
* Get inscription information
*/
getInscriptionInfo(inscriptionId: string): Promise;
/**
* Get address inscription list
*/
getAddressInscriptions(address: string, cursor: number, size: number): Promise<{
list: Inscription[];
total: number;
}>;
/**
* Get inscription summary
*/
getInscriptionSummary(): Promise;
/**
* Get application summary
*/
getAppSummary(): Promise;
/**
* Get Ordinals inscriptions
*/
getOrdinalsInscriptions(address: string, cursor: number, size: number): Promise<{
list: Inscription[];
total: number;
}>;
}
/**
* Market and pricing related API methods
*/
declare class MarketService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get coin price
*/
getCoinPrice(): Promise;
getBrc20sPrice(ticks: string[]): Promise;
getRunesPrice(ticks: string[]): Promise;
getCAT20sPrice(ticks: string[]): Promise;
getAlkanesPrice(ticks: string[]): Promise;
}
/**
* Notification related API methods
*/
declare class NotificationService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get notification list
*/
getList(): Promise<{
list: NotificationListItem[];
total: number;
}>;
read(notificationId: string): Promise<{
success: boolean;
}>;
readAll(notificationIds: string[]): Promise<{
success: boolean;
}>;
}
/**
* Runes-related API methods - Fully compatible with openapi.ts
*/
declare class RunesService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get address Runes list
*/
getRunesList(address: string, cursor: number, size: number): Promise<{
list: RuneBalance[];
total: number;
}>;
/**
* Get Runes UTXO
*/
getRunesUtxos(address: string, runeid: string): Promise;
/**
* Get address Runes token summary
*/
getAddressRunesTokenSummary(address: string, runeid: string): Promise;
}
/**
* Utility and tool related API methods
*/
declare class UtilityService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Check website
*/
checkWebsite(website: string): Promise<{
isScammer: boolean;
warning: string;
}>;
/**
* Get buy coin channel list
*/
getBuyCoinChannelList(coin: 'BTC' | 'FB'): Promise<{
channel: string;
}[]>;
/**
* Create buy coin payment URL
*/
createBuyCoinPaymentUrl(coin: 'BTC' | 'FB', address: string, channel: string): Promise;
/**
* Get application list
*/
getAppList(): Promise<{
tab: string;
items: any[];
}[]>;
/**
* Get extra information for an application
*/
getAppExtra(id: string | number, locale?: string): Promise;
/**
* Get banner list
*/
getBannerList(): Promise<{
id: string;
img: string;
link: string;
}[]>;
/**
* Get application summary
*/
getAppSummary(): Promise;
/**
* Get block activity information
*/
getBlockActiveInfo(): Promise<{
allTransactions: number;
allAddrs: number;
}>;
getAnnouncements(cursor: number, size: number): Promise<{
hasMore: boolean;
list: Announcement[];
}>;
}
declare class DomainService {
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Get domain information
*/
getDomainInfo(domain: string): Promise;
}
/**
* UniSat Wallet API Client - Fully compatible with openapi.ts interface
*
* This client provides a fully compatible interface with openapi.ts from unisat-extension
*/
/**
* Unified API Client - Matches all methods from openapi.ts
*/
declare class UniSatApiClient {
readonly bitcoin: BitcoinService;
readonly inscriptions: InscriptionsService;
readonly brc20: BRC20Service;
readonly runes: RunesService;
readonly alkanes: AlkanesService;
readonly cat: CATService;
readonly market: MarketService;
readonly domain: DomainService;
readonly utility: UtilityService;
readonly config: ConfigService;
readonly notification: NotificationService;
private readonly httpClient;
constructor(httpClient: BaseHttpClient);
/**
* Set base URL
*/
setBaseURL(baseURL: string): void;
/**
* Set request headers
*/
setHeaders(headers: Record): void;
/**
* Get underlying HTTP client
*/
getHttpClient(): BaseHttpClient;
}
interface WalletServiceConfig {
storage?: ProxyStorageAdapter;
logger?: any;
endpoint?: string;
httpClient?: BaseHttpClient;
}
declare class WalletApiService {
private store;
private storage;
private client;
private clientAddress;
private currentEndpoint;
private storageKey;
constructor();
init: (config: WalletServiceConfig) => Promise;
resetAllData: () => Promise;
setEndpoint: (endpoint: string) => Promise;
setClientAddress: (address: string) => Promise;
updateHeaders: () => void;
private generateDeviceId;
getClient: () => UniSatApiClient;
get bitcoin(): BitcoinService;
get inscriptions(): InscriptionsService;
get brc20(): BRC20Service;
get runes(): RunesService;
get alkanes(): AlkanesService;
get cat(): CATService;
get market(): MarketService;
get domain(): any;
get utility(): UtilityService;
get config(): ConfigService;
get notification(): NotificationService;
}
export { BaseHttpClient, HttpClient, WalletApiService, WalletServiceConfig };