rpc: dumptxoutset: check `fopen` return code #25106

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202205-rpc-check_fopen_retval_in_dumptxoutset changing 2 files +11 −1
  1. theStack commented at 2:13 PM on May 11, 2022: member

    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.
    
  2. rpc: check `fopen` return code in dumptxoutset
    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)
    9feb887082
  3. w0xlt approved
  4. MarcoFalke merged this on May 11, 2022
  5. MarcoFalke closed this on May 11, 2022

  6. theStack deleted the branch on May 11, 2022
  7. sidhujag referenced this in commit 326e187d45 on May 11, 2022
  8. luke-jr referenced this in commit 805443ff3f on May 21, 2022
  9. DrahtBot locked this on May 11, 2023
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me