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

Avoid uncommon CoinJoin output amounts #1751

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions wallet/mixing.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ type DialFunc func(ctx context.Context, network, addr string) (net.Conn, error)
func (w *Wallet) MixOutput(ctx context.Context, dialTLS DialFunc, csppserver string, output *wire.OutPoint, changeAccount, mixAccount, mixBranch uint32) error {
op := errors.Opf("wallet.MixOutput(%v)", output)

sdiff, err := w.NextStakeDifficulty(ctx)
if err != nil {
return errors.E(op, err)
}

var updates []func(walletdb.ReadWriteTx) error

hold, err := w.holdUnlock()
Expand Down Expand Up @@ -92,6 +97,17 @@ func (w *Wallet) MixOutput(ctx context.Context, dialTLS DialFunc, csppserver str
var count int
var mixValue, remValue dcrutil.Amount
for i, v := range splitPoints {
// When the sdiff is more than four times this mixed output
// amount, there is a smaller common mixed amount with more
// pairing activity (due to CoinShuffle++ participation from
// ticket buyers). Skipping this amount and moving to the next
// smallest common mixed amount will result in quicker pairings,
// or pairings occurring at all. Unlike any downmixing of mixed
// ticketbuying change, this will result in four or more outputs
// when mixing larger UTXOs.
if i != len(splitPoints)-1 && 4*v >= sdiff {
continue
}
count = int(amount / v)
if count > 0 {
remValue = amount - dcrutil.Amount(count)*v
Expand Down