Pages:
Author

Topic: [PULL] private key and wallet export/import - page 9. (Read 39577 times)

member
Activity: 103
Merit: 17
There's a crash caused by accessing an array element past the last one in base58.h, in the SecretToASecret function.
Code:
vch.insert(vch.end(), &vchSecret[0], &vchSecret[vchSecret.size()]);
vchSecret.size() is one past the last element, so it crashes here.

Since vchSecret is just a vector anyway, we can use this safer alternative:
Code:
vch.insert(vch.end(), vchSecret.begin(), vchSecret.end());
legendary
Activity: 1072
Merit: 1181
Rebased against master, a few bugs fixed, and split off into separate source file.

TODO: known wrong balance cached when importing keys
member
Activity: 98
Merit: 10
When I try to dump my wallet, I get an error:

Code:
$ bitcoind -rpcuser='xxx' -rpcpassword='yyy' dumpwallet
error: {"code":-1,"message":"CKEy::GetPrivKeyInner(): BN_bn2bin failed"}

Sorry, yes, this is a known bug. It happens for 1 private key in 256. I'll fix it soon.


How soon in the system in the main client? And how soon the default format?
legendary
Activity: 1072
Merit: 1181
When I try to dump my wallet, I get an error:

Code:
$ bitcoind -rpcuser='xxx' -rpcpassword='yyy' dumpwallet
error: {"code":-1,"message":"CKEy::GetPrivKeyInner(): BN_bn2bin failed"}

Sorry, yes, this is a known bug. It happens for 1 private key in 256. I'll fix it soon.
legendary
Activity: 2940
Merit: 1333
When I try to dump my wallet, I get an error:

Code:
$ bitcoind -rpcuser='xxx' -rpcpassword='yyy' dumpwallet
error: {"code":-1,"message":"CKEy::GetPrivKeyInner(): BN_bn2bin failed"}

I can dump a newly created wallet just fine, but my real one won't dump.

Any idea why?  Is it anything to worry about?  Should I try spending all my coins to a new address?
legendary
Activity: 1400
Merit: 1005
Please put this in the regular build.  These features are highly useful and I find myself using them regularly.

They will also be vital in making Bitcoin attractive to people too afraid to store wallet.dat's on their computers or use the client.  If private keys can easily be exported and imported from human-readable characters, people can have paper wallets.

Once this is done right, the instructions for making a safe hacker-proof offline wallet become idiot proof:
1 - generate an offline wallet and print it on a piece of paper (or have one mailed to you in a letter from XYZ trusted provider for $1 PPUSD)
2 - transfer your BTC to the public key (the number that starts with 1)
3 - when ready to spend, load the coins with the secret key (the number that starts with 5), OR type the secret key into screen X at MyBitcoin/MtGox/TradeHill/wherever, and redeem your funds.
Just FYI, the public key and the bitcoin address are two separate things.  The address (that starts with a 1) is a series of hashes of the public key.  The logic is sound, the terminology is just off a bit.
vip
Activity: 1386
Merit: 1140
The Casascius 1oz 10BTC Silver Round (w/ Gold B)
Please put this in the regular build.  These features are highly useful and I find myself using them regularly.

They will also be vital in making Bitcoin attractive to people too afraid to store wallet.dat's on their computers or use the client.  If private keys can easily be exported and imported from human-readable characters, people can have paper wallets.

Once this is done right, the instructions for making a safe hacker-proof offline wallet become idiot proof:
1 - generate an offline wallet and print it on a piece of paper (or have one mailed to you in a letter from XYZ trusted provider for $1 PPUSD)
2 - transfer your BTC to the public key (the number that starts with 1)
3 - when ready to spend, load the coins with the secret key (the number that starts with 5), OR type the secret key into screen X at MyBitcoin/MtGox/TradeHill/wherever, and redeem your funds.

BTW, for anyone unfamiliar, this is what a sample private key looks like encoded in Base58: 5KVZnDNgk6VUpe1yWq7HFizU6K5vHCHSbQQonQ8JoqCkyLjDS2R

(Like a Bitcoin address, but about 51 characters, starting with a "5", and includes strong error detection built-in, so typos are virtually always caught automatically)
legendary
Activity: 1400
Merit: 1005
Is there any way to use this pull before it is included in the standard build?  I am anxious to play around with it...
jr. member
Activity: 56
Merit: 1
Is there any chance of adding a method to export a new address/private key without it ever been added to your wallet?
It looks like you are trying to create valid Bitcoin private/public key pairs completely outside of the context of the client.
Maybe check this topic: how to bury some bitcoins without even installing the client.
newbie
Activity: 50
Merit: 0
Is there any chance of adding a method to export a new address/private key without it ever been added to your wallet? Reason is i am looking at using this store bitcoins offline as such but don't want to have to delete my wallet each time i generate a new exported address/private key pair. At this stage i am looking at creating a new data directory of the client so i can do this manually by deleting the wallet each time but just seems like a waste of time and effort that could be done in the method.  Maybe if you don't pass an address in it generates a new address/private key pair and returns them and never adds them to the wallet.
member
Activity: 112
Merit: 10
Now this one is utterly lovable.
legendary
Activity: 1072
Merit: 1181
Added an optional parameter to specify the account for importprivkey. I also changed it to use the default account "" instead of "imported" when no account is given.

https://github.com/mhanne/bitcoin/commit/a774c70727b616e8b9d42caaf2e8b5fbd9cd9087

Nice improvement - I've merged it in my branch.
member
Activity: 98
Merit: 10
About time! yes! thank you with sugar on top.
member
Activity: 73
Merit: 10
Added an optional parameter to specify the account for importprivkey. I also changed it to use the default account "" instead of "imported" when no account is given.

https://github.com/mhanne/bitcoin/commit/a774c70727b616e8b9d42caaf2e8b5fbd9cd9087
legendary
Activity: 1937
Merit: 1001
Hopefully exporting and importing specific keys will be an option soon.
ffe
sr. member
Activity: 308
Merit: 250
I'm interested in this feature as well. Is there a current discussion going on?
full member
Activity: 189
Merit: 100
I'm really looking forward to this feature.  Ideally there should be no wallet.dat, but a directory in .bitcoin where all private keys reside, that would allow the user more flexibility.
legendary
Activity: 1400
Merit: 1005
I'm very interested in using this for importing custom-made key pairs (sec + addr) into a given wallet.  Would that be possible even though an address may not have yet been used in a block, and has a 0 value?

Also, when could we expect this sort of a change to be made?
sr. member
Activity: 322
Merit: 251
FirstBits: 168Bc
I put all my keys in a git repository. Except for the fear that the 'authorities' are gonna knock on my door later in the decade, I'm far more afraid to delete keys than feel the need to obfuscate them. I'm considering sending a CD to my brother and next of kin with keys and instructions. I assume more BitCoins have and will be lost rather than stolen.
legendary
Activity: 1072
Merit: 1181
A wallet dump is a JSON formatted file, with the following definition:


wallet_dump :: object {
  "keys" : list of key_entry  // the key information itself
  "loc" : locator             // information about the currently best known chain
}

key_entry :: object {
  "sec" : string              // private key in base58 format
  "addr" : string             // address in base58 format (verified on input, but ignored)
  "label" : string            // label for the address corresponding to this key
  "height" : int              // first block height this key is known to have been used in
  "heightAvail" : int         // first block height this key is known to have been used in
                              // with a not-yet redeemed transaction output to this key's address
  "value" : string            // decimal representation of total BTC sent to this key's address
  "valueAvail" : string       // decimal representation of available BTC sent to this key's
                              // address
  "tx" : tx_table             // list of transactions
  "reserve" : int             // nonzero if tx is a reserve key
}

tx_table :: object {
  string : tx_entry          // key is txid, or txid:outputid
  ...
}

tx_entry :: object {
  id : string                // txid in hex format
  height : int               // height of block this tx is known to be placed in
  value : string             // decimal representation of BTC sent to the address corresponding to
                             // parent key_entry's private key by this tx
  spent : bool               // whether or not this tx is known to be spent
}

locator :: object {
  string : int               // key is blockid, value is block height
  ...
}


The "addr", "heightAvail", "value", "valueAvail" and "spent" fields are not used when importing.
The "height", "tx" and "loc" fields are used to determining what to rescan.
Only "sec", "label" and "reserve" contain actual data that is imported.
Only 'sec" is really required.
Pages:
Jump to: