mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 15:47:07 +00:00
tendermint/account -> acm
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/merkle"
|
||||
@@ -310,7 +310,7 @@ func (data *Data) Hash() []byte {
|
||||
if data.hash == nil {
|
||||
bs := make([]interface{}, len(data.Txs))
|
||||
for i, tx := range data.Txs {
|
||||
bs[i] = account.SignBytes(config.GetString("chain_id"), tx)
|
||||
bs[i] = acm.SignBytes(config.GetString("chain_id"), tx)
|
||||
}
|
||||
data.hash = merkle.SimpleHashFromBinaries(bs) // NOTE: leaves are TxIDs.
|
||||
}
|
||||
|
||||
+17
-17
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
)
|
||||
@@ -78,11 +78,11 @@ var _ = binary.RegisterInterface(
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type TxInput struct {
|
||||
Address []byte `json:"address"` // Hash of the PubKey
|
||||
Amount int64 `json:"amount"` // Must not exceed account balance
|
||||
Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput
|
||||
Signature account.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
|
||||
PubKey account.PubKey `json:"pub_key"` // Must not be nil, may be nil
|
||||
Address []byte `json:"address"` // Hash of the PubKey
|
||||
Amount int64 `json:"amount"` // Must not exceed account balance
|
||||
Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput
|
||||
Signature acm.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
|
||||
PubKey acm.PubKey `json:"pub_key"` // Must not be nil, may be nil
|
||||
}
|
||||
|
||||
func (txIn *TxInput) ValidateBasic() error {
|
||||
@@ -231,10 +231,10 @@ func (tx *NameTx) String() string {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type BondTx struct {
|
||||
PubKey account.PubKeyEd25519 `json:"pub_key"`
|
||||
Signature account.SignatureEd25519 `json:"signature"`
|
||||
Inputs []*TxInput `json:"inputs"`
|
||||
UnbondTo []*TxOutput `json:"unbond_to"`
|
||||
PubKey acm.PubKeyEd25519 `json:"pub_key"`
|
||||
Signature acm.SignatureEd25519 `json:"signature"`
|
||||
Inputs []*TxInput `json:"inputs"`
|
||||
UnbondTo []*TxOutput `json:"unbond_to"`
|
||||
}
|
||||
|
||||
func (tx *BondTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
|
||||
@@ -265,9 +265,9 @@ func (tx *BondTx) String() string {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type UnbondTx struct {
|
||||
Address []byte `json:"address"`
|
||||
Height int `json:"height"`
|
||||
Signature account.SignatureEd25519 `json:"signature"`
|
||||
Address []byte `json:"address"`
|
||||
Height int `json:"height"`
|
||||
Signature acm.SignatureEd25519 `json:"signature"`
|
||||
}
|
||||
|
||||
func (tx *UnbondTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
|
||||
@@ -282,9 +282,9 @@ func (tx *UnbondTx) String() string {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type RebondTx struct {
|
||||
Address []byte `json:"address"`
|
||||
Height int `json:"height"`
|
||||
Signature account.SignatureEd25519 `json:"signature"`
|
||||
Address []byte `json:"address"`
|
||||
Height int `json:"height"`
|
||||
Signature acm.SignatureEd25519 `json:"signature"`
|
||||
}
|
||||
|
||||
func (tx *RebondTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
|
||||
@@ -316,7 +316,7 @@ func (tx *DupeoutTx) String() string {
|
||||
|
||||
// This should match the leaf hashes of Block.Data.Hash()'s SimpleMerkleTree.
|
||||
func TxID(chainID string, tx Tx) []byte {
|
||||
signBytes := account.SignBytes(chainID, tx)
|
||||
signBytes := acm.SignBytes(chainID, tx)
|
||||
return binary.BinaryRipemd160(signBytes)
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -3,7 +3,7 @@ package types
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
||||
)
|
||||
@@ -39,7 +39,7 @@ func TestSendTxSignable(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
signBytes := account.SignBytes(chainID, sendTx)
|
||||
signBytes := acm.SignBytes(chainID, sendTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"chain_id":"%s","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.GetString("chain_id"))
|
||||
@@ -60,7 +60,7 @@ func TestCallTxSignable(t *testing.T) {
|
||||
Fee: 222,
|
||||
Data: []byte("data1"),
|
||||
}
|
||||
signBytes := account.SignBytes(chainID, callTx)
|
||||
signBytes := acm.SignBytes(chainID, callTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"chain_id":"%s","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`,
|
||||
config.GetString("chain_id"))
|
||||
@@ -73,9 +73,9 @@ func TestBondTxSignable(t *testing.T) {
|
||||
privKeyBytes := make([]byte, 64)
|
||||
var privKeyArray [64]byte
|
||||
copy(privKeyArray[:], privKeyBytes)
|
||||
privAccount := account.GenPrivAccountFromPrivKeyBytes(&privKeyArray)
|
||||
privAccount := acm.GenPrivAccountFromPrivKeyBytes(&privKeyArray)
|
||||
bondTx := &BondTx{
|
||||
PubKey: privAccount.PubKey.(account.PubKeyEd25519),
|
||||
PubKey: privAccount.PubKey.(acm.PubKeyEd25519),
|
||||
Inputs: []*TxInput{
|
||||
&TxInput{
|
||||
Address: []byte("input1"),
|
||||
@@ -99,7 +99,7 @@ func TestBondTxSignable(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
signBytes := account.SignBytes(chainID, bondTx)
|
||||
signBytes := acm.SignBytes(chainID, bondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"chain_id":"%s","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`,
|
||||
config.GetString("chain_id"))
|
||||
@@ -113,7 +113,7 @@ func TestUnbondTxSignable(t *testing.T) {
|
||||
Address: []byte("address1"),
|
||||
Height: 111,
|
||||
}
|
||||
signBytes := account.SignBytes(chainID, unbondTx)
|
||||
signBytes := acm.SignBytes(chainID, unbondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"chain_id":"%s","tx":[18,{"address":"6164647265737331","height":111}]}`,
|
||||
config.GetString("chain_id"))
|
||||
@@ -127,7 +127,7 @@ func TestRebondTxSignable(t *testing.T) {
|
||||
Address: []byte("address1"),
|
||||
Height: 111,
|
||||
}
|
||||
signBytes := account.SignBytes(chainID, rebondTx)
|
||||
signBytes := acm.SignBytes(chainID, rebondTx)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"chain_id":"%s","tx":[19,{"address":"6164647265737331","height":111}]}`,
|
||||
config.GetString("chain_id"))
|
||||
|
||||
+26
-26
@@ -2,11 +2,11 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
)
|
||||
|
||||
type AccountGetter interface {
|
||||
GetAccount(addr []byte) *account.Account
|
||||
GetAccount(addr []byte) *acm.Account
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -19,7 +19,7 @@ func NewSendTx() *SendTx {
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *SendTx) AddInput(st AccountGetter, pubkey account.PubKey, amt int64) error {
|
||||
func (tx *SendTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error {
|
||||
addr := pubkey.Address()
|
||||
acc := st.GetAccount(addr)
|
||||
if acc == nil {
|
||||
@@ -28,13 +28,13 @@ func (tx *SendTx) AddInput(st AccountGetter, pubkey account.PubKey, amt int64) e
|
||||
return tx.AddInputWithNonce(pubkey, amt, acc.Sequence+1)
|
||||
}
|
||||
|
||||
func (tx *SendTx) AddInputWithNonce(pubkey account.PubKey, amt int64, nonce int) error {
|
||||
func (tx *SendTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error {
|
||||
addr := pubkey.Address()
|
||||
tx.Inputs = append(tx.Inputs, &TxInput{
|
||||
Address: addr,
|
||||
Amount: amt,
|
||||
Sequence: nonce,
|
||||
Signature: account.SignatureEd25519{},
|
||||
Signature: acm.SignatureEd25519{},
|
||||
PubKey: pubkey,
|
||||
})
|
||||
return nil
|
||||
@@ -48,7 +48,7 @@ func (tx *SendTx) AddOutput(addr []byte, amt int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tx *SendTx) SignInput(chainID string, i int, privAccount *account.PrivAccount) error {
|
||||
func (tx *SendTx) SignInput(chainID string, i int, privAccount *acm.PrivAccount) error {
|
||||
if i >= len(tx.Inputs) {
|
||||
return fmt.Errorf("Index %v is greater than number of inputs (%v)", i, len(tx.Inputs))
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (tx *SendTx) SignInput(chainID string, i int, privAccount *account.PrivAcco
|
||||
//----------------------------------------------------------------------------
|
||||
// CallTx interface for creating tx
|
||||
|
||||
func NewCallTx(st AccountGetter, from account.PubKey, to, data []byte, amt, gasLimit, fee int64) (*CallTx, error) {
|
||||
func NewCallTx(st AccountGetter, from acm.PubKey, to, data []byte, amt, gasLimit, fee int64) (*CallTx, error) {
|
||||
addr := from.Address()
|
||||
acc := st.GetAccount(addr)
|
||||
if acc == nil {
|
||||
@@ -71,13 +71,13 @@ func NewCallTx(st AccountGetter, from account.PubKey, to, data []byte, amt, gasL
|
||||
return NewCallTxWithNonce(from, to, data, amt, gasLimit, fee, nonce), nil
|
||||
}
|
||||
|
||||
func NewCallTxWithNonce(from account.PubKey, to, data []byte, amt, gasLimit, fee int64, nonce int) *CallTx {
|
||||
func NewCallTxWithNonce(from acm.PubKey, to, data []byte, amt, gasLimit, fee int64, nonce int) *CallTx {
|
||||
addr := from.Address()
|
||||
input := &TxInput{
|
||||
Address: addr,
|
||||
Amount: amt,
|
||||
Sequence: nonce,
|
||||
Signature: account.SignatureEd25519{},
|
||||
Signature: acm.SignatureEd25519{},
|
||||
PubKey: from,
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func NewCallTxWithNonce(from account.PubKey, to, data []byte, amt, gasLimit, fee
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *CallTx) Sign(chainID string, privAccount *account.PrivAccount) {
|
||||
func (tx *CallTx) Sign(chainID string, privAccount *acm.PrivAccount) {
|
||||
tx.Input.PubKey = privAccount.PubKey
|
||||
tx.Input.Signature = privAccount.Sign(chainID, tx)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func (tx *CallTx) Sign(chainID string, privAccount *account.PrivAccount) {
|
||||
//----------------------------------------------------------------------------
|
||||
// NameTx interface for creating tx
|
||||
|
||||
func NewNameTx(st AccountGetter, from account.PubKey, name, data string, amt, fee int64) (*NameTx, error) {
|
||||
func NewNameTx(st AccountGetter, from acm.PubKey, name, data string, amt, fee int64) (*NameTx, error) {
|
||||
addr := from.Address()
|
||||
acc := st.GetAccount(addr)
|
||||
if acc == nil {
|
||||
@@ -109,13 +109,13 @@ func NewNameTx(st AccountGetter, from account.PubKey, name, data string, amt, fe
|
||||
return NewNameTxWithNonce(from, name, data, amt, fee, nonce), nil
|
||||
}
|
||||
|
||||
func NewNameTxWithNonce(from account.PubKey, name, data string, amt, fee int64, nonce int) *NameTx {
|
||||
func NewNameTxWithNonce(from acm.PubKey, name, data string, amt, fee int64, nonce int) *NameTx {
|
||||
addr := from.Address()
|
||||
input := &TxInput{
|
||||
Address: addr,
|
||||
Amount: amt,
|
||||
Sequence: nonce,
|
||||
Signature: account.SignatureEd25519{},
|
||||
Signature: acm.SignatureEd25519{},
|
||||
PubKey: from,
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func NewNameTxWithNonce(from account.PubKey, name, data string, amt, fee int64,
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *NameTx) Sign(chainID string, privAccount *account.PrivAccount) {
|
||||
func (tx *NameTx) Sign(chainID string, privAccount *acm.PrivAccount) {
|
||||
tx.Input.PubKey = privAccount.PubKey
|
||||
tx.Input.Signature = privAccount.Sign(chainID, tx)
|
||||
}
|
||||
@@ -135,8 +135,8 @@ func (tx *NameTx) Sign(chainID string, privAccount *account.PrivAccount) {
|
||||
//----------------------------------------------------------------------------
|
||||
// BondTx interface for adding inputs/outputs and adding signatures
|
||||
|
||||
func NewBondTx(pubkey account.PubKey) (*BondTx, error) {
|
||||
pubkeyEd, ok := pubkey.(account.PubKeyEd25519)
|
||||
func NewBondTx(pubkey acm.PubKey) (*BondTx, error) {
|
||||
pubkeyEd, ok := pubkey.(acm.PubKeyEd25519)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Pubkey must be ed25519")
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func NewBondTx(pubkey account.PubKey) (*BondTx, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (tx *BondTx) AddInput(st AccountGetter, pubkey account.PubKey, amt int64) error {
|
||||
func (tx *BondTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error {
|
||||
addr := pubkey.Address()
|
||||
acc := st.GetAccount(addr)
|
||||
if acc == nil {
|
||||
@@ -156,13 +156,13 @@ func (tx *BondTx) AddInput(st AccountGetter, pubkey account.PubKey, amt int64) e
|
||||
return tx.AddInputWithNonce(pubkey, amt, acc.Sequence+1)
|
||||
}
|
||||
|
||||
func (tx *BondTx) AddInputWithNonce(pubkey account.PubKey, amt int64, nonce int) error {
|
||||
func (tx *BondTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error {
|
||||
addr := pubkey.Address()
|
||||
tx.Inputs = append(tx.Inputs, &TxInput{
|
||||
Address: addr,
|
||||
Amount: amt,
|
||||
Sequence: nonce,
|
||||
Signature: account.SignatureEd25519{},
|
||||
Signature: acm.SignatureEd25519{},
|
||||
PubKey: pubkey,
|
||||
})
|
||||
return nil
|
||||
@@ -176,9 +176,9 @@ func (tx *BondTx) AddOutput(addr []byte, amt int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tx *BondTx) SignBond(chainID string, privAccount *account.PrivAccount) error {
|
||||
func (tx *BondTx) SignBond(chainID string, privAccount *acm.PrivAccount) error {
|
||||
sig := privAccount.Sign(chainID, tx)
|
||||
sigEd, ok := sig.(account.SignatureEd25519)
|
||||
sigEd, ok := sig.(acm.SignatureEd25519)
|
||||
if !ok {
|
||||
return fmt.Errorf("Bond signer must be ED25519")
|
||||
}
|
||||
@@ -186,7 +186,7 @@ func (tx *BondTx) SignBond(chainID string, privAccount *account.PrivAccount) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tx *BondTx) SignInput(chainID string, i int, privAccount *account.PrivAccount) error {
|
||||
func (tx *BondTx) SignInput(chainID string, i int, privAccount *acm.PrivAccount) error {
|
||||
if i >= len(tx.Inputs) {
|
||||
return fmt.Errorf("Index %v is greater than number of inputs (%v)", i, len(tx.Inputs))
|
||||
}
|
||||
@@ -205,8 +205,8 @@ func NewUnbondTx(addr []byte, height int) *UnbondTx {
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *UnbondTx) Sign(chainID string, privAccount *account.PrivAccount) {
|
||||
tx.Signature = privAccount.Sign(chainID, tx).(account.SignatureEd25519)
|
||||
func (tx *UnbondTx) Sign(chainID string, privAccount *acm.PrivAccount) {
|
||||
tx.Signature = privAccount.Sign(chainID, tx).(acm.SignatureEd25519)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -219,6 +219,6 @@ func NewRebondTx(addr []byte, height int) *RebondTx {
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *RebondTx) Sign(chainID string, privAccount *account.PrivAccount) {
|
||||
tx.Signature = privAccount.Sign(chainID, tx).(account.SignatureEd25519)
|
||||
func (tx *RebondTx) Sign(chainID string, privAccount *acm.PrivAccount) {
|
||||
tx.Signature = privAccount.Sign(chainID, tx).(acm.SignatureEd25519)
|
||||
}
|
||||
|
||||
+7
-7
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
)
|
||||
@@ -28,12 +28,12 @@ func (err *ErrVoteConflictingSignature) Error() string {
|
||||
|
||||
// Represents a prevote, precommit, or commit vote from validators for consensus.
|
||||
type Vote struct {
|
||||
Height int `json:"height"`
|
||||
Round int `json:"round"`
|
||||
Type byte `json:"type"`
|
||||
BlockHash []byte `json:"block_hash"` // empty if vote is nil.
|
||||
BlockParts PartSetHeader `json:"block_parts"` // zero if vote is nil.
|
||||
Signature account.SignatureEd25519 `json:"signature"`
|
||||
Height int `json:"height"`
|
||||
Round int `json:"round"`
|
||||
Type byte `json:"type"`
|
||||
BlockHash []byte `json:"block_hash"` // empty if vote is nil.
|
||||
BlockParts PartSetHeader `json:"block_parts"` // zero if vote is nil.
|
||||
Signature acm.SignatureEd25519 `json:"signature"`
|
||||
}
|
||||
|
||||
// Types of votes
|
||||
|
||||
Reference in New Issue
Block a user