Skip to content

Commit

Permalink
Narrow rules of what is considered a possible coinjoin
Browse files Browse the repository at this point in the history
Only consider regular transactions, never any stake ones.

If multiple outputs with zero values are found in the transaction,
these are not considered a mix for having similar output values.

If any output script is reused in the transaction, the tx is not
considered a mix.
  • Loading branch information
jrick committed Jan 12, 2021
1 parent 2fec066 commit bd1fc91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions wallet/mixing.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,17 @@ func PossibleCoinJoin(tx *wire.MsgTx) (isMix bool, mixDenom int64, mixCount uint
numberOfInputs := len(tx.TxIn)

mixedOuts := make(map[int64]uint32)
scripts := make(map[string]int)
for _, o := range tx.TxOut {
scripts[string(o.PkScript)]++
if scripts[string(o.PkScript)] > 1 {
return false, 0, 0
}
val := o.Value
// Multiple zero valued outputs do not count as a coinjoin mix.
if val == 0 {
continue
}
mixedOuts[val]++
}

Expand Down
3 changes: 3 additions & 0 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5230,6 +5230,9 @@ func (w *Wallet) getCoinjoinTxsSumbByAcct(ctx context.Context) (map[uint32]int,
_, tipHeight := w.txStore.MainChainTip(dbtx)
rangeFn := func(details []udb.TxDetails) (bool, error) {
for _, detail := range details {
if detail.TxType != stake.TxTypeRegular {
continue
}
isMixedTx, mixDenom, _ := PossibleCoinJoin(&detail.MsgTx)
if !isMixedTx {
continue
Expand Down

0 comments on commit bd1fc91

Please sign in to comment.