Convert most benign uses of Hex to MustAddressToBech32

pull/992/head
Eugene Kim 6 years ago
parent b520342a63
commit 53bbce84c8
  1. 4
      api/service/explorer/structs.go
  2. 2
      api/service/explorer/structs_test.go
  3. 16
      cmd/client/wallet/main.go
  4. 7
      cmd/harmony/main.go
  5. 4
      cmd/keygen/main.go
  6. 3
      consensus/consensus.go
  7. 7
      consensus/consensus_service.go
  8. 3
      consensus/consensus_service_test.go
  9. 5
      core/state/statedb_test.go
  10. 3
      core/types/shard_state.go
  11. 5
      drand/drand.go
  12. 4
      drand/drand_test.go
  13. 3
      internal/hmyapi/util.go
  14. 6
      node/contract.go

@ -94,8 +94,8 @@ func GetTransaction(tx *types.Transaction, accountBlock *types.Block) *Transacti
return &Transaction{ return &Transaction{
ID: tx.Hash().Hex(), ID: tx.Hash().Hex(),
Timestamp: strconv.Itoa(int(accountBlock.Time().Int64() * 1000)), Timestamp: strconv.Itoa(int(accountBlock.Time().Int64() * 1000)),
From: msg.From().Hex(), From: msg.From().Hex(), // TODO ek – use bech32
To: msg.To().Hex(), To: msg.To().Hex(), // TODO ek – use bech32
Value: msg.Value(), Value: msg.Value(),
Bytes: strconv.Itoa(int(tx.Size())), Bytes: strconv.Itoa(int(tx.Size())),
Data: hex.EncodeToString(tx.Data()), Data: hex.EncodeToString(tx.Data()),

@ -22,6 +22,6 @@ func TestGetTransaction(t *testing.T) {
tx := GetTransaction(tx1, block) tx := GetTransaction(tx1, block)
assert.Equal(t, tx.ID, tx1.Hash().Hex(), "should be equal tx1.Hash()") assert.Equal(t, tx.ID, tx1.Hash().Hex(), "should be equal tx1.Hash()")
assert.Equal(t, tx.To, tx1.To().Hex(), "should be equal tx1.To()") assert.Equal(t, tx.To, tx1.To().Hex(), "should be equal tx1.To()") // TODO ek – use bech32
assert.Equal(t, tx.Bytes, strconv.Itoa(int(tx1.Size())), "should be equal tx1.Size()") assert.Equal(t, tx.Bytes, strconv.Itoa(int(tx1.Size())), "should be equal tx1.Size()")
} }

@ -272,19 +272,19 @@ func processNewCommnad() {
if err != nil { if err != nil {
fmt.Printf("new account error: %v\n", err) fmt.Printf("new account error: %v\n", err)
} }
fmt.Printf("account: %s\n", account.Address.Hex()) fmt.Printf("account: %s\n", common2.MustAddressToBech32(account.Address))
fmt.Printf("URL: %s\n", account.URL) fmt.Printf("URL: %s\n", account.URL)
} }
func _exportAccount(account accounts.Account) { func _exportAccount(account accounts.Account) {
fmt.Printf("account: %s\n", account.Address.Hex()) fmt.Printf("account: %s\n", common2.MustAddressToBech32(account.Address))
fmt.Printf("URL: %s\n", account.URL) fmt.Printf("URL: %s\n", account.URL)
pass := utils.AskForPassphrase("Original Passphrase: ") pass := utils.AskForPassphrase("Original Passphrase: ")
newpass := utils.AskForPassphrase("Export Passphrase: ") newpass := utils.AskForPassphrase("Export Passphrase: ")
data, err := ks.Export(account, pass, newpass) data, err := ks.Export(account, pass, newpass)
if err == nil { if err == nil {
filename := fmt.Sprintf(".hmy/%s.key", account.Address.Hex()) filename := fmt.Sprintf(".hmy/%s.key", common2.MustAddressToBech32(account.Address))
f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, 0644) f, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {
panic("Failed to open keystore") panic("Failed to open keystore")
@ -316,7 +316,7 @@ func processListCommand() {
allAccounts := ks.Accounts() allAccounts := ks.Accounts()
for _, account := range allAccounts { for _, account := range allAccounts {
fmt.Printf("account: %s\n", account.Address.Hex()) fmt.Printf("account: %s\n", common2.MustAddressToBech32(account.Address))
fmt.Printf("URL: %s\n", account.URL) fmt.Printf("URL: %s\n", account.URL)
} }
} }
@ -330,7 +330,7 @@ func processExportCommand() {
allAccounts := ks.Accounts() allAccounts := ks.Accounts()
for _, account := range allAccounts { for _, account := range allAccounts {
if acc == "" || acc == account.Address.Hex() { if acc == "" || acc == common2.MustAddressToBech32(account.Address) {
_exportAccount(account) _exportAccount(account)
} }
} }
@ -360,7 +360,7 @@ func processImportCommnad() {
if err != nil { if err != nil {
panic("Failed to import the private key") panic("Failed to import the private key")
} }
fmt.Printf("Private key imported for account: %s\n", account.Address.Hex()) fmt.Printf("Private key imported for account: %s\n", common2.MustAddressToBech32(account.Address))
} }
func processBalancesCommand() { func processBalancesCommand() {
@ -373,14 +373,14 @@ func processBalancesCommand() {
allAccounts := ks.Accounts() allAccounts := ks.Accounts()
for i, account := range allAccounts { for i, account := range allAccounts {
fmt.Printf("Account %d:\n", i) fmt.Printf("Account %d:\n", i)
fmt.Printf(" Address: %s\n", account.Address.Hex()) fmt.Printf(" Address: %s\n", common2.MustAddressToBech32(account.Address))
for shardID, balanceNonce := range FetchBalance(account.Address) { for shardID, balanceNonce := range FetchBalance(account.Address) {
fmt.Printf(" Balance in Shard %d: %s, nonce: %v \n", shardID, convertBalanceIntoReadableFormat(balanceNonce.balance), balanceNonce.nonce) fmt.Printf(" Balance in Shard %d: %s, nonce: %v \n", shardID, convertBalanceIntoReadableFormat(balanceNonce.balance), balanceNonce.nonce)
} }
} }
} else { } else {
address := common2.ParseAddr(*balanceAddressPtr) address := common2.ParseAddr(*balanceAddressPtr)
fmt.Printf("Account: %s:\n", address.Hex()) fmt.Printf("Account: %s:\n", common2.MustAddressToBech32(address))
for shardID, balanceNonce := range FetchBalance(address) { for shardID, balanceNonce := range FetchBalance(address) {
fmt.Printf(" Balance in Shard %d: %s, nonce: %v \n", shardID, convertBalanceIntoReadableFormat(balanceNonce.balance), balanceNonce.nonce) fmt.Printf(" Balance in Shard %d: %s, nonce: %v \n", shardID, convertBalanceIntoReadableFormat(balanceNonce.balance), balanceNonce.nonce)
} }

@ -18,6 +18,7 @@ import (
"github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/drand" "github.com/harmony-one/harmony/drand"
"github.com/harmony-one/harmony/internal/common"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/ctxerror"
"github.com/harmony-one/harmony/internal/genesis" "github.com/harmony-one/harmony/internal/genesis"
@ -173,7 +174,7 @@ func initSetup() {
foundAccount := false foundAccount := false
for _, account := range allAccounts { for _, account := range allAccounts {
if genesisAccount.Address == account.Address.Hex() { if common.ParseAddr(genesisAccount.Address) == account.Address {
myAccount = account myAccount = account
foundAccount = true foundAccount = true
break break
@ -187,7 +188,7 @@ func initSetup() {
genesisAccount.ShardID = uint32(accountIndex % core.GenesisShardNum) genesisAccount.ShardID = uint32(accountIndex % core.GenesisShardNum)
fmt.Printf("My Account: %s\n", myAccount.Address.Hex()) fmt.Printf("My Account: %s\n", common.MustAddressToBech32(myAccount.Address))
fmt.Printf("Key URL: %s\n", myAccount.URL) fmt.Printf("Key URL: %s\n", myAccount.URL)
fmt.Printf("My Genesis Account: %v\n", *genesisAccount) fmt.Printf("My Genesis Account: %v\n", *genesisAccount)
@ -313,7 +314,7 @@ func setUpConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node {
currentNode.NodeConfig.SetRole(nodeconfig.NewNode) currentNode.NodeConfig.SetRole(nodeconfig.NewNode)
currentNode.StakingAccount = myAccount currentNode.StakingAccount = myAccount
utils.GetLogInstance().Info("node account set", utils.GetLogInstance().Info("node account set",
"address", currentNode.StakingAccount.Address.Hex()) "address", common.MustAddressToBech32(currentNode.StakingAccount.Address))
if gsif, err := consensus.NewGenesisStakeInfoFinder(); err == nil { if gsif, err := consensus.NewGenesisStakeInfoFinder(); err == nil {
currentConsensus.SetStakeInfoFinder(gsif) currentConsensus.SetStakeInfoFinder(gsif)

@ -9,6 +9,8 @@ import (
"strconv" "strconv"
crypto2 "github.com/ethereum/go-ethereum/crypto" crypto2 "github.com/ethereum/go-ethereum/crypto"
"github.com/harmony-one/harmony/internal/common"
) )
var ( var (
@ -38,7 +40,7 @@ func main() {
} }
crypto2.FromECDSA(priKey) crypto2.FromECDSA(priKey)
fmt.Printf("{Address: \"%s\", Private: \"%s\", Public: \"%s\"},\n", crypto2.PubkeyToAddress(priKey.PublicKey).Hex(), hex.EncodeToString(crypto2.FromECDSA(priKey)), crypto2.PubkeyToAddress(priKey.PublicKey).Hex()) fmt.Printf("{Address: \"%s\", Private: \"%s\", Public: \"%s\"},"+"\n", common.MustAddressToBech32(crypto2.PubkeyToAddress(priKey.PublicKey)), hex.EncodeToString(crypto2.FromECDSA(priKey)), common.MustAddressToBech32(crypto2.PubkeyToAddress(priKey.PublicKey)))
} }
} else { } else {
fmt.Println("Unable to parse # as the argument.") fmt.Println("Unable to parse # as the argument.")

@ -15,6 +15,7 @@ import (
"github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/state"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
bls_cosi "github.com/harmony-one/harmony/crypto/bls" bls_cosi "github.com/harmony-one/harmony/crypto/bls"
common2 "github.com/harmony-one/harmony/internal/common"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/ctxerror"
"github.com/harmony-one/harmony/internal/genesis" "github.com/harmony-one/harmony/internal/genesis"
@ -217,7 +218,7 @@ func New(host p2p.Host, ShardID uint32, leader p2p.Peer, blsPriKey *bls.SecretKe
consensus.commitSigs = map[common.Address]*bls.Sign{} consensus.commitSigs = map[common.Address]*bls.Sign{}
consensus.CommitteeAddresses = make(map[common.Address]bool) consensus.CommitteeAddresses = make(map[common.Address]bool)
consensus.validators.Store(utils.GetBlsAddress(leader.ConsensusPubKey).Hex(), leader) consensus.validators.Store(common2.MustAddressToBech32(utils.GetBlsAddress(leader.ConsensusPubKey)), leader)
// For now use socket address as ID // For now use socket address as ID
// TODO: populate Id derived from address // TODO: populate Id derived from address

@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/harmony-one/harmony/crypto/hash" "github.com/harmony-one/harmony/crypto/hash"
common2 "github.com/harmony-one/harmony/internal/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
@ -380,7 +381,7 @@ func (consensus *Consensus) AddPeers(peers []*p2p.Peer) int {
count := 0 count := 0
for _, peer := range peers { for _, peer := range peers {
_, ok := consensus.validators.LoadOrStore(utils.GetBlsAddress(peer.ConsensusPubKey).Hex(), *peer) _, ok := consensus.validators.LoadOrStore(common2.MustAddressToBech32(utils.GetBlsAddress(peer.ConsensusPubKey)), *peer)
if !ok { if !ok {
consensus.pubKeyLock.Lock() consensus.pubKeyLock.Lock()
if _, ok := consensus.CommitteeAddresses[peer.ConsensusPubKey.GetAddress()]; !ok { if _, ok := consensus.CommitteeAddresses[peer.ConsensusPubKey.GetAddress()]; !ok {
@ -510,7 +511,7 @@ func (consensus *Consensus) verifySenderKey(msg *msg_pb.Message) (*bls.PublicKey
senderAddr := common.BytesToAddress(addrBytes[:]) senderAddr := common.BytesToAddress(addrBytes[:])
if !consensus.IsValidatorInCommittee(senderAddr) { if !consensus.IsValidatorInCommittee(senderAddr) {
return nil, fmt.Errorf("Validator address %s is not in committee", senderAddr.Hex()) return nil, fmt.Errorf("Validator address %s is not in committee", common2.MustAddressToBech32(senderAddr))
} }
return senderKey, nil return senderKey, nil
} }
@ -525,7 +526,7 @@ func (consensus *Consensus) verifyViewChangeSenderKey(msg *msg_pb.Message) (*bls
senderAddr := common.BytesToAddress(addrBytes[:]) senderAddr := common.BytesToAddress(addrBytes[:])
if !consensus.IsValidatorInCommittee(senderAddr) { if !consensus.IsValidatorInCommittee(senderAddr) {
return nil, common.Address{}, fmt.Errorf("Validator address %s is not in committee", senderAddr.Hex()) return nil, common.Address{}, fmt.Errorf("Validator address %s is not in committee", common2.MustAddressToBech32(senderAddr))
} }
return senderKey, senderAddr, nil return senderKey, senderAddr, nil
} }

@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/harmony/crypto/bls" "github.com/harmony-one/harmony/crypto/bls"
common2 "github.com/harmony-one/harmony/internal/common"
msg_pb "github.com/harmony-one/harmony/api/proto/message" msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils"
@ -28,7 +29,7 @@ func TestGetPeerFromID(t *testing.T) {
t.Fatalf("Cannot craeate consensus: %v", err) t.Fatalf("Cannot craeate consensus: %v", err)
} }
leaderAddress := utils.GetAddressFromBlsPubKey(leader.ConsensusPubKey) leaderAddress := utils.GetAddressFromBlsPubKey(leader.ConsensusPubKey)
l := consensus.GetPeerByAddress(leaderAddress.Hex()) l := consensus.GetPeerByAddress(common2.MustAddressToBech32(leaderAddress))
if l.IP != leader.IP || l.Port != leader.Port { if l.IP != leader.IP || l.Port != leader.Port {
t.Errorf("leader IP not equal") t.Errorf("leader IP not equal")
} }

@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
common2 "github.com/harmony-one/harmony/internal/common"
) )
// Tests that updating a state trie does not leak any database writes prior to // Tests that updating a state trie does not leak any database writes prior to
@ -280,7 +281,7 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
action := actions[r.Intn(len(actions))] action := actions[r.Intn(len(actions))]
var nameargs []string var nameargs []string
if !action.noAddr { if !action.noAddr {
nameargs = append(nameargs, addr.Hex()) nameargs = append(nameargs, common2.MustAddressToBech32(addr))
} }
for _, i := range action.args { for _, i := range action.args {
action.args[i] = rand.Int63n(100) action.args[i] = rand.Int63n(100)
@ -366,7 +367,7 @@ func (test *snapshotTest) checkEqual(state, checkstate *DB) error {
var err error var err error
checkeq := func(op string, a, b interface{}) bool { checkeq := func(op string, a, b interface{}) bool {
if err == nil && !reflect.DeepEqual(a, b) { if err == nil && !reflect.DeepEqual(a, b) {
err = fmt.Errorf("got %s(%s) == %v, want %v", op, addr.Hex(), a, b) err = fmt.Errorf("got %s(%s) == %v, want %v", op, common2.MustAddressToBech32(addr), a, b)
return false return false
} }
return true return true

@ -9,6 +9,7 @@ import (
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
common2 "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/ctxerror"
) )
@ -208,5 +209,5 @@ func (n NodeID) Serialize() []byte {
} }
func (n NodeID) String() string { func (n NodeID) String() string {
return "ECDSA: " + n.EcdsaAddress.Hex() + ", BLS: " + hex.EncodeToString(n.BlsPublicKey[:]) return "ECDSA: " + common2.MustAddressToBech32(n.EcdsaAddress) + ", BLS: " + hex.EncodeToString(n.BlsPublicKey[:])
} }

@ -5,6 +5,7 @@ import (
"sync" "sync"
"github.com/harmony-one/harmony/crypto/hash" "github.com/harmony-one/harmony/crypto/hash"
common2 "github.com/harmony-one/harmony/internal/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -91,7 +92,7 @@ func New(host p2p.Host, ShardID uint32, peers []p2p.Peer, leader p2p.Peer, confi
dRand.leader = leader dRand.leader = leader
dRand.CommitteeAddresses = map[common.Address]bool{} dRand.CommitteeAddresses = map[common.Address]bool{}
for _, peer := range peers { for _, peer := range peers {
dRand.validators.Store(utils.GetBlsAddress(peer.ConsensusPubKey).Hex(), peer) dRand.validators.Store(common2.MustAddressToBech32(utils.GetBlsAddress(peer.ConsensusPubKey)), peer)
dRand.CommitteeAddresses[utils.GetBlsAddress(peer.ConsensusPubKey)] = true dRand.CommitteeAddresses[utils.GetBlsAddress(peer.ConsensusPubKey)] = true
} }
@ -136,7 +137,7 @@ func (dRand *DRand) AddPeers(peers []*p2p.Peer) int {
count := 0 count := 0
for _, peer := range peers { for _, peer := range peers {
_, ok := dRand.validators.LoadOrStore(utils.GetBlsAddress(peer.ConsensusPubKey).Hex(), *peer) _, ok := dRand.validators.LoadOrStore(common2.MustAddressToBech32(utils.GetBlsAddress(peer.ConsensusPubKey)), *peer)
if !ok { if !ok {
dRand.pubKeyLock.Lock() dRand.pubKeyLock.Lock()
if _, ok := dRand.CommitteeAddresses[peer.ConsensusPubKey.GetAddress()]; !ok { if _, ok := dRand.CommitteeAddresses[peer.ConsensusPubKey.GetAddress()]; !ok {

@ -6,9 +6,11 @@ import (
"testing" "testing"
bls2 "github.com/harmony-one/harmony/crypto/bls" bls2 "github.com/harmony-one/harmony/crypto/bls"
common2 "github.com/harmony-one/harmony/internal/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
msg_pb "github.com/harmony-one/harmony/api/proto/message" msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils"
@ -95,7 +97,7 @@ func TestGetValidatorByPeerId(test *testing.T) {
test.Error("dRand should belong to a leader") test.Error("dRand should belong to a leader")
} }
validatorAddress := utils.GetAddressFromBlsPubKey(validatorPubKey).Hex() validatorAddress := common2.MustAddressToBech32(utils.GetAddressFromBlsPubKey(validatorPubKey))
if dRand.getValidatorPeerByAddress(validatorAddress) == nil { if dRand.getValidatorPeerByAddress(validatorAddress) == nil {
test.Error("Unable to get validator by Peerid") test.Error("Unable to get validator by Peerid")

@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
common2 "github.com/harmony-one/harmony/internal/common"
) )
// SubmitTransaction is a helper function that submits tx to txPool and logs a message. // SubmitTransaction is a helper function that submits tx to txPool and logs a message.
@ -21,7 +22,7 @@ func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c
return common.Hash{}, err return common.Hash{}, err
} }
addr := crypto.CreateAddress(from, tx.Nonce()) addr := crypto.CreateAddress(from, tx.Nonce())
log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex()) log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", common2.MustAddressToBech32(addr))
} else { } else {
log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To()) log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To())
} }

@ -12,10 +12,12 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/common/denominations" "github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/contracts" "github.com/harmony-one/harmony/contracts"
"github.com/harmony-one/harmony/contracts/structs" "github.com/harmony-one/harmony/contracts/structs"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
common2 "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/genesis" "github.com/harmony-one/harmony/internal/genesis"
"github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils"
) )
@ -170,7 +172,7 @@ func (node *Node) CallFaucetContract(address common.Address) common.Hash {
// Temporary code to workaround explorer issue for searching new addresses (https://github.com/harmony-one/harmony/issues/503) // Temporary code to workaround explorer issue for searching new addresses (https://github.com/harmony-one/harmony/issues/503)
nonce := atomic.AddUint64(&node.ContractDeployerCurrentNonce, 1) nonce := atomic.AddUint64(&node.ContractDeployerCurrentNonce, 1)
tx, _ := types.SignTx(types.NewTransaction(nonce-1, address, node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, nil), types.HomesteadSigner{}, node.ContractDeployerKey) tx, _ := types.SignTx(types.NewTransaction(nonce-1, address, node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, nil), types.HomesteadSigner{}, node.ContractDeployerKey)
utils.GetLogInstance().Info("Sending placeholder token to ", "Address", address.Hex()) utils.GetLogInstance().Info("Sending placeholder token to ", "Address", common2.MustAddressToBech32(address))
node.addPendingTransactions(types.Transactions{tx}) node.addPendingTransactions(types.Transactions{tx})
// END Temporary code // END Temporary code
@ -199,7 +201,7 @@ func (node *Node) callGetFreeTokenWithNonce(address common.Address, nonce uint64
return common.Hash{} return common.Hash{}
} }
tx, _ := types.SignTx(types.NewTransaction(nonce, node.ContractAddresses[0], node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, bytesData), types.HomesteadSigner{}, node.ContractDeployerKey) tx, _ := types.SignTx(types.NewTransaction(nonce, node.ContractAddresses[0], node.Consensus.ShardID, big.NewInt(0), params.TxGasContractCreation*10, nil, bytesData), types.HomesteadSigner{}, node.ContractDeployerKey)
utils.GetLogInstance().Info("Sending Free Token to ", "Address", address.Hex()) utils.GetLogInstance().Info("Sending Free Token to ", "Address", common2.MustAddressToBech32(address))
node.addPendingTransactions(types.Transactions{tx}) node.addPendingTransactions(types.Transactions{tx})
return tx.Hash() return tx.Hash()

Loading…
Cancel
Save