Bitcoin Forum
December 03, 2016, 02:28:22 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1] 2 »  All
  Print  
Author Topic: OSX Bitcoin-Qt private key  (Read 6967 times)
DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 25, 2012, 02:24:50 PM
 #1

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.

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
1480732102
Hero Member
*
Offline Offline

Posts: 1480732102

View Profile Personal Message (Offline)

Ignore
1480732102
Reply with quote  #2

1480732102
Report to moderator
1480732102
Hero Member
*
Offline Offline

Posts: 1480732102

View Profile Personal Message (Offline)

Ignore
1480732102
Reply with quote  #2

1480732102
Report to moderator
1480732102
Hero Member
*
Offline Offline

Posts: 1480732102

View Profile Personal Message (Offline)

Ignore
1480732102
Reply with quote  #2

1480732102
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
John (John K.)
Global Troll-buster and
Legendary
*
Online Online

Activity: 1092


Will read PM's. Have more time lately


View Profile
June 25, 2012, 02:47:52 PM
 #2

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.

My BTC Tip Jar: 1Pgvfy19uwtYe5o9dg3zZsAjgCPt3XZqz9 , GPG ID: B3AAEEB0 ,OTC ID: johnthedong
Escrow service is available on a case by case basis! (PM Me to verify I'm the escrow!)

DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 04:18:25 PM
 #3

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:

Quote
sudo port install python27 py27-twisted py27-pip py-bsddb python_select

I get the following error:

Quote
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?

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
June 27, 2012, 04:45:59 PM
 #4

See the following post: https://bitcointalk.org/index.php?topic=88477.msg974356#msg974356

DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 05:03:20 PM
 #5


I was really hoping this was going to work.  It seemed so simple and useful.  Unfortunately, when I ran the curl command:
Quote
curl --user <user> --data-binary '{"method": "dumpprivkey", "params": ["<address>"] }' http://127.0.0.1:8332/
I got the following:
Quote
{"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

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
Rugatu
Full Member
***
Offline Offline

Activity: 182



View Profile WWW
June 27, 2012, 05:18:19 PM
 #6


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:

Quote
{"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:

Code:
curl --user username --data-binary '{"method": "getinfo"}' http://127.0.0.1:8332/

Have any questions? Q&A with BTCitcoins on Rugatu
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
June 27, 2012, 05:25:07 PM
 #7

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.


Code:
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.
Code:
{"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
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 05:58:21 PM
 #8


If you got that far, is already working but probably you didn't format your command correctly. Try this one:

Code:
curl --user username --data-binary '{"method": "getinfo"}' http://127.0.0.1:8332/

Ok, this is promising. I get the following:

Code:
{"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}


The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 06:07:02 PM
 #9

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:

Code:
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:

Code:
{"result":null,"error":{"code":-4,"message":"Private key for address 1GrEBzpFfquAk81zaHnL8pKHRRn3kGHhD5 is not known"},"id":null}

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 06:14:04 PM
 #10

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?

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
June 27, 2012, 06:20:58 PM
 #11

Sign a message with that address, please. Tongue 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 Wink

But I'm not joking about this: Your wallet is encrypted! You need to decrypt it before sending the commands Tongue
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:
Quote
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-client

Well, I guess it's time for you to figure out how to install pywallet Grin
You'll be able to give it the password to decrypt the wallet.

DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 06:41:16 PM
 #12

Your wallet is encrypted! You need to decrypt it before sending the commands Tongue
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?

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

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

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 06:43:49 PM
 #13

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:

Quote
sudo port install python27 py27-twisted py27-pip py-bsddb python_select

I get the following error:

Quote
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?

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
June 27, 2012, 06:50:01 PM
 #14

Try this:
Code:
curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["<passphrase>", 120] }' http://127.0.0.1:8332/
replacing <passphrase> with your walletpassphrase

and next
Code:
curl --user testUser --data-binary '{"method": "dumpprivkey", "params": ["1GrEBzpFfquAk81zaHnL8pKHRRn3kGHhD5"] }' http://127.0.0.1:8332/

When done,
Code:
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
Legendary
*
Offline Offline

Activity: 1624



View Profile
June 27, 2012, 07:04:48 PM
 #15

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:
Code:
read x; curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["$x", "120"] }' http://127.0.0.1:8332/; unset x
and got
Code:
{"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:
Code:
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
Code:
{"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:
Code:
curl --user testUser --data-binary '{"method": "walletpassphrase", "params": ["<passphrase>", 120] }' http://127.0.0.1:8332/
And this time, oddly enough, I got
Code:
{"result":null,"error":{"code":-17,"message":"Error: Wallet is already unlocked."},"id":null}
Huh

So my best guess is that when I got the
Code:
{"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.

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
June 27, 2012, 07:18:20 PM
 #16

OK, glad it worked.
Edited my post to insert the correct command, as not to confuse anyone else Wink

DannyHamilton
Legendary
*
Offline Offline

Activity: 1624



View Profile
September 17, 2012, 03:45:25 PM
 #17

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.

The quality of posts has dropped to such a low level that all users who are participating in a paid signature campaign are added to my ignore list. If you'd like a copy of the list to improve your browsing experience, you can find it here: https://bitcointalk.org/index.php?topic=973843.0 (Updated 2016-1-4)
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
September 17, 2012, 05:31:34 PM
 #18

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. Huh
Not sure what you're trying to do, but you're not doing it right.

Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
September 17, 2012, 05:48:56 PM
 #19

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 Offline

Activity: 1442



View Profile
September 17, 2012, 05:58:53 PM
 #20

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

Pages: [1] 2 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!