0

I already have a an address with Bitcoin and would like to generate a receive address using SHA256 hash which is based on a string.

I've found an example of creating an address using a SHA256 hash:

https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L19

But I haven't found one to create a receive address from a base address using the same method.

closed as unclear what you're asking by Nate Eldredge, Willtech, Dr.Haribo, Andrew Chow Feb 22 '18 at 0:36

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    I don't understand the question. How do you want the new address to be related to the existing one? – Nate Eldredge Feb 9 '18 at 6:06
  • en.bitcoin.it/wiki/… It should just be a one-time use address that is actually part of the base address. – timothyylim Feb 9 '18 at 6:22
  • 1
    I don't know what you mean by "part of". What exactly do you want to be able to do? – Nate Eldredge Feb 9 '18 at 6:27
  • I'm trying to generate a one-time-use address: en.bitcoin.it/wiki/… whose funds will be stored in the main address. – timothyylim Feb 9 '18 at 6:51
2

I think there is some misconception, or we don't get your question right... One cannot create a "receive address" for an existing address. An address is based on a specific private/public key pair. I recommend looking up some fundamentals on wallets and the creation of addresses. A wallet is a collector of many keys, and one of the keys is used for (a generated) receive addresses. I think what you are asking might go into the direction of HD wallets... I provide some hints at the end.

In short, how to come from a string to an address: you have a private key (which can be your hexadecimal string), which is linked by ECDSA logic to a public key. This pubkey is hashed, some version bit and checksum logic, and finally base58 encoded. Look at this page here, it shows the different steps. Also here in stackexchange was a discussion specifically for compressed pubkeys, as the uncompressed keys aren't used widely anymore.

As long as you create many private/public keypairs (based on sha256 and "strings"), you can generate as many addresses as you like, and use one of them as receive address. However keep in mind, that if you generate yourself private/public keypairs, you are running into a trap! The keys need to be based on a certain randomness, and if you don't get it right, you will loose your funds. You have been warned :-)

Andreas' book "Mastering Bitcoin" is an amazing book that'll definitely get you some further insights. It's freely available online here. The chapter 4 on keys and 5 on wallets is what you'd be interested in :-)

0

Use a deterministic wallet like electrum. It'll generate a seed mnemonic of 12 words that you can write down. All the addresses in your wallet are derived from that seed mnemonic. Don't try to generate your own seed. Humans are terrible at creating random numbers and if you make one of your own you will be stolen from. You must let the wallet make one for you.

  • Thank you, but I'm looking to programmatically create receive addresses for an existing address (i.e. not creating a new address from scratch). – timothyylim Feb 9 '18 at 8:43
  • Please see: en.bitcoin.it/wiki/… – timothyylim Feb 9 '18 at 8:43
0

From: https://en.bitcoin.it/wiki/Address#A_Bitcoin_address_is_a_single-use_token

A Bitcoin address is a single-use token

Like e-mail addresses, you can send bitcoins to a person by sending bitcoins to one of their addresses. However, unlike e-mail addresses, people have many different Bitcoin addresses and a unique address should be used for each transaction. Most Bitcoin software and websites will help with this by generating a brand new address each time you create an invoice or payment request.

Your wallet software should (most do) let you create a new receiving address linked to your Private Key. When you receive new Bitcoin on the new receiving address it will show up in your wallet. I think this is what you want.

If you want to create a receiving address yourself from a "string", I would suggest walletgenerator.net. When you open the site, click on skip and then try the Brain Wallet tab. Note that this will let you receive Bitcoin but, in order to see your balance or spend the Bitcoin you will have to import the Private Key into a Bitcoin Wallet. If the Private Key is lost or stolen, your Bitcoin are lost or stolen.

Not the answer you're looking for? Browse other questions tagged or ask your own question.