Fill coinbase transaction data with random bytes

This commit is contained in:
Ivan Kuznetsov 2017-09-19 15:47:03 +07:00
parent ffac3de519
commit 9b9b571028
1 changed files with 7 additions and 1 deletions

View File

@ -173,7 +173,13 @@ func (tx *Transaction) Verify(prevTXs map[string]Transaction) bool {
// NewCoinbaseTX creates a new coinbase transaction
func NewCoinbaseTX(to, data string) *Transaction {
if data == "" {
data = fmt.Sprintf("Reward to '%s'", to)
randData := make([]byte, 20)
_, err := rand.Read(randData)
if err != nil {
log.Panic(err)
}
data = fmt.Sprintf("%x", randData)
}
txin := TXInput{[]byte{}, -1, nil, []byte(data)}