Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficient script matching #32

Open
SimoneBronzini opened this issue Mar 24, 2018 · 0 comments
Open

Efficient script matching #32

SimoneBronzini opened this issue Mar 24, 2018 · 0 comments
Labels
hacktoberfest Contribute to our project and win prizes! https://hacktoberfest.digitalocean.com/ help wanted

Comments

@SimoneBronzini
Copy link
Contributor

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])
@SimoneBronzini SimoneBronzini added the hacktoberfest Contribute to our project and win prizes! https://hacktoberfest.digitalocean.com/ label Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Contribute to our project and win prizes! https://hacktoberfest.digitalocean.com/ help wanted
Projects
None yet
Development

No branches or pull requests

1 participant