You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

  1. package blockchain
  2. import "encoding/hex"
  3. import "github.com/romana/rlog"
  4. import "github.com/deroproject/derosuite/address"
  5. import "github.com/deroproject/derosuite/globals"
  6. func Create_Miner_Transaction(height uint64, median_size uint64, already_generated_coins uint64,
  7. current_block_size uint64, fee uint64,
  8. miner_address address.Address, nonce []byte,
  9. max_outs uint64, hard_fork uint64) (tx *Transaction, err error) {
  10. return nil, nil
  11. }
  12. // genesis transaction hash 5a18d9489bcd353aeaf4a19323d04e90353f98f0d7cc2a030cfd76e19495547d
  13. // genesis amount 35184372088831
  14. func Generate_Genesis_Block() (bl Block) {
  15. genesis_tx_blob, err := hex.DecodeString(globals.Config.Genesis_Tx)
  16. if err != nil {
  17. panic("Failed to hex decode genesis Tx")
  18. }
  19. err = bl.Miner_tx.DeserializeHeader(genesis_tx_blob)
  20. if err != nil {
  21. panic("Failed to parse genesis tx ")
  22. }
  23. rlog.Tracef(2, "Hash of Genesis Tx %x\n", bl.Miner_tx.GetHash())
  24. // verify whether tx is coinbase and valid
  25. // setup genesis block header
  26. bl.Major_Version = 1
  27. bl.Minor_Version = 0
  28. bl.Timestamp = 0 // first block timestamp
  29. //bl.Prev_hash is automatic zero
  30. bl.Nonce = globals.Config.Genesis_Nonce
  31. rlog.Tracef(2, "Hash of genesis block is %x", bl.GetHash())
  32. rlog.Tracef(2, "Genesis Block PoW %x\n", bl.GetPoWHash())
  33. return
  34. }