Skip to main content

SolanaBtcRelay<B>

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:40

Solana BTC relay (bitcoin light client) program representation.

Extends

  • SolanaProgramBase<any>

Type Parameters

Type Parameter
B extends BtcBlock

Implements

Constructors

Constructor

new SolanaBtcRelay<B>(
chainInterface,
bitcoinRpc,
programAddress?): SolanaBtcRelay<B>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:176

Parameters

ParameterTypeDescription
chainInterfaceSolanaChainInterfaceUnderlying chain interface to use for the Solana chain operations
bitcoinRpcBitcoinRpc<B>Bitcoin RPC instance to use for read access to the bitcoin blockchain
programAddress?stringOptional Solana on-chain program address, defaults to the cannonical deployment

Returns

SolanaBtcRelay<B>

Overrides

SolanaProgramBase<any>.constructor

Properties

maxForkHeadersPerTx

readonly maxForkHeadersPerTx: number = 4;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:165

Maximum amount of fork headers that fit in a single transactions

Implementation of

BtcRelay.maxForkHeadersPerTx


maxHeadersPerTx

readonly maxHeadersPerTx: number = 5;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:161

Maximum blockheaders that fit in a single transaction

Implementation of

BtcRelay.maxHeadersPerTx


maxShortForkHeadersPerTx

readonly maxShortForkHeadersPerTx: number = 4;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:169

Maximum amount of fork headers that can be submitted at once using the short fork method

Implementation of

BtcRelay.maxShortForkHeadersPerTx


program

program: Program<T>;

Defined in: atomiq-chain-solana/src/solana/program/SolanaProgramBase.ts:21

Inherited from

SolanaSwapProgram.program

Methods

estimateSynchronizeFee()

