Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: wsxdrfv on March 26, 2018, 06:59:48 AM



Title: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 06:59:48 AM
So at exchanges, so many coins. For each of them, they provide deposit addresses.

If you are engineer, need to implement that, how to do?

Maybe using that coin's daemon?

How is specific procedure of it?

Thanks.


Title: Re: How exchanges make wallet adresses?
Post by: DerekVazz on March 26, 2018, 07:12:23 AM
So at exchanges, so many coins. For each of them, they provide deposit addresses.

If you are engineer, need to implement that, how to do?

Maybe using that coin's daemon?

How is specific procedure of it?

Thanks.

I believe most of the coins use bitcoins method of creating addresses. You can use any programming language for that.
First you generate a random 32-byte private key.
Then create a public key out of it using elliptical curve digital signature algorithm.
Out of public key you can create an address. It works as described in this image:

https://en.bitcoin.it/w/images/en/9/9b/PubKeyToAddr.png


Title: Re: How exchanges make wallet adresses?
Post by: starmyc on March 26, 2018, 07:59:14 AM
So at exchanges, so many coins. For each of them, they provide deposit addresses.

If you are engineer, need to implement that, how to do?

Maybe using that coin's daemon?

How is specific procedure of it?

To be able to generate a wallet address, you need to understand how it works and its format.

As it was said, Bitcoin addresses are a specific format of an edcsa (using secp256k1 parameters) public key, formatted a certain way, as described on this page: Technical background of version 1 bitcoin addresses (https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses). You must also take a look at the wallet import format (https://en.bitcoin.it/wiki/Wallet_import_format) which will help you to import private keys in Bitcoin Core and other wallets. Note that more recent addresses - p2sh & bech32 - are a little different and you will need to do more research about it.

You can either have one daemon to generate/handle those keys, or just a simple script that'll do it on demand, as this is a very simple task to do which doesn't use much cpu. The main problem in the process is to correctly protect the private keys.


Title: Re: How exchanges make wallet adresses?
Post by: AdSkull89 on March 26, 2018, 08:13:10 AM
So at exchanges, so many coins. For each of them, they provide deposit addresses.

If you are engineer, need to implement that, how to do?

Maybe using that coin's daemon?

How is specific procedure of it?

Thanks.

All you need is to generate many adresses from a single seed. Store those addresses in some data structure or csv file.

Then each time user requests deposit address - pick one of the pregenerated addresses from stored pool and assign it to respectable user (i.e. remove it from the address pool and add some field in your users database,  put address there).

That's all.


Don't generate address every time user needs a new one. It will be unsafe since to actually generate address you need access to your private key. It is much more safe to do it just once and then use your addresses as a text file. There is no limit on how much addresses you can generate so you can pregenerate as much as you want for all your existing or new users. Once it is done - you can handle deposits/withdrawals separately.


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on March 26, 2018, 09:11:58 AM
There are more than one approach to this possible.

The two most common would be:

1) Generate an address 'on demand'.
This requires your online service to have a connection to your daemon. This might (in some circumstances) be a possible attack vector.

2) Generate bulk addresses in advance (in an offline environment)
Then, each time someone wants to deposit, you can easily assign one of these addresses to your customer in your database.
This is considered the 'safer' option, since your private keys don't touch your online system at any time.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 09:16:11 AM
There are more than one approach to this possible.

The two most common would be:

1) Generate an address 'on demand'.
This requires your online service to have a connection to your daemon. This might (in some circumstances) be a possible attack vector.

2) Generate bulk addresses in advance (in an offline environment)
Then, each time someone wants to deposit, you can easily assign one of these addresses to your customer in your database.
This is considered the 'safer' option, since your private keys don't touch your online system at any time.

So then, how to pregenerate addresses like 100,000 numbers at once without click [Request payment] button in wallet program 100,000 times?


Title: Re: How exchanges make wallet adresses?
Post by: starmyc on March 26, 2018, 09:29:48 AM
So then, how to pregenerate addresses like 100,000 numbers at once without click [Request payment] button in wallet program 100,000 times?

You can generate a lot of addresses using Vanitygen:

Code:
$ ./vanitygen -k 1|awk '/Address|Privkey/{if($1 == "Address:") {pub = $2} else {if($1 == "Privkey:") {print pub ":" $2}}}'
Difficulty: 1
16ZCL3fKK7hQuRsGK48CGWmqx5rDyv83bm:5J3HRp9RNztekPfKYFjzvzLSSnBN3iy4kPP4sbogWYzctnMdXqi
176zZHK28BgvFZw2Dmv3P7Xy3Vh9CbYnef:5HqDqkxiBKxXvCJnc6Bv9LcveKX9rnZjRfrsyj86jNFtQZ6MxSH
17fZ41JSmTZt9WHAtoAG9PwZVEqrwPmhQa:5K3hma9ePqxdgpVgQc8Nu7m46WLSKsvc1YcEWV1zyGmmYHz1bs2
1AEgJx5F9Y9eBbnmQQeBREbT5zcyvuNz3e:5JGfQHWvLZQCx1UKV8NY6U1K54JYPKVHpTJYUjWBLENgM4hDrEM
...


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 10:06:18 AM
So then, how to pregenerate addresses like 100,000 numbers at once without click [Request payment] button in wallet program 100,000 times?

You can generate a lot of addresses using Vanitygen:

Code:
$ ./vanitygen -k 1|awk '/Address|Privkey/{if($1 == "Address:") {pub = $2} else {if($1 == "Privkey:") {print pub ":" $2}}}'
Difficulty: 1
16ZCL3fKK7hQuRsGK48CGWmqx5rDyv83bm:5J3HRp9RNztekPfKYFjzvzLSSnBN3iy4kPP4sbogWYzctnMdXqi
176zZHK28BgvFZw2Dmv3P7Xy3Vh9CbYnef:5HqDqkxiBKxXvCJnc6Bv9LcveKX9rnZjRfrsyj86jNFtQZ6MxSH
17fZ41JSmTZt9WHAtoAG9PwZVEqrwPmhQa:5K3hma9ePqxdgpVgQc8Nu7m46WLSKsvc1YcEWV1zyGmmYHz1bs2
1AEgJx5F9Y9eBbnmQQeBREbT5zcyvuNz3e:5JGfQHWvLZQCx1UKV8NY6U1K54JYPKVHpTJYUjWBLENgM4hDrEM
...

Thanks. So that "vanitygen" file generate after compile at ubuntu? I can't find vanitygen file in source at bitcoin github.


Title: Re: How exchanges make wallet adresses?
Post by: starmyc on March 26, 2018, 10:08:31 AM
Thanks. So that "vanitygen" file generate after compile at ubuntu? I can't find vanitygen file in source at bitcoin github.

You should try google: https://en.bitcoin.it/wiki/Vanitygen (https://en.bitcoin.it/wiki/Vanitygen) and on github (https://github.com/samr7/vanitygen)


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 10:25:09 AM
Thanks. So that "vanitygen" file generate after compile at ubuntu? I can't find vanitygen file in source at bitcoin github.

You should try google: https://en.bitcoin.it/wiki/Vanitygen (https://en.bitcoin.it/wiki/Vanitygen) and on github (https://github.com/samr7/vanitygen)
How to apply this to alt-coin?


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 10:28:41 AM
There are more than one approach to this possible.

The two most common would be:

1) Generate an address 'on demand'.
This requires your online service to have a connection to your daemon. This might (in some circumstances) be a possible attack vector.

2) Generate bulk addresses in advance (in an offline environment)
Then, each time someone wants to deposit, you can easily assign one of these addresses to your customer in your database.
This is considered the 'safer' option, since your private keys don't touch your online system at any time.
And so this means, exchange generate whole address for users with exchange his own private key, exchange can access whole user's addresses?


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on March 26, 2018, 11:30:28 AM
So then, how to pregenerate addresses like 100,000 numbers at once without click [Request payment] button in wallet program 100,000 times?

The easiest probably would be to use a small script to generate private-/public- keypairs.
It is important to pick a script (or better: write one yourself) with good entropy. Any bug/vulnerability/mistake in implementation could make your private keys 'guessable' and therefore unsafe.



And so this means, exchange generate whole address for users with exchange his own private key, exchange can access whole user's addresses?

Of course.

An (deposit-)address from an exchange is always in full control of the exchange itself.
You (as a customer) are depositing to the exchange. From this moment on the exchange is in control of your funds.
In return they give you 'credits' which match your deposited amount/crypto. Those are just assigned numbers in their database.

Only after withdrawing (after transaction got confirmed) you are in control of your cryptos again.


Title: Re: How exchanges make wallet adresses?
Post by: starmyc on March 26, 2018, 12:05:04 PM
How to apply this to alt-coin?

Depends of your altcoin (especially the address prefix, which is 0x00 for bitcoin). Change prefix, recompile, should work.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 12:58:58 PM
How to apply this to alt-coin?

Depends of your altcoin (especially the address prefix, which is 0x00 for bitcoin). Change prefix, recompile, should work.
Thanks!


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 26, 2018, 01:02:58 PM
The easiest probably would be to use a small script to generate private-/public- keypairs.
It is important to pick a script (or better: write one yourself) with good entropy. Any bug/vulnerability/mistake in implementation could make your private keys 'guessable' and therefore unsafe.
Thanks.
Can you show some example of that small script? Is it just like below?

for(x=0; x<100,000;x++){
   GetAddressFromDaemonOfSomeAltcoin();
}



Title: Re: How exchanges make wallet adresses?
Post by: burakkeceli on March 27, 2018, 12:14:07 AM
You should take a look this video: https://youtu.be/pLJQy0B5OKo
Bitcoin address prefix: 0x00
Litecoin address prefix: 0x30
Dash address prefix: 0x4c
Doge address prefix: 0x1E


Title: Re: How exchanges make wallet adresses?
Post by: robortscatherine on March 27, 2018, 07:44:29 AM
In the top right corner there is a button that says "Create Wallet" and "Import or restore wallet". Click "create Wallet". Enter a wallet name and a description. You can then enter a passphrase for the wallet. You should right this down too in a safe spot. To view your bitcoin address open up "Receive Bitcoins" or "Send Bitcoins".


Title: Re: How exchanges make wallet adresses?
Post by: onurgozupek on March 27, 2018, 09:57:50 AM
They are running full nodes of the cryptocurrencies and generating addresses on their online wallet. But a background process checks online wallets in each period and transfers the amount to offline wallet. So your funds are safe...


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on March 27, 2018, 10:11:16 AM
Can you show some example of that small script? Is it just like below?

for(x=0; x<100,000;x++){
   GetAddressFromDaemonOfSomeAltcoin();
}

Something like this would be an option.
But you don't have to connect to a daemon.

You can create private-/public- keys yourself.
You need to know how to mathematically create private and public keys.
This can be read in any documentation regarding your coin.



Title: Re: How exchanges make wallet adresses?
Post by: DannyHamilton on March 27, 2018, 02:41:03 PM
Can you show some example of that small script? Is it just like below?

for(x=0; x<100,000;x++){
   GetAddressFromDaemonOfSomeAltcoin();
}

Pseudocode?  Sure...

It may be slightly different for each altcoin, since some of them have implemented their own algorithms (and there will be some variations for different address versions) , but if you want to compute a version 1 address for anything that works like Bitcoin does...

Code:
constant ECDSA_BASE_POINT =0x0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798   // See parameters of secp256k1 ECDSA curve.

for(x=0; x<100,000;x++){
    privateKey[x] = generateCrypographicallySecureRandomNumber()                // Range of values is governed by the secp256k1 ECDSA standard.
    publicKey[x] = ellipticCurvePointMultiply(ECDSA_BASE_POINT, privateKey[x])  // Use ECDSA point multiplication to multiply the base point by the private key.
    bitcoinAddress[x] = computeAddressFromPubKey(publicKey[x])                  //
}

You'll probably need some sort of "big number" library for working with 256 bit integers.  You'll also probably want to find an ECDSA library to handle the point multiplication (unless you really want to try to write that yourself).  It would be smart NOT to write your own random number generator, but to make sure that the random number generator that you do use is well accepted as being "cryptographically secure".

See the following link to learn how to compute an address from a public key:
https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on March 28, 2018, 02:05:43 PM
See the following link to learn how to compute an address from a public key:
https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
Thanks much!
So, ./bitcoind (now ./bitcoin-cli ?)  does not provide simple one function to make Address?



Title: Re: How exchanges make wallet adresses?
Post by: ranochigo on March 28, 2018, 02:16:34 PM
Thanks much!
So, ./bitcoind (now ./bitcoin-cli ?)  does not provide simple one function to make Address?
It does. The command is getnewaddress.



Title: Re: How exchanges make wallet adresses?
Post by: DannyHamilton on March 28, 2018, 03:11:38 PM
See the following link to learn how to compute an address from a public key:
https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
Thanks much!
So, ./bitcoind (now ./bitcoin-cli ?)  does not provide simple one function to make Address?

As ranchigo explained, you can just make a request to the client if you prefer, but it is not necessary to install and run a full client just to create addresses if you don't want to.

Some people use the client.  Some people prefer to write their own software that is faster and less complicated.


Title: Re: How exchanges make wallet adresses?
Post by: Kakmakr on March 29, 2018, 06:55:11 AM
Where are these private keys kept? If they are created on the fly, it must be generated online and the keys stored online? This in my opinion is very risky.

The other alternative of generating it offline and storing only the public address in a online database, makes more sense. I know my local exchange does not allow for the signing of any address, so they are maintaining a high level of security with these private keys. < I still prefer to manage my own private keys, but if you have to use exchanges, you then have no choice>

It must be a massive and risky endeavour to extract all the forked coins from these millions of private keys for the bigger exchanges?


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 06, 2018, 10:50:16 PM
See the following link to learn how to compute an address from a public key:
https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
Thanks much!
So, ./bitcoind (now ./bitcoin-cli ?)  does not provide simple one function to make Address?

As ranchigo explained, you can just make a request to the client if you prefer, but it is not necessary to install and run a full client just to create addresses if you don't want to.

Some people use the client.  Some people prefer to write their own software that is faster and less complicated.
How to write own software? So just use same algo that some coin uses, and just make address from that algo? Are there any example code?


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 06, 2018, 10:51:44 PM
Where are these private keys kept? If they are created on the fly, it must be generated online and the keys stored online? This in my opinion is very risky.
Why this is risky?

So if daemon is running on exchange's server, then it means that daemon's private key is also exist in daemon? So you means it is risky?

If hacker come in server, then he can know that daemon's private key?


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 19, 2018, 04:53:49 AM
Why this is risky? (bump)

So user can try http injection attack to know wallet's secret key?
When user click that [generate address] button?


Title: Re: How exchanges make wallet adresses?
Post by: hushan on April 19, 2018, 11:58:31 PM
For online bitcoin wallets, most exchanges will use HD(BIP32) wallets, it will generic the extended key offline, store the correspondent public key on the server, and it only needs to allocate an index number to each user, then new addresses can be generated on the fly whenever user requested a new address.
By using HD wallets, it is much easier to manager, because there is only one private key. Also it is much simple to operate, because each user can have as many new addresses as they want, technically 232-1 addresses, and no private key is needed to generate new addresses.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 20, 2018, 12:16:22 AM
For online bitcoin wallets, most exchanges will use HD(BIP32) wallets, it will generic the extended key offline, store the correspondent public key on the server, and it only needs to allocate an index number to each user, then new addresses can be generated on the fly whenever user requested a new address.
By using HD wallets, it is much easier to manager, because there is only one private key. Also it is much simple to operate, because each user can have as many new addresses as they want, technically 232-1 addresses, and no private key is needed to generate new addresses.
Then what if the alt-coins that does not have HD wallet features?

