2016-03-20 03:00:43 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/tendermint/go-crypto"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Account struct {
|
2017-03-21 13:52:42 -07:00
|
|
|
PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known.
|
|
|
|
Sequence int `json:"sequence"`
|
|
|
|
Balance Coins `json:"coins"`
|
2016-03-20 03:00:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (acc *Account) Copy() *Account {
|
2017-02-16 18:36:49 -08:00
|
|
|
if acc == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2016-03-20 03:00:43 -07:00
|
|
|
accCopy := *acc
|
|
|
|
return &accCopy
|
|
|
|
}
|
|
|
|
|
|
|
|
func (acc *Account) String() string {
|
|
|
|
if acc == nil {
|
|
|
|
return "nil-Account"
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("Account{%v %v %v}",
|
|
|
|
acc.PubKey, acc.Sequence, acc.Balance)
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
type PrivAccount struct {
|
2017-03-21 13:52:42 -07:00
|
|
|
crypto.PrivKey
|
2016-03-20 03:00:43 -07:00
|
|
|
Account
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
type AccountGetter interface {
|
|
|
|
GetAccount(addr []byte) *Account
|
|
|
|
}
|
|
|
|
|
2016-03-29 14:25:17 -07:00
|
|
|
type AccountSetter interface {
|
2016-03-24 12:17:26 -07:00
|
|
|
SetAccount(addr []byte, acc *Account)
|
|
|
|
}
|
|
|
|
|
2016-03-29 14:25:17 -07:00
|
|
|
type AccountGetterSetter interface {
|
2016-03-24 12:17:26 -07:00
|
|
|
GetAccount(addr []byte) *Account
|
|
|
|
SetAccount(addr []byte, acc *Account)
|
2016-03-20 03:00:43 -07:00
|
|
|
}
|