Skip to content

Commit

Permalink
Updated README; Version bump; Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fortesp committed Jan 5, 2021
1 parent 1e59f7d commit 4b6d755
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 57 deletions.
137 changes: 82 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Bitcoin Address
### v.0.1.3
# Bitcoin Address

### v.0.1.4

Bitcoin Wallet Address Generator

This is a simple Bitcoin non-deterministic wallet address generator coded in Python 3.
It generates a Private Key in different formats (hex, wif and compressed wif) and corresponding Public Addresses, raw, P2WPKH addresses starting with prefix 1, P2SH addresses starting with prefix 3 as part of Segwit soft fork and Bech32 addresses with prefix bc1 P2WPKH and P2WSH.
This is a simple Bitcoin non-deterministic wallet address generator coded in Python 3. It generates a Private Key in different
formats (hex, wif and compressed wif) and corresponding Public Addresses, raw, P2WPKH addresses starting with prefix 1, P2SH addresses
starting with prefix 3 as part of Segwit soft fork and Bech32 addresses with prefix bc1 P2WPKH and P2WSH.

## Installation

```
pip install bitcoinaddress
```

## Usage
###### Example 1

###### Example 1 - Mainnet

```python
from bitcoinaddress import Wallet

Expand All @@ -20,70 +26,91 @@ print(wallet)
```

###### Output:

```
Private Key HEX: c2814c56793485f803430ef28ea93ba34e1dc74a74cead43407378350a958792
Private Key WIF: 5KHwxCT8Nrb3MSiQRS5h6fqmAJWrXzi9min15xSzY1EuR3EgLHT
Private Key WIF compressed: L3joYdYKZTsFPEVkNqhhz2SDv4JmdoidiPPdNsjiwr4NLr31PkqK
Private Key WIF (TESTNET): 934aXwGfy5fBKWDh3mybyGPioxsZhAFM7fdxAaoVsjyxC7vYTv3
Private Key WIF compressed (TESTNET): cU6o1YYAzXZWYfy1mFWqMLwHYHcBJFpKnRY6VJCESxiNbbCpd33r
Public Key: 04a0a7d1d00d970b0be7594b5ab12f930d8275156e2d66f92d39525a44c339aff0fb02568075a8928e9f8a865f0e9633482cf8e5b3bb27c8a7279e9afbc06f9072
Public Key compressed: 02a0a7d1d00d970b0be7594b5ab12f930d8275156e2d66f92d39525a44c339aff0
Public Address 1: 1FdqdaXsPTdzHY83NLpue33S2pW1joXcWr
Public Address 3: 3ExX4G6qPBDbMpQH6h1Ka7g26322JQtUfd
Public Address bc1 P2WSH: bc1q27qee3seastzzqgqvyrglj763sw69rymd2m3hv4ph6u7fx2g8a6skzcqer
Public Address bc1 P2WPKH: bc1qv2m5c60h0vnjjuyefwlczla85ctjuev0q4uqkt
Public Address 1 (TESTNET): mv9nvdcrCV5F4ebf5uoHTxFktp6ig1jKtv
Public Address 3 (TESTNET): 2N6Wj812rzdiwZc2pmpdCC4fHJPEC6YyLL4
Public Address tb1 P2WSH (TESTNET): tb1q27qee3seastzzqgqvyrglj763sw69rymd2m3hv4ph6u7fx2g8a6sp2w0rv
Public Address tb1 P2WPKH (TESTNET): tb1qv2m5c60h0vnjjuyefwlczla85ctjuev02n8ndc
Private Key HEX: 03902e4f09664bc177fe4e090dcd9906b432b50f15fb6151984475c1c75c35b6
Private Key WIF: 5HqrbgkWPqBy6dvCE7FoUiMuiCfFPRdtRsyi6NuCM2np8qBZxq5
Private Key WIF compressed: KwLdv6T2jmhQbswnYrcL9KZHerTpVyjozp1JNjfP5QuD3GchCwCc
Public Key: 04c5389a31ce6149c28ba20d14db8540b2319e5a65000a2919fbf7a6296e7840b53f883a9483fb7f2b43f3eacd857c904d1b70ecc168571b64d8f1ab82b57eea88
Public Key compressed: 02c5389a31ce6149c28ba20d14db8540b2319e5a65000a2919fbf7a6296e7840b5
Public Address 1: 1Bu6YxH64nfvhdDsYNEP8PftoBMqgusdPS
Public Address 1 compressed: 18i5PtPisxbGiGGEviW7HPcnfNPmcsscwH
Public Address 3: 38dRrGx5YbrnRWuWcJv5i2XHjYUnHE2wvv
Public Address bc1 P2WPKH: bc1qdveuf0egtfdnd2fnsp0lzfukn2e58czf8323ky6xt8ydew4ecfcqv3ettx
Public Address bc1 P2WSH: bc1q2jxe5azr6zmhk3258av7ul6cqtu4eu4mps8f4p
```

