RPC: Proposal - export coin selection via JSON-RPC API #13313

issue kristapsk opened this issue on May 23, 2018
  1. kristapsk commented at 6:35 PM on May 23, 2018: contributor

    I have idea that it would be useful for some use cases to export coin selection (SelectCoinsBnB()) via JSON-RPC API. For example, I have written a bash script which constructs fake coinjoin transactions (transactions that looks like JoinMarket's coinjoins from blockchain analysis perspective, but all inputs and change outputs are actually from the same wallet) and I currently do very dumb coin selection there (basically, listunspent and then go through UTXO's in that order until I have necessary amount). Would be cool if I could use more clever coin selection algos already present in Bitcoin Core.

    It could be something like this:

    selectcoins amount [use_bnb]
    
    Run coin selection and return array of unspent transaction outputs
    
    Arguments:
    1. amount         (numeric or string, required) The amount in BTC
    2. use_bnb        (bool, optional, default=true) Use "branch and bound" coin selection algorithm
    

    If this sounds ok, I will look at actually implementing it.

    Also, somebody who is more into coin selection stuff could look at proposed syntax of RPC call, probably it would be useful to have some additional parameters, etc...

  2. achow101 commented at 9:19 PM on May 23, 2018: member

    Why not just create a transaction with no inputs and then use fundrawtransaction? You have to set the outputs that you want, and a change output will be created as necessary.

  3. kristapsk commented at 6:07 PM on May 25, 2018: contributor

    The thing with fake coinjoin transactions is that I should simulate multiple participiants and fund each one of them separately. But probably I could in this case create multiple transactions without inputs using createrawtransaction, then fund each of them separately with fundrawtransaction and then use combinerawtransaction to create final transaction to be signed and sent out. Will try to implement and test it, how it works. Probably this new RPC proposal is useless then.

  4. fanquake added the label RPC/REST/ZMQ on May 26, 2018
  5. promag commented at 12:56 PM on May 29, 2018: member

    Agree with @achow101, looks like fundrawtransaction should be enough for your use case. Not sure about the use_bnb option.

  6. kristapsk commented at 9:59 PM on June 6, 2018: contributor

    Looked at rewriting my fake coinjoin script using fundrawtransacion, but, of course, as always, devil is in details, and it would make code too complicated, without too much gains (if I want to simulate JoinMarket's behaviour, there are specific constraints on change amounts too, basically one "participant" pays others, so that would mean manually altering each of change amounts added to transactions before feeding them into combinerawtransaction). So, decided not doing that.

    And I'm now thinking it's actually not such a good idea to implement new RPC if there are no other use cases for it. But probably this issue could be kept open, if somebody comes up with them in future.

    Not sure about the use_bnb option.

    Probably not a good idea to export such option via RPC, as different coin selection algorithms may come and go in future.

  7. promag commented at 12:51 AM on June 7, 2018: member

    I would close though if you are not going to work on it.

  8. kristapsk commented at 8:18 AM on June 7, 2018: contributor

    Yes, not currently. Could come back to this if I would see additional use cases where this could be useful over fundrawtransaction.

  9. MarcoFalke commented at 10:29 PM on April 26, 2020: member

    The feature request didn't seem to attract much attention in the past. Also, the issue seems not important enough right now to keep it sitting around idle in the list of open issues.

    Closing due to lack of interest. Pull requests with improvements are always welcome.

  10. MarcoFalke closed this on Apr 26, 2020

  11. 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: 2026-04-13 15:15 UTC

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