Navigation Menu

Skip to content
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

createtx: Add change output to size estimation. #2057

Merged
merged 1 commit into from Sep 13, 2021

Conversation

JoeGruffins
Copy link
Member

A multisig transaction will sometimes need a change output. Add that
scipt size to the worst case size estimation that is used in fee
calculation.

closes #1972

A multisig transaction will sometimes need a change output. Add that
scipt size to the worst case size estimation that is used in fee
calculation.
feeSize := txsizes.EstimateSerializeSize(scriptSizes, msgtx.TxOut, 0)
// Add change if we need it.
changeSize := 0
if totalInput > amount+feeEstForTx {
Copy link
Member

@matheusd matheusd Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly right, since it could be the case that totalInput is greater than amount+feeEstForTx but lower than the dust limit, which shouldn't create a change amount, but since feeEstForTx is significantly overestimated (0.5 dcr) this shouldn't happen in ordinary usage.

Fixing this edge case (dust limit change) would require tweaking this entire function to do a proper fee estimation, so unless this is really needed, the proposed change fixes the original issue.

@jrick jrick merged commit 714c2f5 into decred:master Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sendtomultisig underestimating tx size
3 participants