###### Example 2
```python
from bitcoinaddress import Address, Key
###### Example 2 - Testnet

key = Key()
key_dict = key.generate()
print(key_dict)
```python
from bitcoinaddress import Wallet

address = Address(key)
address_dict = address.generate()
print(address_dict)
wallet = Wallet(testnet=True)
print(wallet)
```

###### Output:

```
Private Key HEX: 064f8f0bebfa2f65db003b56bc911535614f2764799bc89091398c1aed82e884
Private Key WIF: 91dhN38UTmqGtd3zG1GnDdnyivAP5LnWJQyyj7V7pqthirHAj4X
Private Key WIF compressed: cMny9rPzDAt58r8BjECeamPwN1eQSAKrKrrVNsd78AoCjcWxuVym
Public Key: 04f7a01e30388dea9673db8cdb48b985441db785382efbcecc05abac079a6304818a907f886b0d0518e345a0288a6f1e09072f2b11d4ccb75bc67ec6c71dfef800
Public Key compressed: 02f7a01e30388dea9673db8cdb48b985441db785382efbcecc05abac079a630481
Public Address 1: mwdHSyBBHMbcy8rogvzssvDrGyffRo3amQ
Public Address 1 compressed: n4VzeGfAyZGR7xCXiKmABvnKXojTFJrmKH
Public Address 3: 2MtJ3jPSD2AYgbF25fq9cm1aUCPhSmWUMcJ
Public Address bc1 P2WPKH: tb1qp53qkcsth8ffuvr00cnlg5hde03aszzeq7y0layklhd4nwkxzejs99tlh3
Public Address bc1 P2WSH: tb1qlsw8qqe2aa2avzn9t9nsfjy8kwwgarwcfvfqlh
```

###### Example 3 - Import Private Key

```python
from bitcoinaddress import Wallet

wallet = Wallet('5HqrbgkWPqBy6dvCE7FoUiMuiCfFPRdtRsyi6NuCM2np8qBZxq5')
print(wallet)
```
{'hex': '669182eb2c3169e01cfc305034dc0b1df8328c274865e70d632c711ba62ec3d3',
'wif': '5JbTZ4zCTn1rwCfdkPWLddFgqzieGaG9Qjp3iRhf7R8gNroj4KM',
'wifc': 'Kzf6CYbTbBgoQEVXCWLVef1psFkoVjor7mxeyr2TDKWto7iHfXHh',
'testnet': {
'hex': '669182eb2c3169e01cfc305034dc0b1df8328c274865e70d632c711ba62ec3d3',
'wif': '92N68ook415zuGAvNjQFWDoeVf5MRjoLkgfzo44AT9sj9qhLBkU',
'wifc': 'cR25fTbK2FP4Zfxnav9d1yWtVV4DABuYBp786GUxiSAu3rpq6gkk'}}
{'pubkey': '04e61341f46b529b0fac2c5e15a67af7affceb2be7544af18d14206fff041c02c04d6ca36c97f458cfe5754ce15a8f32d4c917b5f0f5e336042ee3be77c3f58222',
'pubkeyc': '02e61341f46b529b0fac2c5e15a67af7affceb2be7544af18d14206fff041c02c0',
'pubaddr1': '1NaChZV4JJysct8QYcMKFHnQ2SNFpnBund',
'pubaddr3': '34QhdWUjZjv3HLyvNYgb4AR7ikAfcdzfCW',
'pubaddrbc1_p2wsh': 'bc1qup6umurcl7s6zw42gcxfzl346psazws74x72ty6gmlvkaxz6kv4sqsth99',
'pubaddrbc1_p2wpkh': 'bc1qsnwc0y43fpljyl2ep0e2gtsqa55utcj4ntzwlf',
'testnet': {
'pubkey': '04e61341f46b529b0fac2c5e15a67af7affceb2be7544af18d14206fff041c02c04d6ca36c97f458cfe5754ce15a8f32d4c917b5f0f5e336042ee3be77c3f58222',
'pubkeyc': '02e61341f46b529b0fac2c5e15a67af7affceb2be7544af18d14206fff041c02c0',
'pubaddr1': 'n369zca37LR8Pzc2GBKh5CzitRxxhkHDhK',
'pubaddr3': '2MuxuhFQmBCRPV8cU3gJTg7QNw6NqTuUm2A',
'pubaddrbc1_p2wsh': 'tb1qup6umurcl7s6zw42gcxfzl346psazws74x72ty6gmlvkaxz6kv4shcacl2',
'pubaddrbc1_p2wpkh': 'tb1qsnwc0y43fpljyl2ep0e2gtsqa55utcj4edeay6'}}

###### Output:

```
Private Key HEX: 03902e4f09664bc177fe4e090dcd9906b432b50f15fb6151984475c1c75c35b6
Private Key WIF: 5HqrbgkWPqBy6dvCE7FoUiMuiCfFPRdtRsyi6NuCM2np8qBZxq5
Private Key WIF compressed: KwLdv6T2jmhQbswnYrcL9KZHerTpVyjozp1JNjfP5QuD3GchCwCc
Public Key: 04c5389a31ce6149c28ba20d14db8540b2319e5a65000a2919fbf7a6296e7840b53f883a9483fb7f2b43f3eacd857c904d1b70ecc168571b64d8f1ab82b57eea88
Public Key compressed: 02c5389a31ce6149c28ba20d14db8540b2319e5a65000a2919fbf7a6296e7840b5
Public Address 1: 1Bu6YxH64nfvhdDsYNEP8PftoBMqgusdPS
Public Address 1 compressed: 18i5PtPisxbGiGGEviW7HPcnfNPmcsscwH
Public Address 3: 38dRrGx5YbrnRWuWcJv5i2XHjYUnHE2wvv
Public Address bc1 P2WPKH: bc1qdveuf0egtfdnd2fnsp0lzfukn2e58czf8323ky6xt8ydew4ecfcqv3ettx
Public Address bc1 P2WSH: bc1q2jxe5azr6zmhk3258av7ul6cqtu4eu4mps8f4p
```

###### Example 4 - Check attributes

```python
from bitcoinaddress import Wallet

wallet = Wallet()
print(wallet.key.__dict__)
print(wallet.key.__dict__['mainnet'].__dict__)
print(wallet.key.__dict__['testnet'].__dict__)
print(wallet.address.__dict__)
print(wallet.address.__dict__['mainnet'].__dict__)
print(wallet.address.__dict__['testnet'].__dict__)
```

## License and other
This software is distributed under the terms of the MIT License.
See the file 'LICENSE' in the root directory of the present distribution, or http://opensource.org/licenses/MIT.

This software is distributed under the terms of the MIT License. See the file 'LICENSE' in the root directory of the present
distribution, or http://opensource.org/licenses/MIT.

Bech32 address scripts source from https://github.com/sipa/bech32/tree/master/ref/python
3 changes: 2 additions & 1 deletion bitcoinaddress/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class Wallet:

def __init__(self, hash_or_seed=None, testnet=False):
if hash_or_seed is None: hash_or_seed = Seed()
self.key = Key.of(hash_or_seed)
self.address = Address.of(self.key)
self.testnet = testnet
Expand All @@ -21,5 +22,5 @@ def __str__(self):


if __name__ == "__main__":
wallet = Wallet(Seed())
wallet = Wallet()
print(wallet)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setuptools.setup(
name="bitcoinaddress",
version="0.1.3",
version="0.1.4",
author="Pedro Fortes",
author_email="[email protected]",
description="A simple Bitcoin address generator",
Expand Down

0 comments on commit 4b6d755

Please sign in to comment.