# Peg-in & Out Bitcoin

**To eliminate the trust assumption while sustaining decentralization, BitRexe adopted the** [**space chain** ](https://medium.com/@RubenSomsen/21-million-bitcoins-to-rule-all-sidechains-the-perpetual-one-way-peg-96cb2f8ac302)**method.** In short, the initial idea of the spacechain is to make its connection to Bitcoin a one-way peg. You are allowed to burn bitcoin and receive the same amount of xBTC on the layer 2 network, but you cannot peg out.&#x20;

If there's no peg-out wallet on the Bitcoin Layer 1 to manage, no need to assumption-ally trust parties who own your custodian Bitcoin like Liquid, or re-build a POS network like Stacks did that increases consensus abundance.&#x20;

However, the impossibility of Spacechain redeeming your Bitcoin is intimidating to the average user.&#x20;

BitRexe takes one step forward while allowing two-pegged without changing the security and sustaining the zero-trust assumption of the spacechain solution.&#x20;

There's no such function as burning your xBTC and receiving BTC on Layer &#x31;**.**&#x20;

**Instead,**

> **when you peg-in Bitcoin successfully, it means another party(parties) pegged-out the same amount of rxBTC. Vice versa. We call it SWAPCHAIN.**&#x20;

<figure><img src="https://3142435605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZTe9DaPXLrFy1CRilHQU%2Fuploads%2Fx35KJu5rBLDf6q0Os550%2Fimage.png?alt=media&#x26;token=76cdf961-18e5-4794-ae4e-e1b3fd82c1e5" alt=""><figcaption><p>SWAPCHAIN Mechnism Explain</p></figcaption></figure>

If you are familiar with buying crypto via Fiat with C2C trading on central exchanges like Binance and Coinbase, the method should instantly make sense to you. Your peg-in & peg-out requests are essentially orders, they can be fulfilled by any party with the opposite demands.&#x20;



## Peg-in (Bitcoin to BitRexe)

Moving funds from Bitcoin to BitRexe is called a peg-in;&#x20;

A BitRexe user sends Bitcoin to the address belonging to the parties pegging out. Once the orders are matched for both sides, an address will be generated to receive one's peg-in Bitcoin. Once the transaction is finalized, a 1:1 equivalent rxBTC will be minted and transferred to the user's [DIO wallet address. ](https://chrome.google.com/webstore/detail/ghdejoclpabnhidemhnfagafafcmgcfm)

A peg-in transaction requires 6 confirmations on the Bitcoin network before the funds can be claimed on the BitRexe Network. This high level of security is required to protect all participants’ funds in the event of a large block reorganization of the Bitcoin blockchain.

<figure><img src="https://3142435605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZTe9DaPXLrFy1CRilHQU%2Fuploads%2F0gy0zfIiwlfO2PudL2lD%2Fimage.png?alt=media&#x26;token=e5df5e54-afd6-4115-908c-7a0dd41a25c1" alt="" width="374"><figcaption><p>Peg-in rxBTC user interface</p></figcaption></figure>

## Peg-out (BitRexe to Bitcoin)

Reclaim your Bitcoin from BitRexe to Bitcoin is called a peg-out;&#x20;

Once a peg-out request is submitted

<figure><img src="https://3142435605-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZTe9DaPXLrFy1CRilHQU%2Fuploads%2FVVGCTNqfImReLFtc8mYc%2F9e295f9bd07973c25cc0b511a804579.png?alt=media&#x26;token=399450bf-37ec-4eb4-a47f-ee6630948f88" alt=""><figcaption></figcaption></figure>

1. rxBTC will be burnt
2. Once the watcher address has witnessed the burning on-chain activity through RPC
3. Such request will then be transferred to the `datasync` service.&#x20;
4. `Datasync`will then send a withdraw info[ \<txinfo>](#user-content-fn-1)[^1] to the App backend



[^1]: 
