Hello,
I load a wallet from a file like:
import java.io.File
import bitcoin.network.TestNetworkParams
import org.bitcoinj.core.{BlockChain, PeerGroup, Wallet}
import org.bitcoinj.store.MemoryBlockStore
object Main extends App {
val wallet = Wallet.loadFromFile(new File("walletTestNet.wallet"))
val blockStore = new MemoryBlockStore(TestNetworkParams)
val blockChain = new BlockChain(TestNetworkParams, wallet, blockStore)
val peerGroup = new PeerGroup(TestNetworkParams, blockChain)
peerGroup.addWallet(wallet)
peerGroup.startAsync
peerGroup.waitForPeers(1).get
Console.println("Address: " + wallet.currentReceiveAddress)
Console.println("Bitcoins: " + wallet.getBalance)
}
import bitcoin.network.TestNetworkParams is just my own TestNet
When I used WalletAppKit I didn't have any problem. I could connect. But I
don't want to use the kit.
This piece of code throws this exception:
Exception in thread "main" org.bitcoinj.store.UnreadableWalletException:
Unknown network parameters ID
at
org.bitcoinj.store.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:397)
at org.bitcoinj.core.Wallet.loadFromFileStream(Wallet.java:1520)
at org.bitcoinj.core.Wallet.loadFromFile(Wallet.java:1450)
at console.Main$.delayedEndpoint$console$Main$1(Main.scala:14)
at console.Main$delayedInit$body.apply(Main.scala:13)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at
scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at
scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at console.Main$.main(Main.scala:13)
at console.Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
So, I need to load the wallet from a file and I don't know how I can pass it
network parameters.
BitcoinJ version: 0.13.6
Could anyone help me?
Regards
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.