Author

Topic: pure Java code (Xtend actually) to read keys from wallet.dat (Read 2623 times)

hero member
Activity: 938
Merit: 500
https://youengine.io/
Does it handle altcoin wallets as well?
No, not yet. The bitcoinj library I am using to do all EC-Key related stuff and conversion to/from base58 address format (after importing from wallet.dat) only knows the parameters needed to create bitcoin addresses (It can be given different parameters for other coins, maybe (probably) this would work but I haven't tested it yet).

The low level wallet.dat related code itself (the parsing of the Berkeley file) should work (or easily be adaptable) for all altcoin wallets that are based on the bitcoin core client.
sr. member
Activity: 359
Merit: 250
Does it handle altcoin wallets as well?
hero member
Activity: 938
Merit: 500
https://youengine.io/
Nice!! Xtend compiles down to Java source-to-source, right? Perhaps we could merge the result into bitcoinj.

Yes, Xtend is for Java what CoffeScript is for JavaScript (so it should actually be called "Coffee"). The only downside is that other than Eclipse there is zero IDE support (but the Eclipse support is excellent). But I would not try to reuse the generated Java code directly, sometimes its readable but when using lambdas and some of the syntactic sugar the generated code quickly becomes impossible to understand. The wallet.dat parsing code is actually totally imperative and straightforward, so it should be easy to translate it manually to Java without first trying to make sense of the Xtend compiler output, most of the time you would just need to add all the missing type declarations and a semicolon to the end of every line and 90% of the work would be done.
legendary
Activity: 1526
Merit: 1134
Nice!! Xtend compiles down to Java source-to-source, right? Perhaps we could merge the result into bitcoinj.
hero member
Activity: 938
Merit: 500
https://youengine.io/
...decrypt it and and create c.g.bitcoin.core.ECKey instances from the keys.

If anybody of you ever felt the urge to parse a Berkeley database (wallet.dat) without linking against libdb, and use the keys in your bitcoinj based application: here is some inspiration: https://github.com/prof7bit/wallet-key-tool/blob/master/src/main/java/prof7bit/bitcoin/wallettool/fileformats/WalletDatHandler.xtend

 Grin
Jump to: