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

RFC: add consolidate stragegy #58

Closed
wants to merge 1 commit into from

Conversation

Overtorment
Copy link
Collaborator

After discussion here #43 I believe this is a better way to implement consolidation strategy. While I happily use split for sendMax functionality, I think slightly adjusted accumulative strategy will allow tech-savvy users to make regular BTC transactions (utilizing batch send when needed) while sweeping all their inputs for consolidation.

In this PR I basically copied accumulative strategy while fixing the loop to add all inputs and not stop when fee+amount requirements are satisfied. Added couple of tests, but probably not enough.
Did not change any documentation. Looking for an ACK before proceeding.

@Overtorment
Copy link
Collaborator Author

up

var utxoValue = utils.uintOrNaN(utxo.value)

// skip detrimental input
if (utxoFee > utxo.value) {
Copy link
Member

Choose a reason for hiding this comment

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

If I have a 1000 sat utxo and it adds a 1000 sat fee to my transaction, this will add it...

Is this assumption also made in other parts of the library? If so that's fine, but if not, I would perhaps add a parameter for the user to define a percentage of fee that is the cutoff.

IMO if we have a utxo of 1000 value, the highest acceptable fee should be 999 and the lowest should be 0. The user of this API should be able to decide whether they want to skip above 10 or skip above 900.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is copypasted from

if (utxoFee > utxo.value) {
I did not assume anything

@Overtorment
Copy link
Collaborator Author

Overtorment commented May 31, 2020

So whats the general feedback? Should I add more tests (which ones would be best, besides coverage?), amend documentation and submit a PR?

@junderw
Copy link
Member

junderw commented May 31, 2020

My general feedback is that this library needs a big overhaul... but I keep putting it off.

As for this work in progress, I would say coverage definitely needs to get up higher for branches... 100% is a pretty severe threshold though.

I would be fine with merging this if the coverage gets up... but I make no guarantees it will survive when I take a chainsaw to this library and mold it into something better (hopefully).

But I will definitely publish a version with it if you can get coverage and documentation up.

Thx

@Overtorment
Copy link
Collaborator Author

there is no demand for this ATM.

@Overtorment Overtorment deleted the add-consolidate branch January 29, 2021 15:59
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