Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: just_someguy on April 20, 2011, 03:54:51 PM



Title: Extracting Private Key - (java or rpc)
Post by: just_someguy on April 20, 2011, 03:54:51 PM
I'm developing a small bitcoin service and I've got everything working great except for one hangup: I can't for the life of me figure out how to programatically extract the private key from the wallet.
I looked at bitcoinj but it appears to use a different format than the standard client.
I'm pretty new to bitcoin so maybe I'm missing something obvious.
The only way I've been able to do this so far has been modifying bitcointools to show the whole address in a dump and parse it out by hand.
Is there code floating around to do this in java with the standard berkley db format?



Title: Re: Extracting Private Key - (java or rpc)
Post by: Pieter Wuille on April 20, 2011, 03:58:26 PM
I have a patch in my walletdump branch that can export and import private keys. It is still dangerous to do so, including a chance of corrupting your wallet if keys are used in several place at the same time.

See https://github.com/sipa/bitcoin/tree/walletdump


Title: Re: Extracting Private Key - (java or rpc)
Post by: just_someguy on April 20, 2011, 04:05:05 PM
Unfortunately I would need it to work in java.


Title: Re: Extracting Private Key - (java or rpc)
Post by: Pieter Wuille on April 20, 2011, 04:06:03 PM
It adds RPC calls dumpprivkey and importprivkey.


Title: Re: Extracting Private Key - (java or rpc)
Post by: just_someguy on April 20, 2011, 04:22:01 PM
Oh... I see. So its a full client replacement?
Still not sure thats going to work for me but I appreciate it.
The service I'm developing has an end user component that needs access to the keys. Requiring a different client wouldn't be optimal but if thats the only choice I have I may go that way.

If anyone happens to have a pure java version I'd be willing to pay a small amount from my meager bitcoin collection.


Title: Re: Extracting Private Key - (java or rpc)
Post by: Mike Hearn on April 20, 2011, 05:42:08 PM
What are you actually trying to achieve? Sipas patch gives you what you want if you've built software on top of the official BitCoin C++ software. If you want to stay in "pure java" land then BitCoinJ can help but as you note, it can't use the c++ clients wallets. Also if you want to buy/sell things with it, BitCoinJ is too immature for that at present. It's also dangerous to use if you aren't sure what you're doing.

You can just compile your own bitcoind with sipas patch and use a java json-rpc library.


Title: Re: Extracting Private Key - (java or rpc)
Post by: just_someguy on April 21, 2011, 01:30:16 AM
You're right. I got it installed and works great. (No small feat since I'm just good enough at linux to be dangerous).
As far as what I'm doing: I'm feeding the keys into an elliptic curve function to encrypt something else.