Skip to content

Conversation

@theStack
Copy link
Contributor

This change improves the usability of the dumptxoutset RPC in two ways, in the case that an invalid path is passed:

  1. return from the RPC immediately, rather then when the file is first tried to be written (which is after calculating the UTXO set hash)
  2. return a proper return code and error message instead of the cryptic message that appears on master currently (see below)

master branch:
(error message appears after several minutes on my machine)

$ ./src/bitcoin-cli dumptxoutset /invalid/path
error code: -1
error message:
CAutoFile::operator<<: file handle is nullptr: unspecified iostream_category error

PR branch:
(error message appears immediately)

$ ./src/bitcoin-cli dumptxoutset /invalid/path
error code: -8
error message:
Couldn't open file /invalid/path.incomplete for writing.

This change improves the usability of the `dumptxoutset` RPC in two ways,
in the case that an invalid path is passed:
  1. return from the RPC immediately, rather then when the file is first
     tried to be written (which is _after_ calculating the UTXO set hash)
  2. return a proper return code and error message instead of the cryptic
     "CAutoFile::operator<<: file handle is nullptr: unspecified
      iostream_category error" (-1)
Copy link
Contributor

@w0xlt w0xlt 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 9feb887

@maflcko maflcko merged commit 27d7b11 into bitcoin:master May 11, 2022
@theStack theStack deleted the 202205-rpc-check_fopen_retval_in_dumptxoutset branch May 11, 2022 14:34
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 11, 2022
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request May 21, 2022
This change improves the usability of the `dumptxoutset` RPC in two ways,
in the case that an invalid path is passed:
  1. return from the RPC immediately, rather then when the file is first
     tried to be written (which is _after_ calculating the UTXO set hash)
  2. return a proper return code and error message instead of the cryptic
     "CAutoFile::operator<<: file handle is nullptr: unspecified
      iostream_category error" (-1)

Github-Pull: bitcoin#25106
Rebased-From: 9feb887
@bitcoin bitcoin locked and limited conversation to collaborators May 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants