Skip to content

Commit

Permalink
Avoid uncommon CoinJoin output amounts
Browse files Browse the repository at this point in the history
When large UTXOs are mixed, the mixed output amount was chosen as the
smallest preprogramed amount which would result in one or more mixed
outputs.  This had the unfortunate side effect of advertising very
mixed output amounts to a CoinShuffle++ server which were very
uncommon relative to pairing occurring from mixed ticket buying.

As a workaround, the current sdiff is queried, and a decision is made
whether to use an even smaller mixed amount which will allow for
better pairings.
  • Loading branch information
jrick committed Jun 8, 2020
1 parent 86494d5 commit fbcbda0
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit fbcbda0

Please sign in to comment.