This is not complete answer, but hope this will help you to understand some concepts.
- xpriv and xpub are key pairs, which are possessed by every (online) wallet when it is created. xpriv is actually the private key of the wallet (which you must not share with anyone). while xpub is the public key of the wallet (which is used to derive the receiving addresses of wallet, where it can receive funds or coins).
This is brief explanation. you can read more to understand its working and purpose from given link.
How are public and private keys related to the wallet?
- In order to create wallet we use Network Parameters. So, in bitcoinj, we use MainNet (ProdNet) and TestNet. So, xpub is the public key which is used to create the public addresses of Online wallet using MainNet. while tpub is the public key, which is used to create the Receiving addresses of Testing wallet (which doesn't contain real coins).
You can check more difference between mainNet and testNet in following questions.
Practical difference between mainnet and testnet
https://ethereum.stackexchange.com/questions/6278/whats-the-difference-between-the-testnet-and-the-production-network-technical
Good Day!