|
| 1 | + |
| 2 | +# Libit |
| 3 | + |
| 4 | +[](https://libit.readthedocs.io 'libit documentation') [](https://github.com/pylibit/libit) [](https://github.com/pylibit/libit) [](https://github.com/pylibit/libit) [](https://github.com/pylibit/libit) [](https://pypi.org/project/libit/) [](https://libit.readthedocs.io) |
| 5 | + |
| 6 | +Fast and easy converted and generated utils for bitcoin , ethereum and tron wallet in python |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## install & use |
| 14 | + |
| 15 | +### windows |
| 16 | +```batch |
| 17 | +pip install libit |
| 18 | +``` |
| 19 | +### linux & mac |
| 20 | +```shell |
| 21 | +pip3 install libit |
| 22 | +``` |
| 23 | + |
| 24 | +generated and convert base utils key for wallet information and public , private data |
| 25 | + |
| 26 | +## how to |
| 27 | + |
| 28 | +### bytes to wif |
| 29 | + |
| 30 | +```python |
| 31 | +from libit import bytes_wif |
| 32 | +seed_bytes = b"Bytes data (32 bytes)" |
| 33 | +# wif compressed |
| 34 | +wif_compress = bytes_wif(seed_bytes, True) |
| 35 | +wif_decompress = bytes_wif(seed_bytes) |
| 36 | +``` |
| 37 | +### bytes to address |
| 38 | + |
| 39 | +```python |
| 40 | +from libit import bytes_addr |
| 41 | +seed_bytes = b"Bytes data (32 bytes)" |
| 42 | +# compressed |
| 43 | +caddr = bytes_addr(seed_bytes, True) |
| 44 | +# uncompressed |
| 45 | +uaddr = bytes_addr(seed_bytes) |
| 46 | +``` |
| 47 | + |
| 48 | +### Ethereum address |
| 49 | + |
| 50 | +```python |
| 51 | +import libit |
| 52 | +eth = libit.Ethereum(private_key=private_key) |
| 53 | +# Ethereum Address |
| 54 | +eth_addr = eth.get_address() |
| 55 | +# Ethereum Address Hex |
| 56 | +eth_hash = eth.get_hexAddress() |
| 57 | + |
| 58 | +``` |
| 59 | + |
| 60 | +### Tron |
| 61 | + |
| 62 | +Generate and Converted Private Key to Tron (TRX) Address Wallet + Hex |
| 63 | + |
| 64 | +```python |
| 65 | +import libit |
| 66 | +# Tron |
| 67 | +tron = libit.tron(private_key) |
| 68 | +# Address Wallet |
| 69 | +tron_addr = tron.get_address() |
| 70 | +# TVzMud6edfxrdiyfa6ymEh7huQfWHjtiSK |
| 71 | +# Tron Hex |
| 72 | +tron_hex = tron.get_hexAddress() |
| 73 | +# 41db9a5dc0e70338da631da168f8fe4d503de9c8c5 |
| 74 | +``` |
| 75 | +--- |
| 76 | +### wif to address: |
| 77 | + |
| 78 | +convert wif key to compressed and uncompressed address wallet |
| 79 | + |
| 80 | +```python |
| 81 | +import libit |
| 82 | + |
| 83 | +wif_str = "Wif Data String" |
| 84 | +# compressed |
| 85 | +caddr = libit.wif_addr(wif, True) |
| 86 | +# uncompressed |
| 87 | +uaddr = libit.wif_addr(wif) |
| 88 | +``` |
| 89 | +--- |
| 90 | +### Passphrase |
| 91 | + |
| 92 | +Generated and Convereted Passphrase (string) to Compressed and Uncompressed Bitcoin Address Wallet |
| 93 | + |
| 94 | +```python |
| 95 | +import libit |
| 96 | + |
| 97 | +# Passphrase |
| 98 | +pass_target = "libit" |
| 99 | + |
| 100 | +compressed_address = libit.passphrase_addr(pass_target, True) |
| 101 | +# output: 1MpWosiCM7PYubsi6h1QEgcHPAk3STbyzd |
| 102 | +uncompressed_address = libit.passphrase_addr(pass_target, False) |
| 103 | +# output: 1Dmaa5Rc3nbCq6XyQ7ytK2XTXKuNZqdGzV |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +### Private Key (HEX) |
| 109 | + |
| 110 | +```python |
| 111 | +import libit |
| 112 | + |
| 113 | +private_key = "3e891d92f1c2af69e0f38a354247c4cc99ed39c690649a784b28eeed26a33c60" |
| 114 | + |
| 115 | +# Decimal |
| 116 | +decimal = libit.privatekey_decimal(private_key) |
| 117 | +# Output: 28285658772293776204563833849098122629211544261487479808490805808188778298464 |
| 118 | + |
| 119 | +# Wif Compress and Uncompress |
| 120 | +wif_compress = libit.privatekey_wif(private_key, True) |
| 121 | +# output: KyKGj2ZHFv7atucKxGTTsmyCY5ZoPfanvzPd8Ev6w1SM4saVTss7 |
| 122 | +wif_decompress = libit.privatekey_wif(private_key, False) |
| 123 | +# output: 5JHpyCECqh8PBQFM9tzCXY2rjqcXSymp7LoMsaWhmQfNKAnrt9z |
| 124 | + |
| 125 | +# Bitcoin Address Compress and Uncompress |
| 126 | +btc_compress = libit.privatekey_addr(private_key, True) |
| 127 | +# output: 1EwmhfQhsMsYWSd2VwgmxmcSPjVXuovPVa |
| 128 | +btc_decompress = libit.privatekey_addr(private_key, False) |
| 129 | +# output: 16KuHiP42KTxbPJc3y4DmjToRZXX9ePEyH |
| 130 | + |
| 131 | +# Ethereum Address and Hex Address |
| 132 | +eth = libit.Ethereum(private_key=private_key) |
| 133 | +eth_addr = eth.get_address() |
| 134 | +# output: 0xdb9a5dc0e70338da631da168f8fe4d503de9c8c5 |
| 135 | +eth_hex = eth.get_hexAddress() |
| 136 | +# output: 3e891d92f1c2af69e0f38a354247c4cc99ed39c690649a784b28eeed26a33c60 |
| 137 | + |
| 138 | +# Tron Address and Hex Address (Hash) |
| 139 | +tron = libit.tron(private_key=private_key) |
| 140 | +tron_addr = tron.get_address() |
| 141 | +# output: TVzMud6edfxrdiyfa6ymEh7huQfWHjtiSK |
| 142 | +tron_hex = tron.get_hexAddress() |
| 143 | +# output: 41db9a5dc0e70338da631da168f8fe4d503de9c8c5 |
| 144 | +``` |
| 145 | + |
| 146 | +### Reuse Method |
| 147 | + |
| 148 | +Extract Private Key and Public Key From Transaction ID (hash) for reuse type wallet. |
| 149 | + |
| 150 | +```python |
| 151 | +import libit |
| 152 | +from libit import reuse |
| 153 | + |
| 154 | +r = 0x0861cce1da15fc2dd79f1164c4f7b3e6c1526e7e8d85716578689ca9a5dc349d |
| 155 | +s1 = 0x6cf26e2776f7c94cafcee05cc810471ddca16fa864d13d57bee1c06ce39a3188 |
| 156 | +s2 = 0x4ba75bdda43b3aab84b895cfd9ef13a477182657faaf286a7b0d25f0cb9a7de2 |
| 157 | +z1 = 0x01b125d18422cdfa7b153f5bcf5b01927cf59791d1d9810009c70cd37b14f4e6 |
| 158 | +z2 = 0x339ff7b1ced3a45c988b3e4e239ea745db3b2b3fda6208134691bd2e4a37d6e1 |
| 159 | + |
| 160 | +pvk, pub = reuse.extract_key(r, s1, s2, z1, z2) |
| 161 | +# pvk: e773cf35fce567d0622203c28f67478a3361bae7e6eb4366b50e1d27eb1ed82e |
| 162 | +# pub: eaa57720a5b012351d42b2d9ed6409af2b7cff11d2b8631684c1c97f49685fbb |
| 163 | +# convert private key to bitcoin address |
| 164 | +address = libit.privatekey_addr(pvk, True) |
| 165 | +# output: 1FCpHq81nNLPkppTmidmoHAUy8xApTZ292 |
| 166 | +# (Total Transaction: 8 | Received: 1.56534788 BTC | Total Sent: 1.56534788 BTC) |
| 167 | + |
| 168 | +``` |
| 169 | + |
0 commit comments