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

Implement OP_WITHIN opcode #28

Closed
wants to merge 10 commits into from

Conversation

supreme2580
Copy link
Contributor

I implemented the code for op_within

}

fn opcode_within(ref engine: Engine) {
let a = engine.dstack.pop_int();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be prefered to make the variable naming here more explicit, like min_value, max_value, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will rename the variables now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I just pushed an update to rename the variables to be more explicit

});
}

fn opcode_within(ref engine: Engine) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refer to this implementation to see the proper ordering of variables on the stack : https://github.com/btcsuite/btcd/blob/b161cd6a199b4e35acec66afc5aad221f05fe1e3/txscript/opcode.go#L1844

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, opcode_within is number 165 in the order, please could you tell me what you mean? I have pushed an update where I renamed and reordered the variables though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have to make sure the values poped off the stack are in the same order as the bitcoin spec, so here max_value should be popped first, then min_value, then selected_value

Copy link
Contributor Author

@supreme2580 supreme2580 Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Hi @b-j-roberts I have rearranged the variables based on the order max before min before value

@supreme2580 supreme2580 closed this by deleting the head repository Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants