How are funds transferred between the buyer's and seller's wallets, and do my tokens leave my wallet
When a user places a sell order, they essentially create a PSBT (Partially Signed Bitcoin Transaction).
Technically speaking, the PSBT created by the user is a half-done transaction that requires the initiator's conditions to be met and is currently in a pending state. A PSBT can only be confirmed on the blockchain when, and only when, it has been fulfilled, meaning the initiator's requirements have been satisfied by another party. This feature allows PSBTs to circulate off-chain securely before confirmation.
It's like the user has written a signed check for BRC20 Tokens, indicating how many BRC20 Tokens they're willing to pay to receive a certain amount of Bitcoin. However, since the transaction is not complete, the check has not been submitted to the bank, so the user can cancel it at any time.
Before the transaction is finalized, tokens are not transferred from the wallet. Technically, a PSBT can be regarded as an expectation of a transaction from its creation until it is fulfilled and confirmed on the blockchain, and this expectation exists off-chain. During this period, the assets have not left the user's wallet. Only after the expectation is met by the buyer and confirmed by the blockchain does the transaction get considered complete, and the asset exchange occurs at that moment.
Since orders employ atomic swaps, the exchange of tokens and BTC either happens simultaneously or doesn't happen at all. This means the check can circulate before being submitted to the bank, and the signature mechanism and PSBT's characteristics ensure it cannot be tampered with.
Last updated