Skip to content

Efficient script matching #32

@SimoneBronzini

Description

@SimoneBronzini

At the moment ScriptBuilder tries to match scripts by running their verify() method, which in turn tries to both match a script template and return the pushed values (e.g. public key hash, script hash and so on). It would be useful to have a faster way to match script types, for instance having scripts declare fast matching conditions (e.g. P2SH must start with HASH160, followed by a 20-byte push operation, followed by EQUAL) to be used for template matching and verify() logics can be used to return the pushed data once the fast matching succeeds.

To be clear, an example of P2SH efficient matching might be:

def match(script_bytes):
    return all([script_bytes[0] == 169,
                script_bytes[1] == 20,
                script_bytes[-1] == 135,
                len(script_bytes) == 23])

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacktoberfestContribute to our project and win prizes! https://hacktoberfest.digitalocean.com/help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions