Skip to content

Latest commit

 

History

History
385 lines (218 loc) · 11.4 KB

File metadata and controls

385 lines (218 loc) · 11.4 KB

Interface: Bridge

Interface for communication with the Bridge on-chain contract.

Implemented by

Table of contents

Properties

Methods

Properties

getDepositRevealedEvents

getDepositRevealedEvents: Function<DepositRevealedEvent>

Get emitted DepositRevealed events.

See

GetEventsFunction

Defined in

src/lib/contracts/bridge.ts:26


getNewWalletRegisteredEvents

getNewWalletRegisteredEvents: Function<NewWalletRegisteredEvent>

Get emitted NewWalletRegisteredEvent events.

See

GetEventsFunction

Defined in

src/lib/contracts/bridge.ts:155


getRedemptionRequestedEvents

getRedemptionRequestedEvents: Function<RedemptionRequestedEvent>

Get emitted RedemptionRequested events.

See

GetEventsFunction

Defined in

src/lib/contracts/bridge.ts:181

Methods

activeWalletPublicKey

activeWalletPublicKey(): Promise<undefined | Hex>

Gets the public key of the current active wallet.

Returns

Promise<undefined | Hex>

Compressed (33 bytes long with 02 or 03 prefix) active wallet's public key. If there is no active wallet at the moment, undefined is returned.

Defined in

src/lib/contracts/bridge.ts:149


buildUtxoHash

buildUtxoHash(utxo): Hex

Builds the UTXO hash based on the UTXO components.

Parameters

Name Type Description
utxo BitcoinUtxo UTXO components.

Returns

Hex

The hash of the UTXO.

Defined in

src/lib/contracts/bridge.ts:175


deposits

deposits(depositTxHash, depositOutputIndex): Promise<DepositRequest>

Gets a revealed deposit from the on-chain contract.

Parameters

Name Type Description
depositTxHash BitcoinTxHash The revealed deposit transaction's hash.
depositOutputIndex number Index of the deposit transaction output that funds the revealed deposit.

Returns

Promise<DepositRequest>

Revealed deposit data.

Defined in

src/lib/contracts/bridge.ts:68


getChainIdentifier

getChainIdentifier(): ChainIdentifier

Gets the chain-specific identifier of this contract.

Returns

ChainIdentifier

Defined in

src/lib/contracts/bridge.ts:20


pendingRedemptions

pendingRedemptions(walletPublicKey, redeemerOutputScript): Promise<RedemptionRequest>

Gets a pending redemption from the on-chain contract.

Parameters

Name Type Description
walletPublicKey Hex Bitcoin public key of the wallet the request is targeted to. Must be in the compressed form (33 bytes long with 02 or 03 prefix).
redeemerOutputScript Hex The redeemer output script the redeemed funds are supposed to be locked on. Must not be prepended with length.

Returns

Promise<RedemptionRequest>

Promise with the pending redemption.

Defined in

src/lib/contracts/bridge.ts:124


requestRedemption

requestRedemption(walletPublicKey, mainUtxo, redeemerOutputScript, amount): Promise<Hex>

Requests a redemption from the on-chain contract.

Parameters

Name Type Description
walletPublicKey Hex The Bitcoin public key of the wallet. Must be in the compressed form (33 bytes long with 02 or 03 prefix).
mainUtxo BitcoinUtxo The main UTXO of the wallet. Must match the main UTXO held by the on-chain contract.
redeemerOutputScript Hex The output script that the redeemed funds will be locked to. Must not be prepended with length.
amount BigNumber The amount to be redeemed in satoshis.

Returns

Promise<Hex>

Transaction hash of the request redemption transaction.

Defined in

src/lib/contracts/bridge.ts:84


revealDeposit

revealDeposit(depositTx, depositOutputIndex, deposit, vault?): Promise<Hex>

Reveals a given deposit to the on-chain contract.

Parameters

Name Type Description
depositTx BitcoinRawTxVectors Deposit transaction data
depositOutputIndex number Index of the deposit transaction output that funds the revealed deposit
deposit DepositReceipt Data of the revealed deposit
vault? ChainIdentifier Optional parameter denoting the vault the given deposit should be routed to

Returns

Promise<Hex>

Transaction hash of the reveal deposit transaction.

Defined in

src/lib/contracts/bridge.ts:54


submitDepositSweepProof

submitDepositSweepProof(sweepTx, sweepProof, mainUtxo, vault?): Promise<Hex>

Submits a deposit sweep transaction proof to the on-chain contract.

Parameters

Name Type Description
sweepTx BitcoinRawTxVectors Sweep transaction data.
sweepProof BitcoinSpvProof Sweep proof data.
mainUtxo BitcoinUtxo Data of the wallet's main UTXO.
vault? ChainIdentifier Optional identifier of the vault the swept deposits should be routed in.

Returns

Promise<Hex>

Transaction hash of the submit deposit sweep proof transaction.

Defined in

src/lib/contracts/bridge.ts:37


submitRedemptionProof

submitRedemptionProof(redemptionTx, redemptionProof, mainUtxo, walletPublicKey): Promise<Hex>

Submits a redemption transaction proof to the on-chain contract.

Parameters

Name Type Description
redemptionTx BitcoinRawTxVectors Redemption transaction data
redemptionProof BitcoinSpvProof Redemption proof data
mainUtxo BitcoinUtxo Data of the wallet's main UTXO
walletPublicKey Hex Bitcoin public key of the wallet. Must be in the compressed form (33 bytes long with 02 or 03 prefix).

Returns

Promise<Hex>

Transaction hash of the submit redemption proof transaction.

Defined in

src/lib/contracts/bridge.ts:100


timedOutRedemptions

timedOutRedemptions(walletPublicKey, redeemerOutputScript): Promise<RedemptionRequest>

Gets a timed-out redemption from the on-chain contract.

Parameters

Name Type Description
walletPublicKey Hex Bitcoin public key of the wallet the request is targeted to. Must be in the compressed form (33 bytes long with 02 or 03 prefix).
redeemerOutputScript Hex The redeemer output script the redeemed funds are supposed to be locked on. Must not be prepended with length.

Returns

Promise<RedemptionRequest>

Promise with the pending redemption.

Defined in

src/lib/contracts/bridge.ts:138


txProofDifficultyFactor

txProofDifficultyFactor(): Promise<number>

Gets transaction proof difficulty factor from the on-chain contract.

Returns

Promise<number>

Proof difficulty factor.

Dev

This number signifies how many confirmations a transaction has to accumulate before it can be proven on-chain.

Defined in

src/lib/contracts/bridge.ts:113


walletRegistry

walletRegistry(): Promise<WalletRegistry>

Returns the attached WalletRegistry instance.

Returns

Promise<WalletRegistry>

Defined in

src/lib/contracts/bridge.ts:160


wallets

wallets(walletPublicKeyHash): Promise<Wallet>

Gets details about a registered wallet.

Parameters

Name Type Description
walletPublicKeyHash Hex The 20-byte wallet public key hash (computed using Bitcoin HASH160 over the compressed ECDSA public key).

Returns

Promise<Wallet>

Promise with the wallet details.

Defined in

src/lib/contracts/bridge.ts:168