From: muscle_boy Date: Tue, 4 Jun 2019 07:40:43 +0000 (+0800) Subject: validate vote pubkey (#128) X-Git-Tag: v1.0.5~208^2~70 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=33703f3e14106dbf91be25a78e7909c5664baf45 validate vote pubkey (#128) --- diff --git a/protocol/validation/tx.go b/protocol/validation/tx.go index 14d1b87f..d7cc42b5 100644 --- a/protocol/validation/tx.go +++ b/protocol/validation/tx.go @@ -38,6 +38,7 @@ var ( ErrUnbalanced = errors.New("unbalanced asset amount between input and output") ErrOverGasCredit = errors.New("all gas credit has been spend") ErrGasCalculate = errors.New("gas usage calculate got a math error") + ErrVotePubKey = errors.New("invalid public key of vote") ) // GasState record the gas usage status @@ -227,6 +228,9 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { } case *bc.VoteOutput: + if len(e.Vote) != 64 { + return ErrVotePubKey + } vs2 := *vs vs2.sourcePos = 0 if err = checkValidSrc(&vs2, e.Source); err != nil { @@ -270,6 +274,9 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { controlProgram = output.ControlProgram value = output.Source.Value case *bc.VoteOutput: + if len(output.Vote) != 64 { + return ErrVotePubKey + } controlProgram = output.ControlProgram value = output.Source.Value default: