Bitcoin Forum
June 21, 2024, 01:44:13 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: pure Java code (Xtend actually) to read keys from wallet.dat  (Read 2602 times)
prof7bit (OP)
Hero Member
*****
Offline Offline

Activity: 938
Merit: 500


https://youengine.io/


View Profile WWW
May 21, 2014, 09:32:02 PM
 #1

...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

Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
May 22, 2014, 10:54:50 AM
 #2

Nice!! Xtend compiles down to Java source-to-source, right? Perhaps we could merge the result into bitcoinj.
prof7bit (OP)
Hero Member
*****
Offline Offline

Activity: 938
Merit: 500


https://youengine.io/


View Profile WWW
May 22, 2014, 05:32:31 PM
 #3

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.

altsay
Sr. Member
****
Offline Offline

Activity: 359
Merit: 250


View Profile
August 03, 2014, 08:03:54 AM
 #4

Does it handle altcoin wallets as well?
prof7bit (OP)
Hero Member
*****
Offline Offline

Activity: 938
Merit: 500


https://youengine.io/


View Profile WWW
August 03, 2014, 11:46:31 AM
 #5

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!