-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Fix for lockunspent returning true even for non-existent outputs #3574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@aalness Removed the offtopic replies here, sorry for continuing them. I was lost in a maze of twisty github issues all alike... Edit: I also took the liberty to clarify your pull request title somewhat. |
src/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use 4-space indentation here also below throw please.
|
Does this change require any changes in the GUI coin-control code or do we directly benefit from this change? |
|
Good question. At first read, it looks like the coin-control GUI could theoretically by-pass this new check and lock an unlockable coin. This could be confusing to an RPC user. eg. GUI user locks an unlockable coin, RPC user sees it in the output for listlockunspent and when they try to unlock it via lockunspent it fails due to the coin being unlockable. |
|
But does the GUI allow it? I think it's pretty locked down in that regard, showing only coins that can be spent (and thus locked). But I may be wrong. |
|
Havent tested, but I agree with @laanwj. You check 4 conditions (mapwallet output.n !ispent ismine), coin control calls AvailableCoins, checking the same but even more conditions. I also suggest:
This would be consistent with the GUI, checking the same conditions. |
|
Ah, good feedback @cozz. Will make those changes. Thanks. |
lockunspent will now validate all of the provided outputs are both unspent and belong to the local wallet. The operation is now also atomic.
|
@cozz I incorporated your feedback but note the semantic implication: lockunspent lock=true for an already locked coin would now throw an error. Previously, the behavior was: lockunspent lock=true for an already locked coin returns true. I think a case could be made for either behavior but I want to point it out in case this violates a convention I'm unaware of. Or if it's particularly distasteful to anyone. |
|
@aalness yes, maybe in the case "lockunspent lock=true for an already locked coin", Code looks good, not sure what the core devs opinion is on this. So lets wait for another opinion here... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now we have coin.IsAvailable as well as CWallet::IsAvailableCoin? I think that's a bit confusing.
|
@laanwj yes, so maybe not touch AvailableCoins at all. And just introduce 1 new function IsAvailableCoin, duplicating all the necessary logic. Just like IsLockableCoin before. Thats what I meant initially. Would also be easier to review and to compare. What do you think? |
|
@laanwj yeah, that's fair. It bothered me slightly too, although, it seemed to be a bit of an existing convention to call a CWalletTx a "coin" or "pcoin". Do you think it would be less confusing to simply change the variable to "wtx"? Can you think of a better way to describe a transaction in this state, as opposed to "available"? Or would you just prefer that I remove the method altogether? @cozz I do like the property that IsAvailableCoin and AvailableCoins now share the same exact code. It seems like a stronger guarantee that the GUI and listunspent stay consistent with lockunspent. |
|
@aalness Needs rebase |
|
Automatic sanity-testing: FAILED MERGE, see http://jenkins.bluematt.me/pull-tester/p3574_74ad5868245790c1f6c712c6afaa0d76398d2d7d/ for test log. This pull does not merge cleanly onto current master |
|
Closing this pull as it appears to be inactive. If you intend to resume working on this, let me know. |
28f8b66 Diagnose unsuitable outputs in lockunspent(). (Eelis) Pull request description: Fixes #2667. This is a simplified version of pull request #3574, which was abandoned by its author. I added some tests as well. Tree-SHA512: e63e00dec8b1b232079380183805cb0b0b18c78ea6bea769837949aab984689d7f68b2ccfe66b1873517b040b9e616ce0eb058575c3d4382aa8c26eebcf1f14e
28f8b66 Diagnose unsuitable outputs in lockunspent(). (Eelis) Pull request description: Fixes dashpay#2667. This is a simplified version of pull request dashpay#3574, which was abandoned by its author. I added some tests as well. Tree-SHA512: e63e00dec8b1b232079380183805cb0b0b18c78ea6bea769837949aab984689d7f68b2ccfe66b1873517b040b9e616ce0eb058575c3d4382aa8c26eebcf1f14e
lockunspent will now validate all of the provided outputs are
both unspent and belong to the local wallet.
The operation is now also atomic.
Fix for #2667