diff --git a/account/priv_account.go b/account/priv_account.go index 4fdfcf1b572..ccd702b1f32 100644 --- a/account/priv_account.go +++ b/account/priv_account.go @@ -2,6 +2,7 @@ package account import ( "github.com/tendermint/ed25519" + "github.com/tendermint/tendermint/binary" . "github.com/tendermint/tendermint/common" ) @@ -25,6 +26,21 @@ func GenPrivAccount() *PrivAccount { } } +// Generates a new account with private key from SHA256 hash of a secret +func GenPrivAccountFromSecret(secret []byte) *PrivAccount { + privKey32 := binary.BinarySha256(secret) + privKeyBytes := new([64]byte) + copy(privKeyBytes[:32], privKey32) + pubKeyBytes := ed25519.MakePublicKey(privKeyBytes) + pubKey := PubKeyEd25519(pubKeyBytes[:]) + privKey := PrivKeyEd25519(privKeyBytes[:]) + return &PrivAccount{ + Address: pubKey.Address(), + PubKey: pubKey, + PrivKey: privKey, + } +} + func GenPrivAccountFromKey(privKeyBytes [64]byte) *PrivAccount { pubKeyBytes := ed25519.MakePublicKey(&privKeyBytes) pubKey := PubKeyEd25519(pubKeyBytes[:]) diff --git a/state/execution.go b/state/execution.go index dabe8016091..dcccbaf81f5 100644 --- a/state/execution.go +++ b/state/execution.go @@ -434,7 +434,7 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea txCache.UpdateAccount(caller) // because we adjusted by input above, and bumped nonce maybe. txCache.UpdateAccount(callee) // because we adjusted by input above. vmach := vm.NewVM(txCache, params, caller.Address, account.HashSignBytes(tx)) - vmach.SetFireable(_s.evc) + vmach.SetFireable(evc) // NOTE: Call() transfers the value from caller to callee iff call succeeds. ret, err := vmach.Call(caller, callee, code, tx.Data, value, &gas)