Bug in bitcoin.py?
See original GitHub issue#932 just got reported by the crash reporter.
Here is the relevant code (this is from ios newwallet.py):
def _ImportItemify(item : str) -> ImportItem:
item = item.strip()
info = None
typ = 0
if Address.is_valid(item):
typ = 1
info = Address.from_string(item)
item = item.split(':')[-1]
elif bitcoin.is_private_key(item):
typ = 2
try:
info = PublicKey.from_WIF_privkey(item).address
except ValueError:
# Not an address, not a PK
info, typ = None, 0
return ImportItem(item, typ, info)
The ~try...catch
~try...except
clause at the end is new (to handle the exception).
Notice how I ask the library “is_private_key”? And it returns true. Yet later on PublicKey.from_WIF_privkey(item).address
raises an exception.
Any reasonable library shouldn’t answer “yes” to a question to which the answer is “no”.
Or… PublicKey.from_WIF_privkey
has bugs. Can’t tell which.
Thoughts?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
'High' Severity Bug in Bitcoin Software Revealed 2 Years After ...
A previously undisclosed bug in Bitcoin Core could have let attackers steal Lightning Network funds, delay transfers or split the network ...
Read more >bitcoin.params [bug]? · Issue #142 · petertodd/python-bitcoinlib
This has been a strange issue for me, as well, affecting me only when doing some tinkering though an interpreter. Does this continue...
Read more >Bitcoin Core Bug CVE-2018–17144: An Analysis | HackerNoon
It turns out that for the bug, (A) is not a possible attack vector as those transactions are immediately marked as invalid and...
Read more >Value overflow incident - Bitcoin Wiki
The bad transaction no longer exists for people using the longest chain. Therefore, the bitcoins created by it do not exist either. While...
Read more >The Inflation Bug Backport & Python ~ Bitcoin Op Tech #15
The Bitcoin Operations Technology Group (Optech) works to bring the best open source technologies and techniques to Bitcoin -using businesses ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thoughts are that this hides a problem and makes it a) impossible to track down b) adds technical debt.
I suggest we let it continue to happen, and if we make any changes we do so in a way that raises an alternate exception with extra context, and then iterate on that letting it continue to happen until the problem goes away.
A problem with the crash reporting is that it pressures us to fix things with only superficial information. Better to take a iterative approach rather than slapping a band-aid over something and ignoring it IMO.
Ok well never mind. Bitcoin.py was ok, if lacking in comments.
Closing issue. All is right.