Beispiel #1
0
 def getnewsubaccount(self):
     key = CKey()
     key.generate()
     private_key = key.get_privkey()
     public_key = key.get_pubkey()
     address = pubkey_to_address(public_key)
     return {"address": address, "public_key": public_key, "private_key": private_key, "balance": 0.0, 'height' : 0, 'received' : []}
Beispiel #2
0
 def getnewsubaccount(self):
     key = CKey()
     key.generate()
     private_key = key.get_privkey()
     public_key = key.get_pubkey()
     address = pubkey_to_address(public_key)
     print "Address: ", address
     print "Private key: ", type(private_key), private_key
     print "Public key: ", type(public_key), public_key
     return {"address": address, "public_key": public_key, "private_key": private_key, "balance": 0.0, 'height' : 0, 'received' : []}
Beispiel #3
0
 def getnewsubaccount(self):
     key = CKey()
     key.generate()
     private_key = key.get_privkey()
     public_key = key.get_pubkey()
     address = pubkey_to_address(public_key)
     return {
         "address": address,
         "public_key": public_key,
         "private_key": private_key,
         "balance": 0.0,
         'height': 0,
         'received': []
     }
Beispiel #4
0
def getnewaddress():
    # Generate public and private keys
    key = Key()
    key.generate()
    key.set_compressed(True)
    private_key = key.get_privkey()
    public_key = key.get_pubkey()
    private_key_hex = private_key.encode('hex')
    public_key_hex = public_key.encode('hex')
    public_key_bytearray = bytearray.fromhex(public_key_hex)
    # Perform SHA-256 and RIPEMD-160 hashing on public key
    hash160_address = myhash160(public_key_bytearray)
    # add version byte: 0x00 for Main Network
    extended_address = '\x00' + hash160_address
    # generate double SHA-256 hash of extended address
    hash_address = myhash(extended_address)
    # Take the first 4 bytes of the second SHA-256 hash. This is the address checksum
    checksum = hash_address[:4]
    # Add the 4 checksum bytes from point 7 at the end of extended RIPEMD-160 hash from point 4. This is the 25-byte binary Bitcoin Address.
    binary_address = extended_address + checksum
    # Convert the result from a byte string into a base58 string using Base58Check encoding.
    address = encode(binary_address)
    return public_key, private_key, address
Beispiel #5
0
def getnewaddress():
    # Generate public and private keys
    key = Key()
    key.generate()
    key.set_compressed(True)
    private_key = key.get_privkey()
    public_key = key.get_pubkey()
    private_key_hex = private_key.encode('hex')
    public_key_hex = public_key.encode('hex')
    public_key_bytearray = bytearray.fromhex(public_key_hex)
    # Perform SHA-256 and RIPEMD-160 hashing on public key
    hash160_address = myhash160(public_key_bytearray)
    # add version byte: 0x00 for Main Network
    extended_address = '\x00' + hash160_address
    # generate double SHA-256 hash of extended address
    hash_address = myhash(extended_address)
    # Take the first 4 bytes of the second SHA-256 hash. This is the address checksum
    checksum = hash_address[:4]
    # Add the 4 checksum bytes from point 7 at the end of extended RIPEMD-160 hash from point 4. This is the 25-byte binary Bitcoin Address.
    binary_address = extended_address + checksum
    # Convert the result from a byte string into a base58 string using Base58Check encoding.
    address = encode(binary_address)
    return public_key, private_key, address
Beispiel #6
0
    return hashlib.sha256(hashlib.sha256(s).digest()).digest()


def MyHash160(s):
    h = hashlib.new('ripemd160')
    h.update(hashlib.sha256(s).digest())
    return h.digest()


# Generate public and private keys
key = Key()
# key.set_privkey(0x18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725)
# key.set_pubkey(bytearray.fromhex("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6"))
key.generate()
key.set_compressed(True)
private_key = key.get_privkey()
public_key = key.get_pubkey()
secret = key.get_secret()
private_key_hex = private_key.encode('hex')
public_key_hex = public_key.encode('hex')
secret_hex = binascii.hexlify(secret)
print "Private key: ", private_key_hex
print "Public key: ", public_key_hex
print "secret    : ", secret_hex

public_key = bytearray.fromhex(public_key_hex)
# public_key = bytearray.fromhex("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6")

# Perform SHA-256 and RIPEMD-160 hashing on public key
hash160_address = MyHash160(public_key)
Beispiel #7
0
def MyHash(s):
    return hashlib.sha256(hashlib.sha256(s).digest()).digest()

def MyHash160(s):
    h = hashlib.new('ripemd160')
    h.update(hashlib.sha256(s).digest())
    return h.digest()
    
# Generate public and private keys
key = Key()
# key.set_privkey(0x18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725)
# key.set_pubkey(bytearray.fromhex("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6"))
key.generate()
key.set_compressed(True)
private_key = key.get_privkey()
public_key = key.get_pubkey()
secret = key.get_secret()
private_key_hex = private_key.encode('hex')
public_key_hex = public_key.encode('hex')
secret_hex = binascii.hexlify(secret)
print "Private key: ", private_key_hex
print "Public key: ", public_key_hex
print "secret    : ", secret_hex

public_key = bytearray.fromhex(public_key_hex)
# public_key = bytearray.fromhex("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6")

# Perform SHA-256 and RIPEMD-160 hashing on public key
hash160_address = MyHash160(public_key)
Beispiel #8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import paperwallet
import paperwallet.util

from bitcoin.key import CKey

k = CKey()
k.generate()
k.set_compressed(False)

public_key = paperwallet.util.public_key_to_bc_address(k.get_pubkey())
private_key = \
    paperwallet.util.private_key_to_wallet_import_format(k.get_privkey())

pw = paperwallet.PaperWallet(sys.argv[1], sys.argv[2], public_key,
                             private_key)
pw.save('bar.png')