diff options
-rw-r--r-- | core/vm/governance.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go index e4c3b31e3..b78d1bf94 100644 --- a/core/vm/governance.go +++ b/core/vm/governance.go @@ -1182,7 +1182,18 @@ func (g *GovernanceContract) stake(publicKey []byte) ([]byte, error) { return nil, errExecutionReverted } - // TODO(w): check of pk belongs to the address. + pk, err := crypto.DecompressPubkey(publicKey) + if err != nil { + g.penalize() + return nil, errExecutionReverted + } + + // Make sure the public key belongs to the caller. + if crypto.PubkeyToAddress(*pk) != caller { + g.penalize() + return nil, errExecutionReverted + } + offset = g.state.nodesLength() g.state.pushNode(&nodeInfo{ owner: caller, |