Which API call creates new bitcoin addresses

-1

If I have, say 20, priv/pub key pairs in my wallet which bitcoin API calls do I use to:

  1. Select a specific privpub key pair.
  2. Generate a new bitcoin address (using the selected private key)

user11286

Posted 2013-12-27T20:43:12.203

Reputation: 95

Answers

1

bitcoind getnewaddress [account]

Where account is the name you want the new address associated with.

Here is the API documentation.

Loourr

Posted 2013-12-27T20:43:12.203

Reputation: 3 022

OK but getnewaddress does not take the private key as an argument. How do I create a new address using a selected private key?user11286 2013-12-28T13:55:07.700

There is no method which accepts a private key as input. However what you can do is take an address from a specific key from your wallet and then if you call getnewaddress with that account, the new address will be associated with that private key.Loourr 2013-12-28T16:14:02.393

what if I only have one account that uses all the private keys how do I associate a new address with a specific key then?user11286 2013-12-29T15:09:27.563

you cant have an account associated with more then one key, however you can have as many accounts as you want associated with a given key.Loourr 2013-12-29T18:14:40.053

but guys like blockchain.fino (which is a shared e-wallet) allows you to have a unique private key per user. I presume blockchain.info also only has one wallet on bitcoind with user accounts managed in a separate db. Thus if a user transfer funds from his account he uses his own private key to generate a unique address.user11286 2013-12-30T08:07:06.457

You can use things like pywallet to manage lots of different wallet.dat files. But the fact remains, a given account can only ever be associated with one wallet.dat file however each wallet.dat can have arbitrarily many accounts associated with it.

Loourr 2013-12-30T16:42:48.780

0

In order to get your private keys, you have to:

  1. Unlock your wallet if it is encrypted by calling: WalletPassphrase
  2. Call ListReceivedByAddress with arguments: 0, true to get all available addresses
  3. Iterate through those addresses and for each of them that you want to grab the key pair call DumpPrivKey

To get a new address just call the GetNewAddress method.

George Kimionis

Posted 2013-12-27T20:43:12.203

Reputation: 2 824