And most exchange just give 1 address for each coin per 1 user. And user also does not need more than 1 address. And it(multiple addresses per coin per user) only confuses and make it complicated to manage from point of view of exchange.

Are there any actual reason for give more than 1 address?

So point is, you saying about make bunch of addresses before (like 1 million addresses) and store them in DB?


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 20, 2018, 06:43:59 AM
And how to make like 1 million bitcoin addresses? I am running bitcoind at my server.

so there I can use [ bitcoin-cli getnewaddress ]

then how to do it?


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on April 20, 2018, 11:03:08 AM
Why this is risky? (bump)

So user can try http injection attack to know wallet's secret key?
When user click that [generate address] button?


You don't have to store the private keys / seed on your online server just to create new addresses.
You could simply use the Master public key. Public keys (and therefore addresses) can be dervied from this key, without the risk of private keys getting exposed/compromised.




So point is, you saying about make bunch of addresses before (like 1 million addresses) and store them in DB?

This can definetely be done. It does not expose any private keys to theft.


Title: Re: How exchanges make wallet adresses?
Post by: hushan on April 20, 2018, 03:06:23 PM
For online bitcoin wallets, most exchanges will use HD(BIP32) wallets, it will generic the extended key offline, store the correspondent public key on the server, and it only needs to allocate an index number to each user, then new addresses can be generated on the fly whenever user requested a new address.
By using HD wallets, it is much easier to manager, because there is only one private key. Also it is much simple to operate, because each user can have as many new addresses as they want, technically 232-1 addresses, and no private key is needed to generate new addresses.
Then what if the alt-coins that does not have HD wallet features?

And most exchange just give 1 address for each coin per 1 user. And user also does not need more than 1 address. And it(multiple addresses per coin per user) only confuses and make it complicated to manage from point of view of exchange.

Are there any actual reason for give more than 1 address?

So point is, you saying about make bunch of addresses before (like 1 million addresses) and store them in DB?


If a coin does not have HD feature, then you will have to go to the old way, i.e. pre generate lots of keys and addresses, and assign them to customers.

Actually, uses DOES need multiple addresses, most exchanges let the use generate new addresses as they want.

The point of HD is, you don't make bunch of address beforehand, you can generate new addresses on demand, but you neither store multiple private keys(only one master key), nor do you need to store keys in db, you just need to store the hd key path. When transactions are needed, you can always generate keys from the key path.


Title: Re: How exchanges make wallet adresses?
Post by: DannyHamilton on April 21, 2018, 01:47:43 AM
And how to make like 1 million bitcoin addresses? I am running bitcoind at my server.

Are you creating an exchange?

???

Please let us know what the name of your exchange will be.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 21, 2018, 04:24:08 AM
And how to make like 1 million bitcoin addresses? I am running bitcoind at my server.

Are you creating an exchange?

???

Please let us know what the name of your exchange will be.
Yes not myself alone, but making exchange is true.
Why?


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 21, 2018, 04:40:59 AM
If a coin does not have HD feature, then you will have to go to the old way, i.e. pre generate lots of keys and addresses, and assign them to customers.

Actually, uses DOES need multiple addresses, most exchanges let the use generate new addresses as they want.

The point of HD is, you don't make bunch of address beforehand, you can generate new addresses on demand, but you neither store multiple private keys(only one master key), nor do you need to store keys in db, you just need to store the hd key path. When transactions are needed, you can always generate keys from the key path.
Thanks.
So what is HD key path?
and are there any  bad things to use old wallet? There are coins not having HD wallet listed on some exchange right?

And how about none-HD coin and just realtime generate when user request with coin daemon on server? Why this is dangerous?



Title: Re: How exchanges make wallet adresses?
Post by: hieu81 on April 21, 2018, 05:43:42 AM
So at exchanges, so many coins. For each of them, they provide deposit addresses.

If you are engineer, need to implement that, how to do?

Maybe using that coin's daemon?

How is specific procedure of it?

Thanks.
Depending on the specific currency, they will use different wallet and management methods. For example, with XMR coin, they use a Payment ID, with Bitcoin or other coin using the same algorithm they will use for Public key!


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 21, 2018, 06:33:41 AM
How do you think this article? This says HD wallet's flaw?

https://bitcoinmagazine.com/articles/deterministic-wallets-advantages-flaw-1385450276/


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on April 21, 2018, 09:09:08 AM
Are you creating an exchange?

???

Please let us know what the name of your exchange will be.
Yes not myself alone, but making exchange is true.
Why?

Probably because he wants to make sure to never use your exchange.
Without offending you, but if you have to ask such basic questions i highly suspect your 'exchange' will be vulnerable to any kind of attacks.

DannyHamilton is one of the nice guys who ask you this question to never use your exchange.
But there are also another kind of people.. those who will definetely make use of your weak exchange to get a quick buck.

If you really want to open an exchange, i'd suggest you hire a professional team.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 21, 2018, 09:23:11 AM
Are you creating an exchange?

???

Please let us know what the name of your exchange will be.
Yes not myself alone, but making exchange is true.
Why?

Probably because he wants to make sure to never use your exchange.
Without offending you, but if you have to ask such basic questions i highly suspect your 'exchange' will be vulnerable to any kind of attacks.

DannyHamilton is one of the nice guys who ask you this question to never use your exchange.
But there are also another kind of people.. those who will definetely make use of your weak exchange to get a quick buck.

If you really want to open an exchange, i'd suggest you hire a professional team.
Of course I am not in charge about security, professional will involve soon.
This is just curiosity and learn.


Title: Re: How exchanges make wallet adresses?
Post by: The best one on April 27, 2018, 10:55:34 PM
How to apply this to alt-coin?

Depends of your altcoin (especially the address prefix, which is 0x00 for bitcoin). Change prefix, recompile, should work.

As for me how exchange make wallet address  This depends on what you're trying to do.  If you don't mind the multiple receiving addresses holding balances, then use some wallet software which will give you as many addresses as you need, and it will let you select which addresses you want to send from Online wallet: http://www.blockchain.info If you really actually want to sweep coins from the receiving addresses into wallet address (perhaps you keep the private key of the wallet address offline for security), then you will need to build a small bot to periodically check the balances of the receiving addresses, and then make a payment to the wallet address - I don't believe there is a strong wallet service that currently has this functionality at the moment, but I look forward to be corrected thank you.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on April 30, 2018, 02:22:17 PM
  then you will need to build a small bot to periodically check the balances of the receiving addresses, and then make a payment to the wallet address
How to make this automatic monitoring and doing some commands part?
Using linux shell programming and event? Then how to get object of bitcoin daemon?


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on May 02, 2018, 05:44:26 PM
How to make this automatic monitoring and doing some commands part?

You can do this with the language you are most used to.
There are libaries available for the most commonly used languages.
You simply code the logic in your desired language and then use RPC calls via a libary.


Title: Re: How exchanges make wallet adresses?
Post by: network.decentralizer on May 02, 2018, 07:12:56 PM
There are 2 options:
1) RPC call to the daemon to generate new address (the wallet addresses are pre-generated in key pool) and each user_id own some addresses (see open source crypto-trading platforms source code in PHP).
2) (Not recommended) Each user has an unique ID and new addresses are generated via seed, so they are actually pre-generated and easy to recover if you now the seed. Then it goes like that:
[seed]-> [Purpose][Coin][Account][External / Internal][address id]

m/44'/0'/111'/0/1  -> Bitcoin address, user_id 112, second address
m/44'/145'/48271'/0/3  -> Bitcoin Cash address, user_id 48271, fourth address
m/49'/0'/54'/0/0  -> Bitcoin SegWit address, user_id 55, first address


Title: Re: How exchanges make wallet adresses?
Post by: okorocrypto on May 04, 2018, 11:18:44 PM
So then, how to pregenerate addresses like 100,000 numbers at once without click [Request payment] button in wallet program 100,000 times?

The easiest probably would be to use a small script to generate private-/public- keypairs.
It is important to pick a script (or better: write one yourself) with good entropy. Any bug/vulnerability/mistake in implementation could make your private keys 'guessable' and therefore unsafe.



And so this means, exchange generate whole address for users with exchange his own private key, exchange can access whole user's addresses?

Of course.

An (deposit-)address from an exchange is always in full control of the exchange itself.
You (as a customer) are depositing to the exchange. From this moment on the exchange is in control of your funds.
In return they give you 'credits' which match your deposited amount/crypto. Those are just assigned numbers in their database.

Only after withdrawing (after transaction got confirmed) you are in control of your cryptos again.

You are right on this. I made a transaction today to my exchange wallet and I noticed that the TXHash shows my transfer to the exchange wallet but under it I saw that the funds was actually moved from my exchange wallet to another wallet though, the funds actually showed in my wallet as balance. As I saw your post it now became clear to me. Thanks for that clarification.


Title: Re: How exchanges make wallet adresses?
Post by: wsxdrfv on May 09, 2018, 06:29:20 AM
There are 2 options:
2) (Not recommended) Each user has an unique ID and new addresses are generated via seed, so they are actually pre-generated and easy to recover if you now the seed. Then it goes like that:
[seed]-> [Purpose][Coin][Account][External / Internal][address id]

m/44'/0'/111'/0/1  -> Bitcoin address, user_id 112, second address
m/44'/145'/48271'/0/3  -> Bitcoin Cash address, user_id 48271, fourth address
m/49'/0'/54'/0/0  -> Bitcoin SegWit address, user_id 55, first address

What are these seed? m/44'/0'/111'/0/1,  m/44'/145'/48271'/0/3 ,  m/49'/0'/54'/0/0

I just thought made bunch of address from one bitcoin daemon.

Where is seed and how to know what seed used from above?


Title: Re: How exchanges make wallet adresses?
Post by: bob123 on May 09, 2018, 08:45:27 AM
There are 2 options:
2) (Not recommended) Each user has an unique ID and new addresses are generated via seed, so they are actually pre-generated and easy to recover if you now the seed. Then it goes like that:
[seed]-> [Purpose][Coin][Account][External / Internal][address id]

m/44'/0'/111'/0/1  -> Bitcoin address, user_id 112, second address
m/44'/145'/48271'/0/3  -> Bitcoin Cash address, user_id 48271, fourth address
m/49'/0'/54'/0/0  -> Bitcoin SegWit address, user_id 55, first address

What are these seed? m/44'/0'/111'/0/1,  m/44'/145'/48271'/0/3 ,  m/49'/0'/54'/0/0

I just thought made bunch of address from one bitcoin daemon.

Where is seed and how to know what seed used from above?


First: I don't like this approach. It is kinda 'dirty'.

The seed is your mnemonic seed. Your 12/18/24 word seed.
m/0'/0'/0 is a derivation path (specified in BIP 32 (https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)).


https://raw.githubusercontent.com/bitcoin/bips/master/bip-0032/derivation.png


If you want to use a seed you have to actively generate one. Then derive private-/public- keypairs from your seed.


A better approach would be to use the xpub key or to generate a bunch of addresses and store them in your database. Then just link user ID's to the addresses in your database.


Title: Re: How exchanges make wallet adresses?
Post by: etherixdevs on May 09, 2018, 09:28:35 AM
I would suggest you to look at
https://github.com/cryptocoinjs/awesome-cryptocoinjs
to get some more info and the technical details that are most important to your project