Place xPub Key at the BTCPay Server

This post is also available in: German

Place xPub Key at the BTCPay Server

xPub Adresse


Set up and administer BTCPay Shop

place xPub Key with the BTCPay server

With the help of the BTCPayServer, the incoming payments are managed. A Bitcoin Wallet is required to receive and send Bitcoin.

To receive Bitcoin with the BTCPay server you have the following options:

If you want to manage your Bitcoin with the integrated BTCPay Wallet, we recommend the manual “BTCPay Wallet”. This guide explains how to create an xpub key from an existing wallet and store it on the BTCPay server. We describe this using the example of an Electrum Wallet.

With an external Bitcoin Wallet, the Bitcoin balance is never in the BTCPayServer, but always on the merchant’s external wallet.

You need a Bitcoin Wallet with which you can generate a xPub Public Keys (xpub Key / xpubKey).

The xPub key is stored at BTCPayServer and the private key remains in the possession of the merchant.

BTCPayServer is thus able to generate a public key for each transaction and credit the payments directly on the merchant’s wallet without getting into the possession of Bitcoin itself.

The wallet does not have to be permanently online, but is physically separated from the BTCPay server. The wallet can thus be a hardware wallet like from Coldcard or Ledger or a software wallet like electrum, which runs on your own local computer.

In our example, we use the Electrum Wallet, which runs on your own local computer.

How to set up an Electrum Wallet and generate the xPub key, we explain in “xPub Key with the Create Electrum Wallet

export xPub Key to the Electrum Wallet

Within the Electrum Wallet you go to the Wallet area and then to information. There you will find the xPub Key

xPub Key p2wpkh-p2sh

xPub Key p2wpkh-p2sh

Import xPub Key to BTCPay

In the Shop Administration under General Settings we go into the area Derivation Scheme

xbup Key derivation scheme

xbup Key derivation scheme

Click Modify there and get the following view:

Place xPub Key at the BTCPay Server 1

In the Derivation Scheme field, we enter the xPub key, which we exported at Electrum under Wallet and Information.

When inserting, the address type must also be appended.

The address type depends on what your wallet generates or what you set when you created the Electrum Wallet. In the Electrum Wallet it is specified as a script type:

Bitcoin address starts with Address Type Addition
bc1….. P2WPKH, Bech32 Address
3….. P2SH-P2WPKH -[p2sh]
1….. P2PKH -[legacy]

Depending on the script type, the addition, including hyphen and bracket, must be appended to the xpub key.

If a Bech32 address is created with the script type p2wpkh, then an addition is not required.


For merchant, it is recommended that the SegWit (P2SH) format be used instead of the SegWit (Bech32) format.

That’s why we use the address type: p2wpkh-p2sh

Accordingly, we must be appended to the generated xPub key. [p2sh] Including the minus sign and the square bracket.

Place xPub Key at the BTCPay Server 2To check if the address is specified correctly, we set the check mark on Enabled and click Continue.

We receive a list of a total of 10 Bitcoin addresses,

Place xPub Key at the BTCPay Server 3

which must be identical to the addresses displayed in the Electrum Wallet under Address:

Place xPub Key at the BTCPay Server 4From this address pool the Bitcoin addresses are taken, which are needed for receiving the Bitcoin payments.

Because Only 10 addresses are stored by Electrum by default, the Electrum Gap Limit must be increased.

To do this, go to the Menue-Point Console in the Electrum Wallet and enter the command:


and presses Enter

Then the command:

To check how high the gap limit is, type the command:



If you would like to read a detailed description of the creation of the Electrum Wallet and the increase of the Gap Limit, you can find this at:

Create xPub Key with The Electrum Wallet

Any Bitcoin payments are automatically credited to your own Bitcoin Wallet (here Electrum Wallet).

You can check by matching the transactions displayed in BTCPay with the transactions in your wallet.

You also have sole permission to use the Bitcoin on your wallet. You can keep the Bitcoin or forward it to a Bitcoin exchange to exchange for euros.

This post is also available in: German