Skip to main content

ToBTCLNWrapper<T>

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:107

Escrow based (HTLC) swap for Smart chains -> Bitcoin lightning

Extends​

Type Parameters​

Type Parameter
T extends ChainType

Constructors​

Constructor​

new ToBTCLNWrapper<T>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
prices,
tokens,
versionedContracts,
lpApi,
options?,
events?): ToBTCLNWrapper<T>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:114

Parameters​

ParameterType
chainIdentifierstring
unifiedStorageUnifiedSwapStorage<T>
unifiedChainEventsUnifiedSwapEventListener<T>
chainT["ChainInterface"]
pricesISwapPrice
tokensWrapperCtorTokens
versionedContracts{ [version: string]: object; }
lpApiIntermediaryAPI
options?AllOptional<ToBTCLNWrapperOptions>
events?EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }>

Returns​

ToBTCLNWrapper<T>

Overrides​

IToBTCWrapper.constructor

Properties​

_versionedContracts​

readonly _versionedContracts: object = {};

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts:55

Index Signature​

[version: string]: object

Inherited from​

IToBTCWrapper._versionedContracts


chainIdentifier​

readonly chainIdentifier: T["ChainId"];

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:164

Chain identifier string of this wrapper

Inherited from​

IToBTCWrapper.chainIdentifier


events​

readonly events: EventEmitter<{
swapState: [ToBTCLNSwap<T>];
}>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:168

Event emitter emitting "swapState" event when swap's state changes

Inherited from​

IToBTCWrapper.events


TYPE​

readonly TYPE: TO_BTCLN = SwapType.TO_BTCLN;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:108

Swap type

Overrides​

IToBTCWrapper.TYPE

Methods​

checkPastSwaps()​

checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: ToBTCLNSwap<T>[];
removeSwaps: ToBTCLNSwap<T>[];
}>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:424

Runs checks on all the known pending swaps, syncing their state from on-chain data

Parameters​

ParameterTypeDescription
pastSwaps?ToBTCLNSwap<T>[]Optional array of past swaps to check, otherwise all relevant swaps will be fetched from the persistent storage
noSave?booleanWhether to skip saving the swap changes in the persistent storage

Returns​

Promise<{ changedSwaps: ToBTCLNSwap<T>[]; removeSwaps: ToBTCLNSwap<T>[]; }>

Remarks​

Doesn't work properly if you pass non-persisted swaps

Inherited from​

IToBTCWrapper.checkPastSwaps


create()​

create(
signer,
recipient,
amountData,
lps,
options?,
additionalParams?,
abortSignal?,
preFetches?): Promise<object[]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:425

Returns a newly created Smart chain -> Lightning swap using the HTLC based escrow swap protocol, the amount is parsed from the provided lightning network payment request (bolt11 invoice)

Parameters​

ParameterTypeDescription
signerstringSource chain signer address initiating the swap
recipientstringBOLT11 payment request (bitcoin lightning invoice) you wish to pay
amountDataOmit<AmountData, "amount"> & objectToken to swap
lpsIntermediary[]An array of intermediaries (LPs) to get the quotes from
options?ToBTCLNOptionsOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal
preFetches?{ feeRatePromise: { [contractVersion: string]: Promise<string>; }; pricePreFetchPromise: Promise<bigint>; signDataPrefetchPromise?: { [contractVersion: string]: Promise<T["PreFetchVerification"]>; }; usdPricePrefetchPromise: Promise<number>; }Optional existing pre-fetch promises for the swap (only used internally for LNURL swaps)
preFetches.feeRatePromise?{ [contractVersion: string]: Promise<string>; }-
preFetches.pricePreFetchPromise?Promise<bigint>-
preFetches.signDataPrefetchPromise?{ [contractVersion: string]: Promise<T["PreFetchVerification"]>; }-
preFetches.usdPricePrefetchPromise?Promise<number>-

Returns​

Promise<object[]>


createViaInvoiceCreateService()​

createViaInvoiceCreateService(
signer,
invoiceCreateServicePromise,
amountData,
lps,
options?,
additionalParams?,
abortSignal?): Promise<object[]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:644

Returns a newly created Smart chain -> Lightning swap using the HTLC based escrow swap protocol via invoice creation service. This allows exactIn swaps by requesting the desired fixed amount lightning network invoice from the service.

Parameters​

ParameterTypeDescription
signerstringSource chain signer address initiating the swap
invoiceCreateServicePromisePromise<LightningInvoiceCreateService>Service to request destination lightning network invoices from
amountDataAmountDataAmount, token and exact input/output data for to swap
lpsIntermediary[]An array of intermediaries (LPs) to get the quotes from
options?ToBTCLNOptionsOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal

Returns​

Promise<object[]>


createViaLNURL()​

createViaLNURL(
signer,
lnurl,
amountData,
lps,
options?,
additionalParams?,
abortSignal?): Promise<object[]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:732

Returns a newly created Smart chain -> Lightning swap using the HTLC based escrow swap protocol. Pays to an LNURL-pay link. This allows exactIn swaps by requesting the desired fixed amount lightning network invoice from the LNURL service.

Parameters​

ParameterTypeDescription
signerstringSource chain signer address initiating the swap
lnurl| string | LNURLPayParamsWithUrlLNURL-pay link of the recipient
amountDataAmountDataAmount, token and exact input/output data for to swap
lpsIntermediary[]An array of intermediaries (LPs) to get the quotes from
options?ToBTCLNOptions & objectOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal

Returns​

Promise<object[]>


init()​

init(noTimers, noCheckPastSwaps): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:360

Initializes the swap wrapper, needs to be called before any other action can be taken

Parameters​

ParameterTypeDefault valueDescription
noTimersbooleanfalseWhether to skip scheduling a tick timer for the swaps, if the tick timer is not initiated the swap states depending on e.g. expiry can be out of sync with the actual expiration of the swap
noCheckPastSwapsbooleanfalseWhether to skip checking past swaps on initialization (by default all pending swaps are re-checked on init, and their state is synchronized from the on-chain data)

Returns​

Promise<void>

Inherited from​

IToBTCWrapper.init


recoverFromSwapDataAndState()​

recoverFromSwapDataAndState(
init,
state,
contractVersion,
lp?): Promise<ToBTCLNSwap<T>>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts:802

Recovers a swap from smart chain on-chain data, please note that not all values for the recovered swaps might be populated, as some data is purely off-chain and can never be recovered purely from on-chain data.

Parameters​

ParameterTypeDescription
init{ data: T["Data"]; getInitTxId: () => Promise<string>; getTxBlock: () => Promise<{ blockHeight: number; blockTime: number; }>; }Swap escrow initialization transaction and swap data
init.dataT["Data"]-
init.getInitTxId() => Promise<string>-
init.getTxBlock() => Promise<{ blockHeight: number; blockTime: number; }>-
state?SwapCommitStateCurrent on-chain state of the swap
contractVersion?string-
lp?IntermediaryIntermediary (LP) used as a counterparty for the swap

Returns​

Promise<ToBTCLNSwap<T>>

Overrides​

IToBTCWrapper.recoverFromSwapDataAndState


stop()​

stop(): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:401

Un-subscribes from event listeners on the smart chain, terminates the tick interval and stops this wrapper

Returns​

Promise<void>

Inherited from​

IToBTCWrapper.stop


tick()​

tick(swaps?, abortSignal?): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:459

Invokes ISwap._tick on all the known swaps

Parameters​

ParameterTypeDescription
swaps?ToBTCLNSwap<T>[]Optional array of swaps to invoke _tick() on, otherwise all relevant swaps will be fetched from the persistent storage
abortSignal?AbortSignalAbort signal

Returns​

Promise<void>

Inherited from​

IToBTCWrapper.tick