1

So I understand that exchanges don't have to perform updates on the blockchain. However I'm not sure how they figure out the following solution without having to pay blockchain fees? I guess they do

i.e.

  1. An exchange gives 3 users, Bill, Jane & Sally a BTC address.
  2. Bill & Jane both send in 0.001 BTC to that address from a different exchange/wallet.
  3. Now Bill & Jane both send 0.0005 BTC to Sally on the same exchange. Same exchange so this doesn't have to be on the chain.
  4. So now Bill & Jane both have 0.0005 BTC and Sally has 0.001 BTC according to the exchange. However both Bill & Jane's actual wallet address still has 0.001.
  5. Sally now withdraws her 0.001 BTC

The exchange now needs to perform two blockchain updates to fulfill this withdraw which means two transaction fees on the blockchain for the exchange.

Does anybody know how exchanges do this?

3

Users don't have addresses at exchanges. When you deposit to the exchange you're depositing to the exchanges wallet, with a unique address just enabling them to account for who to credit the internal balance to. Withdraws only require one on chain transaction, just debiting the amount from the database and then sending that value to the address requested.

5
  • How can exchanges generate an address that sending exchanges know is a wallet but at the same time be unique to the receiving exchanges entire database? – Trevor Wood Feb 16 at 4:52
  • i.e. One wallet can have multiple (millions) of different possible addresses? – Trevor Wood Feb 16 at 4:53
  • There’s no limit to the number of addresses in a wallet. – Anonymous Feb 16 at 6:06
  • Whattttttttttt. mindblown. okay I need to read up more on bitcoin then. thanks for the info! – Trevor Wood Feb 16 at 6:14
  • 1
    You may find bitcoin.stackexchange.com/q/8804/5406 interesting. – Murch Feb 17 at 0:38
1

This is how it generally works.

  1. When a user clicks "deposit" button first time, The exchange calls the BTC node with getnewaddress command to generate the address, and displays it to user.
  2. User makes the deposit to that address.
  3. Bitcoin has walletNotify feature, so when the deposit hits the exchange node, it will notify the exchange API with transactionHash.
  4. Taking that txHash, exchange will call getTransaction API of bitcoin node and get all details of the transaction, including deposit wallet address.

Now coming back to your question.

Once the exchange has met the confirmation requirement, it will simply update their local Database (Mongo/MySQL or any other) with relevant deposit details. Now when user 1 sends BTC to user 2 on same exchange, there is no onchain transaction.

Exchange just deducts the withdrawal amount from user 1 database, and credits the same to user 2 database.

But when the user inputs a withdrawal address outside of exchange, that is when actual blockchain transaction takes place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.