fortesp / bitcoinaddress Goto Github PK
View Code? Open in Web Editor NEWBitcoin Wallet Address Generator
Home Page: https://pypi.org/project/bitcoinaddress/
License: MIT License
Bitcoin Wallet Address Generator
Home Page: https://pypi.org/project/bitcoinaddress/
License: MIT License
hash160 (20byte) format is very important and missing from output.
Instead of
Public Address bc1 P2WPKH: bc1qdveuf0egtfdnd2fnsp0lzfukn2e58czf8323ky6xt8ydew4ecfcqv3ettx
Public Address bc1 P2WSH: bc1q2jxe5azr6zmhk3258av7ul6cqtu4eu4mps8f4p
it should be
Public Address bc1 P2WSH: bc1qdveuf0egtfdnd2fnsp0lzfukn2e58czf8323ky6xt8ydew4ecfcqv3ettx
Public Address bc1 P2WPKH: bc1q2jxe5azr6zmhk3258av7ul6cqtu4eu4mps8f4p
Could you help me please
Why all generated address hex start with 00? How to change it to start for example 0000 or 000000
I tried to to change key, address, key, seed but no success for making this change
Hex 160:
00C32DE061453296E71E9E9E9D5636E7E7FEE272C7
00BB9EB37303709E92C7D121F8751ECD97B5D407EB
00DFD584C7534C1B8E0BB41AF2C64DC2EE479A7895
Base58:
1Jo1ixjbSN9nzdavauqFNCsNPMBxANyErF
1J73UcLXkeTYXDq9qycDMwwUf1EVbNgh8Y
1MQXUKHP29jVBq6rrmiQzKv6w1kfcBWtdE
Thank you
This library print the address data very pretty but when you want to use it's API to get some information out of it and get different addresses it become really frustrating..Please review and setup some helper functions to retrieve each address accordingly
I'm looking for to double check some of my python code outputs and find that your outputs for p2wsh doesnt match this sample which I was guided:
https://bc-2.jp/tools/bech32demo/index.html
Could You check your metod for this and explain how there is difference.
Thanks in advance.
Type "help", "copyright", "credits" or "license" for more information.
>>> from bitcoinaddress import Wallet
>>> wallet = Wallet()
Traceback (most recent call last):
File "/usr/lib/python3.10/hashlib.py", line 160, in __hash_new
return _hashlib.new(name, data, **kwargs)
ValueError: [digital envelope routines] unsupported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/wallet.py", line 16, in __init__
self.address = Address.of(self.key)
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/address.py", line 88, in of
address.generate()
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/address.py", line 94, in generate
self.mainnet.generate_publicaddress1()
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/address.py", line 38, in generate_publicaddress1
self.pubaddr1 = self.instance._generate_publicaddress1(Address.MainNet.PREFIX_A,
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/address.py", line 107, in _generate_publicaddress1
m = prefix_a + hash160(p).digest()
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/util.py", line 20, in hash160
return ripemd(hashlib.sha256(v).digest())
File "/home/user/.local/lib/python3.10/site-packages/bitcoinaddress/util.py", line 24, in ripemd
r = hashlib.new('ripemd160')
File "/usr/lib/python3.10/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/usr/lib/python3.10/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name) ```
```
ValueError: unsupported hash type ripemd160
Kernel: 5.15.0-33
Ubuntu 22.04 LTS
OpenSSL: OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
https://www.openssl.org/news/changelog.html
The low-level MD2, MD4, MD5, MDC2, RIPEMD160 and Whirlpool digest functions have been deprecated.
I would need some advice here ?
First thank you so much for the library, really it's big effort from you:
Q1: Where is the wif or wifc for eth {bc1}. your code creates BTC uncompresed and compresed and privatekey for every one
is there is privatekey for bc1 address?
Q2. is this random number can bring real existing BTC address with balance ?
Q3. how can I have your package 2 time inside my pc. I need to edit the library files and keep original one?
Thank you again
Best Regards,
Hi,
first of all, thank you very much for your job, It's fantastic.
Is it possible to use Wallet() with a defined private key in string format?
Can you provide a quickly example for this?
Thank you in advance.
First of all, thank you for sharing this library.
I noticed that the __init__
method of the Key
class does not store the optionally passed seed
value as an instance variable:
bitcoinaddress/bitcoinaddress/key.py
Line 12 in b7f4385
Also, the generate()
method does not try to use self.seed
in case it was defined upon instantiation.
Consequently, when you do:
key = Key('some seed')
key.generate()
It will generate from a random seed instead of the value passed upon instantiation. For example here:
bitcoinaddress/bitcoinaddress/wallet.py
Line 11 in b7f4385
To work, it would need to look like this (currently):
key = Key()
key.generate('some seed')
(Unrelated: it would be interesting if the Address
class would provide convenience functions to convert one format to another without having a private key. The use case would be: I have a bc1 address and want to know its base58 version starting with 1 etc. This means one can have an Address
instance without having a private key, but at least one version of the public key.)
I get an error. What am I doing wrong?
from bitcoinaddress import Wallet
priv = "KwLdv6T2jmhQbswnYrcL9KZHerTpVyjozp1JNjfP5QuD3GchCwCc"
wallet = Wallet(priv)
print(wallet)
Cloned and just running the example immediately fails:
In [11]: from bitcoinaddress import Wallet
AttributeError Traceback (most recent call last)
in
----> 1 wallet = Wallet()
/usr/lib/python3.9/site-packages/bitcoinaddress/wallet.py in init(self, hash_or_seed, testnet)
13 def init(self, hash_or_seed=None, testnet=False):
14 if hash_or_seed is None: hash_or_seed = Seed()
---> 15 self.key = Key.of(hash_or_seed)
16 self.address = Address.of(self.key)
17 self.testnet = testnet
/usr/lib/python3.9/site-packages/bitcoinaddress/key/key.py in of(obj)
57 key = Key()
58 if isinstance(obj, Seed):
---> 59 key._from_seed(obj)
60 else:
61 try:
/usr/lib/python3.9/site-packages/bitcoinaddress/key/key.py in _from_seed(self, seed)
77 self._generate_digest()
78 self._generate_hex()
---> 79 self.mainnet.generate_wif()
80 self.mainnet.generate_wif_compressed()
81 self.testnet.generate_wif()
/usr/lib/python3.9/site-packages/bitcoinaddress/key/key.py in generate_wif(self)
28
29 def generate_wif(self):
---> 30 self.wif = self.instance._generate_wif(Key.MainNet.PREFIX)
31
32 def generate_wif_compressed(self):
/usr/lib/python3.9/site-packages/bitcoinaddress/key/key.py in _generate_wif(self, prefix)
110 digest = prefix + self.digest
111 c = checksum(digest)
--> 112 return base58.b58encode(digest + c).decode('utf-8')
113
114 def _generate_wif_compressed(self, prefix, suffix):
AttributeError: 'str' object has no attribute 'decode'
How to get an address in txt with a view
address
private key?
Good day,
would you mind providing a small example, how do I generate all possible BTC public addresses (P2PKH, P2SH, Bech32) using existing WIF private key, in string format?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.