DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 25, 2012, 02:24:50 PM |
|
I tried searching, but all my attempts turned up advice about using bitcoind. I don't see bitcoind on my computer (although perhaps I just don't know where to look).
I'm using OSX Lion, and running Bitcoin-Qt 0.6.2.2 with an encrypted wallet.
I'd like to identify what the private key is for one of my bitcoin addresses. I'm guessing this is a simple thing to do, so I've posted my question here instead of "Technical Support". I'm sure this question has to have been asked before, so I apologize for asking a question that people are tired of answering.
Given a bitcoin address of ABC and an encryption password of XYZ, how would I go about finding the private key?
I'm aware that it isn't possible from the GUI, but was really hoping there was a way to do it from a command line. I'm relatively fluent in BASH, KSH, PERL, AWK, SED so if there is a script that can help me, that would be fine as well.
Thanks in advance for any advice.
|
|
|
|
John (John K.)
Global Troll-buster and
Legendary
Offline
Activity: 1288
Merit: 1227
Away on an extended break
|
|
June 25, 2012, 02:47:52 PM |
|
Dump your keys from the wallet.dat file by using pywallet : https://bitcointalk.org/index.php?topic=34028.0 and running the command pywallet.py --dumpwallet --password=PASSWORD Bitcoind is not present on OSX.
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 04:18:25 PM |
|
Ok, so if pywallet is the answer, then I guess my new question is: Can anyone help me get pywallet working in OSX Lion? I understand that to run pywallet I need some libraries from MacPorts, and I understand the MacPorts website says that I'll also need Apple's Xcode Developer Tools. I believe I've taken care of installing both, but when I try to run: sudo port install python27 py27-twisted py27-pip py-bsddb python_select
I get the following error: Error: Unable to open port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
Any idea what I've done wrong?
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
June 27, 2012, 04:45:59 PM |
|
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 05:03:20 PM Last edit: June 27, 2012, 05:15:22 PM by DannyHamilton |
|
I was really hoping this was going to work. It seemed so simple and useful. Unfortunately, when I ran the curl command: I got the following: {"result":null,"error":{"code":-4,"message":"Private key for address <address> is not known"},"id":null}
Where <address> is a bitcoin address copied from Bitcoin-qt and pasted into the curl command, and <user> is the value I assigned to rpcuser in the bitcoin.conf
|
|
|
|
Rugatu
|
|
June 27, 2012, 05:18:19 PM |
|
I was really hoping this was going to work. It seemed so simple and useful. Unfortunately, when I ran the curl command I got the following: {"result":null,"error":{"code":-4,"message":"Private key for address <address> is not known"},"id":null}
Where <address> is a bitcoin address copied from Bitcoin-qt and pasted into the curl command. If you got that far, is already working but probably you didn't format your command correctly. Try this one: curl --user username --data-binary '{"method": "getinfo"}' http://127.0.0.1:8332/
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
June 27, 2012, 05:25:07 PM Last edit: June 27, 2012, 05:36:44 PM by psy |
|
Did you leave the quotation marks around the address? You should have left them there.
Example using the address I have on my signature, just replace it with yours.curl --user <username> --data-binary '{"method": "dumpprivkey", "params": ["1PKyq6aMKcCwn8cmb9Jc5SkNydLsQb5n7K"] }' http://127.0.0.1:8332/ EDIT: I tried without the quotation marks and it gave me the following error, so that wasn't your problem. {"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null} Are you sure you didn't paste a Bitcoin address taken from the Address Book, that is, a Bitcoin address that belongs to someone else and not to you? Your addresses are listed on the "Receive Coins" separator only.
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 05:58:21 PM |
|
If you got that far, is already working but probably you didn't format your command correctly. Try this one: curl --user username --data-binary '{"method": "getinfo"}' http://127.0.0.1:8332/ Ok, this is promising. I get the following: {"result":{"version":60300,"protocolversion":60001,"walletversion":40000,"balance":<xxxxxx>,"blocks":186513,"connections":8,"proxy":"","difficulty":1726566.55919348,"testnet":false,"keypoololdest":1330757976,"keypoolsize":101,"paytxfee":0.00000000,"unlocked_until":0,"errors":""},"error":null,"id":null}
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 06:07:02 PM |
|
Are you sure you didn't paste a Bitcoin address taken from the Address Book, that is, a Bitcoin address that belongs to someone else and not to you? Your addresses are listed on the "Receive Coins" separator only.
Yes, I double checked the address and it definitely was correct, but here is another I just copied and pasted. You can verify on the blockchain that it is a valid address since I received coins there in the past (although I suppose you have to take my word for it that I own the address and it is in my wallet) Command copied from my terminal and pasted into this post: curl --user testUser --data-binary '{"method": "dumpprivkey", "params": ["1GrEBzpFfquAk81zaHnL8pKHRRn3kGHhD5"] }' http://127.0.0.1:8332/
Result copied from my terminal and pasted into this post: {"result":null,"error":{"code":-4,"message":"Private key for address 1GrEBzpFfquAk81zaHnL8pKHRRn3kGHhD5 is not known"},"id":null}
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 06:14:04 PM |
|
Honestly, I'm surprised that the curl command would work without my encryption password. That seems to me to be a serious security flaw if any malicious program could look up a password in bitcoin.conf and access the private keys in my wallet. Are you sure there isn't a need to pass in the encryption password somehow?
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
June 27, 2012, 06:20:58 PM Last edit: June 27, 2012, 06:39:16 PM by psy |
|
Sign a message with that address, please. No need to take your word for it. But looking at the blockchain.info page and seeing as it only received half a bitcent in there and never sent anything, it really is yours and not an address that happened to send you coins. BTW, I was just joking about the message signing But I'm not joking about this: Your wallet is encrypted! You need to decrypt it before sending the commands And given that there is no bitcoind on Mac I don't know of a way for you to do it on the Terminal. This is the way to do it on linux: Oh, you need to unencrypt your wallet temporarily so it can add the new key. I do the following, so my passphrase doesn't end up in my shell history. It unlocks the wallet for 60 seconds: read x; ./bitcoind walletpassphrase "$x" 60; unset x From: http://bitcoin.stackexchange.com/questions/3530/how-to-import-a-private-key-to-an-encrypted-wallet-on-standard-clientWell, I guess it's time for you to figure out how to install pywallet You'll be able to give it the password to decrypt the wallet.
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 06:41:16 PM |
|
Your wallet is encrypted! You need to decrypt it before sending the commands Yep see my original post here: I'm using OSX Lion, and running Bitcoin-Qt 0.6.2.2 with an encrypted wallet.
But one thing I can say: pywallet will also not work on an encrypted wallet. Well, at least not before you decrypt it.
So this post in this thread was wrong/misleading?I took that to mean that pywallet would accept a PASSWORD parameter on the command line that would decrypt the private key in the wallet?Nevermind, I see you already mentioned that. So back to my question...
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 06:43:49 PM |
|
Ok, so if pywallet is the answer, then I guess my new question is: Can anyone help me get pywallet working in OSX Lion? I understand that to run pywallet I need some libraries from MacPorts, and I understand the MacPorts website says that I'll also need Apple's Xcode Developer Tools. I believe I've taken care of installing both, but when I try to run: sudo port install python27 py27-twisted py27-pip py-bsddb python_select
I get the following error: Error: Unable to open port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
Any idea what I've done wrong?
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
June 27, 2012, 06:50:01 PM Last edit: June 27, 2012, 07:16:47 PM by psy |
|
Try this: curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["<passphrase>", 120] }' http://127.0.0.1:8332/ replacing <passphrase> with your walletpassphrase and next curl --user testUser --data-binary '{"method": "dumpprivkey", "params": ["1GrEBzpFfquAk81zaHnL8pKHRRn3kGHhD5"] }' http://127.0.0.1:8332/ When done, curl --user testUser --data-binary '{"method": "walletlock"}' http://127.0.0.1:8332/ To lock the wallet again with the passphrase as it seems the timeout doesn't work quite well when unlocking, so better safe than sorry. After all that you may wish to delete your terminal history or else the passphrase will be left in there. http://www.mactricksandtips.com/2012/01/clear-terminal-history.html
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
June 27, 2012, 07:04:48 PM |
|
Good news and bad news. Good news first. It WORKED! Hurray! Thanks so much for your help. Bad news. Even though it worked, I got odd results. First to keep my password out of the terminal history I tried: read x; curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["$x", "120"] }' http://127.0.0.1:8332/; unset x
and got {"result":null,"error":{"code":-14,"message":"Error: The wallet passphrase entered was incorrect."},"id":null}
Even though I could see my passphrase where I typed it, and it was correct. So then I tried: curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["<passphrase>", "120"] }' http://127.0.0.1:8332/
Using my actual passphrase in place of <passphrase>, and I got {"result":null,"error":{"code":-1,"message":"value is type str, expected int"},"id":null}
The only string I saw in the command where an INT might be expected was the "120", so I tried: curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["<passphrase>", 120] }' http://127.0.0.1:8332/
And this time, oddly enough, I got {"result":null,"error":{"code":-17,"message":"Error: Wallet is already unlocked."},"id":null}
So my best guess is that when I got the {"code":-1,"message":"value is type str, expected int"}
error, it must have unlocked the wallet anyhow and just not set any timeout, because the "dumpprivkey" then worked. Thanks again for all your help! Hopefully this thread will be useful for many other OSX users.
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
June 27, 2012, 07:18:20 PM |
|
OK, glad it worked. Edited my post to insert the correct command, as not to confuse anyone else
|
|
|
|
DannyHamilton (OP)
Legendary
Offline
Activity: 3472
Merit: 4798
|
|
September 17, 2012, 03:45:25 PM |
|
I don't, but if you get this resolved, please post your resolution back here. I'll avoid upgrading to Mountain Lion until I'm sure this is going to work.
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
September 17, 2012, 05:31:34 PM |
|
I don't, but if you get this resolved, please post your resolution back here. I'll avoid upgrading to Mountain Lion until I'm sure this is going to work. Bitcoin-Qt has worked fine on 10.8 for me. It just crashes after I manually added the optional bitcoin.conf file so I can get pywallet working. You don't need and you shouldn't have bitcoin running when messing with the wallet.dat using pywallet. Not sure what you're trying to do, but you're not doing it right.
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
September 17, 2012, 05:48:56 PM |
|
That's not to use pywallet. That's to use bitcoin-qt in server mode and pass it the commands using curl because there is no bitcoind for Mac.
Those instructions I gave to that other user were for him to avoid installing pywallet as he was having trouble installing it.
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
September 17, 2012, 05:58:53 PM |
|
Then you are out of luck it seems. Can't install pywallet and bitcoin-qt doesn't work with a config file...
Is the config file text encoding UTF-8? I know for a fact Mac's like to fuck up text files with odd encodings. lol
|
|
|
|
|