question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
rt121212121commented, Nov 14, 2018

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.

0reactions
cculianucommented, Nov 14, 2018

Ok well never mind. Bitcoin.py was ok, if lacking in comments.

Closing issue. All is right.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found