Documentation
¶
Index ¶
- Constants
- Variables
- func CheckMultisigRequestRawTransaction(req *mixin.SafeMultisigRequest, ver *common.VersionedTransaction) (*common.VersionedTransaction, error)
- func CheckRetryableError(err error) bool
- func DecodeMixinExtraBase64(extra string) (string, []byte)
- func DecodeMixinExtraHEX(memo string) (string, []byte)
- func EncodeMixinExtraBase64(appId string, extra []byte) string
- func ExpandTilde(path string) string
- func GetKernelTransaction(rpc, hash string) (*common.VersionedTransaction, string, error)
- func NewMixAddress(ctx context.Context, members []string, threshold byte) (*mixin.MixAddress, bool, error)
- func ReplayCheck(a *Action, txs1, txs2 []*Transaction, asset1, asset2 string)
- func SerializeTransactions(txs []*Transaction) []byte
- func UniqueId(a, b string) string
- type Action
- func (act *Action) BuildStorageTransaction(ctx context.Context, extra []byte) *Transaction
- func (act *Action) BuildTransaction(ctx context.Context, traceId, opponentAppId, assetId, amount, memo string, ...) *Transaction
- func (act *Action) BuildTransactionWithReference(ctx context.Context, traceId, opponentAppId, assetId, amount, memo string, ...) *Transaction
- func (act *Action) BuildTransactionWithStorageTraceId(ctx context.Context, traceId, opponentAppId, assetId, amount, memo string, ...) *Transaction
- func (act *Action) BuildWithdrawTransaction(ctx context.Context, traceId, assetId, amount, memo, destination, tag string) *Transaction
- func (act *Action) CheckAssetBalanceAt(ctx context.Context, assetId string) decimal.Decimal
- func (act *Action) CheckAssetBalanceForStorageAt(ctx context.Context, extra []byte) bool
- func (a *Action) Restored() bool
- func (a *Action) TestAttachActionToGroup(g *Group)
- type ActionState
- type Configuration
- type DepositEntry
- type Group
- func (grp *Group) AddNode(ctx context.Context, id string, threshold int, epoch uint64) error
- func (grp *Group) AttachWorker(appId string, wkr Worker)
- func (grp *Group) EnableDebug()
- func (grp *Group) FindAppByEntry(entry string) string
- func (grp *Group) FindWorker(appId string) Worker
- func (grp *Group) GenesisId() string
- func (grp *Group) GetMembers() []string
- func (grp *Group) GetThreshold() int
- func (grp *Group) Index() int
- func (grp *Group) ListActiveNodes(ctx context.Context) ([]string, int, uint64, error)
- func (grp *Group) ListConfirmedWithdrawalTransactionsAfter(ctx context.Context, offset time.Time, limit int) []*Transaction
- func (grp *Group) ListOutputsForAsset(ctx context.Context, appId, assetId string, consumedUntil, sequence uint64, ...) []*UnifiedOutput
- func (grp *Group) ListOutputsForTransaction(ctx context.Context, traceId string, sequence uint64) []*UnifiedOutput
- func (grp *Group) ListUnconfirmedWithdrawalTransactions(ctx context.Context, limit int) []*Transaction
- func (grp *Group) ReadFinishedTxHashByTraceId(ctx context.Context, id string) string
- func (grp *Group) ReadKernelTransactionUntilSufficient(ctx context.Context, txHash string) (*common.VersionedTransaction, error)
- func (grp *Group) RegisterDepositEntry(appId string, entry DepositEntry)
- func (grp *Group) Run(ctx context.Context)
- func (grp *Group) SetKernelRPC(rpc string)
- func (grp *Group) Synced(ctx context.Context) bool
- func (grp *Group) TestUpdateOutputsState(ctx context.Context, os []*UnifiedOutput, state string) error
- type Iteration
- type Row
- type SQLite3Store
- func (s *SQLite3Store) Close() error
- func (s *SQLite3Store) ConfirmWithdrawalTransaction(ctx context.Context, traceId, hash string) error
- func (s *SQLite3Store) FinishAction(ctx context.Context, id string, state ActionState, ts []*Transaction) error
- func (s *SQLite3Store) FinishTransaction(ctx context.Context, traceId string) error
- func (s *SQLite3Store) ListActions(ctx context.Context, state ActionState, limit int) ([]*Action, error)
- func (s *SQLite3Store) ListConfirmedWithdrawalTransactionsAfter(ctx context.Context, offset time.Time, limit int) ([]*Transaction, error)
- func (s *SQLite3Store) ListIterations(ctx context.Context) ([]*Iteration, error)
- func (s *SQLite3Store) ListOutputsForAsset(ctx context.Context, appId, assetId string, consumedUntil, sequence uint64, ...) ([]*UnifiedOutput, error)
- func (s *SQLite3Store) ListOutputsForTransaction(ctx context.Context, traceId string, sequence uint64) ([]*UnifiedOutput, error)
- func (s *SQLite3Store) ListPreviousInitialTransactions(ctx context.Context, asset string, sequence uint64) ([]*Transaction, error)
- func (s *SQLite3Store) ListTransactions(ctx context.Context, state, limit int) ([]*Transaction, map[string][]*Transaction, error)
- func (s *SQLite3Store) ListUnconfirmedWithdrawalTransactions(ctx context.Context, limit int) ([]*Transaction, error)
- func (s *SQLite3Store) ReadCache(ctx context.Context, k string) (string, error)
- func (s *SQLite3Store) ReadOutputByHashAndIndex(ctx context.Context, hash string, index uint) (*UnifiedOutput, error)
- func (s *SQLite3Store) ReadOutputById(ctx context.Context, id string) (*UnifiedOutput, error)
- func (s *SQLite3Store) ReadProperty(ctx context.Context, k string) (string, error)
- func (s *SQLite3Store) ReadTransactionByHash(ctx context.Context, hash crypto.Hash) (*Transaction, error)
- func (s *SQLite3Store) ReadTransactionByTraceId(ctx context.Context, id string) (*Transaction, error)
- func (s *SQLite3Store) RestoreAction(ctx context.Context, act *Action, t *Transaction) error
- func (s *SQLite3Store) TestUpdateOutputsState(ctx context.Context, os []*UnifiedOutput, state string) error
- func (s *SQLite3Store) UpdateTxWithOutputs(ctx context.Context, t *Transaction, os []*UnifiedOutput, ...) error
- func (s *SQLite3Store) WriteAction(ctx context.Context, out *UnifiedOutput, state ActionState) error
- func (s *SQLite3Store) WriteCache(ctx context.Context, k, v string) error
- func (s *SQLite3Store) WriteIteration(ctx context.Context, ir *Iteration) error
- func (s *SQLite3Store) WriteProperty(ctx context.Context, k, v string) error
- type SafeDepositView
- type SafeTransactionReceiver
- type SafeTransactionRequest
- type SafeUtxoState
- type Transaction
- type TransactionRecipient
- type UnifiedOutput
- type Worker
Constants ¶
View Source
const ( IterationActionAdd = 11 IterationActionRemove = 12 )
View Source
const ( TransactionStateInitial = 10 TransactionStateSigned = 12 TransactionStateSnapshot = 13 OutputsBatchSize = 36 StorageAssetId = "c94ac88f-4671-3976-b60a-09064f1811e8" MixinFeeUserId = "674d6776-d600-4346-af46-58e77d8df185" )
Variables ¶
View Source
var SCHEMA string
Functions ¶
func CheckMultisigRequestRawTransaction ¶ added in v0.26.0
func CheckMultisigRequestRawTransaction(req *mixin.SafeMultisigRequest, ver *common.VersionedTransaction) (*common.VersionedTransaction, error)
CheckMultisigRequestRawTransaction verifies that a multisig request carries the same transaction payload as the locally built ver. The request may have been created beforehand by anyone, because multisig request ids are public and deterministic, and creating a request with an existing id returns the previous one. Signing or accepting such a foreign raw transaction would spend the group outputs to arbitrary recipients, so it must be rejected before any signature is made.
func CheckRetryableError ¶
func DecodeMixinExtraBase64 ¶
func DecodeMixinExtraHEX ¶
func EncodeMixinExtraBase64 ¶
func ExpandTilde ¶
func GetKernelTransaction ¶
func GetKernelTransaction(rpc, hash string) (*common.VersionedTransaction, string, error)
func NewMixAddress ¶
func ReplayCheck ¶
func ReplayCheck(a *Action, txs1, txs2 []*Transaction, asset1, asset2 string)
func SerializeTransactions ¶
func SerializeTransactions(txs []*Transaction) []byte
Types ¶
type Action ¶
type Action struct {
ActionState ActionState
UnifiedOutput
// contains filtered or unexported fields
}
func (*Action) BuildStorageTransaction ¶
func (act *Action) BuildStorageTransaction(ctx context.Context, extra []byte) *Transaction
func (*Action) BuildTransaction ¶
func (*Action) BuildTransactionWithReference ¶
func (*Action) BuildTransactionWithStorageTraceId ¶
func (*Action) BuildWithdrawTransaction ¶ added in v0.19.0
func (act *Action) BuildWithdrawTransaction(ctx context.Context, traceId, assetId, amount, memo, destination, tag string) *Transaction
func (*Action) CheckAssetBalanceAt ¶
this function or rpc should be used only in ProcessOutput
func (*Action) CheckAssetBalanceForStorageAt ¶
func (*Action) TestAttachActionToGroup ¶
type ActionState ¶
type ActionState int
const ( ActionStateInitial ActionState = 10 ActionStateDone ActionState = 11 ActionStateRestorable ActionState = 12 )
type Configuration ¶
type Configuration struct {
App struct {
AppId string `toml:"app-id"`
SessionId string `toml:"session-id"`
SessionPrivateKey string `toml:"session-private-key"`
ServerPublicKey string `toml:"server-public-key"`
SpendPrivateKey string `toml:"spend-private-key"`
} `toml:"app"`
Genesis struct {
Members []string `toml:"members"`
Threshold int `toml:"threshold"`
Epoch uint64 `toml:"epoch"`
} `toml:"genesis"`
Project string `toml:"project"`
StoreDir string `toml:"store-dir"`
GroupSize int `toml:"group-size"`
}
type DepositEntry ¶
func (DepositEntry) UniqueKey ¶
func (e DepositEntry) UniqueKey() string
type Group ¶
type Group struct {
GroupId string
// contains filtered or unexported fields
}
func BuildGroup ¶
func BuildGroup(ctx context.Context, store *SQLite3Store, conf *Configuration) (*Group, error)
func (*Group) AttachWorker ¶
func (*Group) EnableDebug ¶
func (grp *Group) EnableDebug()
func (*Group) FindAppByEntry ¶
func (*Group) FindWorker ¶
func (*Group) GetMembers ¶
func (*Group) GetThreshold ¶
func (*Group) ListActiveNodes ¶
func (*Group) ListConfirmedWithdrawalTransactionsAfter ¶ added in v0.19.0
func (*Group) ListOutputsForAsset ¶
func (grp *Group) ListOutputsForAsset(ctx context.Context, appId, assetId string, consumedUntil, sequence uint64, state SafeUtxoState, limit int) []*UnifiedOutput
func (*Group) ListOutputsForTransaction ¶
func (*Group) ListUnconfirmedWithdrawalTransactions ¶ added in v0.19.0
func (grp *Group) ListUnconfirmedWithdrawalTransactions(ctx context.Context, limit int) []*Transaction
func (*Group) ReadFinishedTxHashByTraceId ¶ added in v0.20.3
func (*Group) ReadKernelTransactionUntilSufficient ¶
func (*Group) RegisterDepositEntry ¶
func (grp *Group) RegisterDepositEntry(appId string, entry DepositEntry)
func (*Group) SetKernelRPC ¶
func (*Group) TestUpdateOutputsState ¶ added in v0.20.0
type Iteration ¶
a node joins or leaves the group with an iteration this is for the evolution mechanism of MTG TODO not implemented yet
type SQLite3Store ¶
type SQLite3Store struct {
// contains filtered or unexported fields
}
func OpenSQLite3Store ¶
func OpenSQLite3Store(path string) (*SQLite3Store, error)
func (*SQLite3Store) Close ¶
func (s *SQLite3Store) Close() error
func (*SQLite3Store) ConfirmWithdrawalTransaction ¶ added in v0.19.0
func (s *SQLite3Store) ConfirmWithdrawalTransaction(ctx context.Context, traceId, hash string) error
func (*SQLite3Store) FinishAction ¶
func (s *SQLite3Store) FinishAction(ctx context.Context, id string, state ActionState, ts []*Transaction) error
func (*SQLite3Store) FinishTransaction ¶
func (s *SQLite3Store) FinishTransaction(ctx context.Context, traceId string) error
func (*SQLite3Store) ListActions ¶
func (s *SQLite3Store) ListActions(ctx context.Context, state ActionState, limit int) ([]*Action, error)
func (*SQLite3Store) ListConfirmedWithdrawalTransactionsAfter ¶ added in v0.19.0
func (s *SQLite3Store) ListConfirmedWithdrawalTransactionsAfter(ctx context.Context, offset time.Time, limit int) ([]*Transaction, error)
func (*SQLite3Store) ListIterations ¶
func (s *SQLite3Store) ListIterations(ctx context.Context) ([]*Iteration, error)
func (*SQLite3Store) ListOutputsForAsset ¶
func (s *SQLite3Store) ListOutputsForAsset(ctx context.Context, appId, assetId string, consumedUntil, sequence uint64, state SafeUtxoState, limit int) ([]*UnifiedOutput, error)
func (*SQLite3Store) ListOutputsForTransaction ¶
func (s *SQLite3Store) ListOutputsForTransaction(ctx context.Context, traceId string, sequence uint64) ([]*UnifiedOutput, error)
func (*SQLite3Store) ListPreviousInitialTransactions ¶
func (s *SQLite3Store) ListPreviousInitialTransactions(ctx context.Context, asset string, sequence uint64) ([]*Transaction, error)
func (*SQLite3Store) ListTransactions ¶
func (s *SQLite3Store) ListTransactions(ctx context.Context, state, limit int) ([]*Transaction, map[string][]*Transaction, error)
func (*SQLite3Store) ListUnconfirmedWithdrawalTransactions ¶ added in v0.19.0
func (s *SQLite3Store) ListUnconfirmedWithdrawalTransactions(ctx context.Context, limit int) ([]*Transaction, error)
func (*SQLite3Store) ReadOutputByHashAndIndex ¶
func (s *SQLite3Store) ReadOutputByHashAndIndex(ctx context.Context, hash string, index uint) (*UnifiedOutput, error)
func (*SQLite3Store) ReadOutputById ¶ added in v0.22.0
func (s *SQLite3Store) ReadOutputById(ctx context.Context, id string) (*UnifiedOutput, error)
func (*SQLite3Store) ReadProperty ¶
func (*SQLite3Store) ReadTransactionByHash ¶
func (s *SQLite3Store) ReadTransactionByHash(ctx context.Context, hash crypto.Hash) (*Transaction, error)
func (*SQLite3Store) ReadTransactionByTraceId ¶
func (s *SQLite3Store) ReadTransactionByTraceId(ctx context.Context, id string) (*Transaction, error)
func (*SQLite3Store) RestoreAction ¶
func (s *SQLite3Store) RestoreAction(ctx context.Context, act *Action, t *Transaction) error
func (*SQLite3Store) TestUpdateOutputsState ¶ added in v0.20.0
func (s *SQLite3Store) TestUpdateOutputsState(ctx context.Context, os []*UnifiedOutput, state string) error
func (*SQLite3Store) UpdateTxWithOutputs ¶
func (s *SQLite3Store) UpdateTxWithOutputs(ctx context.Context, t *Transaction, os []*UnifiedOutput, change common.Integer) error
func (*SQLite3Store) WriteAction ¶
func (s *SQLite3Store) WriteAction(ctx context.Context, out *UnifiedOutput, state ActionState) error
func (*SQLite3Store) WriteCache ¶
func (s *SQLite3Store) WriteCache(ctx context.Context, k, v string) error
func (*SQLite3Store) WriteIteration ¶
func (s *SQLite3Store) WriteIteration(ctx context.Context, ir *Iteration) error
func (*SQLite3Store) WriteProperty ¶
func (s *SQLite3Store) WriteProperty(ctx context.Context, k, v string) error
type SafeDepositView ¶
type SafeTransactionReceiver ¶ added in v0.19.0
type SafeTransactionRequest ¶ added in v0.19.0
type SafeTransactionRequest struct {
RequestID string `json:"request_id"`
TransactionHash string `json:"transaction_hash"`
UserID string `json:"user_id"`
KernelAssetID mixinnet.Hash `json:"kernel_asset_id"`
AssetID mixinnet.Hash `json:"asset_id"`
Amount decimal.Decimal `json:"amount"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Extra string `json:"extra"`
Receivers []*SafeTransactionReceiver `json:"receivers"`
Senders []string `json:"senders"`
SendersHash string `json:"senders_hash"`
SendersThreshold uint8 `json:"senders_threshold"`
Signers []string `json:"signers"`
State SafeUtxoState `json:"state"`
RawTransaction string `json:"raw_transaction"`
Views []mixinnet.Key `json:"views"`
RevokedBy string `json:"revoked_by"`
Asset mixinnet.Hash `json:"asset"`
}
type SafeUtxoState ¶
type SafeUtxoState string
const ( OutputTypeSafeOutput = "kernel_output" SafeUtxoStateUnreceived SafeUtxoState = "unreceived" SafeUtxoStateUnspent SafeUtxoState = "unspent" SafeUtxoStateAssigned SafeUtxoState = "assigned" SafeUtxoStateSigned SafeUtxoState = "signed" SafeUtxoStateSpent SafeUtxoState = "spent" )
type Transaction ¶
type Transaction struct {
TraceId string
AppId string
OpponentAppId string
ActionId string
State int
AssetId string
Receivers []string
Threshold int
Amount string
Memo string
Raw []byte
Hash crypto.Hash
Sequence uint64
UpdatedAt time.Time
Destination sql.NullString
Tag sql.NullString
WithdrawalHash sql.NullString
// contains filtered or unexported fields
}
func Deserialize ¶
func Deserialize(rb []byte) (*Transaction, error)
func DeserializeTransactions ¶
func DeserializeTransactions(tb []byte) ([]*Transaction, error)
func (*Transaction) Equal ¶
func (t *Transaction) Equal(tx *Transaction) bool
func (*Transaction) IsNormal ¶ added in v0.19.0
func (t *Transaction) IsNormal() bool
func (*Transaction) IsStorage ¶ added in v0.19.0
func (t *Transaction) IsStorage() bool
func (*Transaction) IsWithdrawal ¶ added in v0.19.0
func (t *Transaction) IsWithdrawal() bool
func (*Transaction) RequestID ¶
func (tx *Transaction) RequestID() string
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize() []byte
type TransactionRecipient ¶
type UnifiedOutput ¶
type UnifiedOutput struct {
Type string `json:"type"`
OutputId string `json:"output_id"`
TransactionRequestId string `json:"request_id,omitempty"`
TransactionHash string `json:"transaction_hash"`
OutputIndex int `json:"output_index"`
AssetId string `json:"asset_id"`
KernelAssetId string `json:"kernel_asset_id"`
Amount decimal.Decimal `json:"amount"`
SendersHash string `json:"senders_hash"`
SendersThreshold int64 `json:"senders_threshold"`
Senders []string `json:"senders"`
ReceiversHash string `json:"receivers_hash"`
ReceiversThreshold int64 `json:"receivers_threshold"`
Extra string `json:"extra"`
State SafeUtxoState `json:"state"`
Sequence uint64 `json:"sequence"`
Signers []string `json:"signers"`
SignedBy string `json:"signed_by"`
SequencerCreatedAt time.Time `json:"created_at"`
TraceId string
AppId string
DepositHash sql.NullString
DepositIndex sql.NullInt64
// contains filtered or unexported fields
}
type Worker ¶
type Worker interface {
// process the action in a queue and return transactions
// need to ensure enough balance with CheckAssetBalanceAt(ctx, a)
// before return any transactions, otherwise the transactions
// will be ignored when issuficient balance
//
// if we want to make a multi process worker, it's possible that
// we pass some RPC handle to the process, or we could build a
// whole state of the current sequence and send it to the process
// i.e. ProcessOutput(StateAtSequence, Action) []*Transaction
ProcessOutput(context.Context, *Action) ([]*Transaction, string)
}
Click to show internal directories.
Click to hide internal directories.