Documentation ¶
Index ¶
- Constants
- Variables
- func CanExecTx(executor TxExecutor, tx Tx) bool
- func IsValidEntityType(b byte) bool
- func SignTx(signedBytes []byte, addr []byte, privKey crypto.PrivKey) (crypto.Signature, error)
- type Account
- type AccountGetter
- type AccountGetterSetter
- type AccountIndex
- type AccountIndexGetter
- type AccountIndexGetterSetter
- type AccountIndexSetter
- type AccountSetter
- type AccountsReturned
- type ConcreteCurrency
- type CreateAccountTx
- type CreateLegalEntityTx
- func (tx *CreateLegalEntityTx) SignBytes(chainID string) []byte
- func (tx *CreateLegalEntityTx) SignTx(privateKey crypto.PrivKey, chainID string) error
- func (tx *CreateLegalEntityTx) String() string
- func (tx *CreateLegalEntityTx) TxType() byte
- func (tx *CreateLegalEntityTx) ValidateBasic() abci.Result
- type CreateUserTx
- type Currency
- type Index
- type LegalEntitiesReturned
- type LegalEntity
- func NewCH(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
- func NewCustodian(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
- func NewGCM(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
- func NewICM(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
- func NewLegalEntity(id string, t byte, name string, permissions Perm, creatorAddr []byte, ...) *LegalEntity
- func NewLegalEntityByType(t byte, id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
- type LegalEntityGetter
- type LegalEntityGetterSetter
- type LegalEntityIndex
- type LegalEntitySetter
- type Perm
- type PrivUser
- type SignedTx
- type TransferTx
- func (tx *TransferTx) SetSignature(addr []byte, sig crypto.Signature) bool
- func (tx *TransferTx) SignBytes(chainID string) []byte
- func (tx *TransferTx) SignTx(privateKey crypto.PrivKey, chainID string) error
- func (tx *TransferTx) String() string
- func (tx *TransferTx) TxType() byte
- func (tx *TransferTx) ValidateBasic() (res abci.Result)
- type Tx
- type TxBasicValidator
- type TxExecutor
- type TxTransferCommitter
- type TxTransferCounterSigner
- type TxTransferRecipient
- type TxTransferSender
- type User
- type UserGetter
- type UserGetterSetter
- type UserSetter
- type Wallet
Constants ¶
const ( EntityTypeCHByte = byte(0x01) EntityTypeGCMByte = byte(0x02) EntityTypeICMByte = byte(0x03) EntityTypeCustodianByte = byte(0x04) )
EntityType byte identifiers
const ( PermTransferTx = Perm(1 << iota) PermCreateAccountTx PermCreateLegalEntityTx PermCreateUserTx PermNone = Perm(0) )
Each permission listed below reprent a respective transaction.
const ( // TxTypeCreateAccount defines CreateAccountTx's code TxTypeCreateAccount = byte(0x02) )
const ( // TxTypeCreateLegalEntity defines CreateLegalEntityTx's code TxTypeCreateLegalEntity = byte(0x03) )
const ( // TxTypeCreateUser defines CreateUserTx's code TxTypeCreateUser = byte(0x04) )
const ( // TxTypeTransfer defines TrasferTx's code TxTypeTransfer = byte(0x01) )
Variables ¶
var ( // Currencies contains the in-memory database of supported currencies Currencies map[string]ConcreteCurrency )
Functions ¶
func CanExecTx ¶
func CanExecTx(executor TxExecutor, tx Tx) bool
CanExecTx is a convenience function that validates caller's execution permission on a Tx.
func IsValidEntityType ¶
IsValidEntityType checks whether a byte is a valid type for an entity.
Types ¶
type Account ¶
type Account struct { ID string `json:"id"` // Account's address EntityID string `json:"entity_id"` // Account's owner Wallets []Wallet `json:"wallets"` // Account's wallets }
Account defines the attributes of an account
type AccountGetter ¶
AccountGetter is implemented by any value that has a GetAccount
type AccountGetterSetter ¶
type AccountGetterSetter interface { GetAccount(id string) *Account SetAccount(id string, acc *Account) }
AccountGetterSetter is implemented by any value that has both GetAccount and SetAccount
type AccountIndex ¶
type AccountIndex struct {
Accounts []string `json:"accounts"`
}
AccountIndex stores the list of accounts managed on the ledger.
func NewAccountIndex ¶
func NewAccountIndex() *AccountIndex
NewAccountIndex creates a new accounts index
func (*AccountIndex) Add ¶
func (i *AccountIndex) Add(s string)
Add adds an account to the index, if it's not yet there.
func (*AccountIndex) Has ¶
func (i *AccountIndex) Has(s string) bool
Has returns whether s is listed in the accounts index.
func (*AccountIndex) ToStringSlice ¶
func (i *AccountIndex) ToStringSlice() []string
ToStringSlice returns a string slice representation of the index.
type AccountIndexGetter ¶
type AccountIndexGetter interface {
GetAccountIndex() *AccountIndex
}
AccountIndexGetter is implemented by any value that has a GetAccountIndex
type AccountIndexGetterSetter ¶
type AccountIndexGetterSetter interface { GetAccountIndex() *AccountIndex SetAccountIndex(i *AccountIndex) }
AccountIndexGetterSetter is implemented by any value that has both GetAccountIndex and SetAccountIndex
type AccountIndexSetter ¶
type AccountIndexSetter interface {
SetAccountIndex(i *AccountIndex)
}
AccountIndexSetter is implemented by any value that has a SetAccountIndex
type AccountSetter ¶
AccountSetter is implemented by any value that has a SetAccount
type AccountsReturned ¶
type AccountsReturned struct {
Account []*Account `json:"accounts"`
}
AccountsReturned defines the attributes of response's payload
type ConcreteCurrency ¶
type ConcreteCurrency struct {
// contains filtered or unexported fields
}
ConcreteCurrency defines the attributes of a concrete currency type
func (ConcreteCurrency) DecimalPlaces ¶
func (c ConcreteCurrency) DecimalPlaces() uint
DecimalPlaces returns the number of decimals of the currency
func (ConcreteCurrency) MinimumUnit ¶
func (c ConcreteCurrency) MinimumUnit() int64
MinimumUnit returns the minimum amount for the currency
func (ConcreteCurrency) Symbol ¶
func (c ConcreteCurrency) Symbol() string
Symbol returns the 3-letter ISO 4217 code
func (ConcreteCurrency) ValidateAmount ¶
func (c ConcreteCurrency) ValidateAmount(amount int64) bool
ValidateAmount checks whether an amount is valid for the currency
type CreateAccountTx ¶
type CreateAccountTx struct { Address []byte `json:"address"` // Hash of the user's PubKey AccountID string `json:"account_id"` // ID of the new account Signature crypto.Signature `json:"signature"` }
CreateAccountTx defines the attributes of an account create.
func (*CreateAccountTx) SignBytes ¶
func (tx *CreateAccountTx) SignBytes(chainID string) []byte
SignBytes generates a byte-to-byte signature
func (*CreateAccountTx) SignTx ¶
func (tx *CreateAccountTx) SignTx(privateKey crypto.PrivKey, chainID string) error
SignTx signs the transaction if its address and the privateKey's one match.
func (*CreateAccountTx) String ¶
func (tx *CreateAccountTx) String() string
func (*CreateAccountTx) TxType ¶
func (tx *CreateAccountTx) TxType() byte
TxType returns the byte type of CreateAccountTx
func (*CreateAccountTx) ValidateBasic ¶
func (tx *CreateAccountTx) ValidateBasic() abci.Result
ValidateBasic performs basic validation on the Tx.
type CreateLegalEntityTx ¶
type CreateLegalEntityTx struct { Address []byte `json:"address"` // Hash of the user's PubKey EntityID string `json:"entity_id"` // ID of the new legal entity ParentID string `json:"parent_id"` // ID of the new legal entity's parent Type byte `json:"type"` // Mandatory Name string `json:"name"` // Could be empty Signature crypto.Signature `json:"signature"` }
CreateLegalEntityTx defines the attributes of a legal entity create.
func (*CreateLegalEntityTx) SignBytes ¶
func (tx *CreateLegalEntityTx) SignBytes(chainID string) []byte
SignBytes generates a byte-to-byte signature
func (*CreateLegalEntityTx) SignTx ¶
func (tx *CreateLegalEntityTx) SignTx(privateKey crypto.PrivKey, chainID string) error
SignTx signs the transaction if its address and the privateKey's one match.
func (*CreateLegalEntityTx) String ¶
func (tx *CreateLegalEntityTx) String() string
func (*CreateLegalEntityTx) TxType ¶
func (tx *CreateLegalEntityTx) TxType() byte
TxType returns the byte type of CreateLegalEntityTx
func (*CreateLegalEntityTx) ValidateBasic ¶
func (tx *CreateLegalEntityTx) ValidateBasic() abci.Result
ValidateBasic performs basic validation on the Tx.
type CreateUserTx ¶
type CreateUserTx struct { Address []byte `json:"address"` // Hash of the user's PubKey Name string `json:"name"` // Human-readable identifier, mandatory PubKey crypto.PubKey `json:"pub_key"` // New user's public key CanCreate bool `json:"can_create"` // Whether the user is a super user or not Signature crypto.Signature `json:"signature"` }
CreateUserTx defines the attributes of a user create.
func (*CreateUserTx) SignBytes ¶
func (tx *CreateUserTx) SignBytes(chainID string) []byte
SignBytes generates a byte-to-byte signature
func (*CreateUserTx) SignTx ¶
func (tx *CreateUserTx) SignTx(privateKey crypto.PrivKey, chainID string) error
SignTx signs the transaction if its address and the privateKey's one match.
func (*CreateUserTx) String ¶
func (tx *CreateUserTx) String() string
func (*CreateUserTx) TxType ¶
func (tx *CreateUserTx) TxType() byte
TxType returns the byte type of CreateUserTx
func (*CreateUserTx) ValidateBasic ¶
func (tx *CreateUserTx) ValidateBasic() abci.Result
ValidateBasic performs basic validation on the Tx.
type Currency ¶
type Currency interface { Symbol() string DecimalPlaces() uint MinimumUnit() int64 ValidateAmount(int64) bool }
Currency represents a support currency type
type LegalEntitiesReturned ¶
type LegalEntitiesReturned struct {
LegalEntities []*LegalEntity `json:"legal_entities"`
}
type LegalEntity ¶
type LegalEntity struct { ID string `json:"id"` // LegalEntity's ID EntityID string `json:"entity_id"` // LegalEntity's owner Type byte `json:"type"` // Mandatory Name string `json:"name"` // This could be empty Permissions Perm `json:"permissions"` // Set of allowed Txs CreatorAddr []byte `json:"creator_addr"` // ID of the creator of the Clearing House that created the legal entity }
LegalEntity defines the attributes of a legal entity
func NewCH ¶
func NewCH(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
NewCH is a convenience function to create a new CH
func NewCustodian ¶
func NewCustodian(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
NewCustodian is a convenience function to create a new Custodian
func NewGCM ¶
func NewGCM(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
NewGCM is a convenience function to create a new GCM
func NewICM ¶
func NewICM(id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
NewICM is a convenience function to create a new ICM
func NewLegalEntity ¶
func NewLegalEntity(id string, t byte, name string, permissions Perm, creatorAddr []byte, EntityID string) *LegalEntity
NewLegalEntity initializes a new LegalEntity
func NewLegalEntityByType ¶
func NewLegalEntityByType(t byte, id string, name string, creatorAddr []byte, EntityID string) *LegalEntity
NewLegalEntityByType is a convenience function to create a legal entity according to the type given.
func (*LegalEntity) CanExecTx ¶
func (l *LegalEntity) CanExecTx(txType byte) bool
CanExecTx determines whether a LegalEntity can execute a Tx
func (*LegalEntity) Equal ¶
func (l *LegalEntity) Equal(e *LegalEntity) bool
Equal provides an equality operator
func (*LegalEntity) String ¶
func (l *LegalEntity) String() string
type LegalEntityGetter ¶
type LegalEntityGetter interface {
GetLegalEntity(id string) *LegalEntity
}
LegalEntityGetter is implemented by any value that has a GetLegalEntity
type LegalEntityGetterSetter ¶
type LegalEntityGetterSetter interface { GetLegalEntity(id string) *LegalEntity SetLegalEntity(id string, acc *LegalEntity) }
LegalEntityGetterSetter is implemented by any value that has both GetLegalEntity and SetLegalEntity
type LegalEntityIndex ¶
type LegalEntityIndex struct {
Ids []string `json:"ids"`
}
func (*LegalEntityIndex) Add ¶
func (i *LegalEntityIndex) Add(s string)
func (*LegalEntityIndex) Has ¶
func (i *LegalEntityIndex) Has(s string) bool
type LegalEntitySetter ¶
type LegalEntitySetter interface {
SetLegalEntity(id string, acc *LegalEntity)
}
LegalEntitySetter is implemented by any value that has a SetLegalEntity
type Perm ¶
type Perm uint64
Perm is a synonym of uint64
func NewPermByTxType ¶
NewPermByTxType creates a Perm object by ORing the Tx respective permissions.
type PrivUser ¶
type PrivUser struct { crypto.PrivKey User }
PrivUser defines the attributes of a private user
type SignedTx ¶
type SignedTx interface { TxType() byte SignBytes(chainID string) []byte SignTx(privateKey crypto.PrivKey, chainID string) error }
SignedTx extends Tx with a method to generate signatures.
type TransferTx ¶
type TransferTx struct { Committer TxTransferCommitter `json:"committer"` Sender TxTransferSender `json:"sender"` Recipient TxTransferRecipient `json:"recipient"` CounterSigners []TxTransferCounterSigner `json:"counter_signers"` }
TransferTx defines the attributes of transfer transaction
func (*TransferTx) SetSignature ¶
func (tx *TransferTx) SetSignature(addr []byte, sig crypto.Signature) bool
SetSignature sets account's signature to the relevant TxInputTransfer
func (*TransferTx) SignBytes ¶
func (tx *TransferTx) SignBytes(chainID string) []byte
SignBytes generates a byte-to-byte signature
func (*TransferTx) SignTx ¶
func (tx *TransferTx) SignTx(privateKey crypto.PrivKey, chainID string) error
SignTx signs the transaction if its address and the privateKey's one match.
func (*TransferTx) String ¶
func (tx *TransferTx) String() string
func (*TransferTx) TxType ¶
func (tx *TransferTx) TxType() byte
TxType returns the byte type of TransferTx
func (*TransferTx) ValidateBasic ¶
func (tx *TransferTx) ValidateBasic() (res abci.Result)
ValidateBasic validates Tx basic structure.
type TxBasicValidator ¶
TxBasicValidator implements basic validation rules.
type TxExecutor ¶
TxExecutor validates Tx execution permission
type TxTransferCommitter ¶
type TxTransferCommitter struct { Address []byte `json:"address"` // Hash of the user's PubKey Signature crypto.Signature `json:"signature"` }
TxTransferCommitter defines the attributes of a transfer's sender
func (TxTransferCommitter) SignBytes ¶
func (t TxTransferCommitter) SignBytes(chainID string) []byte
SignBytes generates a byte-to-byte signature.
func (*TxTransferCommitter) SignTx ¶
func (t *TxTransferCommitter) SignTx(privateKey crypto.PrivKey, chainID string) error
SignTx signs the transaction if its address and the privateKey's one match.
func (TxTransferCommitter) String ¶
func (t TxTransferCommitter) String() string
String returns a string representation of TxTransferCommitter
func (TxTransferCommitter) ValidateBasic ¶
func (t TxTransferCommitter) ValidateBasic() abci.Result
ValidateBasic performs basic validation on a TxInputTransfer
type TxTransferCounterSigner ¶
type TxTransferCounterSigner struct { Address []byte `json:"address"` // Hash of the user's PubKey Signature crypto.Signature `json:"signature"` }
TxTransferCounterSigner defines the attributes of a transfer's counter signer
func (TxTransferCounterSigner) SignBytes ¶
func (t TxTransferCounterSigner) SignBytes(chainID string) []byte
SignBytes generates a byte-to-byte signature.
func (*TxTransferCounterSigner) SignTx ¶
func (t *TxTransferCounterSigner) SignTx(privateKey crypto.PrivKey, chainID string) error
SignTx signs the transaction if its address and the privateKey's one match.
func (TxTransferCounterSigner) String ¶
func (t TxTransferCounterSigner) String() string
String returns a string representation of TxTransferCounterSigner
func (TxTransferCounterSigner) ValidateBasic ¶
func (t TxTransferCounterSigner) ValidateBasic() abci.Result
ValidateBasic performs basic validation on a TxTransferCounterSigner
type TxTransferRecipient ¶
type TxTransferRecipient struct {
AccountID string `json:"account_id"` // Recipient's Account ID
}
TxTransferRecipient defines the attributes of a transfer's recipient
func (TxTransferRecipient) String ¶
func (t TxTransferRecipient) String() string
String returns a string representation of TxInputTransfer
func (TxTransferRecipient) ValidateBasic ¶
func (t TxTransferRecipient) ValidateBasic() abci.Result
ValidateBasic performs basic validation on a TxTransferRecipient
type TxTransferSender ¶
type TxTransferSender struct { AccountID string `json:"account_id"` // Sender's Account ID Amount int64 `json:"amount"` Currency string `json:"currency"` //3-letter ISO 4217 code or "" Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput or 0 if the account is just a countersigner }
TxTransferSender defines the attributes of a transfer's sender
func (TxTransferSender) String ¶
func (t TxTransferSender) String() string
String returns a string representation of TxTransferSender
func (TxTransferSender) ValidateBasic ¶
func (t TxTransferSender) ValidateBasic() abci.Result
ValidateBasic performs basic validation on a TxInputTransfer
type User ¶
type User struct { PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known. Name string `json:"name"` // Human-readable identifier, mandatory EntityID string `json:"entity_id"` // LegalEntity's ID Permissions Perm `json:"permissions"` // User is disabled if empty }
User defines the attribute of a ledger's user
func (*User) VerifySignature ¶
VerifySignature verifies a signed message against the User's PubKey.
type UserGetter ¶
UserGetter is implemented by any value that has a GetUser
type UserGetterSetter ¶
UserGetterSetter is implemented by any value that has both GetUser and SetUser
type UserSetter ¶
UserSetter is implemented by any value that has a SetUser