rpc: trigger error before dealing strSecret / strLabel #22549

pull bdescamps wants to merge 1 commits into bitcoin:master from bdescamps:importprivkey_optimize changing 1 files +5 −5
  1. bdescamps commented at 7:35 PM on July 25, 2021: none

    Improvement on importprivkey method. Errors can be triggered early.

  2. trigger error before dealing strSecret / strLabel 35ac5abf1c
  3. ccr781804 approved
  4. ccr781804 commented at 8:04 PM on July 25, 2021: none

    For me. It's very difficult to understand clearly.

  5. DrahtBot added the label RPC/REST/ZMQ on Jul 25, 2021
  6. DrahtBot added the label Wallet on Jul 25, 2021
  7. bdescamps commented at 9:02 PM on July 25, 2021: none

    I think it's better to deal directly exit function. Here we can trigger two JSONRPCError, without instantiate string for strLabel & strSecret

  8. laanwj commented at 2:03 PM on July 28, 2021: member

    What does this change from a user perspective?

  9. bdescamps commented at 2:18 PM on July 28, 2021: none

    At this time nothing, but it can prevent future bug.

  10. laanwj commented at 2:40 PM on July 28, 2021: member

    What kind of bug?

  11. bdescamps commented at 3:09 PM on July 28, 2021: none

    A bug create by a bad interpretation of code Here we create 2 variables strSecret StrLabel.

    • strSecret which is instanciate by a request params
    • strLabel which is instanciate by an empty string and set after by a request params (if it is present)

    There is no reason to dealing them now because we don't use them. Moreover if the wallet rescan is disabled or if the wallet is currently rescanning we have creating all that for nothing

  12. tryphe commented at 9:15 AM on July 30, 2021: contributor

    This code doesn't get called very much (people only use it to manually type in their legacy private keys) and the performance doesn't really matter. It would save us from copying a string each time an error happens...

    The initializations could also be moved up before LOCK(pwallet->cs_wallet); to save on lock time. The initialization of strLabel could be moved down further also, to line 168.

    :bike: :bike: :bike:

  13. MarcoFalke commented at 11:38 AM on August 2, 2021: member

    With argument parsing moving to RPCHelpMan, this will become obsolete. So tend to NACK on this diff.

    Maybe it could make sense to use the zeroing-on-destruction string here.

  14. laanwj commented at 2:55 PM on August 18, 2021: member

    As it stands, this doesn't seem worth the hassle, so closing this.

  15. laanwj closed this on Aug 18, 2021

  16. DrahtBot locked this on Aug 18, 2022

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-13 15:14 UTC

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