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
Add effective value calculation #2230
Add effective value calculation #2230
Conversation
8e25e41
to
12262cb
Compare
@Kixunil what do you think? Will add some tests around this if it seems ok. |
7dc0a5c
to
4822b07
Compare
force push to add test for |
4822b07
to
1dc4627
Compare
Thinking about this it's weird that it's a method on If there's a method on I think there should be something like |
Ok, well in the meantime re-opening this PR #2217 then which I had closed in favor of this current work would fix the broken crate I'm working on. Any opposition to that? |
I mean I'm intrigued by the advanced stuff. A free-standing function would be still fine (and still useful for uncommon cases like custom scripts). |
Ah ok, I thought you where second guessing if |
Yeah, I think it should be a free-standing function. |
Sure, but where? I mean it does need |
In the |
85e7cc0
to
e64a8dd
Compare
0badc52
to
3391cfd
Compare
Rebased and dropped a clippy commit that had already been merged with master. |
dbf7b61
to
f2b992c
Compare
I added |
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.
ACK f2b992c
Composing an input set for a transaction requires the input amount to be the net amount of spending the corresponding output (TxOut), so I believe the terminology TxOut here is correct. |
f2b992c
to
a248f57
Compare
Sorry for all the noise. Should read "value of a output" not input which is what it was before. |
a248f57
to
0796ee9
Compare
changed to |
0796ee9
to
4c753c8
Compare
Rebased with master |
Maybe I ought to reword the doc comment since it's sort of confusing how the commit uses the What about something like: The |
@sanket1729 I'm not sure I follow. Can you give an example of how using the effective cost of a change output is used? |
@yancyribbens, I have seen some coin selection code where the cost of a change output is subtracted from the change output. It is also useful when building complex transactions with multiple recipients. In any case, we don't need to add this as there is no requirement for this. |
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.
ACK 4c753c8
Ah ok, I see. I'm starting to 2nd guess if this is actually worth adding to Rust Bitcoin since it's so specific to coin selection. Maybe it's better to just keep this within rust-bitcoin-coin-selection instead of rust-bitcoin. |
4c753c8
to
d69d628
Compare
The effective_value method is useful for coin selection algorithms. By providing this effective value method, the effective value of each output can be known during the coin selection process.
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.
ACK d69d628
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.
ACK d69d628
Draft PR for adding effective value calculation to TxOut. Adding this method was discussed here: #2217