@avalabs/bridge-unified
Advanced tools
Comparing version 0.0.0-CP-8544-BTC-bridge-2-20240910161708 to 0.0.0-CP-8544-BTC-bridge-2-20240911220816
import { Address } from 'viem'; | ||
import { NETWORK } from '@scure/btc-signer'; | ||
interface BitcoinTx { | ||
hash: string; | ||
fees: number; | ||
block: number; | ||
amount: number; | ||
confirmations: number; | ||
blockTime: number; | ||
addresses: string[]; | ||
inputs: { | ||
txid: string; | ||
vout: number; | ||
sequence: number; | ||
n: number; | ||
addresses: string[]; | ||
isAddress: boolean; | ||
value: number; | ||
}[]; | ||
outputs: { | ||
addresses: string[]; | ||
value: number; | ||
n: number; | ||
spent: boolean; | ||
hex: string; | ||
isAddress: boolean; | ||
}[]; | ||
} | ||
/** | ||
* Custom Bitcoin UTXO interface. | ||
*/ | ||
interface BitcoinInputUTXO { | ||
txHash: string; | ||
txHex?: string; | ||
index: number; | ||
value: number; | ||
script: string; | ||
blockHeight: number; | ||
confirmations: number; | ||
confirmedTime?: string; | ||
} | ||
interface BitcoinInputUTXOWithOptionalScript extends Omit<BitcoinInputUTXO, 'script'> { | ||
script?: string; | ||
} | ||
/** | ||
* An interface to simplify historic BTC transactions. | ||
*/ | ||
interface BitcoinHistoryTx { | ||
hash: string; | ||
isSender: boolean; | ||
addresses: string[]; | ||
fee: number; | ||
block: number; | ||
amount: number; | ||
confirmations: number; | ||
containsMultisig: boolean; | ||
receivedTime: number; | ||
confirmedTime?: number; | ||
} | ||
type Network = typeof NETWORK; | ||
declare abstract class BitcoinProviderAbstract { | ||
/** | ||
* Returns the UTXOs owned by the given address. | ||
* @param address | ||
*/ | ||
abstract getUTXOs(address: string, withScripts: boolean): Promise<{ | ||
confirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
unconfirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
}>; | ||
/** | ||
* Returns the connected network. | ||
*/ | ||
abstract getNetwork(): Network; | ||
/** | ||
* Get the current chain height. | ||
*/ | ||
abstract getChainHeight(): Promise<number>; | ||
/** | ||
* Returns the available balance for the user in satoshis. | ||
*/ | ||
abstract getBalances(address: string): Promise<{ | ||
available: bigint; | ||
pending: bigint; | ||
final: bigint; | ||
}>; | ||
/** | ||
* Returns available (confirmed) UTXOs and their total balance for the given address. | ||
* @address Address to get UTXOs of. | ||
*/ | ||
getUtxoBalance(address: string, withScripts?: boolean): Promise<{ | ||
balance: number; | ||
balanceUnconfirmed: number; | ||
utxos: BitcoinInputUTXOWithOptionalScript[]; | ||
utxosUnconfirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
}>; | ||
/** | ||
* Given a transaction hash, return the base information of the transaction | ||
*/ | ||
abstract getTransaction(hash: string): Promise<BitcoinTx>; | ||
/** | ||
* Given a transaction hash, return the whole transaction in hex format. | ||
* @param txHash | ||
*/ | ||
abstract getTxHex(txHash: string): Promise<string>; | ||
/** | ||
* Issues the given transaction to the bitcoin network | ||
* @param tx | ||
*/ | ||
abstract issueRawTx(tx: string): Promise<string>; | ||
/** | ||
* Returns the suggested fee rate in satoshis per byte. | ||
*/ | ||
abstract getFeeRates(): Promise<{ | ||
high: number; | ||
medium: number; | ||
low: number; | ||
}>; | ||
} | ||
declare class BitcoinProvider extends BitcoinProviderAbstract { | ||
#private; | ||
private readonly isMainnet; | ||
private readonly extraParams?; | ||
constructor(isMainnet?: boolean, apiKey?: string, explorerUrl?: string, nodeUrl?: string, extraParams?: Record<string, string> | undefined); | ||
getTxHex(txHash: string): Promise<string>; | ||
getUTXOs(address: string, withScripts?: boolean): Promise<{ | ||
confirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
unconfirmed: BitcoinInputUTXOWithOptionalScript[]; | ||
}>; | ||
getScriptsForUtxos(utxos: BitcoinInputUTXOWithOptionalScript[]): Promise<BitcoinInputUTXO[]>; | ||
private _parseUtxo; | ||
getBalances(address: string): Promise<{ | ||
available: bigint; | ||
pending: bigint; | ||
final: bigint; | ||
}>; | ||
getChainHeight(): Promise<number>; | ||
getFeeRates(): Promise<{ | ||
low: number; | ||
medium: number; | ||
high: number; | ||
}>; | ||
getNetwork(): Network; | ||
issueRawTx(tx: string): Promise<string>; | ||
getTransaction(hash: string): Promise<BitcoinTx>; | ||
/** | ||
* Returns the last 25 transactions | ||
*/ | ||
getTxHistory(address: string): Promise<BitcoinHistoryTx[]>; | ||
waitForTx(txHash: string, { maxAttempts, attempt, pollInterval, }?: { | ||
maxAttempts?: number; | ||
attempt?: number; | ||
pollInterval?: number; | ||
}): Promise<BitcoinTx>; | ||
} | ||
type Chain = { | ||
@@ -66,2 +222,3 @@ chainName: string; | ||
INCORRECT_HASH_PROVIDED = "INCORRECT_HASH_PROVIDED", | ||
INCORRECT_PROVIDER_PROVIDED = "INCORRECT_PROVIDER_PROVIDED", | ||
INCORRECT_TXHASH_PROVIDED = "INCORRECT_TXHASH_PROVIDED", | ||
@@ -131,4 +288,4 @@ INVALID_PARAMS = "INVALID_PARAMS", | ||
targetChain: Chain; | ||
sourceProvider?: Provider; | ||
targetProvider?: Provider; | ||
sourceProvider?: Provider | BitcoinProvider; | ||
targetProvider?: Provider | BitcoinProvider; | ||
onStepChange?: (stepDetails: BridgeStepDetails) => void; | ||
@@ -135,0 +292,0 @@ sign: Signer; |
{ | ||
"name": "@avalabs/bridge-unified", | ||
"license": "Limited Ecosystem License", | ||
"version": "0.0.0-CP-8544-BTC-bridge-2-20240910161708", | ||
"version": "0.0.0-CP-8544-BTC-bridge-2-20240911220816", | ||
"main": "dist/index.cjs", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
818691
1041