Skip to content

Conversation

@yyforyongyu
Copy link
Collaborator

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.

@coveralls
Copy link

coveralls commented Mar 14, 2024

Pull Request Test Coverage Report for Build 8328968456

Details

  • 104 of 105 (99.05%) changed or added relevant lines in 2 files are covered.
  • 11 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.07%) to 56.865%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcclient/errors.go 103 104 99.04%
Files with Coverage Reduction New Missed Lines %
btcutil/gcs/gcs.go 1 81.25%
mempool/mempool.go 1 66.84%
peer/peer.go 9 73.86%
Totals Coverage Status
Change from base Build 8211354034: 0.07%
Covered Lines: 29418
Relevant Lines: 51733

💛 - Coveralls

Copy link
Contributor

@ziggie1984 ziggie1984 left a 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.

// `sendrawtransaction` with missing inputs.
ErrMissingInputsOrSpent BitcoindRPCErr = iota

// ErrMissingInputs is returned when calling `sendrawtransaction` with
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

// 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.
Copy link
Contributor

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 ?

Copy link
Collaborator Author

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`.
Copy link
Contributor

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 ?

Copy link
Collaborator Author

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

Copy link
Collaborator

@guggero guggero left a 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.
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.

4 participants