Documentation ¶
Index ¶
- Constants
- func CreateError(status, code int, msg, hint string) error
- func NewOutput(addrs []*hxnet.Address, asset crypto.Hash, amount decimal.Decimal, ...) (*hxnet.Output, error)
- type Error
- type KernelService
- type PendingTransaction
- type Snapshot
- type Store
- type UTXO
- type User
- func (user *User) HxAddress(publicOnly bool) (*hxnet.Address, error)
- func (user User) NewOutput(asset crypto.Hash, amount decimal.Decimal, outputIndex int) (*hxnet.Output, error)
- func (user User) NewTransaction(dests []*hxnet.Address, utxo *UTXO, memo string) (*hxnet.Transaction, error)
- func (user User) TableName() string
Constants ¶
View Source
const ( ErrCodeInternal = 1 ErrCodeInvalidParam = 2 ErrCodePermissionDenied = 4 )
View Source
const ( // transaction ErrCodeTransactionNotExists = 10000 ErrCodeInvalidSignature = 10001 ErrCodeInvalidAsset = 10002 )
View Source
const ( // output ErrCodeOutputNotExists = 10100 ErrCodeOutputKeyExists = 10101 ErrCodeOutputAlreadySpent = 10102 )
View Source
const ( ErrCodeInsufficientBalance = 10202 ErrCodeTracePaidByOthers = 10203 )
Variables ¶
This section is empty.
Functions ¶
func CreateError ¶
Types ¶
type Error ¶
type KernelService ¶
type KernelService interface { SubmitTransaction(ctx context.Context, tx *hxnet.Transaction) (crypto.Hash, error) ReadTransaction(ctx context.Context, txHash crypto.Hash) (*hxnet.Transaction, error) ReadUTXO(ctx context.Context, txHash crypto.Hash, index int) (*hxnet.UTXO, error) ReadSnapshots(ctx context.Context, from, count int) ([]*hxnet.Snapshot, error) }
type PendingTransaction ¶
type PendingTransaction struct { ID uint `gorm:"PRIMARY_KEY;" json:"id"` TraceID string `gorm:"SIZE:36;UNIQUE;" json:"trace_id"` UserID uuid.UUID `gorm:"SIZE:36;" json:"user_id"` CreatedAt time.Time `json:"created_at"` DeletedAt *time.Time `gorm:"INDEX;" json:"deleted_at,omitempty"` Hash crypto.Hash `gorm:"SIZE:128;" json:"hash"` RawTransaction string `gorm:"type:LONGTEXT;" json:"raw_transaction"` }
func (PendingTransaction) TableName ¶
func (t PendingTransaction) TableName() string
type Snapshot ¶
type Snapshot struct { ID uint `gorm:"PRIMARY_KEY;" json:"id"` CreatedAt time.Time `json:"created_at"` Hash crypto.Hash `gorm:"SIZE:128;" json:"hash"` TraceID string `gorm:"SIZE:36;" json:"trace_id"` Asset crypto.Hash `gorm:"SIZE:128;" json:"asset"` UserID uuid.UUID `gorm:"SIZE:36;" json:"user_id"` OpponentID uuid.UUID `gorm:"SIZE:36;" json:"opponent_id"` Amount decimal.Decimal `gorm:"type:DECIMAL(30,8);" json:"amount"` Memo string `gorm:"type:LONGTEXT;" json:"memo"` }
type Store ¶
type Store interface { AddUser(ctx context.Context, user *User) error ReadUser(ctx context.Context, userID uuid.UUID) (*User, error) QueryUser(ctx context.Context, pubSpend string) (*User, error) ReadUTXO(ctx context.Context, userID uuid.UUID, asset crypto.Hash) (*UTXO, error) QuerySnapshots(ctx context.Context, userID uuid.UUID, asset crypto.Hash, order string, from uint, limit int) ([]*Snapshot, error) AddKernelTransaction(ctx context.Context, transaction *hxnet.Transaction, timestamp time.Time) error QueryPendingTransactions(ctx context.Context, limit int) ([]*PendingTransaction, error) AddPendingTransaction(ctx context.Context, traceID string, tx *hxnet.Transaction, sender uuid.UUID, addresses []string) (crypto.Hash, error) ExpirePendingTransaction(ctx context.Context, tx *PendingTransaction) error }
type UTXO ¶
type UTXO struct { ID uint `gorm:"PRIMARY_KEY;" json:"id"` CreatedAt time.Time `json:"created_at"` UserID uuid.UUID `gorm:"SIZE:36;" json:"user_id"` Asset crypto.Hash `gorm:"SIZE:64;" json:"asset"` TxHash crypto.Hash `gorm:"SIZE:64;" json:"tx_hash"` Index int `json:"index"` KeyIndex int `json:"key_index"` KeyCount int `json:"key_count"` Amount decimal.Decimal `gorm:"type:DECIMAL(30,8);" json:"amount"` Mask crypto.Key `gorm:"SIZE:64;" json:"mask"` Key crypto.Key `gorm:"SIZE:64;" json:"key"` }
type User ¶
type User struct { UserID uuid.UUID `gorm:"SIZE:36;PRIMARY_KEY;" json:"user_id"` CreatedAt time.Time `json:"created_at"` Address string `gorm:"SIZE:255;" json:"address"` PublicSpend crypto.Key `gorm:"SIZE:64;" json:"public_spend"` Keystore string `gorm:"SIZE:512;" json:"keystore"` // contains filtered or unexported fields }
func (User) NewTransaction ¶
Click to show internal directories.
Click to hide internal directories.