Skip to content

Commit

Permalink
Adding get_address function
Browse files Browse the repository at this point in the history
  • Loading branch information
dbscooper authored Apr 12, 2023
1 parent 82d17c1 commit f3ed39e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bitcoin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ def create_wallet():
address = P2PKHBitcoinAddress.from_pubkey(secret.pub)
return str(address), str(secret)

def get_address(secret):
"""
Get the associated Bitcoin address from the secret key.
Args:
secret (str): The secret key for the Bitcoin address.
Returns:
str: The associated Bitcoin address.
"""
secret_key = CBitcoinSecret(secret)
address = P2PKHBitcoinAddress.from_pubkey(secret_key.pub)
return str(address)

def get_balance(address):
url = f'https://blockchain.info/q/addressbalance/{address}?confirmations=6'
Expand Down

0 comments on commit f3ed39e

Please sign in to comment.