0% found this document useful (0 votes)
19 views2 pages

Bitcoin Address Generation

The document contains Python code for generating Bitcoin private and public keys, creating a multi-signature address, and viewing transaction history for a specific Bitcoin address. It also includes functionality to fetch Bitcoin prices in various currencies and convert a specified amount into Bitcoin. Additionally, the code retrieves details about a specific block and the latest block in the Bitcoin blockchain.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Bitcoin Address Generation

The document contains Python code for generating Bitcoin private and public keys, creating a multi-signature address, and viewing transaction history for a specific Bitcoin address. It also includes functionality to fetch Bitcoin prices in various currencies and convert a specified amount into Bitcoin. Additionally, the code retrieves details about a specific block and the latest block in the Bitcoin blockchain.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# import bitcoin

from bitcoin import *

# Create Private Keys

my_private_key1 = random_key()

my_private_key2 = random_key()

my_private_key3 = random_key()

print("Private Key1: %s" % my_private_key1)

print("Private Key2: %s" % my_private_key2)

print("Private Key3: %s" % my_private_key3)

print('\n')

# Create Public keys

my_public_key1 = privtopub(my_private_key1)

my_public_key2 = privtopub(my_private_key2)

my_public_key3 = privtopub(my_private_key3)

print("Public Key1: %s" % my_public_key1)

print("Public Key2: %s" % my_public_key2)

print("Public Key3: %s" % my_public_key3)

print('\n')

# Create Multi-signature address

my_multi_sig = mk_multisig_script(my_private_key1, my_private_key2, my_private_key3, 2,3)

my_multi_address = scriptaddr(my_multi_sig)

print("Multi signature address: %s" % my_multi_address)

Bitcoin Address Transaction History

# import bitcoin

from bitcoin import *

#View address transaction history

a_valid_bitcoin_address =

'329e5RtfraHHNPKGDMXNxtuS4QjZTXqBDg'

print(history(a_valid_bitcoin_address))
# Bitcoin Price in Various currencies

# import blockchain library

from blockchain import exchangerates

# get the Bitcoin rates in various currencies

ticker = exchangerates.get_ticker()

# print the Bitcoin price for every currency

print("Bitcoin Prices in various currencies:")

for k in ticker:

print(k, ticker[k].p15min)

# Getting Bitcoin value for a particular amount and currency

btc = exchangerates.to_btc('EUR', 100)

print("\n100 euros in Bitcoin: %s " % btc)

# import blockchain library

from blockchain import blockexplorer

# get a particular block

block = blockexplorer.get_block('0000000000000000002e90b284607359f341564762644

7643b9b880ee00e41fa')

print("Block Fee: %s\n" % block.fee)

print("Block size: %s\n" % block.size)

print("Block transactions: %s\n" % block.transactions)

# get the latest block

block = blockexplorer.get_latest_block()

You might also like