Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadFromFile not working #36

Open
joriswa opened this issue May 2, 2020 · 1 comment
Open

loadFromFile not working #36

joriswa opened this issue May 2, 2020 · 1 comment

Comments

@joriswa
Copy link

joriswa commented May 2, 2020

I get this error

[18:33:19] [Server thread/WARN]: org.bitcoinj.wallet.UnreadableWalletException: Unknown network parameters ID org.dogecoin.production [18:33:19] [Server thread/WARN]: at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:416) [18:33:19] [Server thread/WARN]: at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:391) [18:33:19] [Server thread/WARN]: at org.bitcoinj.wallet.Wallet.loadFromFileStream(Wallet.java:1606) [18:33:19] [Server thread/WARN]: at org.bitcoinj.wallet.Wallet.loadFromFile(Wallet.java:1512) [18:33:19] [Server thread/WARN]: at net.waals.dogecraft.DogeCraft.onEnable(DogeCraft.java:29) [18:33:19] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) [18:33:19] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [18:33:19] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [18:33:19] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:462) [18:33:19] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:376) [18:33:19] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.reload(CraftServer.java:811) [18:33:19] [Server thread/WARN]: at org.bukkit.Bukkit.reload(Bukkit.java:576) [18:33:19] [Server thread/WARN]: at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) [18:33:19] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) [18:33:19] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:711) [18:33:19] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchServerCommand(CraftServer.java:696) [18:33:19] [Server thread/WARN]: at net.minecraft.server.v1_15_R1.DedicatedServer.handleCommandQueue(DedicatedServer.java:436) [18:33:19] [Server thread/WARN]: at net.minecraft.server.v1_15_R1.DedicatedServer.b(DedicatedServer.java:400) [18:33:19] [Server thread/WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:984) [18:33:19] [Server thread/WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:824) [18:33:19] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:834)

@ygk44
Copy link

ygk44 commented Jun 13, 2022

I guess I'm too late, but if anybody faces it again:
In BitcoinJ loadFromFile() and loadFromFileStream() use NetworkParameters.fromId() which is static. It's only aware of BTC IDs and thus returns null for all others.
The option I used is to create own instance of WalletProtobufSerializer and pass parameters inside directly:

try (InputStream in = new FileInputStream("yourFile")) {
    Protos.Wallet walletProto = WalletProtobufSerializer.parseToProto(in);
    WalletProtobufSerializer serializer = new WalletProtobufSerializer();
    Wallet yourWallet = serializer.readWallet(params, null, walletProto);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants