Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Add p2ms as a recognized standard script type. #49

Open
wardlem opened this issue Feb 14, 2019 · 5 comments
Open

Add p2ms as a recognized standard script type. #49

wardlem opened this issue Feb 14, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@wardlem
Copy link
Collaborator

wardlem commented Feb 14, 2019

No description provided.

@wardlem wardlem added the enhancement New feature or request label Feb 14, 2019
@wardlem wardlem added this to the v1.1.0 milestone Feb 14, 2019
@wardlem
Copy link
Collaborator Author

wardlem commented Feb 16, 2019

This PR requires a consideration of what a templating ASM syntax should look like. Currently, it looks like OP_HASH160 <20-byte-script-hash> OP_EQUAL. The template processor sees that the script begins with 20-byte and enforces that the push_data value is 20 bytes. This works ok, though it isn't perfect. The templating language currently doesn't support opcode parameters, which are required in a p2ms template (for m and n). For this, I was considering <OP_1-OP_16> and it would see that it expects an op within that range. The public keys also need to be repeated, and this needs a syntax. I was considering, for the public keys <33-byte-public-key...> where the ... indicates repetition.

I am not sold on any of these choices.

@JBaczuk
Copy link
Owner

JBaczuk commented Feb 18, 2019

Can you explain how this would be used/exposed? Or maybe what you mean by templating syntax. I'm trying to figure out when I would want to type <20-byte-script-hash> instead of the actual hash.

@wardlem wardlem added the needs discussion For issues that require further discussion label Feb 23, 2019
@wardlem
Copy link
Collaborator Author

wardlem commented Feb 23, 2019

Can you explain how this would be used/exposed? Or maybe what you mean by templating syntax. I'm trying to figure out when I would want to type <20-byte-script-hash> instead of the actual hash.

Yes. Script types are recognized using special "template" scripts that have placeholder values where variable data is used in standard scripts. For example, the template: OP_HASH160 <20-byte-script-hash> OP_EQUAL will match the script OP_HASH160 52973f3519d5d248004767efb874aa2a3b2b37ce OP_EQUAL which allows the script to be detected as a p2sh pubKey script. You can see how this is implemented in the templates.js file. This functionality is not currently directly exposed to the end user as a top-level export, though it could be in the future.

@JBaczuk
Copy link
Owner

JBaczuk commented Mar 2, 2019

Ok I get what your talking about. So for the p2ms why not just use a template like:

<p2ms>

Then the template processor knows to look for an OP_M which must be 0-16, then it looks for the last byte to be OP_N from 0-16, and finally after the OP_M, there must be N compressed pubkeys (always 33 bytes). I'm not positive, but I don't think uncompressed keys are valid in a standard p2ms, but we should verify this.

Another alternative (which might be more descriptive if this template was ever exposed to the user):

<OP_M> <pubkey> ... <OP_N>

Though this seems to make more work for the template processor.

@wardlem
Copy link
Collaborator Author

wardlem commented Mar 2, 2019

Another alternative (which might be more descriptive if this template was ever exposed to the user):

<OP_M> <pubkey> ... <OP_N>

Though this seems to make more work for the template processor.

It is a little more work for the template processor, but I believe that this is a natural way to describe what a p2ms looks like. I vote for this.

@wardlem wardlem self-assigned this Mar 3, 2019
@wardlem wardlem removed the needs discussion For issues that require further discussion label Mar 3, 2019
wardlem added a commit to wardlem/bscript-parser that referenced this issue Mar 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants