Author

Topic: [PATCH] dumpprivkey and importprivkey RPC commands (Read 9316 times)

gim
member
Activity: 90
Merit: 10
This patch is superceded by http://forum.bitcoin.org/index.php?topic=8091.0

It is not merged yet into mainline.


Ha! maybe you could edit your first post!
I've been following 3 full threads already to find this last link :-)
legendary
Activity: 1072
Merit: 1174
This patch is superceded by http://forum.bitcoin.org/index.php?topic=8091.0

It is not merged yet into mainline.
legendary
Activity: 1540
Merit: 1001
Did this get rolled into 0.3.21 and if not will the 0.3.20 patch still work?

Also, I'm assuming the .patch is linux-only which is fine for my home install, but I might want to export keys from the wallet on my work PC which (through no choice of my own) is a Win7 box. Anyone know if this is even possible in Windows at all?

I don't think this got included yet, but you can use gnuwin on windows http://www.google.pt/url?sa=t&source=web&cd=1&ved=0CCAQFjAA&url=http%3A%2F%2Fgnuwin32.sourceforge.net%2Fpackages%2Fpatch.htm&ei=LQPgTZOtF8-xhAezjtC_Cg&usg=AFQjCNF0DgIiBVNJjTXm07I_nySTN75Kzw or, for a prettier solution I think tortoisesvn had a tool iirc.
hero member
Activity: 742
Merit: 500
Did this get rolled into 0.3.21 and if not will the 0.3.20 patch still work?

Also, I'm assuming the .patch is linux-only which is fine for my home install, but I might want to export keys from the wallet on my work PC which (through no choice of my own) is a Win7 box. Anyone know if this is even possible in Windows at all?
legendary
Activity: 1540
Merit: 1001
The only other thing this patch could do to make the thing complete is 'popkey', where the key is printed AND removed from wallet. I know it's kind of dangerous, maybe dump first would be required just to have some sanity check, but for bitbills it would make everything much simpler, no need for a new wallet for each bill, just address.

I do have other use cases in mind, like simple backup wallet creation on paper, that I can put in a safe box (which with the current patch I can already do) without all the stop client, move wallet, start client, new address, dump key, stop client, rm wallet, move old wallet back, start client... which is in itself very, very dangerous when undercaffeinated or overalcoholized Smiley
member
Activity: 98
Merit: 13
what need is there for dumping private keys?

Implementing bitbills is one example.

Personally, I want to print out private keys and store them on paper, in a safety deposit box.

newbie
Activity: 8
Merit: 0
what need is there for dumping private keys?
member
Activity: 98
Merit: 13
Bump.  Let's make sure this is not forgotten.
legendary
Activity: 1072
Merit: 1174
What happens if:

-- you dump a private key from bitcoin client 'A'
-- shutdown A
-- import it into bitcoin client 'B'
-- spend it from B
 ... wait for a confirmation or three...
-- restart A

Does A notice that the coin's been spent?  I think there's a bug that it does not, and I think that bug needs to be fixed before we make it easy to export/import private keys.  So, please bang on sipa's patch and see if anything else breaks!

This was indeed not detected - incoming blocks and transactions were only checked for transactions to your own addresses, not from. Updated version of the patch fixes this as well: http://bitcoin.sipa.be/bitcoin-0.3.20.01-dumpprivkey.patch

PS: it also changes the unix makefile to use wx-config to find the locations of headers and libraries.  If necessary, i'll split this into separate patches.
legendary
Activity: 1072
Merit: 1174
Here are some (new) testnet coins to play with (thanks comboy) for those who have applied the patch: 93VYUMzRG9DdbRP72uQXjaWibbQwygnvaCu9DumcqDjGybD864T.
hero member
Activity: 489
Merit: 504
Actually I think the default client will detect it. there was an early pool that used to split the gained coins directly in the generation block :-)
hero member
Activity: 504
Merit: 500
PGP OTC WOT: EB7FCE3D
What happens if:

-- you dump a private key from bitcoin client 'A'
-- shutdown A
-- import it into bitcoin client 'B'
-- spend it from B
 ... wait for a confirmation or three...
-- restart A

Does A notice that the coin's been spent?  I think there's a bug that it does not, and I think that bug needs to be fixed before we make it easy to export/import private keys.  So, please bang on sipa's patch and see if anything else breaks!

not yet intimately familiar with the way wallet & client work but after dumping the key from A & executing your scenario
the attempted spending from A would be rejected as double spending by the network.
wait, not rejected, there would be no key to sign the spending transaction

A wallet probably would not notice (guessing here, do not really know how the balance info is internaly managed)
but a rescan with next start would help. maybe adding a flag to wallet after dumping keys that would force rescan on restart could be accepted as workaround without having to rescan after each dump.
legendary
Activity: 1652
Merit: 2216
Chief Scientist
What happens if:

-- you dump a private key from bitcoin client 'A'
-- shutdown A
-- import it into bitcoin client 'B'
-- spend it from B
 ... wait for a confirmation or three...
-- restart A

Does A notice that the coin's been spent?  I think there's a bug that it does not, and I think that bug needs to be fixed before we make it easy to export/import private keys.  So, please bang on sipa's patch and see if anything else breaks!
hero member
Activity: 489
Merit: 504
Looks promising to me, although I didn't test it yet. Looks clean ^^

+1 for inclusion
legendary
Activity: 1072
Merit: 1174
EDIT: this patch is for version 0.3.20 and isn't updated anymore. It is incorporated in my showwallet branch. See this thread for more information: http://forum.bitcoin.org/index.php?topic=3906.0

Hello all,

after working Hal's challenge to import a private key into a wallet last week, I created a patch for bitcoin which adds 2 new RPC commands:
* dumpprivkey reveals the private key corresponding to the given address (if known)
* importprivkey adds a private key to the wallet.

See http://bitcoin.sipa.be/bitcoin-0.3.20-dumpprivkey.patch

The format is similar to that of addresses, but:
* contains the 256-bit private key instead of a 160-bit hash of a public key (resulting in 51-character strings)
* uses version byte 128 (239 for testnet) instead of 0 (111 for testnet)

This is not the same format as used by Hal initially (adds version number and checksum, but I think these are useful properties).

importprivkey will perform a rescan of the block chain after adding the key, to discover transactions based on it.
dumpprivkey does not delete a key from the wallet though, so it is not really intended as a way of moving funds from one client to another, but it's a first step towards making handling private keys more accessible.
Jump to: