There is no DeterministicKeyChain constructor that receives a custom path in bitcoinj 0.14. The DeterministicKeyChain.builder() does not help with that either.
Just to be clear, there is no issue with bip44 wallets created/saved with bitcoinj 0.15, the problem is just the migration. Anyway, I solved the migration using a custom KeyChainFactory. See https://github.com/oscarguindzberg/bisq/blob/437d720e7db08e8a6b733ab5b40e7ad7497a5a88/core/src/main/java/bisq/core/btc/setup/BisqKeyChainFactory.java https://github.com/oscarguindzberg/bisq/blob/437d720e7db08e8a6b733ab5b40e7ad7497a5a88/core/src/main/java/bisq/core/btc/setup/WalletConfig.java#L462 (WalletConfig is a customized WalletAppKit) On Fri, Apr 19, 2019 at 2:20 PM Andreas Schildbach <andr...@schildbach.de> wrote: > > On 18/04/2019 20.57, Oscar Guindzberg wrote: > > > On bitcoinj 0.14 to use a bip32 custom path (eg bip44) we had to > > subclass DeterministicKeyChain and override getAccountPath(). > > Subclassing KeyChainFactory and KeyChainGroup was also required to > > make everything work. > > Maybe we weren't aware of this way to set a path during our work on > custom account paths. I usually passed the path into the constructor and > didn't subclass at all. The constructor has been replaced with the > builder, see DeterministicKeyChain.builder(). > > The KeyChainGroupStructure is kind of the successor to a single account > path for if you need multiple active keychains (one for each script > type). See KeyChainGroupStructure.DEFAULT for how it is implemented. I > can imagine a KeyChainGroupStructure for BIP44 (P2PK) and BIP84 (P2WPKH) > would make sense, but I left this to those really wanting to go this route. > > > There is a new field in the Wallet protobuf format for the Key > > message: account_path. That field was not present in 0.14. > > > > So, when opening a 0.14 wallet from 0.15 code, the Wallet is not > > properly built because of account path is not persisted on the wallet > > file. > > Ah, that's maybe an overlook on my part. There is this code in > DeterministicKeyChain.fromProtobuf(): > > if (accountPath.isEmpty()) > accountPath = ACCOUNT_ZERO_PATH; > > which is obviously tailored to BIP32-structured wallets. We should > probably try to find a lightweight way to change the default here. > > > What is the proper migration mechanism? Use a custom > > WalletProtobufSerializer? A custom KeyChainFactory? > > If all the protobuf de/serialization code would be in > WalletProtobufSerializer, then a custom WalletProtobufSerializer could > be an option. But it isn't the case, as there are fromProtobuf() / > toProtobuf() methods cluttered over several classes. > > I currently cannot say anything about KeyChainFactory, as I don't > understand the purpose of the concept thoroughly. > > -- > You received this message because you are subscribed to the Google Groups > "bitcoinj" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to bitcoinj+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Oscar Guindzberg -- You received this message because you are subscribed to the Google Groups "bitcoinj" group. To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.