estimateSynchronizeFee(requiredBlockheight, feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:559

Estimate required synchronization fee (worst case) to synchronize btc relay to the required blockheight

Parameters

ParameterTypeDescription
requiredBlockheightnumberBlockheight to which to synchronize
feeRate?stringOptional fee rate to use for the estimation

Returns

Promise<bigint>

Implementation of

BtcRelay.estimateSynchronizeFee


getFeePerBlock()

getFeePerBlock(feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:578

Returns required fee in native token to synchronize a single block to btc relay

Parameters

ParameterTypeDescription
feeRate?stringOptional fee rate to use for the estimation

Returns

Promise<bigint>

Implementation of

BtcRelay.getFeePerBlock


getForkFeeRate()

getForkFeeRate(signer, forkId): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:598

Gets fee rate required for submitting blockheaders to the specific fork

Parameters

ParameterTypeDescription
signerstringA signer's address to use for the estimation
forkIdnumberA fork ID to use for estimation

Returns

Promise<string>

Implementation of

BtcRelay.getForkFeeRate


getMainFeeRate()

getMainFeeRate(signer): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:587

Gets fee rate required for submitting blockheaders to the main chain

Parameters

ParameterTypeDescription
signerstringA signer's address to use for the estimation

Returns

Promise<string>

Implementation of

BtcRelay.getMainFeeRate


getTipData()

getTipData(): Promise<{
blockhash: string;
blockheight: number;
chainWork: Buffer;
commitHash: string;
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:267

Returns data about current main chain tip stored in the btc relay

Returns

Promise<{ blockhash: string; blockheight: number; chainWork: Buffer; commitHash: string; }>

Implementation of

BtcRelay.getTipData


retrieveLatestKnownBlockLog()

retrieveLatestKnownBlockLog(): Promise<{
resultBitcoinHeader: B;
resultStoredHeader: SolanaBtcStoredHeader;
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:338

Retrieves latest known bitcoin blockheader stored in the BTC Relay and also known to the bitcoin RPC

Returns

Promise<{ resultBitcoinHeader: B; resultStoredHeader: SolanaBtcStoredHeader; }>

Implementation of

BtcRelay.retrieveLatestKnownBlockLog


retrieveLogAndBlockheight()

retrieveLogAndBlockheight(blockData, requiredBlockheight?): Promise<{
header: SolanaBtcStoredHeader;
height: number;
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:282

Retrieves blockheader with a specific blockhash, returns null if requiredBlockheight is provided and btc relay contract is not synced up to the desired blockheight

Parameters

ParameterTypeDescription
blockData{ blockhash: string; }
blockData.blockhashstring-
requiredBlockheight?number

Returns

Promise<{ header: SolanaBtcStoredHeader; height: number; }>

Implementation of

BtcRelay.retrieveLogAndBlockheight


retrieveLogByCommitHash()

retrieveLogByCommitHash(commitmentHashStr, blockData): Promise<SolanaBtcStoredHeader>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:317

Retrieves stored bitcoin blockheader data by blockheader's commit hash and provided blockhash from blockData

Parameters

ParameterTypeDescription
commitmentHashStrstring
blockData{ blockhash: string; }
blockData.blockhashstring-

Returns

Promise<SolanaBtcStoredHeader>

Implementation of

BtcRelay.retrieveLogByCommitHash


saveForkHeaders()

saveForkHeaders(
signer,
forkHeaders,
storedHeader,
forkId,
tipWork,
feeRate?): Promise<{
computedCommitedHeaders: SolanaBtcStoredHeader[];
forkId: number;
lastStoredHeader: SolanaBtcStoredHeader;
tx: {
signers: any[];
tx: any;
};
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:451

Returns a transaction that continues submitting blockheaders to an existing long fork

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersBtcBlock[]New fork bitcoin blockheaders to submit
storedHeaderSolanaBtcStoredHeaderCommitted and stored bitcoin blockheader in the BTC relay from which to fork
forkIdnumberFork ID to submit the blockheaders to
tipWorkBufferChainwork of the current BTC Relay main chain tip
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: SolanaBtcStoredHeader[]; forkId: number; lastStoredHeader: SolanaBtcStoredHeader; tx: { signers: any[]; tx: any; }; }>

Implementation of

BtcRelay.saveForkHeaders


saveInitialHeader()

saveInitialHeader(
signer,
header,
epochStart,
pastBlocksTimestamps,
feeRate?): Promise<{
signers: Signer[];
tx: Transaction;
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:374

Initializes the underlying BTC Relay contract

Parameters

ParameterTypeDescription
signerstringA signer's address to use for the transaction
headerBMain chain blockheader to use as a genesis
epochStartnumberTimestamp of the first block in this difficulty epoch
pastBlocksTimestampsnumber[]Timestamps of the last 11 blockheaders, for median block time rule
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ signers: Signer[]; tx: Transaction; }>

Implementation of

BtcRelay.saveInitialHeader


saveMainHeaders()

saveMainHeaders(
signer,
mainHeaders,
storedHeader,
feeRate?): Promise<{
computedCommitedHeaders: SolanaBtcStoredHeader[];
forkId: number;
lastStoredHeader: SolanaBtcStoredHeader;
tx: {
signers: any[];
tx: any;
};
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:394

Returns a transaction that submits bitcoin blockheaders as a bitcoin main chain to the btc relay

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
mainHeadersBtcBlock[]New bitcoin blockheaders to submit
storedHeaderSolanaBtcStoredHeaderLatest committed and stored bitcoin blockheader in the BTC relay
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: SolanaBtcStoredHeader[]; forkId: number; lastStoredHeader: SolanaBtcStoredHeader; tx: { signers: any[]; tx: any; }; }>

Implementation of

BtcRelay.saveMainHeaders


saveNewForkHeaders()

saveNewForkHeaders(
signer,
forkHeaders,
storedHeader,
tipWork,
feeRate?): Promise<{
computedCommitedHeaders: SolanaBtcStoredHeader[];
forkId: number;
lastStoredHeader: SolanaBtcStoredHeader;
tx: {
signers: any[];
tx: any;
};
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:415

Returns a transaction that submits a new long fork and submits the first headers to it

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersBtcBlock[]New fork bitcoin blockheaders to submit
storedHeaderSolanaBtcStoredHeaderCommitted and stored bitcoin blockheader in the BTC relay from which to fork
tipWorkBufferChainwork of the current BTC Relay main chain tip
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: SolanaBtcStoredHeader[]; forkId: number; lastStoredHeader: SolanaBtcStoredHeader; tx: { signers: any[]; tx: any; }; }>

Implementation of

BtcRelay.saveNewForkHeaders


saveShortForkHeaders()

saveShortForkHeaders(
signer,
forkHeaders,
storedHeader,
tipWork,
feeRate?): Promise<{
computedCommitedHeaders: SolanaBtcStoredHeader[];
forkId: number;
lastStoredHeader: SolanaBtcStoredHeader;
tx: {
signers: any[];
tx: any;
};
}>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:486

Returns a transaction that submits a short fork with the provided blockheaders

Parameters

ParameterTypeDescription
signerstringA signer's address for the transaction
forkHeadersBtcBlock[]New fork bitcoin blockheaders to submit
storedHeaderSolanaBtcStoredHeaderCommitted and stored bitcoin blockheader in the BTC relay from which to fork
tipWorkBufferChainwork of the current BTC Relay main chain tip
feeRate?stringOptional fee rate for the transaction

Returns

Promise<{ computedCommitedHeaders: SolanaBtcStoredHeader[]; forkId: number; lastStoredHeader: SolanaBtcStoredHeader; tx: { signers: any[]; tx: any; }; }>

Implementation of

BtcRelay.saveShortForkHeaders


sweepForkData()

sweepForkData(signer, lastSweepId?): Promise<number>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:517

Checks and sweeps data accounts which contain yet unused fork data (use for Solana's PDAs)

Parameters

ParameterTypeDescription
signerSolanaSignerA signer's address to check account for
lastSweepId?numberTimestamp of the last sweep

Returns

Promise<number>

A number of data accounts swept

Implementation of

BtcRelay.sweepForkData


Verify()

Verify(
signer,
reversedTxId,
confirmations,
position,
reversedMerkleProof,
committedHeader): Promise<SolanaAction>;

Defined in: atomiq-chain-solana/src/solana/btcrelay/SolanaBtcRelay.ts:85

Creates verify action to be used with the swap program, specifies the action to be firstIxBeforeComputeBudget, such that the verify instruction will always be the 0th in the transaction, this is required because swap program expects the verify instruction to be at the 0th position

Parameters

ParameterTypeDescription
signerPublicKey
reversedTxIdBuffer
confirmationsnumber
positionnumber
reversedMerkleProofBuffer<ArrayBufferLike>[]
committedHeaderSolanaBtcStoredHeader

Returns

Promise<SolanaAction>