core

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAssetNotExist = errors.New("asset not exist")
)

Functions

func DecodeTransactionAction

func DecodeTransactionAction(privateKey ed25519.PrivateKey, message []byte) ([]byte, error)

Types

type Asset added in v0.0.3

type Asset struct {
	ID            string          `sql:"size:36;PRIMARY_KEY" json:"id,omitempty"`
	UpdatedAt     time.Time       `json:"updated_at,omitempty"`
	Name          string          `sql:"size:64" json:"name,omitempty"`
	Symbol        string          `sql:"size:32" json:"symbol,omitempty"`
	DisplaySymbol string          `sql:"size:32" json:"display_symbol,omitempty"`
	ChainID       string          `sql:"size:36" json:"chain_id,omitempty"`
	Price         decimal.Decimal `sql:"type:decimal(24,8)" json:"price_usd,omitempty"`
}

type AssetService added in v0.0.3

type AssetService interface {
	Find(ctx context.Context, id string) (*Asset, error)
	ListAll(ctx context.Context) ([]*Asset, error)
}

AssetService provides access to assets information in the remote system like mixin network.

type AssetStore added in v0.0.3

type AssetStore interface {
	Save(ctx context.Context, asset *Asset, columns ...string) error
	Find(ctx context.Context, id string) (*Asset, error)
	ListAll(ctx context.Context) ([]*Asset, error)
	ListPrices(ctx context.Context, ids ...string) (number.Values, error)
}

AssetStore defines operations for working with assets on db.

type Member

type Member struct {
	ClientID  string
	Name      string
	VerifyKey ed25519.PublicKey
}

func DecodeMemberAction

func DecodeMemberAction(message []byte, members []*Member) (*Member, []byte, error)

type MemoData added in v0.0.4

type MemoData struct {
	Member   string `json:"member,omitempty"`
	Type     int    `json:"type,omitempty"`
	UserID   string `json:"user_id,omitempty"`
	FollowID string `json:"follow_id,omitempty"`
	Data     []byte `json:"data,omitempty"`
}

TODO Deprecated, remove in the future version

func (*MemoData) Scan added in v0.0.4

func (m *MemoData) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database deserialization.

func (MemoData) Value added in v0.0.4

func (m MemoData) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database serialization.

type Message added in v0.0.3

type Message struct {
	ID        int64          `sql:"PRIMARY_KEY" json:"id,omitempty"`
	CreatedAt time.Time      `json:"created_at,omitempty"`
	MessageID string         `sql:"size:36" json:"message_id,omitempty"`
	UserID    string         `sql:"size:36" json:"user_id,omitempty"`
	Raw       types.JSONText `sql:"type:TEXT" json:"raw,omitempty"`
}

func BuildMessage added in v0.0.3

func BuildMessage(req *mixin.MessageRequest) *Message

type MessageStore added in v0.0.3

type MessageStore interface {
	Create(ctx context.Context, messages []*Message) error
}

type Notifier

type Notifier interface {
	Snapshot(ctx context.Context, transfer *Transfer, TxHash string) error
}

type Output

type Output struct {
	ID        int64           `sql:"PRIMARY_KEY" json:"id,omitempty"`
	CreatedAt time.Time       `json:"created_at,omitempty"`
	UpdatedAt time.Time       `json:"updated_at,omitempty"`
	Version   int64           `sql:"NOT NULL" json:"version,omitempty"`
	Sender    string          `sql:"type:char(36)" json:"sender,omitempty"`
	TraceID   string          `sql:"type:char(36)" json:"trace_id,omitempty"`
	AssetID   string          `sql:"type:char(36)" json:"asset_id,omitempty"`
	Amount    decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"`
	Memo      string          `sql:"type:char(200)" json:"memo,omitempty"`
	MemoData  MemoData        `sql:"type:TEXT" json:"memo_data,omitempty"`
	State     string          `sql:"size:24" json:"state,omitempty"`

	// SpentBy represent the associated transfer trace id
	SpentBy string `sql:"type:char(36);NOT NULL" json:"spent_by,omitempty"`

	// UTXO json Data
	Data types.JSONText `sql:"type:TEXT" json:"data,omitempty"`

	// Raw Mixin UTXO
	UTXO *mixin.MultisigUTXO `sql:"-" json:"-,omitempty"`
}

Output represent Mixin Network multisig Outputs

type RawTransaction

type RawTransaction struct {
	ID        int64     `sql:"PRIMARY_KEY" json:"id,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	TraceID   string    `sql:"type:char(36);" json:"trace_id,omitempty"`
	Data      string    `sql:"type:TEXT" json:"data,omitempty"`
}

type System

type System struct {
	Admins     []string
	ClientID   string
	Members    []*Member
	Threshold  uint8
	VoteAsset  string
	VoteAmount decimal.Decimal
	PrivateKey ed25519.PrivateKey
	SignKey    ed25519.PrivateKey
	Version    string
}

System stores system information.

func (*System) MemberIDs

func (s *System) MemberIDs() []string

type Transfer

type Transfer struct {
	ID        int64           `sql:"PRIMARY_KEY" json:"id,omitempty"`
	CreatedAt time.Time       `json:"created_at,omitempty"`
	UpdatedAt time.Time       `json:"updated_at,omitempty"`
	TraceID   string          `sql:"type:char(36)" json:"trace_id,omitempty"`
	AssetID   string          `sql:"type:char(36)" json:"asset_id,omitempty"`
	Amount    decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"`
	Memo      string          `sql:"size:200" json:"memo,omitempty"`
	Handled   types.BitBool   `sql:"type:bit(1)" json:"handled,omitempty"`
	Passed    types.BitBool   `sql:"type:bit(1)" json:"passed,omitempty"`
	Threshold uint8           `json:"threshold,omitempty"`
	Opponents pq.StringArray  `sql:"type:varchar(1024)" json:"opponents,omitempty"`
}

type WalletService

type WalletService interface {
	// Pull fetch NEW Output updates
	Pull(ctx context.Context, offset time.Time, limit int) ([]*Output, error)
	// Spend spend multiple Output
	Spend(ctx context.Context, outputs []*Output, transfer *Transfer) (*RawTransaction, error)
	// ReqTransfer generate payment code for multisig transfer
	ReqTransfer(ctx context.Context, transfer *Transfer) (string, error)
}

type WalletStore

type WalletStore interface {
	// Save batch update multiple Output
	Save(ctx context.Context, outputs []*Output) error
	// List return a list of Output by order
	List(ctx context.Context, fromID int64, limit int) ([]*Output, error)
	// ListUnspent list unspent Output
	ListUnspent(ctx context.Context, assetID string, limit int) ([]*Output, error)
	ListSpentBy(ctx context.Context, assetID string, spentBy string) ([]*Output, error)
	// Transfers
	CreateTransfers(ctx context.Context, transfers []*Transfer) error
	UpdateTransfer(ctx context.Context, transfer *Transfer) error
	ListPendingTransfers(ctx context.Context) ([]*Transfer, error)
	ListNotPassedTransfers(ctx context.Context) ([]*Transfer, error)
	Spent(ctx context.Context, outputs []*Output, transfer *Transfer) error
	// mixin net transaction
	CreateRawTransaction(ctx context.Context, tx *RawTransaction) error
	ListPendingRawTransactions(ctx context.Context, limit int) ([]*RawTransaction, error)
	ExpireRawTransaction(ctx context.Context, tx *RawTransaction) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL