Add safe flag to listunspent result #9830

pull NicolasDorier wants to merge 2 commits into bitcoin:master from NicolasDorier:listunspenttrusted changing 7 files +40 −20
  1. NicolasDorier commented at 6:01 AM on February 23, 2017: contributor

    This flag is useful to know if a particular UTXO will be considered by the wallet as part of fundrawtransaction of sendtoaddress.

  2. jonasschnelli added the label Wallet on Feb 23, 2017
  3. gmaxwell commented at 9:33 AM on February 23, 2017: contributor

    I think trusted may be a bad name for this -- sure its the internal name but that doesn't mean it's good. :)

  4. NicolasDorier commented at 11:19 AM on February 23, 2017: contributor

    what about "safe" ?

  5. laanwj commented at 11:29 AM on February 23, 2017: member
    (bool) Whether this coin is safe to spend (eligible to be spent by fundrawtransaction or sendtoaddress)
    

    Call it 'eligible' maybe?

  6. jonasschnelli commented at 12:00 PM on February 23, 2017: contributor

    Concept ACK. Related: I wasn't really aware that fundraw with the watch-only option can't spend/select 0-conf watch-onlys. I think we should fix this.

  7. NicolasDorier force-pushed on Feb 23, 2017
  8. NicolasDorier force-pushed on Feb 23, 2017
  9. NicolasDorier commented at 12:58 PM on February 23, 2017: contributor

    Fixed to 'eligible', it looks indeed better.

    For my work on hdwatchonly, I kind of fixed it on https://github.com/bitcoin/bitcoin/pull/9728/commits/358ec69ae0a809db030a5a4e72133bc538026cbe . This is only for hdwatchonly though. I think not all watchonly might be trusted.

    But definitively, hdwatchonly generated address are trusted.

  10. ryanofsky commented at 3:04 PM on February 23, 2017: member

    I think it would be bad to expose a new txout "eligible" attribute from listunspent which is 99% but not 100% identical to the "unsafe" attribute just exposed in 52dde66770d833ee5e42e7c5fee610453ae3852a (new in .14 release).

    I think the best thing would be to decide whether the name "safe" or "eligible" is better and use that name consistently. CWallet::AvailableCoins could be modified to return whether each coin is safe/eligible, either by adding a new fIsSafe/fIsEligible field to COutput, or by just changing the function arguments. The CWallet::AvailableCoins fOnlyConfirmed argument could also be eliminated, or renamed to fOnlySafe/fOnlyEligible.

  11. NicolasDorier commented at 3:24 PM on February 23, 2017: contributor

    @ryanofsky I think it is rather different purpose. include_unsafe act as a filter, here I need an attribute to differenciate whose which will be selected by fundrawtransaction and those which will not.

  12. ryanofsky commented at 3:32 PM on February 23, 2017: member

    Right, include_unsafe is a filter on the safe/eligible boolean that you want to return. Maybe my suggestion for how to unify the two implementations is unclear? Let me know if the changes I was suggesting for AvailableCoins don't make sense. I'd also be happy to post a PR.

  13. NicolasDorier commented at 3:36 PM on February 23, 2017: contributor

    ah got it, you want both to be the same rather than slightly different ? I would be happy to see a PR about it, the difference is indeed confusing.

  14. ryanofsky referenced this in commit f4cace484c on Feb 23, 2017
  15. ryanofsky commented at 4:27 PM on February 23, 2017: member

    @NicolasDorier I posted a possible implementation in https://github.com/ryanofsky/bitcoin/commit/f4cace484cde19ee285bbb0260b51fc251665d1c based on your PR. I used "safe" instead of eligible here because it seemed more natural to me, but I think either name would be ok. Maybe take a look, and feel free to incorporate any of these changes.

  16. ryanofsky commented at 4:56 PM on February 23, 2017: member

    This branch with the same change is a little better: https://github.com/ryanofsky/bitcoin/commits/pr/safelist

    It splits it up into a refactoring commit ad89a07bb16fb13a7007eecfb03b7ec931d54751, and a commit updating the RPC 5c08fcb9277b40fe38d2582dc01d52ade3e2b1de.

  17. NicolasDorier commented at 2:36 AM on February 24, 2017: contributor

    @ryanofsky I like your branch. Will update this PR.

  18. luke-jr commented at 3:28 AM on February 25, 2017: member

    Suggest refactoring by adding a CWalletTx::IsSafe also.

  19. NicolasDorier force-pushed on Feb 26, 2017
  20. NicolasDorier renamed this:
    Add trusted flag to listunspent result
    Add safe flag to listunspent result
    on Feb 26, 2017
  21. NicolasDorier commented at 9:12 AM on February 26, 2017: contributor

    As @ryanofsky advice, I renamed the flag to "safe". I added his commit which add a safe flag to the COutput type and rename the parameter in CWallet::AvailableCoins.

    I then renamed CWallet::IsTrusted to CWallet::IsSafe which more properly reflect the meaning of the function.

  22. ryanofsky commented at 3:35 PM on March 8, 2017: member

    utACK 037d2876a00cb6a3a01de9beb604b6bfa8d2601c.

    Personally I would prefer not to rename IsTrusted function to IsSafe because the trusted and safe conditions are not identical. I think luke-jr's suggestion to add a new IsSafe method that takes a wallet tx instead of a plain tx and computes the real fSafe value would be better.

  23. NicolasDorier force-pushed on Mar 9, 2017
  24. NicolasDorier commented at 1:32 AM on March 9, 2017: contributor

    @ryanofsky fair enough, I removed the renaming. (it was the last commit) Can you re-ACK?

    I think to deal with deeper refactoring in another PR. This one is only for exposing more information.

  25. ryanofsky commented at 1:34 AM on March 9, 2017: member

    utACK 23cbc366a7c3633e694286a693a4223de02b95ad

  26. ryanofsky commented at 2:59 PM on March 9, 2017: member

    Needs rebase because of #9643

  27. Add COutput::fSafe member for safe handling of unconfirmed outputs
    This exposes a value computed in CWallet::AvailableCoins so it can used for
    other things, like inclusion in listunspent output.
    af61d9f78b
  28. Add safe flag to listunspent result dcf2112de6
  29. NicolasDorier force-pushed on Mar 10, 2017
  30. NicolasDorier commented at 5:12 AM on March 10, 2017: contributor

    rebased

  31. ryanofsky commented at 8:01 PM on March 10, 2017: member

    utACK dcf2112de6ec5a7a5e97076d1ce826eb233a1042, confirmed no changes in rebase.

  32. jonasschnelli commented at 7:40 AM on March 11, 2017: contributor

    utACK af61d9f78bec62ff3688d88409a53df9ff5bc591

  33. btcdrak commented at 12:59 PM on March 12, 2017: contributor

    utACK af61d9f78bec62ff3688d88409a53df9ff5bc591

  34. TheBlueMatt commented at 1:46 AM on March 13, 2017: member

    utACK dcf2112de6ec5a7a5e97076d1ce826eb233a1042

  35. laanwj merged this on Mar 13, 2017
  36. laanwj closed this on Mar 13, 2017

  37. laanwj referenced this in commit afcd7c0e52 on Mar 13, 2017
  38. PastaPastaPasta referenced this in commit eb94509082 on Jan 2, 2019
  39. PastaPastaPasta referenced this in commit 7a0e0cd25d on Jan 2, 2019
  40. PastaPastaPasta referenced this in commit 9cad8fbf0f on Jan 2, 2019
  41. PastaPastaPasta referenced this in commit 1bb6fa2f77 on Jan 3, 2019
  42. PastaPastaPasta referenced this in commit af2831b9af on Jan 21, 2019
  43. PastaPastaPasta referenced this in commit bcbb096baa on Jan 29, 2019
  44. PastaPastaPasta referenced this in commit 1b2aad1458 on Feb 26, 2019
  45. PastaPastaPasta referenced this in commit ee2048ae44 on Feb 26, 2019
  46. UdjinM6 referenced this in commit b7a3c7582e on Mar 9, 2019
  47. PastaPastaPasta referenced this in commit b4426860e2 on Mar 10, 2019
  48. random-zebra referenced this in commit 2d50b6e3b9 on Jun 9, 2021
  49. DrahtBot locked this on Sep 8, 2021

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-21 15:15 UTC

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