Bitcoin light client (on-chain)
Bitcoin light client is used to ensure atomicity for swaps between Solana & On-chain Bitcoin without using inefficient constructions such as HTLCs for on-chain swaps.
Last updated
Bitcoin light client is used to ensure atomicity for swaps between Solana & On-chain Bitcoin without using inefficient constructions such as HTLCs for on-chain swaps.
Last updated
Bitcoin light client is an on-chain Solana program used to verify and store bitcoin blockheaders. This program is completely permissionless and trustless, anyone can write blockheaders as their validity is verified on-chain. Bitcoin blockheaders contain a merkle root of all the transactions executed in it, this can be used to easily prove that any Bitcoin transaction was actually confirmed/included in a block, by providing a short merkle proof, this is utilized in proof-time locked contracts (PTLCs). A more technical explanation about inner workings of our bitcoin light client can be found .
Contract construction is similar to hash-time locked contract (HTLC), where claimer needs to provide a proof instead of a secret for a hash. In this case the proof is transaction verification through bitcoin light client by providing a valid merkle proof for a transaction inclusion inside a bitcoin blockheader.
PTLC is an agreement (smart contract) between 2 parties (A & B) consisting of proof-lock & timelock. It is created with 2 parameters: bitcoin transaction TX (as identified by the tx id, or a specific transaction input/output) & timelock T
Enables A to claim the funds from the smart contract if he is able to prove that a bitcoin transaction TX was confirmed in a bitcoin block (using bitcoin light client & merkle proof of transaction inclusion). This is used for happy path (the bitcoin payment was successful).
Allows B to claim the funds from the smart contract once the timelock T expires. This is used for sad path (e.g. when the counterparty doesn't cooperate) and makes sure the funds are returned to the original sender.
It is also possible to cooperatively close the contract together (but both A & B must agree on the closing terms of the contract).
Bitcoin light client cannot work all by itself, there needs to be some party submitting the latest bitcoin blockheaders to the bitcoin light client Solana program, so they can be verified, stored on Solana and later used for transaction verification. For this purpose atomiq.exchange uses a permission-less network of relayers (which also double-down as watchtowers).
Being a watchtower is a profit motive for running a relayer, so these two are inseparable. Watchtowers are tasked with claiming swaps (specifically Bitcoin on-chain -> Solana) on behalf of users, to improve UX & security for those swaps, for this they are compensated by a small fee paid for by the users. To do this they need to make sure the bitcoin light client Solana program synced to latest bitcoin blockheader (so they are able to verify the to-be-claimed transactions).
Watchtower observes an event of creation of PTLC on-chain (PTLC creator/claimer must explicitly opt-in for this feature)
Watchtower starts checking if subsequent bitcoin blocks contain the required transaction
If the transaction was found, the watchtower waits till that transaction gets required number of confirmations on bitcoin blockchain
Once the transaction got the required number of confirmations watchtower claims the funds from the PTLC to the claimer's account, and receives a fee (which was initially paid by the creator/claimer to create the PTLC).