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

rpc: Improve invalid vout value rpc error message #19956

Merged
merged 1 commit into from
Oct 3, 2020

Conversation

n1rna
Copy link
Contributor

@n1rna n1rna commented Sep 14, 2020

Since the vout value can start at 0, the error message for negative values can be improved to something like: vout cannot be negative.

@n1rna n1rna force-pushed the rpc-invalid-vout-message branch from cf6befe to 9dce22b Compare September 14, 2020 21:50
@theStack
Copy link
Contributor

Concept ACK -- "positive" means greater than zero by definition, so the error message was incorrect

I think you should squash those commits.

Welcome as new contributor by the way! 🎉

@n1rna n1rna force-pushed the rpc-invalid-vout-message branch from 19b7996 to 89860a8 Compare September 16, 2020 04:13
@n1rna
Copy link
Contributor Author

n1rna commented Sep 16, 2020

Welcome as new contributor by the way!

THANKS @theStack

@tryphe
Copy link
Contributor

tryphe commented Sep 16, 2020

ACK 89860a8. Agree with the concept, changes are no-risk.

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK 89860a8 🆗

@adaminsky
Copy link
Contributor

Concept ACK -- This error also appears some other places. Here are the first two I found from git grep "vout must be positive", but there were some others.

bitcoin/src/bitcoin-tx.cpp

Lines 599 to 600 in d052f5e

if (nOut < 0)
throw std::runtime_error("vout must be positive");

if (nOut < 0) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive");
}

@n1rna n1rna force-pushed the rpc-invalid-vout-message branch from 89860a8 to 4be8380 Compare September 24, 2020 16:48
@n1rna
Copy link
Contributor Author

n1rna commented Sep 24, 2020

This error also appears some other places.

Addressed. @adaminsky

@adaminsky
Copy link
Contributor

ACK 4be8380.

@maflcko
Copy link
Member

maflcko commented Sep 24, 2020

Could be a scripted diff to show the replacement is complete?

@n1rna
Copy link
Contributor Author

n1rna commented Sep 24, 2020

I was not familiar with scripted diff, I will replace my commit with with script diff enabled. @MarcoFalke

@n1rna n1rna force-pushed the rpc-invalid-vout-message branch 2 times, most recently from ea57639 to f56bff4 Compare September 24, 2020 18:17
@laanwj
Copy link
Member

laanwj commented Sep 30, 2020

Please insert an empty line in your commit message between the title of the commit and the body, otherwise it appears like this in one-line summary format:

* f56bff455f6b965cd4f50ec8e6fe2bf5981ca30d scripted diff: Improve invalid vout value rpc error message -BEGIN VERIFY SCRIPT- r() { sed -i 's/vout must be positive/vout cannot be negative/g' $1 } r src/bitcoin-tx.cpp r src/rpc/rawtransaction_util.cpp r src/wallet.cpp r test/functional/rpc_rawtransaction.py -END VERIFY SCRIPT- (Nima Yazdanmehr) (pull/19956/head)

The change itself looks good to me.

@n1rna n1rna force-pushed the rpc-invalid-vout-message branch from f56bff4 to 43bfec8 Compare September 30, 2020 15:49
@n1rna
Copy link
Contributor Author

n1rna commented Sep 30, 2020

Addressed @laanwj

@maflcko
Copy link
Member

maflcko commented Sep 30, 2020

Instead of hardcoding the file names, you can use $(git grep -l 'vout must be positive')

@n1rna n1rna force-pushed the rpc-invalid-vout-message branch from 43bfec8 to f471a3b Compare September 30, 2020 17:08
@n1rna
Copy link
Contributor Author

n1rna commented Sep 30, 2020

Yes, much better now. Thanks for the suggestoin @MarcoFalke

-BEGIN VERIFY SCRIPT-
r() { sed -i 's/vout must be positive/vout cannot be negative/g' $1 }
r $(git grep -l 'vout must be positive')
-END VERIFY SCRIPT-
Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK f471a3b.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK f471a3b

@fanquake fanquake merged commit 54fc96f into bitcoin:master Oct 3, 2020
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 3, 2021
Summary:
Since the vout value can start at 0, the error message for negative values can be improved to something like: vout cannot be negative.

This is a backport of [[bitcoin/bitcoin#19956 | core#19956]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10423
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 22, 2021
f471a3b scripted diff: Improve invalid vout value rpc error message (Nima Yazdanmehr)

Pull request description:

  Since the `vout` value can start at `0`, the error message for *negative* values can be improved to something like: `vout cannot be negative`.

ACKs for top commit:
  fanquake:
    ACK f471a3b
  promag:
    Code review ACK f471a3b.

Tree-SHA512: fbdee3d0ddd5b58eb93934a1217b44e125a9ad39e672b1f35c7609c6c5fcf45ae1b731d3d6135b7225d98792dbfc34a50907b8c41274a5b029d7b5c59f886560
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 22, 2021
f471a3b scripted diff: Improve invalid vout value rpc error message (Nima Yazdanmehr)

Pull request description:

  Since the `vout` value can start at `0`, the error message for *negative* values can be improved to something like: `vout cannot be negative`.

ACKs for top commit:
  fanquake:
    ACK f471a3b
  promag:
    Code review ACK f471a3b.

Tree-SHA512: fbdee3d0ddd5b58eb93934a1217b44e125a9ad39e672b1f35c7609c6c5fcf45ae1b731d3d6135b7225d98792dbfc34a50907b8c41274a5b029d7b5c59f886560
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 22, 2021
f471a3b scripted diff: Improve invalid vout value rpc error message (Nima Yazdanmehr)

Pull request description:

  Since the `vout` value can start at `0`, the error message for *negative* values can be improved to something like: `vout cannot be negative`.

ACKs for top commit:
  fanquake:
    ACK f471a3b
  promag:
    Code review ACK f471a3b.

Tree-SHA512: fbdee3d0ddd5b58eb93934a1217b44e125a9ad39e672b1f35c7609c6c5fcf45ae1b731d3d6135b7225d98792dbfc34a50907b8c41274a5b029d7b5c59f886560
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 28, 2021
f471a3b scripted diff: Improve invalid vout value rpc error message (Nima Yazdanmehr)

Pull request description:

  Since the `vout` value can start at `0`, the error message for *negative* values can be improved to something like: `vout cannot be negative`.

ACKs for top commit:
  fanquake:
    ACK f471a3b
  promag:
    Code review ACK f471a3b.

Tree-SHA512: fbdee3d0ddd5b58eb93934a1217b44e125a9ad39e672b1f35c7609c6c5fcf45ae1b731d3d6135b7225d98792dbfc34a50907b8c41274a5b029d7b5c59f886560
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants