rpc listunspent should expose "is_mine" and "replaceable" #11613

issue RHavar opened this issue on November 5, 2017
  1. RHavar commented at 7:06 PM on November 5, 2017: contributor

    Currently listunspent only exposes a safe which is coded roughly as confirmations > 0 || (is_mine && !replaceable) however a consumer very well might want to distinguish between when it's "mine" and when it's not (as I presently need to).

    This ideally would be extended to listunspent, gettransaction and listtransactions.

    (The listtransactions already exposes a "trusted" which is basically "is_mine" but also uses the spendZeroConf configuration, which is imho rather confusing. So my suggestion would be that all apis expose a consistent set of "is_mine", "replaceable" and "confirmations" (which is already always exposed) and RPC consumers can use these primitives to make decisions.

  2. fanquake added the label RPC/REST/ZMQ on Nov 5, 2017
  3. gmaxwell commented at 3:12 AM on November 10, 2017: contributor

    Seems reasonable to me. Though for clarity, I assume you would want a "Are all inputs mine" (can a third party double spend me) rather than a "Is any input mine?" (which is IIRC what is_mine actually does). Right? Assuming you're not coinjoining they're the same, but they aren't generally the same.

  4. sipa commented at 3:30 AM on November 10, 2017: member

    I'm confused. Isn't everything reported by listunspent by definition is_mine?

  5. RHavar commented at 11:35 AM on November 10, 2017: contributor

    Though for clarity, I assume you would want a "Are all inputs mine" (can a third party double spend me) rather than a "Is any input mine?"

    Well for my case it doesn't matter (as you say, I'm not doing coinjoins). I suspect "are all inputs mine" to generally be more useful, but it might not be worth the trouble of doing that if that's not easily accessible. If "is_mine" just means "one of the inputs is mine", I'd suggest keeping that behavior and if needed in the future create an "is_all_mine" or something

    I'm confused. Isn't everything reported by listunspent by definition is_mine?

    Hmm not really. listunspent lists all your shit, but you want to know about the source of it. Consider there two common ways for you to get money: someone sends it to you (not is_mine) or you sent to yourself (i.e. change) and it (is_mine). It makes sense to distinguish these two cases for a variety of things.

    In my particular case, I do coin-selection outside of core (I call "listunspent" then do coin selection, and generate a transaction) so knowing the source of the unspent is pretty important (as core itself does in it's own coin selection, for example)

  6. GabrielDav commented at 10:27 PM on March 31, 2018: contributor

    @RHavar I'm looking into this. I think there is minor confusion with regards of wording (and please correct me if I'm wrong). listunspent indeed has IsMine function being used. And this function is being discussed by others here. However, IsMine means that 'coins are mine to spend' (is any input mine) and not 'coins source belongs to one of my accounts'. If I understand this issue correctly what you actually want to expose is 'from_me'. Correct?

  7. RHavar commented at 2:09 PM on April 1, 2018: contributor

    @GabrielDav

    Sorry, I don't understand what you mean. What I want is inputs that are mine to spend (which is what listunspent returns) but for each of those inputs I want to know if I was the one who created them or not.

    (i.e. if I was the one who created it, I know that it can't be double-spent or replaced without me myself doing it. Which allows me to treat it differently to other coins)

  8. sipa commented at 2:16 PM on April 1, 2018: member

    @RHavar I believe what @GabrielDav is trying to say is that internally what you're describing is the IsFromMe function (did I create this output?) rather than the IsMine function (is the output considered mine to spend).

  9. RHavar commented at 3:17 PM on April 1, 2018: contributor

    Ah, sorry, I see. So yeah, I guess it should be IsFromMe

  10. GabrielDav commented at 8:00 PM on April 2, 2018: contributor

    PR #12862 does not extend functionality to listtransactions since this operation already has field category indicating whether transaction is incoming (to_me) or outgoing (from_me). Thus making from_me redundant on this function.

  11. MarcoFalke commented at 12:31 PM on May 9, 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.

  12. MarcoFalke closed this on May 9, 2020

  13. 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