diff options
author | Wei-Ning Huang <w@cobinhood.com> | 2018-10-11 14:05:09 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 25486bbcfe6cb43707e93ba5c16c99c9c53026e9 (patch) | |
tree | 403c10ee59da8dfc2945c2e7aaa3849bef1452de /core/vm | |
parent | f5b04dce7eb6b4f9a41f2312c83ba5d531632df0 (diff) | |
download | dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.tar dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.tar.gz dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.tar.bz2 dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.tar.lz dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.tar.xz dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.tar.zst dexon-25486bbcfe6cb43707e93ba5c16c99c9c53026e9.zip |
core: vm: check pk ownership in stake()
Diffstat (limited to 'core/vm')
-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, |