-
Notifications
You must be signed in to change notification settings - Fork 37.7k
QA: segwit.py: s/find_unspent/find_spendable_utxo/ #11869
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
I don't think it's obvious that a function with that name would only return spendable UTXOs. If there is a use case for it, perhaps make it a boolean argument require_spendable? |
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.
I would say to extend the scope to add minimumSumAmount=min_value
and maximumCount=1
to listunspent
options BUT the result could be an unspendable unspent. I guess listunspent
could have a new option to filter server side.
Also, callers assume this call always work, it should throw after the loop?
Agree with @sipa.
Is there any use case where the function is used to return unspendable outputs? By defintion, if they're unspendable they're not part of the utxo, right? Perhaps this doesn't make sense without #8994, but I don't see the point in adding new parameters to the function that aren't used for any test.
Yeah, that makes sense to me. |
@jtimon Ah, I see the confusion. Spendable here means you have the private keys and scripts necessary to spend them. Watch-only addresses can result in non-spendable UTXOs being listed. |
I see. So would it be fine to add the require_spendable argument and default to True? |
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.
utACK d01b06991a4e10b2cb95b25bfcddcddc58ed0738. Some style nits.
test/functional/segwit.py
Outdated
@@ -70,7 +70,7 @@ def getutxo(txid): | |||
|
|||
def find_unspent(node, min_value): | |||
for utxo in node.listunspent(): |
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.
nit: Can use query_options={"minimumAmount": min_value}
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.
Not sure I understand the suggestion.
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.
listunspent
takes named arguments according to the documentation, so you could add the named argument and remove some code from the python script instead.
test/functional/segwit.py
Outdated
@@ -70,7 +70,7 @@ def getutxo(txid): | |||
|
|||
def find_unspent(node, min_value): | |||
for utxo in node.listunspent(): | |||
if utxo['amount'] >= min_value: | |||
if utxo['amount'] >= min_value and utxo['spendable']: | |||
return utxo | |||
|
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.
Should throw
for clarity.
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.
Yeah, @promag pointed this out already and I said I would do it. Then I ask a question that nobody answered.
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.
I'd say either add the new arg or rename the function and add the missing throw.
test/functional/segwit.py
Outdated
@@ -70,7 +70,7 @@ def getutxo(txid): | |||
|
|||
def find_unspent(node, min_value): |
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.
nit: Rename to find_spendable_output
or something.
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.
That would make the PR much more disruptive, is it worth it?
Also, if I add the require_spendable param, I don't think it makes sense to rename it to that.
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.
much more disruptive.
It is used in less than 5 places.
Changing the function name when the functionality changes aims review and prevents silent merge conflicts/bugs.
@jtimon Are you still working on this? Otherwise I will close |
@MarcoFalke I'm on vacation and I didn't saw your nits. |
@jtimon No rush. Feel free to revisit next year. ;) |
d01b069
to
528e39c
Compare
Hopefully fixed all nits. |
538a07f
to
7a80979
Compare
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.
Nits, don't mind ignoring them. +1 squash.
test/functional/segwit.py
Outdated
return utxo | ||
|
||
raise AssertionError("Unspent output higher than %s not found." % min_value) |
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.
Nit, equal or higher.
Nit, remove .
.
test/functional/segwit.py
Outdated
def find_unspent(node, min_value): | ||
for utxo in node.listunspent(): | ||
if utxo['amount'] >= min_value: | ||
def find_spendable_output(node, min_value): |
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.
Nit, s/output/utxo.
7a80979
to
31260af
Compare
Force pushed to fix newest nits. EDIT: and squashed too. |
ca2a458
to
305c345
Compare
utACK 305c345cc16c21160f07459156b36bd71e86395e |
Needs rebase |
305c345
to
9bb59cf
Compare
Rebased |
re-utACK 9bb59cf |
Tested ACK 9bb59cf |
9bb59cf QA: segwit.py: s/find_unspent/find_spendable_utxo/ (Jorge Timón) Pull request description: Separated from #8994 It was found out testing that PR but I think this fix should be done even without #8994 the fix is not necessary by luck. Unless I'm missing something. Tree-SHA512: ba1a970e674878ae2f27ee8bba372fa3b42dafff682374f50e5ddc9896fd8808fef2b2b70c7028f2a7b0dbea9f3e29a757e2cde98970f5761bf414455ba02c09
Separated from #8994
It was found out testing that PR but I think this fix should be done even without #8994 the fix is not necessary by luck. Unless I'm missing something.