X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=config%2Fgenesis.go;h=58ad266a8e037a46a2269acf0aad863c12a6a5d1;hp=5f643a02f102944b69095346bd4be207100e2769;hb=85d69b6527ed724f0785e180db12230b71f2e2a9;hpb=04e99309457c70c11b0538e38b6a0b68d5b64a87 diff --git a/config/genesis.go b/config/genesis.go index 5f643a02..58ad266a 100644 --- a/config/genesis.go +++ b/config/genesis.go @@ -6,20 +6,42 @@ import ( log "github.com/sirupsen/logrus" "github.com/vapor/consensus" + "github.com/vapor/crypto" + "github.com/vapor/crypto/ed25519/chainkd" "github.com/vapor/protocol/bc" "github.com/vapor/protocol/bc/types" + "github.com/vapor/protocol/vm/vmutil" ) +func GenesisArguments(c *Config) []byte { + pubKeys := chainkd.XPubKeys(c.Federation.Xpubs) + fedpegScript, err := vmutil.P2SPMultiSigProgram(pubKeys, c.Federation.Quorum) + if err != nil { + log.Panicf("fail on decode genesis arguments for federation") + } + + scriptHash := crypto.Sha256(fedpegScript) + + control, err := vmutil.P2WSHProgram(scriptHash) + if err != nil { + log.Panicf("Fail converts scriptHash to program on GenesisArguments: %v", err) + } + + return control +} + func GenesisTx() *types.Tx { contract, err := hex.DecodeString("00148c9d063ff74ee6d9ffa88d83aeb038068366c4c4") if err != nil { log.Panicf("fail on decode genesis tx output control program") } + coinbaseInput := GenesisArguments(CommonConfig) + txData := types.TxData{ Version: 1, Inputs: []*types.TxInput{ - types.NewCoinbaseInput([]byte("Information is power. -- Jan/11/2013. Computing is power. -- Apr/24/2018.")), + types.NewCoinbaseInput(coinbaseInput[:]), }, Outputs: []*types.TxOutput{ types.NewIntraChainOutput(*consensus.BTMAssetID, consensus.InitialBlockSubsidy, contract),