Bitcoin Overview
Bitcoin architure
LI.FI offers seamless native Bitcoin bridging and swaps between native Bitcoin, major EVM chains and Solana.
Bridging in and out of Bitcoin is powered via Thorswap and Chainflip.
Currently only native SegWit addresses are supported which are addresses that start with “bc1q”
Requesting a quote
A quote for Bitcoin can be requested using the same endpoints as EVM. The only differce will be the transaction data when source chain is Bitcoin.
fromAddress
when source chain is Bitcoin needs to have enough UTXOs to cover the requested tx amount otherwise no quote will be returned.
The check is in place in order to build a transaction on Bitcoin where user’s wallet’s UTXOs are checked and combined in the most efficient way.
Executing a transaction
Transaction data
After retrieving the quote, the funds need to be sent to the BTC vault address provided in the response, along with a memo.
-
Memo Functionality: Similar to Thorchain, LI.FI uses memos for BTC to EVM swaps. The memo in the BTC transaction specifies the swap’s destination address and chain.
-
Transaction Handling: The transaction that leaves BTC and goes to EVM needs to be sent to an EVM address. The memo ensures that the swap details are correctly processed by the validators.
NOTE: Only send tx n a timely manner (30min), it is always recommended to request an up-to-date quote to ensure to get the latest information.
data’ in transactionRequest object is PSBT (partially signed bitcoin transaction) and memo needs to be retrieved from PSBT by decoding it.
Retrieving memo from PSBT
PSBT can be decoded using any library like bitcoinjs or scure-btc-signer.
Here’s an example using bitcoinjs