mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 14:34:17 +00:00
tendermint/account -> acm
This commit is contained in:
+6
-6
@@ -2,7 +2,7 @@ package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/tendermint/tendermint/vm"
|
||||
)
|
||||
|
||||
func toVMAccount(acc *account.Account) *vm.Account {
|
||||
func toVMAccount(acc *acm.Account) *vm.Account {
|
||||
return &vm.Account{
|
||||
Address: LeftPadWord256(acc.Address),
|
||||
Balance: acc.Balance,
|
||||
@@ -78,7 +78,7 @@ func CallCode(code, data []byte) (*ctypes.ResponseCall, error) {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) {
|
||||
func SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (types.Tx, error) {
|
||||
// more checks?
|
||||
|
||||
for i, privAccount := range privAccounts {
|
||||
@@ -101,17 +101,17 @@ func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error)
|
||||
bondTx := tx.(*types.BondTx)
|
||||
// the first privaccount corresponds to the BondTx pub key.
|
||||
// the rest to the inputs
|
||||
bondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), bondTx).(account.SignatureEd25519)
|
||||
bondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), bondTx).(acm.SignatureEd25519)
|
||||
for i, input := range bondTx.Inputs {
|
||||
input.PubKey = privAccounts[i+1].PubKey
|
||||
input.Signature = privAccounts[i+1].Sign(config.GetString("chain_id"), bondTx)
|
||||
}
|
||||
case *types.UnbondTx:
|
||||
unbondTx := tx.(*types.UnbondTx)
|
||||
unbondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), unbondTx).(account.SignatureEd25519)
|
||||
unbondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), unbondTx).(acm.SignatureEd25519)
|
||||
case *types.RebondTx:
|
||||
rebondTx := tx.(*types.RebondTx)
|
||||
rebondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), rebondTx).(account.SignatureEd25519)
|
||||
rebondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), rebondTx).(acm.SignatureEd25519)
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package core_types
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
@@ -18,8 +18,8 @@ type ResponseCall struct {
|
||||
}
|
||||
|
||||
type ResponseListAccounts struct {
|
||||
BlockHeight int `json:"block_height"`
|
||||
Accounts []*account.Account `json:"accounts"`
|
||||
BlockHeight int `json:"block_height"`
|
||||
Accounts []*acm.Account `json:"accounts"`
|
||||
}
|
||||
|
||||
type StorageItem struct {
|
||||
@@ -51,7 +51,7 @@ type Receipt struct {
|
||||
type ResponseStatus struct {
|
||||
NodeInfo *types.NodeInfo `json:"node_info"`
|
||||
GenesisHash []byte `json:"genesis_hash"`
|
||||
PubKey account.PubKey `json:"pub_key"`
|
||||
PubKey acm.PubKey `json:"pub_key"`
|
||||
LatestBlockHash []byte `json:"latest_block_hash"`
|
||||
LatestBlockHeight int `json:"latest_block_height"`
|
||||
LatestBlockTime int64 `json:"latest_block_time"` // nano
|
||||
|
||||
@@ -4,7 +4,6 @@ package core_client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
@@ -33,7 +32,7 @@ type Client interface {
|
||||
ListUnconfirmedTxs() ([]types.Tx, error)
|
||||
ListValidators() (*ctypes.ResponseListValidators, error)
|
||||
NetInfo() (*ctypes.ResponseNetInfo, error)
|
||||
SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error)
|
||||
SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (types.Tx, error)
|
||||
Status() (*ctypes.ResponseStatus, error)
|
||||
}
|
||||
|
||||
@@ -547,7 +546,7 @@ func (c *ClientHTTP) NetInfo() (*ctypes.ResponseNetInfo, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) {
|
||||
func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (types.Tx, error) {
|
||||
values, err := argsToURLValues([]string{"tx", "privAccounts"}, tx, privAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1066,7 +1065,7 @@ func (c *ClientJSON) NetInfo() (*ctypes.ResponseNetInfo, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) {
|
||||
func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (types.Tx, error) {
|
||||
request := rpctypes.RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: reverseFuncMap["SignTx"],
|
||||
|
||||
+11
-11
@@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
nm "github.com/tendermint/tendermint/node"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
@@ -37,11 +37,11 @@ var (
|
||||
)
|
||||
|
||||
// deterministic account generation, synced with genesis file in config/tendermint_test/config.go
|
||||
func makeUsers(n int) []*account.PrivAccount {
|
||||
accounts := []*account.PrivAccount{}
|
||||
func makeUsers(n int) []*acm.PrivAccount {
|
||||
accounts := []*acm.PrivAccount{}
|
||||
for i := 0; i < n; i++ {
|
||||
secret := []byte("mysecret" + strconv.Itoa(i))
|
||||
user := account.GenPrivAccountFromSecret(secret)
|
||||
user := acm.GenPrivAccountFromSecret(secret)
|
||||
accounts = append(accounts, user)
|
||||
}
|
||||
return accounts
|
||||
@@ -71,8 +71,8 @@ func init() {
|
||||
// Save new priv_validator file.
|
||||
priv := &state.PrivValidator{
|
||||
Address: user[0].Address,
|
||||
PubKey: account.PubKeyEd25519(user[0].PubKey.(account.PubKeyEd25519)),
|
||||
PrivKey: account.PrivKeyEd25519(user[0].PrivKey.(account.PrivKeyEd25519)),
|
||||
PubKey: acm.PubKeyEd25519(user[0].PubKey.(acm.PubKeyEd25519)),
|
||||
PrivKey: acm.PrivKeyEd25519(user[0].PrivKey.(acm.PrivKeyEd25519)),
|
||||
}
|
||||
priv.SetFile(config.GetString("priv_validator_file"))
|
||||
priv.Save()
|
||||
@@ -133,7 +133,7 @@ func getNonce(t *testing.T, typ string, addr []byte) int {
|
||||
}
|
||||
|
||||
// get the account
|
||||
func getAccount(t *testing.T, typ string, addr []byte) *account.Account {
|
||||
func getAccount(t *testing.T, typ string, addr []byte) *acm.Account {
|
||||
client := clients[typ]
|
||||
ac, err := client.GetAccount(addr)
|
||||
if err != nil {
|
||||
@@ -143,9 +143,9 @@ func getAccount(t *testing.T, typ string, addr []byte) *account.Account {
|
||||
}
|
||||
|
||||
// sign transaction
|
||||
func signTx(t *testing.T, typ string, tx types.Tx, privAcc *account.PrivAccount) types.Tx {
|
||||
func signTx(t *testing.T, typ string, tx types.Tx, privAcc *acm.PrivAccount) types.Tx {
|
||||
client := clients[typ]
|
||||
signedTx, err := client.SignTx(tx, []*account.PrivAccount{privAcc})
|
||||
signedTx, err := client.SignTx(tx, []*acm.PrivAccount{privAcc})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -219,12 +219,12 @@ func getNameRegEntry(t *testing.T, typ string, name string) *types.NameRegEntry
|
||||
//--------------------------------------------------------------------------------
|
||||
// utility verification function
|
||||
|
||||
func checkTx(t *testing.T, fromAddr []byte, priv *account.PrivAccount, tx *types.SendTx) {
|
||||
func checkTx(t *testing.T, fromAddr []byte, priv *acm.PrivAccount, tx *types.SendTx) {
|
||||
if bytes.Compare(tx.Inputs[0].Address, fromAddr) != 0 {
|
||||
t.Fatal("Tx input addresses don't match!")
|
||||
}
|
||||
|
||||
signBytes := account.SignBytes(chainID, tx)
|
||||
signBytes := acm.SignBytes(chainID, tx)
|
||||
in := tx.Inputs[0] //(*types.SendTx).Inputs[0]
|
||||
|
||||
if err := in.ValidateBasic(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user