How can I generate a bitcoin address?

2

Is there any way to generate bitcoin addresses other than the Blockchain API? (given the fact that it is not public)

Coup de Grace

Posted 2013-12-02T12:53:18.847

Reputation: 337

Answers

1

I wrote a long and detailed tutorial on it http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript

In short, scroll all the way down to the summary to see this short version:

var randArr = new Uint8Array(32) //create a typed array of 32 bytes (256 bits)
window.crypto.getRandomValues(randArr) //populate array with cryptographically secure random numbers

//some Bitcoin and Crypto methods don't like Uint8Array for input. They expect regular JS arrays.
var privateKeyBytes = []
for (var i = 0; i < randArr.length; ++i)
  privateKeyBytes[i] = randArr[i]

var eckey = new Bitcoin.ECKey(privateKeyBytes)
eckey.compressed = true
var address = eckey.getBitcoinAddress().toString()
console.log(address)// 1FkKMsKNJqWSDvTvETqcCeHcUQQ64kSC6s

var privateKeyBytesCompressed = privateKeyBytes.slice(0) //clone array
privateKeyBytesCompressed.push(0x01)
var privateKeyWIFCompressed = new Bitcoin.Address(privateKeyBytesCompressed)
privateKeyWIFCompressed.version = 0x80
privateKeyWIFCompressed = privateKeyWIFCompressed.toString()

Open up the JavaScript console on the page (in your browser) and follow along. You can create your very own address right there in the browser. I wouldn't recommend using this newly created address to actually conduct commerce. Just use it as an academic exercise.

JP Richardson

Posted 2013-12-02T12:53:18.847

Reputation: 256

I wouldn't recommend using this newly created address to actually conduct commerce. Just use it as an academic exercise. Why do you say that? Are there any risks associated with this method (as I intend to use it for generating personal cold-storage keys)Albert Renshaw 2017-11-30T22:46:57.030

Yes, generating a private key in the browser where other scripts/plugins may have access to the keys puts your money at risk.JP Richardson 2017-12-02T11:31:56.013

Gotcha, but I can use my own personal Javascript IDE or something just fine. Just wanted to make sure there wasn't a potential risk with the code itself (as opposed to the environment) Thanks for clarificationAlbert Renshaw 2017-12-02T12:06:10.603

1

There are a number of sample programs here: https://bitcointalk.org/index.php?topic=1026.0

Also see the wiki for the step-by-step algorithm for generating a valid address.

Neil Neyman

Posted 2013-12-02T12:53:18.847

Reputation: 598

0

There are plenty of very easy-to-use tools that can generate addresses for you, the exact process is detailed in the Bitcoin wiki.

Some examples of such tools are:

Steven Roose

Posted 2013-12-02T12:53:18.847

Reputation: 10 855

-3

Coinbase Your wallet on Coinbase is a collection of bitcoin addresses. New bitcoin addresses are automatically generated for each payment on Coinbase and stay associated with your account forever (so it is safe to reuse them).

user9933

Posted 2013-12-02T12:53:18.847

Reputation: 1

I meant programatically, that's why I mentioned the blockchain API. And here you are giving me your "referral" link to coinbase.Coup de Grace 2013-12-02T20:40:37.637