test: Return dict in MiniWallet::send_to #27640

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2305-test-mini-wallet-send-to- changing 8 files +20 −16
  1. maflcko commented at 1:32 PM on May 12, 2023: member

    Returning a tuple has many issues:

    • If only one value is needed, it can not be indexed by name
    • If another value is added to the return value, all call sites need to be updated

    Bite the bullet now and update all call sites to fix the above issues.

  2. test: Return dict in MiniWallet::send_to faf4315c88
  3. DrahtBot commented at 1:32 PM on May 12, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK brunoerg, theStack, stickies-v

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #27602 (net processing: avoid serving non-announced txs as a result of a MEMPOOL message by sr-gi)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot added the label Tests on May 12, 2023
  5. theStack commented at 2:20 PM on May 12, 2023: contributor

    Concept ACK

  6. brunoerg approved
  7. brunoerg commented at 2:40 PM on May 12, 2023: contributor

    crACK faf4315c88d8c81c2ff84870bc81aef3cf719816

  8. stickies-v commented at 11:05 AM on May 15, 2023: contributor

    Concept ACK for moving away from a tuple return value. I think I'd prefer something more struct-like though, for example a typing.NamedTuple? Also, I don't see the point in returning tx, wtxid, and hex if no one is accessing them yet - can easily be added later on when needed?

  9. maflcko commented at 11:13 AM on May 15, 2023: member

    I'd prefer something more struct-like

    The idea is to use the same return type as the other MiniWallet methods. Not sure if it is worth it to use a named tuple. (rant: If you want compile-time type checks, you are better off using rust, instead of maiming python code with type annotations)

    I don't see the point in returning tx, wtxid, and hex if no one is accessing them yet

    The idea was to use the same return values as the other MiniWallet methods, but I am happy to drop this.

  10. theStack approved
  11. theStack commented at 7:48 PM on May 16, 2023: contributor

    Code-review ACK faf4315c88d8c81c2ff84870bc81aef3cf719816

  12. maflcko commented at 11:03 AM on May 18, 2023: member

    Anything left to do here?

  13. fanquake commented at 11:10 AM on May 18, 2023: member

    @stickies-v want to take a final look?

  14. stickies-v approved
  15. stickies-v commented at 12:41 PM on May 18, 2023: contributor

    Code review ACK faf4315c88d8c81c2ff84870bc81aef3cf719816

    I'd have preferred doing things a bit differently but I think as per the PRs rationale, it's better to move away from the tuple return type quickly to avoid larger refactorings in the future. My comments can easily be implemented in follow-ups, if people want them.


    The idea is to use the same return type as the other MiniWallet methods.

    Fair enough, I hadn't considered that.

    If you want compile-time type checks <...>

    My main concern is readability and usability, being explicit about the structure of the dict is helpful to users imo and integrates well with IDEs. I still prefer using e.g. a namedtuple but that can be a follow-up (I don't think I feel strongly enough about it to open that PR myself, at least for now) that updates all relevant functions at the same time instead of doing it just for this one.

    The idea was to use the same return values as the other MiniWallet methods, but I am happy to drop this.

    If it were up to me I'd just have it return ["tx", "sent_vout"] since all 3 other fields can easily be accessed through "tx", but I see your rationale your rationale and I think it's reasonable.

  16. fanquake merged this on May 18, 2023
  17. fanquake closed this on May 18, 2023

  18. maflcko deleted the branch on May 18, 2023
  19. sidhujag referenced this in commit fcf11f7ca8 on May 19, 2023
  20. bitcoin locked this on May 17, 2024

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-24 09:14 UTC

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