fix private key constant

pull/504/head
Minh Doan 6 years ago committed by Minh Doan
parent 93c94c4bd9
commit 269e4f6119
  1. 23
      internal/utils/contract/constants.go
  2. 3
      node/contract.go

@ -1,7 +1,9 @@
package contract package contract
import ( import (
"github.com/ethereum/go-ethereum/common" "crypto/ecdsa"
"strings"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
) )
@ -12,15 +14,22 @@ type DeployAccount struct {
Public string Public string
} }
// GenesisBeaconAccount is the account which creates contract account. // // GenesisBeaconAccount is the account which creates contract account.
var GenesisBeaconAccount = DeployAccount{ // var GenesisBeaconAccount = DeployAccount{
Address: "0x4e464afF0aB44780fC9A008AC890047BcbDf376f", // Address: "0x4e464afF0aB44780fC9A008AC890047BcbDf376f",
Private: "b167c74da42202fc2093f8e2ed8171b4ad67d095595ac655fc56df236cad9714", // Private: "b167c74da42202fc2093f8e2ed8171b4ad67d095595ac655fc56df236cad9714",
Public: "0x4e464afF0aB44780fC9A008AC890047BcbDf376f", // Public: "0x4e464afF0aB44780fC9A008AC890047BcbDf376f",
// }
func BeaconAccountPriKey() *ecdsa.PrivateKey {
prikey, _ := ecdsa.GenerateKey(crypto.S256(), strings.NewReader("Deposit Smart Contract Key"))
return prikey
} }
var GenesisBeaconAccountPriKey = BeaconAccountPriKey()
// DeployedContractAddress is the deployed contract address of the staking smart contract in beacon chain. // DeployedContractAddress is the deployed contract address of the staking smart contract in beacon chain.
var DeployedContractAddress = crypto.CreateAddress(common.HexToAddress(GenesisBeaconAccount.Address), uint64(0)) var DeployedContractAddress = crypto.CreateAddress(crypto.PubkeyToAddress(GenesisBeaconAccountPriKey.PublicKey), uint64(0))
// FakeAccounts is the accounts only used for development purpose. // FakeAccounts is the accounts only used for development purpose.
var FakeAccounts = [...]DeployAccount{ var FakeAccounts = [...]DeployAccount{

@ -12,6 +12,7 @@ import (
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/utils/contract" "github.com/harmony-one/harmony/internal/utils/contract"
contract_constants "github.com/harmony-one/harmony/internal/utils/contract"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
) )
@ -27,7 +28,7 @@ const (
func (node *Node) AddStakingContractToPendingTransactions() { func (node *Node) AddStakingContractToPendingTransactions() {
// Add a contract deployment transaction // Add a contract deployment transaction
//Generate contract key and associate funds with the smart contract //Generate contract key and associate funds with the smart contract
priKey, _ := ecdsa.GenerateKey(crypto.S256(), strings.NewReader("Deposit Smart Contract Key")) priKey := contract_constants.GenesisBeaconAccountPriKey
contractAddress := crypto.PubkeyToAddress(priKey.PublicKey) contractAddress := crypto.PubkeyToAddress(priKey.PublicKey)
//Initially the smart contract should have minimal funds. //Initially the smart contract should have minimal funds.
contractFunds := big.NewInt(0) contractFunds := big.NewInt(0)

Loading…
Cancel
Save