subscriptions

package
v0.0.0-...-4fc266b Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigStorageEmpty = errors.New("config storage not set")
	ErrUnknownTransaction = errors.New("unknown transaction")
	ErrUnknownServiceId   = errors.New("unknown serviceId")
)

Functions

This section is empty.

Types

type BlockNotification

type BlockNotification struct {
	ChainId  string
	BlockNum int64
	BlockId  string
}

type Config

type Config struct {
	Debug bool `json:"debug"`
	// contains filtered or unexported fields
}

func (*Config) Load

func (c *Config) Load() (err error)

func (*Config) Save

func (c *Config) Save() (err error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(options ...Option) (*Manager, error)

func (*Manager) BlockEvent

func (s *Manager) BlockEvent(blockNum int64, blockId string)

func (*Manager) NotifySubscriber

func (s *Manager) NotifySubscriber(serviceId ServiceId, subject string, data Signer)

func (*Manager) SearchTransactionsAfterBlock

func (s *Manager) SearchTransactionsAfterBlock(blockNum int) (txList []*TransferInfoRecord, err error)

func (*Manager) SearchTransactionsBeforeBlock

func (s *Manager) SearchTransactionsBeforeBlock(blockNum int) (txList []*TransferInfoRecord, err error)

func (*Manager) SubscriptionEdit

func (s *Manager) SubscriptionEdit(serviceId ServiceId, edit func(subscription *Subscription)) (err error)

func (*Manager) SubscriptionGet

func (s *Manager) SubscriptionGet(serviceId ServiceId) (subscription *Subscription, err error)

func (*Manager) TransactionEvent

func (s *Manager) TransactionEvent(transactionInfo *types.TransferInfo)

type Option

type Option func(w *Manager) error

func WithAddressManager

func WithAddressManager(pool *address.Manager) Option

func WithBlockchainClient

func WithBlockchainClient(client types.ChainClient) Option

func WithConfigStorage

func WithConfigStorage(storage storage.BinStorage) Option

func WithGlobalConfig

func WithGlobalConfig(config types.Config) Option

func WithSubscribersStorage

func WithSubscribersStorage(storage storage.BinStorage) Option

func WithTransactionStorage

func WithTransactionStorage(storage *storage.BadgerHoldStorage) Option

type ServiceId

type ServiceId int

type Signer

type Signer interface {
	Sign(apiKey string)
}

type Subscription

type Subscription struct {
	ServiceName          string          `json:"serviceName"`
	ServiceId            ServiceId       `json:"serviceId"`
	Internal             bool            `json:"internal,omitempty"`
	ApiToken             string          `json:"apiToken"`
	ApiKey               string          `json:"apiKey"`
	EndpointUrl          string          `json:"eventUrl"`
	ReportNewBlock       bool            `json:"reportNewBlock"`
	ReportIncomingTx     bool            `json:"reportIncomingTx"`
	ReportOutgoingTx     bool            `json:"reportOutgoingTx"`
	ReportMainCoin       bool            `json:"reportMainCoin"`
	ReportTokens         map[string]bool `json:"reportTokens"`
	ReportBalanceChange  bool            `json:"balanceChange"`
	GatherToMaster       bool            `json:"gatherToMaster"`
	MasterList           []string        `json:"masterList"`
	SecuritySignRequests bool            `json:"securitySignRequests,omitempty"`
	SecuritySignResponse bool            `json:"securitySignResponse,omitempty"`
	//Reserved for future use
	SecurityUseEncryption bool `json:"securityUseEncryption,omitempty"`
	// contains filtered or unexported fields
}

func NewSubscription

func NewSubscription(serviceId ServiceId, endpointUrl string, fillSettings func(s *Subscription)) *Subscription

type TransferInfoRecord

type TransferInfoRecord struct {
	TxID              string   `json:"tx_id" badgerhold:"key"`
	Timestamp         int64    `json:"timestamp"`
	BlockNum          int      `json:"blockNum" badgerhold:"index"`
	Ignore            bool     `json:"ignore"`
	Success           bool     `json:"success"`
	Transfer          bool     `json:"transfer"`
	NativeCoin        bool     `json:"nativeCoin,omitempty"`
	Symbol            string   `json:"symbol,omitempty"`
	SmartContract     bool     `json:"smartContract,omitempty"`
	From              string   `json:"from" badgerhold:"index"`
	To                string   `json:"to" badgerhold:"index"`
	Amount            *big.Int `json:"amount"`
	Token             string   `json:"token,omitempty"`
	TokenSymbol       string   `json:"tokenSymbol,omitempty"`
	Fee               *big.Int `json:"fee"`
	InPool            bool     `json:"inPool"`
	Confirmed         bool     `json:"confirmed" badgerhold:"index"`
	ChainSpecificData []byte   `json:"chainSpecificData,omitempty"`
}

type TransferNotification

type TransferNotification struct {
	ChainId       string   `json:"chainId"`
	TxID          string   `json:"tx_id"`
	Timestamp     int64    `json:"timestamp"`
	BlockNum      int      `json:"blockNum"`
	Success       bool     `json:"success"`
	Transfer      bool     `json:"transfer"`
	NativeCoin    bool     `json:"nativeCoin,omitempty"`
	Symbol        string   `json:"symbol,omitempty"`
	SmartContract bool     `json:"smartContract,omitempty"`
	From          string   `json:"from"`
	To            string   `json:"to"`
	Amount        *big.Int `json:"amount"`
	Token         string   `json:"token,omitempty"`
	TokenSymbol   string   `json:"tokenSymbol,omitempty"`
	Fee           *big.Int `json:"fee"`
	InPool        bool     `json:"inPool"`
	Confirmed     bool     `json:"confirmed"`
	Confirmations int      `json:"confirmations"`
	UserId        int64    `json:"userId,omitempty"`
	InvoiceId     int64    `json:"invoiceId,omitempty"`
	Signature     string   `json:"sign,omitempty"`
}

func (*TransferNotification) Sign

func (n *TransferNotification) Sign(apiKey string)

Jump to

Keyboard shortcuts

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