-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
rpcclient: add detailed error types #2138
Conversation
Pull Request Test Coverage Report for Build 8328968456Details
💛 - Coveralls |
b0e800d
to
9df62a9
Compare
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.
LGTM, just had a few Nits regarding the comments otherwise straightforward PR.
rpcclient/errors.go
Outdated
// `sendrawtransaction` with missing inputs. | ||
ErrMissingInputsOrSpent BitcoindRPCErr = iota | ||
|
||
// ErrMissingInputs is returned when calling `sendrawtransaction` with |
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.
Nit: :s/ErrMissingInputs/ErrMaxBurnExceeded/g
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!
rpcclient/errors.go
Outdated
// A timelocked transaction. | ||
"transaction is not finalized": "non-final", | ||
"tried to spend coinbase transaction output": "non-final", | ||
// Minimally-small transaction(in non-witness bytes) that is allowed. |
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.
Nit: Is the comment correct ?
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.
yeah totally wrong🤦🏻 now fixed
// Get the error string and turn it into lower case. | ||
btcErr := strings.ToLower(err.Error()) | ||
// Error implements the error interface. It returns the error message defined | ||
// in `bitcoind`. |
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.
should we link the bitcoind code file for the specific error string ?
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.
updated the comments! Think we need to find a way to automatically create these errors, maybe parsing the package https://github.com/bitcoin/bitcoin/tree/master/test/functional
9df62a9
to
1e41068
Compare
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.
Nice!
This commit adds detailed errors for all possible errors returned from `sendrawtransaction` or `testmempoolaccept`, enabling upstream callers to have refined control over the actions to be taken.
This commit changes the `RejectReason` resulted from calling btcd's `testmempoolaccept` to be un-matched, leaving it to the caller to decide when and where to match it.
1e41068
to
8abf969
Compare
This PR adds detailed error types so the caller can use the structured errors to gain finer control, eg, handling an error resulted from an RBF attempt.