I'm trying to create a bitcoinj
determinstic key chain from a BIP32 master public key. This is the code that I have written so far:
val xpub = "xpub661MyMwAqRbcGiwzoCu93MuL6H91qANYUoYBwD4xSH8bRKJVNXsP1FUnNYiWUiu4trHbs3tavhbr4ih9bwNeVBmdQAnrA5SwSEVVCFza8dy"
val keyChainSeed : DeterministicKey = DeterministicKey.deserializeB58(null,xpub, MainNetParams.get)
val w = Wallet.fromWatchingKey(MainNetParams.get, keyChainSeed)
but I get the following error:
No key found for absolute path M/0H.
java.lang.IllegalArgumentException: No key found for absolute path M/0H.
at org.bitcoinj.crypto.DeterministicHierarchy.get(DeterministicHierarchy.java:94)
at org.bitcoinj.crypto.DeterministicHierarchy.deriveChild(DeterministicHierarchy.java:152)
at org.bitcoinj.wallet.DeterministicKeyChain.initializeHierarchyUnencrypted(DeterministicKeyChain.java:590)
at org.bitcoinj.wallet.DeterministicKeyChain.<init>(DeterministicKeyChain.java:384)
at org.bitcoinj.wallet.DeterministicKeyChain.<init>(DeterministicKeyChain.java:393)
at org.bitcoinj.wallet.DeterministicKeyChain.watch(DeterministicKeyChain.java:444)
at org.bitcoinj.wallet.DeterministicKeyChain.watch(DeterministicKeyChain.java:436)
at org.bitcoinj.wallet.KeyChainGroup.<init>(KeyChainGroup.java:115)
at org.bitcoinj.core.Wallet.fromWatchingKey(Wallet.java:260)
at com.suredbits.core.bitcoin.WalletTest$$anonfun$2.apply$mcV$sp(WalletTest.scala:84)
at com.suredbits.core.bitcoin.WalletTest$$anonfun$2.apply(WalletTest.scala:80)
at com.suredbits.core.bitcoin.WalletTest$$anonfun$2.apply(WalletTest.scala:80)
I'm not sure why this isn't working, as bitcoinj
supports BIP32. Can anyone spot what I am doing incorrectly?