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.

66 lines
2.3 KiB

  1. // Copyright 2017-2018 DERO Project. All rights reserved.
  2. // Use of this source code in any form is governed by RESEARCH license.
  3. // license can be found in the LICENSE file.
  4. // GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8
  5. //
  6. //
  7. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  8. // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  9. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  10. // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  13. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  14. // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. package blockchain
  17. import "encoding/hex"
  18. import "github.com/romana/rlog"
  19. //import "github.com/arnaucode/derosuite/address"
  20. import "github.com/arnaucode/derosuite/block"
  21. import "github.com/arnaucode/derosuite/globals"
  22. /*
  23. func Create_Miner_Transaction(height uint64, median_size uint64, already_generated_coins uint64,
  24. current_block_size uint64, fee uint64,
  25. miner_address address.Address, nonce []byte,
  26. max_outs uint64, hard_fork uint64) (tx *transaction.Transaction, err error) {
  27. return nil, nil
  28. }
  29. */
  30. // genesis transaction hash 5a18d9489bcd353aeaf4a19323d04e90353f98f0d7cc2a030cfd76e19495547d
  31. // genesis amount 35184372088831
  32. func Generate_Genesis_Block() (bl block.Block) {
  33. genesis_tx_blob, err := hex.DecodeString(globals.Config.Genesis_Tx)
  34. if err != nil {
  35. panic("Failed to hex decode genesis Tx")
  36. }
  37. err = bl.Miner_tx.DeserializeHeader(genesis_tx_blob)
  38. if err != nil {
  39. panic("Failed to parse genesis tx ")
  40. }
  41. rlog.Tracef(2, "Hash of Genesis Tx %x\n", bl.Miner_tx.GetHash())
  42. // verify whether tx is coinbase and valid
  43. // setup genesis block header
  44. bl.Major_Version = 1
  45. bl.Minor_Version = 0
  46. bl.Timestamp = 0 // first block timestamp
  47. //bl.Prev_hash is automatic zero
  48. bl.Nonce = globals.Config.Genesis_Nonce
  49. rlog.Tracef(2, "Hash of genesis block is %x", bl.GetHash())
  50. rlog.Tracef(2, "Genesis Block PoW %x\n", bl.GetPoWHash())
  51. return
  52. }