Skip to content

Commit

Permalink
wire-mix: more max count error formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Nov 21, 2023
1 parent 47d8312 commit 6693718
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion wire/msgmixct.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func (msg *MsgMixCT) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if count > MaxPrevMixMsgs {
msg := fmt.Sprintf("too many previous referenced messages [%v]", count)
msg := fmt.Sprintf("too many previous referenced messages [count %v, max %v]",
count, MaxPrevMixMsgs)
return messageError(op, ErrTooManyPrevMixMsgs, msg)
}

Expand Down
6 changes: 4 additions & 2 deletions wire/msgmixdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func (msg *MsgMixDC) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if mcount > MaxMixMcount {
msg := fmt.Sprintf("too many total mixed messages [%v]", mcount)
msg := fmt.Sprintf("too many total mixed messages [count %v, max %v]",
mcount, MaxMixMcount)
return messageError(op, ErrInvalidMsg, msg)
}

Expand All @@ -61,7 +62,8 @@ func (msg *MsgMixDC) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if count > MaxPrevMixMsgs {
msg := fmt.Sprintf("too many previous referenced messages [%v]", count)
msg := fmt.Sprintf("too many previous referenced messages [count %v, max %v]",
count, MaxPrevMixMsgs)
return messageError(op, ErrTooManyPrevMixMsgs, msg)
}

Expand Down
3 changes: 2 additions & 1 deletion wire/msgmixke.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (msg *MsgMixKE) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if count > MaxPrevMixMsgs {
msg := fmt.Sprintf("too many previous referenced messages [%v]", count)
msg := fmt.Sprintf("too many previous referenced messages [count %v, max %v]",
count, MaxPrevMixMsgs)
return messageError(op, ErrTooManyPrevMixMsgs, msg)
}

Expand Down
12 changes: 8 additions & 4 deletions wire/msgmixpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ func (msg *MsgMixPR) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if count > MaxMixPRUTXOs {
msg := fmt.Sprintf("too many UTXOs in message [%v]", count)
msg := fmt.Sprintf("too many UTXOs in message [count %v, max %v]",
count, MaxMixPRUTXOs)
return messageError(op, ErrTooManyMixPRUTXOs, msg)
}
utxos := make([]MixPRUTXO, count)
Expand Down Expand Up @@ -240,7 +241,8 @@ func (msg *MsgMixPR) writeMessageNoSignature(op string, w io.Writer, pver uint32
}

if l := len(utxo.Script); l > MaxMixPRUTXOScriptLen {
msg := fmt.Sprintf("UTXO script is too long [%v]", l)
msg := fmt.Sprintf("UTXO script is too long [len %v, max %v]",
l, MaxMixPRUTXOScriptLen)
return messageError(op, ErrVarBytesTooLong, msg)
}
err = WriteVarBytes(w, pver, utxo.Script)
Expand All @@ -249,7 +251,8 @@ func (msg *MsgMixPR) writeMessageNoSignature(op string, w io.Writer, pver uint32
}

if l := len(utxo.PubKey); l > MaxMixPRUTXOPubKeyLen {
msg := fmt.Sprintf("UTXO public key is too long [%v]", l)
msg := fmt.Sprintf("UTXO public key is too long [len %v, max %v]",
l, MaxMixPRUTXOPubKeyLen)
return messageError(op, ErrVarBytesTooLong, msg)
}
err = WriteVarBytes(w, pver, utxo.PubKey)
Expand All @@ -258,7 +261,8 @@ func (msg *MsgMixPR) writeMessageNoSignature(op string, w io.Writer, pver uint32
}

if l := len(utxo.Signature); l > MaxMixPRUTXOSignatureLen {
msg := fmt.Sprintf("UTXO signature is too long [%v]", l)
msg := fmt.Sprintf("UTXO signature is too long [len %v, max %v]",
l, MaxMixPRUTXOSignatureLen)
return messageError(op, ErrVarBytesTooLong, msg)
}
err = WriteVarBytes(w, pver, utxo.Signature)
Expand Down
6 changes: 4 additions & 2 deletions wire/msgmixrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func (msg *MsgMixRS) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if numSRs > MaxMixMcount {
msg := fmt.Sprintf("too many total mixed messages [%v]", numSRs)
msg := fmt.Sprintf("too many total mixed messages [count %v, max %v]",
numSRs, MaxMixMcount)
return messageError(op, ErrInvalidMsg, msg)
}
msg.SR = make([][]byte, numSRs)
Expand All @@ -67,7 +68,8 @@ func (msg *MsgMixRS) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if numMs > MaxMixMcount {
msg := fmt.Sprintf("too many total mixed messages [%v]", numMs)
msg := fmt.Sprintf("too many total mixed messages [count %v, max %v]",
numMs, MaxMixMcount)
return messageError(op, ErrInvalidMsg, msg)
}
msg.M = make([][]byte, numMs)
Expand Down
6 changes: 4 additions & 2 deletions wire/msgmixsr.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (msg *MsgMixSR) BtcDecode(r io.Reader, pver uint32) error {
return messageError(op, ErrInvalidMsg, msg)
}
if kpcount > MaxMixKPCount {
msg := fmt.Sprintf("too many mixing peers [%v]", kpcount)
msg := fmt.Sprintf("too many mixing peers [count %v, max %v]",
kpcount, MaxMixKPCount)
return messageError(op, ErrInvalidMsg, msg)
}
dcmix := make([][][]byte, mcount)
Expand All @@ -98,7 +99,8 @@ func (msg *MsgMixSR) BtcDecode(r io.Reader, pver uint32) error {
return err
}
if count > MaxPrevMixMsgs {
msg := fmt.Sprintf("too many previous referenced messages [%v]", count)
msg := fmt.Sprintf("too many previous referenced messages [count %v, max %v]",
count, MaxPrevMixMsgs)
return messageError(op, ErrTooManyPrevMixMsgs, msg)
}

Expand Down

0 comments on commit 6693718

Please sign in to comment.