<p>If you are looking to accept deposits from your customers then you should create one deterministic wallet using software like electrum and the install the extended public key aka xpub aka master public key (MPK) on the server. Then from that you can generate all the addresses you need. </p>

<p>The above creates a watch-only setup where you can generate addresses to receive bitcoin but not spend. So in case someone compromises your server they learn your entire transaction history but they can't steal from you. In order to spend the money you need to use the seeded wallet on your PC.</p>

<p>In order to associate addresses with users you would make a note of it in your app's database.</p>

<p>If you want to associate addresses with users in some deterministic fashion then you can assign each user an ID number and a counter which will serve as an address index. Then you can devise an appropriate derivation path that incorporates those two things. So for example Alice could be user ID 5430. Alice's deposit addresses are m/5430/i where i is the counter in the database. First Alice address would be m/5430/0, second would be m/5430/1 and so on. The user ID would not change once a user registers so even with slightly older backups as long as you have the user ID you can increment the counter until you get to the correct one.</p>

CC BY-SA 3.0
2018-02-16T15:39:48.683Z
2018-02-16T15:39:48.683Z
Abdussamad
<p>The best thing to do is make sure that each customer has their own wallet, with a recoverable phrase.</p>

<p>You mentioned you are using a server, which is unwise as hackers will be looking at that as a big bull's eye.</p>

<p>It sounds like you are making an exchange.</p>

<p>So what they do, is they have receive addresses which are real and on the blockchain. Each user is assigned an address where they can receieve X amount of BTC.</p>

<p>The send addresses however, are in the database, and the database keeps track of how many BTC you have internally.</p>

<p>When you ask to send BTC to someone, the database checks whether that someone is also in their database based on the toAdress, if so, then just minus amount from you and add amount to other person. This happens off the chain.</p>

<p>If not, then they minus the amount from you and send the BTC from one of their own addresses.</p>

<p>You should get someone to build your system for you, as you are dealing with people's finances, and one wrong move could leave you like Mt. Gox</p>

<p>Good luck!</p>

CC BY-SA 3.0
2018-02-16T15:26:15.203Z
Down voted because a) addresses don't have to be broadcast or "on the blockchain" before you can use them b) you can't limit how much money someone sends to your address c) there are no from addresses in bitcoin
Abdussamad
CC BY-SA 3.0
2018-02-16T15:30:43.707Z
I did not use the proper terminology like UTXo because OP does not sounds like he knows that much about the blockchain. Also the OP sounds like he wants to build an exchange. Exchanges normally work by doing all exchanges that happen inside of the exchange via their own database.

If you can tell me where I went wrong barring the terminology, then I will be happy to change. Blockchain is a difficult concept and I may have mistakenly said something out of place, let me know
Kyle Graham
CC BY-SA 3.0
2018-02-16T15:42:54.547Z
I've explained where you went wrong above.
Abdussamad
CC BY-SA 3.0
2018-01-16T14:43:00.067Z
2018-01-16T14:43:00.067Z
Kyle Graham
<p>So I'm in the process of starting a new service, but want to make sure I build the foundation correctly from the start. When customers deposit to their user account on my service, I need to understand whether I should be using one giant wallet with a new address for every customer and assign that address in the database against their user, or if I should generate a new wallet (with, presumably, new seeds) on signup for every customer, so each customer has their own unique wallet. What is the best course of action here? One thing to be aware of is how the backup process will go, and any potential race conditions (say someone generates themselves an address and sends coins, but the server gets wiped out and the backup doesn't have that last 10 seconds of activity, so the address that was generated can't be tied back to the appropriate user).</p>

CC BY-SA 3.0
2018-02-16T18:11:46.137Z
Do you take custody of the funds when they are deposited or are you trying to resell a wallet product?
Murch
<bitcoind><client>
New wallet per customer, or new address?
b0xxed1n
# New wallet per customer, or new address?

(Asked by: username_0 on 2018-01-03)

So I'm in the process of starting a new service, but want to make sure I build the foundation correctly from the start. When customers deposit to their user account on my service, I need to understand whether I should be using one giant wallet with a new address for every customer and assign that address in the database against their user, or if I should generate a new wallet (with, presumably, new seeds) on signup for every customer, so each customer has their own unique wallet. What is the best course of action here? One thing to be aware of is how the backup process will go, and any potential race conditions (say someone generates themselves an address and sends coins, but the server gets wiped out and the backup doesn't have that last 10 seconds of activity, so the address that was generated can't be tied back to the appropriate user).

**Tags:** bitcoind, client

> **Comments:**
> **username_1**: Do you take custody of the funds when they are deposited or are you trying to resell a wallet product?  

---

## 2 answers

### Answer by username_2 on 2018-02-16. Score: 1

If you are looking to accept deposits from your customers then you should create one deterministic wallet using software like electrum and the install the extended public key aka xpub aka master public key (MPK) on the server. Then from that you can generate all the addresses you need.

The above creates a watch-only setup where you can generate addresses to receive bitcoin but not spend. So in case someone compromises your server they learn your entire transaction history but they can't steal from you. In order to spend the money you need to use the seeded wallet on your PC.

In order to associate addresses with users you would make a note of it in your app's database.

If you want to associate addresses with users in some deterministic fashion then you can assign each user an ID number and a counter which will serve as an address index. Then you can devise an appropriate derivation path that incorporates those two things. So for example Alice could be user ID 5430. Alice's deposit addresses are m/5430/i where i is the counter in the database. First Alice address would be m/5430/0, second would be m/5430/1 and so on. The user ID would not change once a user registers so even with slightly older backups as long as you have the user ID you can increment the counter until you get to the correct one.


---

### Answer by username_3 on 2018-01-16. Score: -1

The best thing to do is make sure that each customer has their own wallet, with a recoverable phrase.

You mentioned you are using a server, which is unwise as hackers will be looking at that as a big bull's eye.

It sounds like you are making an exchange.

So what they do, is they have receive addresses which are real and on the blockchain. Each user is assigned an address where they can receieve X amount of BTC.

The send addresses however, are in the database, and the database keeps track of how many BTC you have internally.

When you ask to send BTC to someone, the database checks whether that someone is also in their database based on the toAdress, if so, then just minus amount from you and add amount to other person. This happens off the chain.

If not, then they minus the amount from you and send the BTC from one of their own addresses.

You should get someone to build your system for you, as you are dealing with people's finances, and one wrong move could leave you like Mt. Gox

Good luck!

> **Comments:**
> **username_2**: Down voted because a) addresses don't have to be broadcast or "on the blockchain" before you can use them b) you can't limit how much money someone sends to your address c) there are no from addresses in bitcoin  
> **username_3**: I did not use the proper terminology like UTXo because OP does not sounds like he knows that much about the blockchain. Also the OP sounds like he wants to build an exchange. Exchanges normally work by doing all exchanges that happen inside of the exchange via their own database.  If you can tell me where I went wrong barring the terminology, then I will be happy to change. Blockchain is a difficult concept and I may have mistakenly said something out of place, let me know  
> **username_2**: I've explained where you went wrong above.  

---

