Bitcoin Forum

Bitcoin => BitcoinJ => Topic started by: Sanka555 on December 26, 2023, 10:29:01 AM



Title: Taproot getting an address
Post by: Sanka555 on December 26, 2023, 10:29:01 AM
getting an address

I use bitcoin to easily get a bitcoin address from Seed

Quote
byte[] seed = PBKDF2SHA512.derive(seedCode, "mnemonic", 2048, 64);
      DeterministicKey deterministicKey = HDKeyDerivation.createMasterPrivateKey(seed);
      deterministicKey = HDKeyDerivation.createMasterPrivateKey(seed);
      deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, true));
      deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, false));
      for (int i = 0; i <= deep; i++) {
         temp = (Address.fromKey(MainNetParams.get(),
               HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(i, false)),
               Script.ScriptType.P2WPKH)).toString();
         adressAndseed.add(temp + " " + seedCode);
      }

how do I change this code to get a taproot type address? the latest version of bitcoinJ does not help

Tell me please.


Title: Re: Taproot getting an address
Post by: NotATether on January 25, 2024, 11:14:33 AM
Hi, I don't think generation of Taproot keys is supported in BitcoinJ yet: https://github.com/bitcoinj/bitcoinj/issues/1949

Read the last message by msgilligan:

Quote
WIP PR #3342 adds P2TR support to bitcoinj keychains. The comment on that PR explains what additional work is needed.

And also from reading the release notes, it seems like you can send a transaction amount to someone else's taproot address, which is simple because the scriptpubkey is very similar to Segwit v0, but you can't receive addreses to your own taproot address in BitcoinJ (because that feature doesn't exist) or spend them.