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

Prevent prepareTransaction from overwriting values in txJSON #1000

Merged
merged 2 commits into from Apr 13, 2019

Conversation

intelliot
Copy link
Collaborator

Fix #997

@intelliot intelliot requested a review from mDuo13 April 12, 2019 12:09
Copy link

@jwbusch jwbusch left a comment

Choose a reason for hiding this comment

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

Just took a quick glance, only had one comment. LGTM

const disallowedFieldsInTxJSON = ['maxLedgerVersion', 'maxLedgerVersionOffset', 'fee', 'sequence']
const badFields = disallowedFieldsInTxJSON.filter(field => txJSON[field])
if (badFields.length) {
return Promise.reject(new ValidationError('txJSON additionalProperty "' + badFields[0] +
Copy link

Choose a reason for hiding this comment

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

nit: this only returns the first invalid error, could include all of the bad fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 Thanks! I think it'll be rare for someone to use multiple bad fields and if they do, it's still OK to point them out one by one.

Copy link
Collaborator

@mDuo13 mDuo13 left a comment

Choose a reason for hiding this comment

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

👍

// instructions.maxLedgerVersionOffset
if (txJSON.LastLedgerSequence && instructions.maxLedgerVersion) {
return Promise.reject(new ValidationError('`LastLedgerSequence` in txJSON and `maxLedgerVersion`' +
' in Instructions cannot both be set'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I suggest writing `instructions` rather than Instructions, to be consistent with how the other parts are written

}
if (txJSON.LastLedgerSequence && instructions.maxLedgerVersionOffset) {
return Promise.reject(new ValidationError('`LastLedgerSequence` in txJSON and `maxLedgerVersionOffset`' +
' in Instructions cannot both be set'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

`instructions` here too

@intelliot intelliot merged commit 4da8002 into develop Apr 13, 2019
@intelliot intelliot deleted the fix-prepareTransaction branch April 13, 2019 18:33
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.

prepareTransaction should not overwrite Fee
3 participants