# Bitcoin IBC protocol

## Deposit

Before you send Bitcoin to our multi-sig wallet, you have to do mapping your BTC address and Orbit address to the Orbit network

For mapping your address, you have to send mapping transaction to BtcPeggingContract

```javascript
function setDepositDestinations(bytes32[] memory btcPubKeyX, bytes32[] memory btcPubKeyY, address[] memory toAddrs, address[] memory extraToAddrs, bytes32[] memory nonces, uint8[] memory v, bytes32[] memory r, bytes32[] memory s) public
```

If mapping succeed,

```javascript
event DepositDestinationsMapping(bytes32 btcPubKeyX, bytes32 btcPubKeyY, address toAddr, address extraToAddr);
```

DepositDestinationsMapping event occur in BtcPeggingContract

After deposit destination is mapped, you can send Bitcoin to our multi-sig wallet

{% hint style="info" %}
You have to use p2sh wallet for sending bitcoin to our multi-sig wallet.

V\[in] UTXO in your transaction have to solve by public key
{% endhint %}

After your transaction is 1 confirmed, Orbit btc operator, validator will begin to proceed your deposit

```javascript
//BtcPeggingContract
event DepositValidated(bytes32 txid, uint vout, uint amount, bytes scriptPubKey, address toAddr, address extraToAddr, bytes32 depositPubKeyX, bytes32 depositPubKeyY)
//BalanceContract
event BalanceChange(address indexed user, bytes32 indexed tokenId, uint balance);
```

## Withdrawal

Send a withdrawal transaction to Orbit Balancecontract

```javascript
function withdrawBySignature(bytes32[] memory bytes32s, uint[] memory uints, address fromAddr, bytes memory destination, bytes memory comment, uint8 v) public
function withdraw(bytes32 tokenId, bytes memory destination, uint amount, bytes memory comment) public
```

Then, Bitcoin IBC operator and Validator begin to proceed this withdrawal
