> For the complete documentation index, see [llms.txt](https://guide.mmdrza.com/guidelines/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.mmdrza.com/guidelines/cryptofuzz/private-key-to-bitcoin.md).

# Private Key To Bitcoin

### Generating Bitcoin Addresses with Cryptofuzz

This example demonstrates generating various types of Bitcoin addresses using the <mark style="color:yellow;">`cryptofuzz`</mark> library in Python, utilizing a specific private key. The process results in addresses that support different transaction protocols and optimizations.

#### Implementing Address Generation

The script below initializes a Bitcoin object and generates four types of addresses: P2PKH, P2SH, P2WPKH, and P2WSH, based on the provided private key.

```python
from cryptofuzz import Bitcoin
private_key = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"

# Initialize Bitcoin class
btc = Bitcoin()

# Generate addresses
p2pkh = btc.hex_addr(private_key, "p2pkh")
p2sh = btc.hex_addr(private_key, "p2sh")
p2wpkh = btc.hex_addr(private_key, "p2wpkh")
p2wsh = btc.hex_addr(private_key, "p2wsh")

# Print addresses
print(p2pkh)
print(p2sh)
print(p2wpkh)
print(p2wsh)
```

#### Generated Addresses Overview

In the Python script above, we successfully generated different types of Bitcoin addresses using a specific private key (`0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef`) via the `cryptofuzz` library. The resulting addresses for each type are as follows:

* **P2PKH (Pay to Public Key Hash):** <mark style="color:orange;">`1M8Qk46ERsPrEtWLBRSET5NUH2Ck5wwREU`</mark>
* **P2SH (Pay to Script Hash):** <mark style="color:orange;">`34omeRgNLiDqbP7BTdVUSGoPBoFKy3BX44`</mark>
* **P2WPKH (Pay to Witness Public Key Hash):** <mark style="color:orange;">`bc1qmnyn7x24xj6vraxeeq56dfkxa009tvhgqffstc`</mark>
* **P2WSH (Pay to Witness Script Hash):** <mark style="color:orange;">`bc1qgahjmt5vkm8wkv70adwyrvw9qy22cygafc7h9nur9nfk8gj6dc3s3v24wf`</mark>

Each address type serves different purposes regarding transaction efficiency, fee cost, and security measures, providing various choices for Bitcoin wallet operations.
