Skip to content

sweepbatcher: batch change outputs #976

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Jul 9, 2025

The batcher receives the ability to sign and publish batches with change outputs.

Change is created when the clients choose fractional swap amounts from the input values to be swapped. Usually the change is sent back to client's addresses.

If change is provided to ensurePresigned, presign and publishPresigned, it is expected to be placed within the passed []sweep.
Each sweep optionally holds a pointer to a change output. Multiple sweeps holding the same change reference will produce a single change output in the batch transaction.

  • unit test coverage for change outputs

@hieblmi hieblmi self-assigned this Jul 9, 2025
@hieblmi hieblmi marked this pull request as draft July 9, 2025 13:39
@hieblmi hieblmi requested a review from starius July 9, 2025 13:39
hieblmi added 3 commits July 9, 2025 15:46
Optional change of a swap is encoded in its sweeps
as a pointer to the same change output. This change
is taken into account when constructing the unsigned
batch transaction when it comes to tx weight and
outputs.
Presigning sweeps takes change outputs into account.
Each sweep belonging to the same sweep group points
to the same change output, if existent.
sweepbatcher.presign scans all passed sweeps for
change outputs and passes them to constructUnsignedTx.
The batcher now presigns sweep groups including
an optional change output. Change is usually
leftover from the client's swap amount which
is returned to the client.
@hieblmi hieblmi force-pushed the batcher-change-outputs branch from 19b13cd to c7091de Compare July 9, 2025 13:46
for _, sweep := range sweeps {
// If the sweep has a change output, add it to the changeOutputs
// map to avoid duplicates.
if sweep.change != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

flatten depth by if == nil { continue }

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.

1 participant