GUI: Add generate method #16000

issue MarcoFalke openend 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. fanquake deleted a comment on May 11, 2019
  6. fanquake deleted a comment on May 11, 2019
  7. fanquake 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. MarcoFalke 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. 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
    0{
    1  "result": [
    2    "1e9a6484111cdebe4d1794ad7994a8504e692cdd2c43d8ccea66ce819fbc1209"
    3  ],
    4  "error": null,
    5  "id": 0
    6}
    
    • bitcoin-cli -generate 2
    0{
    1  "result": [
    2    "2fcd8f7a0b03c0111fec02f185ad20acce68fee8a649b39e6409e51fb6d5dc87",
    3    "234f63fbdd4d8292617127d4f0559295098785f54372f857a19651d98d2a59ab"
    4  ],
    5  "error": null,
    6  "id": 0
    7}
    
    • bitcoin-cli -generate 3 10000
    0{
    1  "result": [
    2    "2c5cf3a0ff25b1708b5a4648e4c4c5c09ff309a0afa743f3d602011b97e00be2",
    3    "0d61891a44ca9f177a4632e4a30d612f78b459cd7dea29ebaa13d647a94c3708",
    4    "2d1e1e911747d3d5bc452d8a1f8d906971023b9811831aa5b9dd937ef403ab66"
    5  ],
    6  "error": null,
    7  "id": 0
    8}
    

    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,

  14. meshcollider referenced this in commit 47a30ef0c6 on Jun 21, 2020
  15. sidhujag referenced this in commit 4868422bc1 on Jul 7, 2020
  16. 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.
  17. fanquake closed this on Aug 14, 2020

  18. DrahtBot 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: 2024-12-23 03:12 UTC

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