verify signing tx

This commit is contained in:
Nguyen Sy Thanh Son 2019-01-11 17:14:12 +00:00
parent cd81c5c8b6
commit 381864d869
3 changed files with 32 additions and 14 deletions

View file

@ -39,6 +39,7 @@ const (
UnvoteMethod = "0x02aa9be2" UnvoteMethod = "0x02aa9be2"
ProposeMethod = "0x01267951" ProposeMethod = "0x01267951"
ResignMethod = "0xae6e43f5" ResignMethod = "0xae6e43f5"
SignMethod = "0xe341eaa4"
) )
var ( var (

View file

@ -336,6 +336,7 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, number ui
var signTxs []*types.Transaction var signTxs []*types.Transaction
for _, tx := range txs { for _, tx := range txs {
if tx.IsSigningTransaction() {
var b uint var b uint
for _, r := range receipts { for _, r := range receipts {
if r.TxHash == tx.Hash() { if r.TxHash == tx.Hash() {
@ -353,6 +354,7 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, number ui
from := *tx.From() from := *tx.From()
data[blkHash] = append(data[blkHash], from) data[blkHash] = append(data[blkHash], from)
} }
}
c.BlockSigners.Add(header.Hash(), signTxs) c.BlockSigners.Add(header.Hash(), signTxs)
} }

View file

@ -291,7 +291,22 @@ func (tx *Transaction) IsSigningTransaction() bool {
if tx.To() == nil { if tx.To() == nil {
return false return false
} }
return tx.To().String() == common.BlockSigners
if tx.To().String() != common.BlockSigners {
return false
}
method := common.ToHex(tx.Data()[0:4])
if method != common.SignMethod {
return false
}
if len(tx.Data()) != (32*2 + 4) {
return false
}
return true
} }
func (tx *Transaction) IsVotingTransaction() (bool, *common.Address) { func (tx *Transaction) IsVotingTransaction() (bool, *common.Address) {