<p>The extended public key, xPub, consists of both a chaincode and the public key itself. These are effectively distinct from each other, you cannot generate the chain code from the public key or vice-versa. Normally they are both generated at the same time from a seed, but without the seed you cannot generate the same chain code.</p>

CC BY-SA 3.0
2017-12-13T12:14:07.693Z
@TygaChristed please accept the answer if it satisfied your question, because otherwise it remains "unanswered" on the site :)
meshcollider
CC BY-SA 3.0
2017-12-10T20:42:15.327Z
2017-12-10T20:42:15.327Z
meshcollider
<p>I am working on a Bitcoin Wallet, i have public key but can't figure out how can i genrate xPub key from this.</p>

CC BY-SA 3.0
2017-12-07T03:54:55.277Z
You can't. Perhaps you can ask a more specific question after reading more about BIP32?
Pieter Wuille
CC BY-SA 3.0
2017-12-07T12:51:19.280Z
I also recommend to have a look into Andreas' book "Mastering Bitcoin" (2nd edition), where he explains in chapter 5, how HD wallets and BIP32 work. The book is somewhere online readable (I think it was even on Amazon, but there is the pre-release only, and has chapter 4 with wallets).
pebwindkraft
<java>
How to generate xPub Key from public key in java
Zombie
# How to generate xPub Key from public key in java

(Asked by: username_0 on 2017-12-06)

I am working on a Bitcoin Wallet, i have public key but can't figure out how can i genrate xPub key from this.

**Tags:** java

> **Comments:**
> **username_1**: You can't. Perhaps you can ask a more specific question after reading more about BIP32?  
> **username_2**: I also recommend to have a look into Andreas' book "Mastering Bitcoin" (2nd edition), where he explains in chapter 5, how HD wallets and BIP32 work. The book is somewhere online readable (I think it was even on Amazon, but there is the pre-release only, and has chapter 4 with wallets).  

---

## 1 answers

### Answer by username_3 on 2017-12-10. Score: 2 | Accepted answer

The extended public key, xPub, consists of both a chaincode and the public key itself. These are effectively distinct from each other, you cannot generate the chain code from the public key or vice-versa. Normally they are both generated at the same time from a seed, but without the seed you cannot generate the same chain code.

> **Comments:**
> **username_3**: @TygaChristed please accept the answer if it satisfied your question, because otherwise it remains "unanswered" on the site :)  

---

