-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixed Script.fromASM support PUSHDATA #3807
base: master
Are you sure you want to change the base?
Conversation
The test results of CircleCI do not seem to be related to this commit.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -157,12 +157,23 @@ Script.fromASM = function(str) { | |||
var opcode = Opcode(token); | |||
var opcodenum = opcode.toNumber(); | |||
|
|||
if (opcodenum == null) { | |||
if (_.isUndefined(opcodenum)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and for linting, would you mind just copying the code from the bitcore-lib-cash script.js? Feel free to clean it up a little (don't need to re-declare opcodenum, for example), but your code here has some inconsistent formatting/linting with the rest of the codebase.
@@ -205,6 +205,25 @@ describe('Script', function() { | |||
}); | |||
}); | |||
|
|||
describe('#fromASM PUSHDATA', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already a #fromASM
describe in this file, and bitcore-lib-cash already has some pushdata tests. Would you please copy those tests to the existing #fromASM describe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
In the cash code, a constant is calculated every time
|
…throw an exception. Signed-off-by: Long Li <[email protected]>
Constants are fine - I agree that your constants are better than the computed values in BCH lib. I was more noticing the linting. You have inconsistent spacing around the braces and we're trying to move away from using lodash (_), so There are 3 PUSHDATA tests in the BCH lib that are relevant to this codeblock, but your additional test is welcome. Lastly, all of your commits need to be signed, so you'll need to squash all your commits into a new one and force push. |
Script.fromASM should support PUSHDATA, otherwise it will lead to incorrect chunks settings, which in turn makes the result of toBuffer incorrect.
The bitcore-lib-cash code was previously fixed. LTC and DOGE are also incorrect, if corrections are needed, submit a patch separately.