This flag is useful to know if a particular UTXO will be considered by the wallet as part of fundrawtransaction of sendtoaddress.
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-
NicolasDorier commented at 6:01 AM on February 23, 2017: contributor
- jonasschnelli added the label Wallet on Feb 23, 2017
-
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. :)
-
NicolasDorier commented at 11:19 AM on February 23, 2017: contributor
what about "safe" ?
-
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?
-
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.
- NicolasDorier force-pushed on Feb 23, 2017
- NicolasDorier force-pushed on Feb 23, 2017
-
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.
-
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.
-
NicolasDorier commented at 3:24 PM on February 23, 2017: contributor
@ryanofsky I think it is rather different purpose.
include_unsafeact as a filter, here I need an attribute to differenciate whose which will be selected by fundrawtransaction and those which will not. -
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.
-
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.
- ryanofsky referenced this in commit f4cace484c on Feb 23, 2017
-
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.
-
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.
-
NicolasDorier commented at 2:36 AM on February 24, 2017: contributor
@ryanofsky I like your branch. Will update this PR.
-
luke-jr commented at 3:28 AM on February 25, 2017: member
Suggest refactoring by adding a CWalletTx::IsSafe also.
- NicolasDorier force-pushed on Feb 26, 2017
- NicolasDorier renamed this:
Add trusted flag to listunspent result
Add safe flag to listunspent result
on Feb 26, 2017 -
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
COutputtype and rename the parameter in CWallet::AvailableCoins.I then renamed
CWallet::IsTrustedtoCWallet::IsSafewhich more properly reflect the meaning of the function. -
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.
- NicolasDorier force-pushed on Mar 9, 2017
-
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.
-
ryanofsky commented at 1:34 AM on March 9, 2017: member
utACK 23cbc366a7c3633e694286a693a4223de02b95ad
-
af61d9f78b
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.
-
Add safe flag to listunspent result dcf2112de6
- NicolasDorier force-pushed on Mar 10, 2017
-
NicolasDorier commented at 5:12 AM on March 10, 2017: contributor
rebased
-
ryanofsky commented at 8:01 PM on March 10, 2017: member
utACK dcf2112de6ec5a7a5e97076d1ce826eb233a1042, confirmed no changes in rebase.
-
jonasschnelli commented at 7:40 AM on March 11, 2017: contributor
utACK af61d9f78bec62ff3688d88409a53df9ff5bc591
-
btcdrak commented at 12:59 PM on March 12, 2017: contributor
utACK af61d9f78bec62ff3688d88409a53df9ff5bc591
-
TheBlueMatt commented at 1:46 AM on March 13, 2017: member
utACK dcf2112de6ec5a7a5e97076d1ce826eb233a1042
- laanwj merged this on Mar 13, 2017
- laanwj closed this on Mar 13, 2017
- laanwj referenced this in commit afcd7c0e52 on Mar 13, 2017
- PastaPastaPasta referenced this in commit eb94509082 on Jan 2, 2019
- PastaPastaPasta referenced this in commit 7a0e0cd25d on Jan 2, 2019
- PastaPastaPasta referenced this in commit 9cad8fbf0f on Jan 2, 2019
- PastaPastaPasta referenced this in commit 1bb6fa2f77 on Jan 3, 2019
- PastaPastaPasta referenced this in commit af2831b9af on Jan 21, 2019
- PastaPastaPasta referenced this in commit bcbb096baa on Jan 29, 2019
- PastaPastaPasta referenced this in commit 1b2aad1458 on Feb 26, 2019
- PastaPastaPasta referenced this in commit ee2048ae44 on Feb 26, 2019
- UdjinM6 referenced this in commit b7a3c7582e on Mar 9, 2019
- PastaPastaPasta referenced this in commit b4426860e2 on Mar 10, 2019
- random-zebra referenced this in commit 2d50b6e3b9 on Jun 9, 2021
- DrahtBot locked this on Sep 8, 2021