I am a beginner in Bitcoin development and just started with the bitcoinj library for Java. You can get a code snippet to create a Bitcoin wallet and legacy address.
Timestamp createdAt = Timestamp.valueOf(LocalDateTime.now());
DeterministicSeed seed = new DeterministicSeed(entropy, "", createdAt.getTime());
Wallet btcWallet = Wallet.fromSeed(netParams, seed, Script.ScriptType.P2PKH);
Address receiveAddress = btcWallet.currentReceiveAddress();
String bitcoinAddress = receiveAddress.toString();
This works well for P2PKH, but I want the newer type, P2TR. I just changed that parameter and an exception occurred. Googling didn’t provide any help. Any help would be great for me. Thank you in advance.