-
Notifications
You must be signed in to change notification settings - Fork 69
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 build and send sweep transaction for bitcoin js wallet #358
Conversation
63f1c37
to
54dbc54
Compare
Hey @matthewjablack thanks for the PR here, this is a very cool function |
Hey @monokh we're pretty focused on Bitcoin development at the moment, so unfortunately the ETH side of things would be out of scope of us. |
@matthewjablack To ensure the library is predictable and fits the purpose of being an abstraction layer between the chains, we really need any functionality implemented to have a suitable interface and be implemented across the supported chains where possible. Maintaining single chain based functionality adds overhead that the library is not suited towards. For example the current signature for So we ask for new features to be implemented cross chain because it:
|
Hey @monokh good point about I've changed it to |
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.
Please also include the ERC20 implementation. I believe it would be in EthereumErc20Provider
throw Error('There should not be any change for sweeping transaction') | ||
} | ||
|
||
_outputs.forEach((output, i) => { |
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.
What is going on here with the _outputs
and fixedInputs
?
The common set of function across chains would be to send all value in the wallet to a single address.
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.
Having _outputs
and fixedInputs
allows you to spend all utxos in a wallet, and send a specific amount to an address, while sending the change to another address.
Useful if you want to pay someone and sweep your wallet at the same time.
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.
Ok, i see what you are going for here. However i think the functions should not cater for complex features, unless it can be abstracted cross chain or is required for a specific need.
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.
we want to reduce our maintenance to what is necessary for common usage
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.
changing that should make this function as well as getInputsForAmount
simpler
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.
There are actually a couple of use cases where this is quite important.
If you want to allow users to select specific utxos and spend them or send funds to a particular location (similar to Wasabi) having defined inputs and outputs is necessary.
Another case is for DLC's. Every DLC created, must commit to a specific utxo for the funding tx. If the user wants to create multiple DLC's, they must split up the utxos beforehand. To do this as efficiently as possible, it's important to be able to specify a particular utxo, create one output to be used for a specific DLC, and the other one be change.
@monokh 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.
This is looking in really good shape! Just one final comment
throw Error('There should not be any change for sweeping transaction') | ||
} | ||
|
||
_outputs.forEach((output, i) => { |
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.
Ok, i see what you are going for here. However i think the functions should not cater for complex features, unless it can be abstracted cross chain or is required for a specific need.
throw Error('There should not be any change for sweeping transaction') | ||
} | ||
|
||
_outputs.forEach((output, i) => { |
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.
we want to reduce our maintenance to what is necessary for common usage
throw Error('There should not be any change for sweeping transaction') | ||
} | ||
|
||
_outputs.forEach((output, i) => { |
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.
changing that should make this function as well as getInputsForAmount
simpler
Updated @monokh to remove Bitcoin specific functionality. This can be implemented externally if developers wish to allow wasabi type functionality |
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.
Looking good! Thanks for this
Description
This PR adds
buildSweepTransaction
andsendSweepTransaction
for Bitcoin js wallet enabling the ability to sweep all utxos to a destination of choice.This is particularly useful if you wish to remove all funds from a wallet
Note: This can be useful for Ethereum as well. The major use case would be for sweeping all ETH from a wallet (since it's already pretty easy to do this for ERC20's)
Submission Checklist 📝
sendSweepTransaction