GUI: Add generate method #16000

issue MarcoFalke opened this issue on May 9, 2019
  1. MarcoFalke commented at 10:18 PM on May 9, 2019: member

    The generate method has been removed from Bitcoin Core, but it would be nice if the GUI had a generate method in the debug console. That method would effectively expand to generatetoaddress(getnewaddress()) (just like the def generate in our test node python class)

  2. MarcoFalke added the label GUI on May 9, 2019
  3. MarcoFalke added the label good first issue on May 9, 2019
  4. MarcoFalke commented at 10:39 PM on May 9, 2019: member

    The same could be added to bitcoin-cli (similar to -getinfo)

  5. bitcoin deleted a comment on May 11, 2019
  6. bitcoin deleted a comment on May 11, 2019
  7. bitcoin deleted a comment on May 11, 2019
  8. jonasschnelli commented at 7:09 AM on May 11, 2019: contributor

    I also miss the generate function. Instead of adding it client-side (which would be fine by me), we could add a generatetowallet(<nblocks>) function (without directly coupling the miner and the wallet).

  9. bitcoin deleted a comment on May 11, 2019
  10. Meshugah commented at 7:21 AM on May 14, 2019: none

    Could I work on this? Also, in general, is there a procedure to starting working on an issue?

  11. jonasschnelli commented at 7:24 AM on May 14, 2019: contributor

    @Meshugah: sure. You're more than welcome to work on this. Maybe start by reading the developer notes: https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md

  12. ezegom commented at 2:07 AM on July 11, 2019: contributor

    @MarcoFalke Is this issue still open? I'ld like to work on this if it is.

  13. MarcoFalke cross-referenced this on Jul 17, 2019 from issue rpc: Add getblockbyheight method by emilengler
  14. brakmic commented at 4:06 PM on November 23, 2019: contributor

    Hi,

    I've tried to implement the idea from @MarcoFalke by expanding the bitcoin-cli. However, as I'm not sure if someone else is still working on it, go ahead and just grab my code and integrate it in yours (if it's of any use to you).


    There's now the option "-generate" available. The allowed (optional) parameters are nblocks and maxtries. For example:

    • bitcoin-cli -generate
    {
      "result": [
        "1e9a6484111cdebe4d1794ad7994a8504e692cdd2c43d8ccea66ce819fbc1209"
      ],
      "error": null,
      "id": 0
    }
    
    • bitcoin-cli -generate 2
    {
      "result": [
        "2fcd8f7a0b03c0111fec02f185ad20acce68fee8a649b39e6409e51fb6d5dc87",
        "234f63fbdd4d8292617127d4f0559295098785f54372f857a19651d98d2a59ab"
      ],
      "error": null,
      "id": 0
    }
    
    • bitcoin-cli -generate 3 10000
    {
      "result": [
        "2c5cf3a0ff25b1708b5a4648e4c4c5c09ff309a0afa743f3d602011b97e00be2",
        "0d61891a44ca9f177a4632e4a30d612f78b459cd7dea29ebaa13d647a94c3708",
        "2d1e1e911747d3d5bc452d8a1f8d906971023b9811831aa5b9dd937ef403ab66"
      ],
      "error": null,
      "id": 0
    }
    

    First, I have tried to implement it directly in wallet/rpcwallet.cpp, but as there is no good way to access the server functionality without coupling them together I've moved to bitcoin-cli directly. However, the code I wrote is...abysmal, from my point of view. It works, sure, but maybe there's a nicer, more Bitcoin-idiomatic way to accomplish it?

    To achieve the results, I had to code two RequestHandlers in bitcoin-cli: GenerateRequestHandler and GetNewAddressRequestHandler. These will then be called in CommandLineRPC.

    Yes, there is some "magic" in between, because I had to manipulate the args vector. This is because I needed a valid address for "generatetoaddress". I'm pretty sure, there are more intelligent ways to do it, so I hope, someone will take this piece of bad code and give it a few antifragile hits. ;)

    Here's the commit: https://github.com/brakmic/bitcoin/commit/faf5f037a42bfc01fcaf80985af24ae92c9b7fb0

    Regarding tests, well, I don't know what would be the proper way to do it. Maybe expanding the Python code (node stuff etc.) by implementing a "generate" call there? If I could get some hints on that, it'd be great. Thanks in advance!

    Regards,

  15. brakmic cross-referenced this on Dec 9, 2019 from issue cli: add -generate option by brakmic
  16. jonatack cross-referenced this on Jun 1, 2020 from issue rpc, cli, test: add bitcoin-cli -generate command by jonatack
  17. meshcollider referenced this in commit 47a30ef0c6 on Jun 21, 2020
  18. sidhujag referenced this in commit 4868422bc1 on Jul 7, 2020
  19. fanquake cross-referenced this on Aug 14, 2020 from issue Add generate method to debug console by fanquake
  20. fanquake commented at 10:03 AM on August 14, 2020: member

    Given that the bitcoin-cli portion of this has been done. I've moved the issue over to the GUI repo: https://github.com/bitcoin-core/gui/issues/55.

  21. fanquake closed this on Aug 14, 2020

  22. bitcoin locked this on Feb 15, 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-05-20 06:54 UTC