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

Make sweep work for less than 500 outputs #328

Open
wants to merge 3 commits into
base: release/1.1.0.0
Choose a base branch
from

Conversation

sondreb
Copy link
Contributor

@sondreb sondreb commented Dec 30, 2020

  • This fixes an issue where the sweep would only work if there was more than 500 outputs.
  • The "currentOutputCount" is not really used and is reset for every single UTXOs discovered and individual transactions is generated for each UTXOs, they are not combined into a single transaction.
  • The sweep might need some refactoring, and the FallbackFee might need to be increased a little bit to work properly and not generate transactions with too low fee during sweep.

- This fixes an issue where the sweep would only work if there was more than 500 outputs.
- The "currentOutputCount" is not really used and is reset for every single UTXOs discovered and individual transactions is generated for each UTXOs, they are not combined into a single transaction.
- The sweep might need some refactoring, and the FallbackFee might need to be increased a little bit to work properly and not generate transactions with too low fee during sweep.
@sondreb
Copy link
Contributor Author

sondreb commented Dec 30, 2020

I think the original thinking behind this sweep code was to grab all UTXOs and generate a single transaction, but it just doesn't do that right now so this is a tiny fix to make it actually work.

@zeptin
Copy link
Collaborator

zeptin commented Dec 30, 2020

No, the purpose of the < was to keep adding UTXOs to the builder until the transaction has that many inputs, as a rough heuristic for the maximum possible number. A more robust but expensive approach is to estimate the transaction size after each addition, as different types of transactions have differing scriptSig sizes.

Once a large enough transaction is reached the remainder of the loop executes. You thus get a list of transactions with 500 inputs at the end. So I think more of a refactor would be needed in order to handle the case where there aren't at least 500 inputs. Probably the latter part of the loop should be moved to a method, and it should be executed once more once the loop terminates to make a final transaction with the remaining UTXOs.

@sondreb
Copy link
Contributor Author

sondreb commented Dec 31, 2020

So this small PR will fix it so that it accepts a sweep, but there is more to be done in the implementation I think. I might do some more improvements and make another PR, unless someone else does it. Additionally I had to increase the FallbackFee a little bit to ensure it used enough fee to be approved by the policy. Fee should probably be added as an parameter to the API.

- This change probably updates the sweep code with the original intention.
- Will sweep for up to 500 UTXOs, and then build transaction until there are no more UTXOs.
- Will in the end send the final transaction that has less or more than 500 left over.
@sondreb
Copy link
Contributor Author

sondreb commented Jan 8, 2021

Made an update to the sweep, please review =)

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.

2 participants