Author

Topic: How is exchange's wallet structure? (Read 239 times)

jr. member
Activity: 413
Merit: 5
April 27, 2018, 03:36:18 AM
#14
A wallet, in its simplest form, is a collection of private keys. Depending on the wallet software those may be stored in a wallet file or generated on the fly (ie. only the wallet seed is stored and private keys / addresses are derived as requested). Assuming a full node, this wallet software also checks for incoming and outgoing transactions.
The Bitcoin daemon is a headless wallet, that is: Instead of a GUI for users to click on, it provides an interface for other software to talk with.
Thanks for reply.
So how to consist exchange's wallet then?
Running a full node(really need to run as full node? how to know it is now full node?) of newest bitcoin node (0.16 version) support HD wallet, make bunch of addresses before, and when user join, assign one address to each user and store its info (what address belong to what user ID) to own DB?

Then this one exchange wallet (bitcoin daemon running on exchange's one physical server) has all the access to each user's addresses and its balance and can send to another address?

legendary
Activity: 3122
Merit: 2178
Playgram - The Telegram Casino
April 20, 2018, 04:37:31 AM
#13

The exchange will control the private key to all of the coins (be it bitcoin, or some other altcoin) on deposit at the exchange along with having ownership of fiat on deposit and they will make an entry in their database once a trade takes place.

Exchanges will generate deposit addresses for each customer for each coin.
Thx for reply.

So I heard that exchange give specific coin's (Lets say, just Bitcoin) addresses to users. And one private key control them all.

Not quite.

Each address has its own private key. There's also cases where different addresses can be accessed by the same private key (ie. you can derive a P2SH SegWit address and a legacy address from the same private key) but that's a different matter.

I think the "one private key" you heard about refers to the wallet seed. That is, when using a deterministic wallet or address generation algorithm, you can deterministically -- as opposed to randomly -- derive multiple private keys and their respective addresses from a single private key or passphrase (ie. the wallet seed). If you ever used Electrum, Mycelium, Trezor or any of those wallets -- that's the seed words you get for backing up when setting up a new wallet. Non-deterministic wallets -- such as Bitcoin Core, for the longest time -- generate their private keys / addresses at random, making it necessary to back up to the collection of private keys instead of just a single wallet seed / master key.

Some general info on deterministic wallets:
https://en.bitcoin.it/wiki/Deterministic_wallet

BIP-0044: Multi-Account Hierarchy for Deterministic Wallets:
https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

BIP-0039: Mnemonic code for generating deterministic keys:
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Most wallets nowadays are hierarchical deterministic wallets (HD wallets); that is: Using a single wallet seed you can not only derive a list of addresses, but a whole tree of addresses. This is usually reflected in the form of accounts, effectively sub-wallets. It would make sense for an exchange to provide each user with an address branch of their own, I'm not sure if that's really the case in practice though.


But when I just test with -qt wallet program, after I click [Request payment], it generates new address, 3 times, made 3 addresses,

then I typed [dumpprivkey
] at console for each addresses above, it shows different private key per each address.

Why?

See above.


So then this means, wallet program is bunch of private keys gatherings, exchange run its bitcoin daemon, then this daemon has all the access the generated addresses given to users? Confused.

A wallet, in its simplest form, is a collection of private keys. Depending on the wallet software those may be stored in a wallet file or generated on the fly (ie. only the wallet seed is stored and private keys / addresses are derived as requested). Assuming a full node, this wallet software also checks for incoming and outgoing transactions.

The Bitcoin daemon is a headless wallet, that is: Instead of a GUI for users to click on, it provides an interface for other software to talk with.

Note that running the Bitcoin daemon on the same machine that hosts your web server is both the simplest and most insecure way to set up your infrastructure. At least assuming you use the Bitcoin daemon for generating addresses as well and not just watching the network.
jr. member
Activity: 413
Merit: 5
April 19, 2018, 07:38:30 PM
#12

The exchange will control the private key to all of the coins (be it bitcoin, or some other altcoin) on deposit at the exchange along with having ownership of fiat on deposit and they will make an entry in their database once a trade takes place.

Exchanges will generate deposit addresses for each customer for each coin.
Thx for reply.

So I heard that exchange give specific coin's (Lets say, just Bitcoin) addresses to users. And one private key control them all.

But when I just test with -qt wallet program, after I click [Request payment], it generates new address, 3 times, made 3 addresses,

then I typed [dumpprivkey
] at console for each addresses above, it shows different private key per each address.

Why?

So then this means, wallet program is bunch of private keys gatherings, exchange run its bitcoin daemon, then this daemon has all the access the generated addresses given to users? Confused.
newbie
Activity: 5
Merit: 0
April 16, 2018, 09:54:38 PM
#11
Specific coin's wallet is one and its private key is owned by exchange, and then for user, just give address. Isn't it? So private key for each user will not be given?

And what is good way between full node or API? And is this server should be ubuntu?

And API means this? https://blockchain.info/api/blockchain_wallet_api

You do know want to give away the exchange's user account's private key. Because if you do that the user could potentially squander you out of some bitcoins (e.g. setup an open order and then transfering away all bitcoin before order is completed)

Full node is when you know your data is correct. An API is good if you're providing that API otherwise you're relying on a 3rd party to provide you correct information (which is something we don't want in a trustless world).

The server can be anything, doesn't need to be ubuntu.

Yes that is an API, but a more common use for an exchange API would be to retrieve funds of specific accounts (to see if a user deposited money into it or not).

E.g. to get the data of address `1M2n7X42iGAheNSNCNq5nfGq5Z3JeRBw8H` we could just go to this link: https://insight.bitpay.com/api/addr/1M2n7X42iGAheNSNCNq5nfGq5Z3JeRBw8H
jr. member
Activity: 413
Merit: 5
April 16, 2018, 09:44:24 PM
#10
You'll need a standard database to get started with (e.g. PostgresSQL/MySQL).

This is needed to track open/close orders as well as the private keys associated with each user account (private keys are randomly generated).

Then to verify the balance of those user accounts, you can either use a full node or communicate with an API (e.g. blockchain.info)
Specific coin's wallet is one and its private key is owned by exchange, and then for user, just give address. Isn't it? So private key for each user will not be given?

And what is good way between full node or API? And is this server should be ubuntu?

And API means this? https://blockchain.info/api/blockchain_wallet_api
newbie
Activity: 5
Merit: 0
April 16, 2018, 09:40:45 PM
#9
You'll need a standard database to get started with (e.g. PostgresSQL/MySQL).

This is needed to track open/close orders as well as the private keys associated with each user account (private keys are randomly generated).

Then to verify the balance of those user accounts, you can either use a full node or communicate with an API (e.g. blockchain.info)
jr. member
Activity: 413
Merit: 5
April 16, 2018, 09:36:02 PM
#8
Thx for replies.

So how to actually implement exchange wallet?

For example first things first, Bitcoin,

Download bitcoin node and full blockchain datas?

And then locate and run it as daemon with same server of exchange's web server?
For communicate realtime with server and when exchange's user sign up and first logged in, exchange should give deposit address of all crypto coins.

Or?
hero member
Activity: 1834
Merit: 759
March 31, 2018, 10:11:49 PM
#7
The simplest way I can explain this is that in most exchanges, you don't actually own the addresses assigned to you. Your account balance is independent from your address balance. If you deposited Bitcoins to your receiving address, it just tells the exchange to credit that many Bitcoins to your account; this is obviously done off-chain, and the Bitcoins in that address don't belong to you. Trading internally only affects the balance credited to your account, while the coins traded stay where they're stored. Coins only move when you take them out of the exchange.

Think of it like banks. If you deposit money in a certain branch, that doesn't necessarily mean it's going to stay there. They are absorbed by the bank system, and they simply credit your account. If, say, you decide to transfer money to a certain person who has the same bank but is based on a different branch, they don't actually physically transfer money; this is done internally by deducting that amount from your account and crediting it to the other person's account. Money only really moves when you take it out.

I hope that was a clear explanation.
full member
Activity: 541
Merit: 137
March 31, 2018, 03:30:16 AM
#6
1. How exchange provide each coin's address to each users?


2. At exchanges, buy/sell occurs at real time.
Then it is not actual send/receive bitcoin between buyer/seller's real bitcoin address. Because it took so much time.


Then how exchange implement these part?


if you want actual send/receive at real time transactions then you should try DEX (Decentralized Exchange)
here's for reference https://coinsutra.com/best-decentralized-exchanges-dex/
sr. member
Activity: 952
Merit: 339
invest trade and gamble wisely
March 31, 2018, 02:41:49 AM
#5
The exchange will control the private key to all of the coins (be it bitcoin, or some other altcoin) on deposit at the exchange along with having ownership of fiat on deposit and they will make an entry in their database once a trade takes place.

Exchanges will generate deposit addresses for each customer for each coin.
How to do that?

And how about deals occured in exchange?

What's your point?
Trading on exchanges is actualy off-chain (there is no real transaction between seller and buyer)

It's more like: You open an account, make deposit and this deposit is turned into some sort of "credit".  Traders are exchanging these credits.
Once you want to withdraw, this amount is deducted from your credit and via blockchain transfered to your address.

legendary
Activity: 3122
Merit: 2178
Playgram - The Telegram Casino
March 31, 2018, 02:36:12 AM
#4
The exchange will control the private key to all of the coins (be it bitcoin, or some other altcoin) on deposit at the exchange along with having ownership of fiat on deposit and they will make an entry in their database once a trade takes place.

Exchanges will generate deposit addresses for each customer for each coin.
How to do that?

Most likely by running the wallet software (or some derivation of it) of each respective cryptocurrency. Then you either use an existing library or write a wrapper yourself to use said wallet software for generating addresses and watching them. In the case of Bitcoin you'd likely have the wrapper access your wallet via its JSON-RPC interface. In the case of alts it would probably look similar.


And how about deals occured in exchange?

Like Quickseller already said: Trades are just entries in a database.

In other words:

1) Your balances are stored in a database on the exchange's servers.
2) Whenever you place an order, this order will also be stored on a database somewhere.
3) The trading engine will do its magic and match buy and asks. If it finds a proper match it executes the order.
4) The state of your order is updated in the database. The state of your balances is updated in the database.

In the case of centralized exchanges, none of the above ever hits a blockchain. Only once you withdraw some of the balances of yours, an on-chain transaction will take place.
jr. member
Activity: 413
Merit: 5
March 31, 2018, 12:28:13 AM
#3
The exchange will control the private key to all of the coins (be it bitcoin, or some other altcoin) on deposit at the exchange along with having ownership of fiat on deposit and they will make an entry in their database once a trade takes place.

Exchanges will generate deposit addresses for each customer for each coin.
How to do that?

And how about deals occured in exchange?
copper member
Activity: 2996
Merit: 2374
March 30, 2018, 10:30:01 PM
#2
The exchange will control the private key to all of the coins (be it bitcoin, or some other altcoin) on deposit at the exchange along with having ownership of fiat on deposit and they will make an entry in their database once a trade takes place.

Exchanges will generate deposit addresses for each customer for each coin.
jr. member
Activity: 413
Merit: 5
March 30, 2018, 10:11:32 PM
#1
1. How exchange provide each coin's address to each users?


2. At exchanges, buy/sell occurs at real time.
Then it is not actual send/receive bitcoin between buyer/seller's real bitcoin address. Because it took so much time.


Then how exchange implement these part?
Jump to: