Author

Topic: Create bitcoin address with python (Read 1352 times)

hero member
Activity: 865
Merit: 1006
December 09, 2016, 04:06:27 AM
#12
I found this fast python (only python 2.7 not 3) address generator:

https://github.com/weex/addrgen

hero member
Activity: 865
Merit: 1006
December 01, 2016, 02:40:25 PM
#11

I know this library, but I do not know how to do the same with it.

I found this code:

Code:
import hashlib
from pycoin import ecdsa, encoding
import os
import codecs

rand = codecs.encode(os.urandom(32), 'hex').decode()
secret_exponent= int('0x'+rand, 0)
print ('WIF: ' + encoding.secret_exponent_to_wif(secret_exponent, compressed=False))
public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
print('Bitcoin address: %s' % encoding.hash160_sec_to_bitcoin_address(hash160))

Awesome... works!

Yes but it is much slower than the other (1/3)

Can you share me some status on much times these are taking

It's easy to check the diference:

Program 1:
Code:
from bitcoin import *
import time

def create_addr():
priv = random_key()
pub = privtopub(priv)
addr = pubtoaddr(pub)
return addr, priv

elapsed_time = time.time()
for a in range(100):
        addr,priv = create_addr()

print ('Total time = ' + str(time.time() - elapsed_time))

Program 2:

Code:
import hashlib
from pycoin import ecdsa, encoding
import os
import codecs
import time

def create_addr():
        priv = codecs.encode(os.urandom(32), 'hex').decode()
        secret_exponent= int('0x'+rand, 0)
        public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
        hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
        addr =  encoding.hash160_sec_to_bitcoin_address(hash160)
return addr, priv

elapsed_time = time.time()
for a in range(100):
        addr,priv = create_addr()

print ('Total time = ' + str(time.time() - elapsed_time))
hero member
Activity: 692
Merit: 569
December 01, 2016, 01:45:29 AM
#10

I know this library, but I do not know how to do the same with it.

I found this code:

Code:
import hashlib
from pycoin import ecdsa, encoding
import os
import codecs

rand = codecs.encode(os.urandom(32), 'hex').decode()
secret_exponent= int('0x'+rand, 0)
print ('WIF: ' + encoding.secret_exponent_to_wif(secret_exponent, compressed=False))
public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
print('Bitcoin address: %s' % encoding.hash160_sec_to_bitcoin_address(hash160))

Awesome... works!

Yes but it is much slower than the other (1/3)

Can you share me some status on much times these are taking
hero member
Activity: 865
Merit: 1006
December 01, 2016, 01:41:02 AM
#9
Any code in c++?
hero member
Activity: 865
Merit: 1006
November 30, 2016, 10:43:10 AM
#8
Some faster library?
hero member
Activity: 865
Merit: 1006
November 28, 2016, 09:13:25 AM
#7

I know this library, but I do not know how to do the same with it.

I found this code:

Code:
import hashlib
from pycoin import ecdsa, encoding
import os
import codecs

rand = codecs.encode(os.urandom(32), 'hex').decode()
secret_exponent= int('0x'+rand, 0)
print ('WIF: ' + encoding.secret_exponent_to_wif(secret_exponent, compressed=False))
public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
print('Bitcoin address: %s' % encoding.hash160_sec_to_bitcoin_address(hash160))

Awesome... works!

Yes but it is much slower than the other (1/3)
hero member
Activity: 692
Merit: 569
November 28, 2016, 08:14:45 AM
#6
moneywagon  also can do this for you

Code:
from moneywagon import generate_keypair
print generate_keypair('btc', 'randomtextwithentropy')
Internally uses https://github.com/petertodd/python-bitcoinlib library.
The Swiss Army Knife of the Bitcoin protocol." - Wladimir J. van der Laan

hero member
Activity: 692
Merit: 569
November 28, 2016, 07:09:20 AM
#5

I know this library, but I do not know how to do the same with it.

I found this code:

Code:
import hashlib
from pycoin import ecdsa, encoding
import os
import codecs

rand = codecs.encode(os.urandom(32), 'hex').decode()
secret_exponent= int('0x'+rand, 0)
print ('WIF: ' + encoding.secret_exponent_to_wif(secret_exponent, compressed=False))
public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
print('Bitcoin address: %s' % encoding.hash160_sec_to_bitcoin_address(hash160))

Awesome... works!
hero member
Activity: 865
Merit: 1006
November 28, 2016, 07:02:05 AM
#4

I know this library, but I do not know how to do the same with it.

I found this code:

Code:
import hashlib
from pycoin import ecdsa, encoding
import os
import codecs

rand = codecs.encode(os.urandom(32), 'hex').decode()
secret_exponent= int('0x'+rand, 0)
print ('WIF: ' + encoding.secret_exponent_to_wif(secret_exponent, compressed=False))
public_pair = ecdsa.public_pair_for_secret_exponent(ecdsa.secp256k1.generator_secp256k1, secret_exponent)
hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True)
print('Bitcoin address: %s' % encoding.hash160_sec_to_bitcoin_address(hash160))
hero member
Activity: 865
Merit: 1006
November 28, 2016, 04:52:05 AM
#3

I know this library, but I do not know how to do the same with it.
hero member
Activity: 692
Merit: 569
hero member
Activity: 865
Merit: 1006
November 26, 2016, 02:49:08 PM
#1
Hello.

Im searching python bitcoin library to create speed bitcoin address (public, private and wif) like:

https://github.com/vbuterin/pybitcointools

And example of code:

Code:
from bitcoin import *

def create_addr():
priv = random_key()
pub = privtopub(priv)
addr = pubtoaddr(pub)
        electrumPKey = encode_privkey(priv, 'wif')
return addr, priv, electrumPKey

addr,priv,electrumPKey = create_addr()


Another code?

Thanks
Jump to: