<p>You might want to checkout BTCPay, which is a self-hosted payment gateway</p>
<ul>
<li><a href="https://alternativeto.net/software/btcpay-server/about/" rel="nofollow noreferrer">https://alternativeto.net/software/btcpay-server/about/</a></li>
</ul>

CC BY-SA 4.0
2021-08-22T09:20:56.863Z
2021-08-22T09:20:56.863Z
Michael Altfield
<p>Storing private keys in an online server is not best practices (even if you quickly transfer to an offline wallet). Generally, you should not store private keys on an online device</p>

<p>Instead, if you use a <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" rel="nofollow noreferrer">BIP32 HD wallet architecture</a>, you can just store an extended public key on your online server. This will allow you to generate receiving addresses on the fly, while generating (and securely storing) the private keys on an offline machine. </p>

CC BY-SA 4.0
2018-09-14T22:47:39.157Z
I do not understand the whole concept of BPIP32, it seems to be quite complex. For example, each request will have a single wallet to receive the funds, using the BIP32 it stores all the private keys of each address in a single parent key and I would just use the parent key to withdraw the coins and send it to an offline wallet? Sorry, it's a little confusing for me yet.
Vinicius Aquino
CC BY-SA 4.0
2018-09-14T23:24:31.153Z
@viniciussvl I don't mean to be rude, but you'll need to take some time to read about BIP32 and its implementation, it isn't really possible to give a full synopsis in a short comment. There is lots of good info on this site alone. Think of it simply as a method of generating keypairs that is much easier to backup, and allows for better opsec. In regards to spending funds at a child key using a parent privkey (not possible), see the third part of this Q: https://bitcoin.stackexchange.com/questions/73376/a-few-questions-about-how-hd-wallet-works/73381?noredirect=1#comment92253_73381
chytrik
CC BY-SA 4.0
2018-09-14T23:27:31.990Z
Okay, I'll give it a look at it because it's too complex to understand. Thank you very much for your patience.
Vinicius Aquino
CC BY-SA 4.0
2018-09-14T23:30:21.873Z
@viniciussvl happy to help :)  Though BIP32 may be a little more complex, it is worth learning if you are trying to build a legitimate system!
chytrik
CC BY-SA 4.0
2018-09-14T23:31:42.107Z
I wanted to develop something similar to Coinpayments, I already used it. Do you think they use the technology of HD wallets?
Vinicius Aquino
CC BY-SA 4.0
2018-09-15T00:14:18.200Z
@viniciussvl I am not familiar with their system, sorry.
chytrik
CC BY-SA 4.0
2018-09-15T01:05:35.493Z
@viniciusscl - Look at https://github.com/libbitcoin/libbitcoin/wiki/Altcoin-Version-Mappings#7-bitcoin-btc-bip-3944-technology-examples and surrounding info.  Much safer to store public extended keys on a server.  Here is how a public key can be synthesized from private BIP 39 words: ```% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-public -d -i 0```
**xpub6DHi64TFkDPx2AH4q2ku3vX9LJYNpTis5tLrET8Sb9irp174eCkgtAnvBpyzQXgrtmF31Lrq4gTMGFUGcjJicMu9LdueVdqt6FZ2Wzcg8F**
skaht
CC BY-SA 4.0
2021-08-06T18:24:18.757Z
I understand how I can store the extended public keys in the online server to generate receiving addresses but what if I want to send money from one of these addresses? how do I go from an online http request to the offline server to sign the transaction and avoid exposing the pvt keys?
Warao
CC BY-SA 4.0
2018-09-14T22:17:01.283Z
2018-09-15T00:15:42.143Z
2018-09-15T00:15:42.143Z
chytrik
<p>I want to receive payments from Bitcoin on my <strong>web app</strong>, but I do not want to use corporate gateways (coinpayments, bitpay, etc), I'm wanting to make my own gateway. I do not know how best to do this but initially thought of generating the bitcoin address and storing the public/<strong>private key in MySQL</strong> after the payment was confirmed the system would use the private key and send the balance to an offline wallet.</p>

<p>How can I securely <strong>store</strong> the <strong>private keys</strong> that are generated for each payment in <strong>MySQL</strong>?</p>

<p>Let's say I do not want to leave the funds in these wallets, once I receive the system already sends the official wallet.</p>

<security><private-key><database><storage>
How to store private key in MySQL database?
Vinicius Aquino
# How to store private key in MySQL database?

(Asked by: username_0 on 2018-09-14)

I want to receive payments from Bitcoin on my **web app**, but I do not want to use corporate gateways (coinpayments, bitpay, etc), I'm wanting to make my own gateway. I do not know how best to do this but initially thought of generating the bitcoin address and storing the public/**private key in MySQL** after the payment was confirmed the system would use the private key and send the balance to an offline wallet.

How can I securely **store** the **private keys** that are generated for each payment in **MySQL**?

Let's say I do not want to leave the funds in these wallets, once I receive the system already sends the official wallet.

**Tags:** security, private-key, database, storage


---

## 2 answers

### Answer by username_2 on 2018-09-14. Score: 4 | Accepted answer

Storing private keys in an online server is not best practices (even if you quickly transfer to an offline wallet). Generally, you should not store private keys on an online device

Instead, if you use a [BIP32 HD wallet architecture](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), you can just store an extended public key on your online server. This will allow you to generate receiving addresses on the fly, while generating (and securely storing) the private keys on an offline machine.

> **Comments:**
> **username_0**: I do not understand the whole concept of BPIP32, it seems to be quite complex. For example, each request will have a single wallet to receive the funds, using the BIP32 it stores all the private keys of each address in a single parent key and I would just use the parent key to withdraw the coins and send it to an offline wallet? Sorry, it's a little confusing for me yet.  
> **username_2**: @viniciussvl I don't mean to be rude, but you'll need to take some time to read about BIP32 and its implementation, it isn't really possible to give a full synopsis in a short comment. There is lots of good info on this site alone. Think of it simply as a method of generating keypairs that is much easier to backup, and allows for better opsec. In regards to spending funds at a child key using a parent privkey (not possible), see the third part of this Q: https://bitcoin.stackexchange.com/questions/73376/a-few-questions-about-how-hd-wallet-works/73381?noredirect=1#comment92253_73381  
> **username_0**: Okay, I'll give it a look at it because it's too complex to understand. Thank you very much for your patience.  
> **username_2**: @viniciussvl happy to help :)  Though BIP32 may be a little more complex, it is worth learning if you are trying to build a legitimate system!  
> **username_0**: I wanted to develop something similar to Coinpayments, I already used it. Do you think they use the technology of HD wallets?  
> **username_2**: @viniciussvl I am not familiar with their system, sorry.  
> **username_3**: @viniciusscl - Look at https://github.com/libbitcoin/libbitcoin/wiki/Altcoin-Version-Mappings#7-bitcoin-btc-bip-3944-technology-examples and surrounding info.  Much safer to store public extended keys on a server.  Here is how a public key can be synthesized from private BIP 39 words: ```% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-public -d -i 0``` **xpub6DHi64TFkDPx2AH4q2ku3vX9LJYNpTis5tLrET8Sb9irp174eCkgtAnvBpyzQXgrtmF31Lrq4gTMGFUGcjJicMu9LdueVdqt6FZ2Wzcg8F**  
> **username_4**: I understand how I can store the extended public keys in the online server to generate receiving addresses but what if I want to send money from one of these addresses? how do I go from an online http request to the offline server to sign the transaction and avoid exposing the pvt keys?  

---

### Answer by username_1 on 2021-08-22. Score: 0

You might want to checkout BTCPay, which is a self-hosted payment gateway

* <https://alternativeto.net/software/btcpay-server/about/>


---

