Skip to content

ENH: Resolve conflicts in the case mentioned in the description #35

Description

@Shashankss1205

Heuristic vs. Actual Return Value

Why to use heuristic, if we can directly see the method actual return value?

It's possible to find the actual return value. To do this, the tool would need to:

  1. See the call P2shAddress.from_script.
  2. Use the imports_map to find the file where P2shAddress is defined (e.g., /path/to/bitcoinutils/keys.py).
  3. Pause its current work, open and parse keys.py into a new AST.
  4. Search that new AST for the ClassDef named P2shAddress.
  5. Search within that class for the FunctionDef named from_script.
  6. Analyze the code inside from_script to find its return statement(s) and determine what type is being returned (e.g., by seeing return cls(...)).

This is a much more complex and "heavy" operation than simply analyzing one file at a time. The "heuristic" (ClassName.method() likely returns an instance of ClassName) is a lightweight shortcut. It's not 100% accurate (a method could return something else), but it's extremely fast and covers the vast majority of real-world object-oriented code.

Reproducible by cloning python-bitcoin-utils and analyzing the file 'create_p2sh_csv_p2pkh_address.py'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions