Documentation ¶
Overview ¶
Package bux is the Bitcoin UTXO & xPub Management Engine
If you have any suggestions or comments, please feel free to open an issue on this GitHub repository!
By BuxOrg (https://github.com/BuxOrg)
Index ¶
- Constants
- Variables
- func CreateSignature(xPriv *bip32.ExtendedKey, bodyString string) (string, error)
- func DisplayModels(models interface{}) interface{}
- func Get(ctx context.Context, model ModelInterface, conditions map[string]interface{}, ...) error
- func GetXpubFromRequest(req *http.Request) (string, bool)
- func GetXpubHashFromRequest(req *http.Request) (string, bool)
- func GetXpubIDFromRequest(req *http.Request) (string, bool)
- func IsAdminRequest(req *http.Request) (bool, bool)
- func MarshalIDs(i IDs) graphql.Marshaler
- func MarshalMetadata(m Metadata) graphql.Marshaler
- func Save(ctx context.Context, model ModelInterface) (err error)
- func SetSignature(header *http.Header, xPriv *bip32.ExtendedKey, bodyString string) error
- func SetSignatureFromAccessKey(header *http.Header, privateKeyHex, bodyString string) error
- type AccessKey
- func (m *AccessKey) BeforeCreating(_ context.Context) error
- func (m *AccessKey) GetID() string
- func (m *AccessKey) GetModelName() string
- func (m *AccessKey) GetModelTableName() string
- func (m *AccessKey) Migrate(client datastore.ClientInterface) error
- func (m *AccessKey) RegisterTasks() error
- func (m *AccessKey) Save(ctx context.Context) error
- type AccessKeyService
- type AdminInterface
- type AdminStats
- type AuthPayload
- type BlockHeader
- func (m *BlockHeader) AfterCreated(_ context.Context) error
- func (m *BlockHeader) BeforeCreating(_ context.Context) error
- func (m *BlockHeader) Display() interface{}
- func (m *BlockHeader) GetHash() string
- func (m *BlockHeader) GetID() string
- func (m *BlockHeader) GetModelName() string
- func (m *BlockHeader) GetModelTableName() string
- func (m *BlockHeader) Migrate(client datastore.ClientInterface) error
- func (m *BlockHeader) Save(ctx context.Context) (err error)
- type BlockHeaderService
- type ChangeStrategy
- type Client
- func (c *Client) AddModels(ctx context.Context, autoMigrate bool, models ...interface{}) error
- func (c *Client) AuthenticateRequest(ctx context.Context, req *http.Request, adminXPubs []string, ...) (*http.Request, error)
- func (c *Client) Cachestore() cachestore.ClientInterface
- func (c *Client) Chainstate() chainstate.ClientInterface
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) Datastore() datastore.ClientInterface
- func (c *Client) Debug(on bool)
- func (c *Client) DefaultModelOptions(opts ...ModelOps) []ModelOps
- func (c *Client) DefaultSyncConfig() *SyncConfig
- func (c *Client) DeletePaymailAddress(ctx context.Context, address string, opts ...ModelOps) error
- func (c *Client) EnableNewRelic()
- func (c *Client) GetAccessKey(ctx context.Context, xPubID, id string) (*AccessKey, error)
- func (c *Client) GetAccessKeys(ctx context.Context, metadataConditions *Metadata, ...) ([]*AccessKey, error)
- func (c *Client) GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) ([]*AccessKey, error)
- func (c *Client) GetAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetAccessKeysCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetBlockHeaderByHeight(ctx context.Context, height uint32) (*BlockHeader, error)
- func (c *Client) GetBlockHeaders(ctx context.Context, metadataConditions *Metadata, ...) ([]*BlockHeader, error)
- func (c *Client) GetBlockHeadersCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetDestinationByAddress(ctx context.Context, xPubID, address string) (*Destination, error)
- func (c *Client) GetDestinationByID(ctx context.Context, xPubID, id string) (*Destination, error)
- func (c *Client) GetDestinationByLockingScript(ctx context.Context, xPubID, lockingScript string) (*Destination, error)
- func (c *Client) GetDestinations(ctx context.Context, metadataConditions *Metadata, ...) ([]*Destination, error)
- func (c *Client) GetDestinationsByXpubID(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) ([]*Destination, error)
- func (c *Client) GetDestinationsByXpubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetDestinationsCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetDraftTransactions(ctx context.Context, metadataConditions *Metadata, ...) ([]*DraftTransaction, error)
- func (c *Client) GetDraftTransactionsCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetLastBlockHeader(ctx context.Context) (*BlockHeader, error)
- func (c *Client) GetOrStartTxn(ctx context.Context, name string) context.Context
- func (c *Client) GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error)
- func (c *Client) GetPaymailAddresses(ctx context.Context, metadataConditions *Metadata, ...) ([]*PaymailAddress, error)
- func (c *Client) GetPaymailAddressesByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) ([]*PaymailAddress, error)
- func (c *Client) GetPaymailAddressesCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetPaymailConfig() *PaymailServerOptions
- func (c *Client) GetStats(ctx context.Context, opts ...ModelOps) (stats *AdminStats, err error)
- func (c *Client) GetTaskPeriod(name string) time.Duration
- func (c *Client) GetTransaction(ctx context.Context, xPubID, txID string) (*Transaction, error)
- func (c *Client) GetTransactions(ctx context.Context, metadataConditions *Metadata, ...) ([]*Transaction, error)
- func (c *Client) GetTransactionsByXpubID(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) ([]*Transaction, error)
- func (c *Client) GetTransactionsByXpubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetTransactionsCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetUnsyncedBlockHeaders(ctx context.Context) ([]*BlockHeader, error)
- func (c *Client) GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error)
- func (c *Client) GetUtxos(ctx context.Context, metadataConditions *Metadata, ...) ([]*Utxo, error)
- func (c *Client) GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, ...) ([]*Utxo, error)
- func (c *Client) GetUtxosCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetXPubs(ctx context.Context, metadataConditions *Metadata, ...) ([]*Xpub, error)
- func (c *Client) GetXPubsCount(ctx context.Context, metadataConditions *Metadata, ...) (int64, error)
- func (c *Client) GetXpub(ctx context.Context, xPubKey string) (*Xpub, error)
- func (c *Client) GetXpubByID(ctx context.Context, xPubID string) (*Xpub, error)
- func (c *Client) HTTPClient() HTTPInterface
- func (c *Client) ImportBlockHeadersFromURL() string
- func (c *Client) ImportXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*ImportResults, error)
- func (c *Client) IsDebug() bool
- func (c *Client) IsITCEnabled() bool
- func (c *Client) IsIUCEnabled() bool
- func (c *Client) IsMempoolMonitoringEnabled() bool
- func (c *Client) IsNewRelicEnabled() bool
- func (c *Client) Logger() logger.Interface
- func (c *Client) ModifyTaskPeriod(name string, period time.Duration) error
- func (c *Client) NewAccessKey(ctx context.Context, rawXpubKey string, opts ...ModelOps) (*AccessKey, error)
- func (c *Client) NewDestination(ctx context.Context, xPubKey string, chain uint32, destinationType string, ...) (*Destination, error)
- func (c *Client) NewDestinationForLockingScript(ctx context.Context, xPubID, lockingScript string, monitor bool, ...) (*Destination, error)
- func (c *Client) NewPaymailAddress(ctx context.Context, xPubKey, address, publicName, avatar string, ...) (*PaymailAddress, error)
- func (c *Client) NewTransaction(ctx context.Context, rawXpubKey string, config *TransactionConfig, ...) (*DraftTransaction, error)
- func (c *Client) NewXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*Xpub, error)
- func (c *Client) Notifications() notifications.ClientInterface
- func (c *Client) PaymailClient() paymail.ClientInterface
- func (c *Client) RecordBlockHeader(ctx context.Context, hash string, height uint32, bh bc.BlockHeader, ...) (*BlockHeader, error)
- func (c *Client) RecordMonitoredTransaction(ctx context.Context, txHex string, opts ...ModelOps) (*Transaction, error)
- func (c *Client) RecordTransaction(ctx context.Context, xPubKey, txHex, draftID string, opts ...ModelOps) (*Transaction, error)
- func (c *Client) RevokeAccessKey(ctx context.Context, rawXpubKey, id string, opts ...ModelOps) (*AccessKey, error)
- func (c *Client) SetNotificationsClient(client notifications.ClientInterface)
- func (c *Client) Taskmanager() taskmanager.ClientInterface
- func (c *Client) UpdateDestinationMetadataByAddress(ctx context.Context, xPubID, address string, metadata Metadata) (*Destination, error)
- func (c *Client) UpdateDestinationMetadataByID(ctx context.Context, xPubID, id string, metadata Metadata) (*Destination, error)
- func (c *Client) UpdateDestinationMetadataByLockingScript(ctx context.Context, xPubID, lockingScript string, metadata Metadata) (*Destination, error)
- func (c *Client) UpdatePaymailAddress(ctx context.Context, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error)
- func (c *Client) UpdatePaymailAddressMetadata(ctx context.Context, address string, metadata Metadata, opts ...ModelOps) (*PaymailAddress, error)
- func (c *Client) UpdateTransactionMetadata(ctx context.Context, xPubID, id string, metadata Metadata) (*Transaction, error)
- func (c *Client) UpdateXpubMetadata(ctx context.Context, xPubID string, metadata Metadata) (*Xpub, error)
- func (c *Client) UserAgent() string
- func (c *Client) Version() string
- type ClientInterface
- type ClientOps
- func WithAutoMigrate(migrateModels ...interface{}) ClientOps
- func WithBroadcastMiners(miners []*chainstate.Miner) ClientOps
- func WithChainstateOptions(broadcasting, paymailP2P, syncOnChain bool) ClientOps
- func WithCronService(cronService taskmanager.CronService) ClientOps
- func WithCustomCachestore(cacheStore cachestore.ClientInterface) ClientOps
- func WithCustomChainstate(chainState chainstate.ClientInterface) ClientOps
- func WithCustomDatastore(dataStore datastore.ClientInterface) ClientOps
- func WithCustomNotifications(customNotifications notifications.ClientInterface) ClientOps
- func WithCustomTaskManager(taskManager taskmanager.ClientInterface) ClientOps
- func WithDebugging() ClientOps
- func WithEncryption(key string) ClientOps
- func WithFreeCache() ClientOps
- func WithFreeCacheConnection(client *freecache.Cache) ClientOps
- func WithHTTPClient(httpClient HTTPInterface) ClientOps
- func WithITCDisabled() ClientOps
- func WithIUCDisabled() ClientOps
- func WithImportBlockHeaders(importBlockHeadersURL string) ClientOps
- func WithLogger(customLogger logger.Interface) ClientOps
- func WithMatterCloudAPIKey(apiKey string) ClientOps
- func WithModels(models ...interface{}) ClientOps
- func WithMongoConnection(database *mongo.Database, tablePrefix string) ClientOps
- func WithMongoDB(config *datastore.MongoDBConfig) ClientOps
- func WithMonitoring(ctx context.Context, monitorOptions *chainstate.MonitorOptions) ClientOps
- func WithMonitoringInterface(monitor chainstate.MonitorService) ClientOps
- func WithNewRelic(app *newrelic.Application) ClientOps
- func WithNotifications(webhookEndpoint string) ClientOps
- func WithNowNodesAPIKey(apiKey string) ClientOps
- func WithPaymailClient(client paymail.ClientInterface) ClientOps
- func WithPaymailServerConfig(config *server.Configuration, defaultFromPaymail, defaultNote string) ClientOps
- func WithPaymailSupport(domains []string, defaultFromPaymail, defaultNote string, ...) ClientOps
- func WithQueryMiners(miners []*chainstate.Miner) ClientOps
- func WithRedis(config *cachestore.RedisConfig) ClientOps
- func WithRedisConnection(activeClient *cache.Client) ClientOps
- func WithSQL(engine datastore.Engine, config *datastore.SQLConfig) ClientOps
- func WithSQLConfigs(engine datastore.Engine, configs []*datastore.SQLConfig) ClientOps
- func WithSQLConnection(engine datastore.Engine, sqlDB *sql.DB, tablePrefix string) ClientOps
- func WithSQLite(config *datastore.SQLiteConfig) ClientOps
- func WithTaskQ(config *taskq.QueueOptions, factory taskmanager.Factory) ClientOps
- func WithTaskQUsingRedis(config *taskq.QueueOptions, redisOptions *redis.Options) ClientOps
- func WithUserAgent(userAgent string) ClientOps
- func WithWhatsOnChainAPIKey(apiKey string) ClientOps
- type ClientServices
- type Destination
- func (m *Destination) AfterCreated(_ context.Context) error
- func (m *Destination) AfterDeleted(_ context.Context) error
- func (m *Destination) AfterUpdated(_ context.Context) error
- func (m *Destination) BeforeCreating(_ context.Context) error
- func (m *Destination) GetID() string
- func (m *Destination) GetModelName() string
- func (m *Destination) GetModelTableName() string
- func (m *Destination) Migrate(client datastore.ClientInterface) error
- func (m *Destination) Save(ctx context.Context) (err error)
- type DestinationService
- type DraftStatus
- type DraftTransaction
- func (m *DraftTransaction) AfterUpdated(ctx context.Context) error
- func (m *DraftTransaction) BeforeCreating(ctx context.Context) (err error)
- func (m *DraftTransaction) GetID() string
- func (m *DraftTransaction) GetModelName() string
- func (m *DraftTransaction) GetModelTableName() string
- func (m *DraftTransaction) Migrate(client datastore.ClientInterface) error
- func (m *DraftTransaction) RegisterTasks() error
- func (m *DraftTransaction) Save(ctx context.Context) (err error)
- func (m *DraftTransaction) SignInputs(xPriv *bip32.ExtendedKey) (signedHex string, err error)
- func (m *DraftTransaction) SignInputsWithKey(xPrivKey string) (signedHex string, err error)
- type DraftTransactionService
- type HTTPInterface
- type IDs
- type ImportResults
- type IncomingTransaction
- func (m *IncomingTransaction) AfterCreated(ctx context.Context) error
- func (m *IncomingTransaction) BeforeCreating(ctx context.Context) error
- func (m *IncomingTransaction) GetID() string
- func (m *IncomingTransaction) GetModelName() string
- func (m *IncomingTransaction) GetModelTableName() string
- func (m *IncomingTransaction) Migrate(client datastore.ClientInterface) error
- func (m *IncomingTransaction) RegisterTasks() error
- func (m *IncomingTransaction) Save(ctx context.Context) error
- type MapProtocol
- type Metadata
- func (Metadata) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (m Metadata) GormDataType() string
- func (m *Metadata) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (m *Metadata) Scan(value interface{}) error
- func (m *Metadata) UnmarshalBSONValue(t bsontype.Type, data []byte) error
- func (m Metadata) Value() (driver.Value, error)
- type Model
- func (m *Model) AfterCreated(_ context.Context) error
- func (m *Model) AfterDeleted(_ context.Context) error
- func (m *Model) AfterUpdated(_ context.Context) error
- func (m *Model) BeforeUpdating(_ context.Context) error
- func (m *Model) ChildModels() []ModelInterface
- func (m *Model) Client() ClientInterface
- func (m *Model) DebugLog(text string)
- func (m *Model) Display() interface{}
- func (m *Model) GetID() string
- func (m *Model) GetOptions(isNewRecord bool) (opts []ModelOps)
- func (m *Model) IsNew() bool
- func (m *Model) Name() string
- func (m *Model) New()
- func (m *Model) NotNew()
- func (m *Model) RawXpub() string
- func (m *Model) RegisterTasks() error
- func (m *Model) SetOptions(opts ...ModelOps)
- func (m *Model) SetRecordTime(created bool)
- func (m *Model) UpdateMetadata(metadata Metadata)
- type ModelInterface
- type ModelName
- type ModelOps
- func New() ModelOps
- func WithClient(client ClientInterface) ModelOps
- func WithEncryptionKey(encryptionKey string) ModelOps
- func WithMetadata(key string, value interface{}) ModelOps
- func WithMetadatas(metadata map[string]interface{}) ModelOps
- func WithPageSize(pageSize int) ModelOps
- func WithXPub(rawXpubKey string) ModelOps
- type MonitorEventHandler
- func (h *MonitorEventHandler) GetWhatsOnChain() whatsonchain.ClientInterface
- func (h *MonitorEventHandler) OnConnect(client *centrifuge.Client, e centrifuge.ConnectEvent)
- func (h *MonitorEventHandler) OnDisconnect(_ *centrifuge.Client, _ centrifuge.DisconnectEvent)
- func (h *MonitorEventHandler) OnError(_ *centrifuge.Client, e centrifuge.ErrorEvent)
- func (h *MonitorEventHandler) OnJoin(_ *centrifuge.Subscription, e centrifuge.JoinEvent)
- func (h *MonitorEventHandler) OnLeave(_ *centrifuge.Subscription, e centrifuge.LeaveEvent)
- func (h *MonitorEventHandler) OnMessage(_ *centrifuge.Client, e centrifuge.MessageEvent)
- func (h *MonitorEventHandler) OnPublish(subscription *centrifuge.Subscription, e centrifuge.PublishEvent)
- func (h *MonitorEventHandler) OnServerJoin(_ *centrifuge.Client, e centrifuge.ServerJoinEvent)
- func (h *MonitorEventHandler) OnServerLeave(_ *centrifuge.Client, e centrifuge.ServerLeaveEvent)
- func (h *MonitorEventHandler) OnServerPublish(_ *centrifuge.Client, e centrifuge.ServerPublishEvent)
- func (h *MonitorEventHandler) OnServerSubscribe(_ *centrifuge.Client, e centrifuge.ServerSubscribeEvent)
- func (h *MonitorEventHandler) OnServerUnsubscribe(_ *centrifuge.Client, e centrifuge.ServerUnsubscribeEvent)
- func (h *MonitorEventHandler) OnSubscribeError(_ *centrifuge.Subscription, e centrifuge.SubscribeErrorEvent)
- func (h *MonitorEventHandler) OnSubscribeSuccess(_ *centrifuge.Subscription, e centrifuge.SubscribeSuccessEvent)
- func (h *MonitorEventHandler) OnUnsubscribe(_ *centrifuge.Subscription, e centrifuge.UnsubscribeEvent)
- func (h *MonitorEventHandler) ProcessBlockHeaders(ctx context.Context, client *centrifuge.Client) error
- func (h *MonitorEventHandler) ProcessBlocks(ctx context.Context, client *centrifuge.Client) error
- func (h *MonitorEventHandler) RecordBlockHeader(_ context.Context, _ bc.BlockHeader) error
- func (h *MonitorEventHandler) RecordTransaction(ctx context.Context, txHex string) error
- func (h *MonitorEventHandler) SetMonitor(monitor *chainstate.Monitor)
- type OpReturn
- type ParamRequestKey
- type PaymailAddress
- func (m *PaymailAddress) BeforeCreating(_ context.Context) (err error)
- func (m *PaymailAddress) GetExternalXpub() (*bip32.ExtendedKey, error)
- func (m *PaymailAddress) GetID() string
- func (m *PaymailAddress) GetIdentityXpub() (*bip32.ExtendedKey, error)
- func (m *PaymailAddress) GetModelName() string
- func (m *PaymailAddress) GetModelTableName() string
- func (m *PaymailAddress) Migrate(client datastore.ClientInterface) error
- func (m *PaymailAddress) Save(ctx context.Context) (err error)
- type PaymailDefaultServiceProvider
- func (p *PaymailDefaultServiceProvider) CreateAddressResolutionResponse(ctx context.Context, alias, domain string, _ bool, ...) (*paymail.ResolutionPayload, error)
- func (p *PaymailDefaultServiceProvider) CreateP2PDestinationResponse(ctx context.Context, alias, domain string, satoshis uint64, ...) (*paymail.PaymentDestinationPayload, error)
- func (p *PaymailDefaultServiceProvider) GetPaymailByAlias(ctx context.Context, alias, domain string, ...) (*paymail.AddressInformation, error)
- func (p *PaymailDefaultServiceProvider) RecordTransaction(ctx context.Context, p2pTx *paymail.P2PTransaction, ...) (*paymail.P2PTransactionPayload, error)
- type PaymailP4
- type PaymailServerOptions
- type PaymailService
- type ScriptOutput
- type SyncConfig
- type SyncResult
- type SyncResults
- type SyncStatus
- type SyncTransaction
- func (m *SyncTransaction) BeforeCreating(_ context.Context) error
- func (m *SyncTransaction) GetID() string
- func (m *SyncTransaction) GetModelName() string
- func (m *SyncTransaction) GetModelTableName() string
- func (m *SyncTransaction) Migrate(client datastore.ClientInterface) error
- func (m *SyncTransaction) RegisterTasks() error
- func (m *SyncTransaction) Save(ctx context.Context) error
- type Transaction
- func (m *Transaction) AfterCreated(ctx context.Context) error
- func (m *Transaction) AfterDeleted(_ context.Context) error
- func (m *Transaction) AfterUpdated(_ context.Context) error
- func (m *Transaction) BeforeCreating(ctx context.Context) error
- func (m *Transaction) ChildModels() (childModels []ModelInterface)
- func (m *Transaction) Display() interface{}
- func (m *Transaction) GetID() string
- func (m *Transaction) GetModelName() string
- func (m *Transaction) GetModelTableName() string
- func (m *Transaction) IsXpubAssociated(rawXpubKey string) bool
- func (m *Transaction) IsXpubIDAssociated(xPubID string) bool
- func (m *Transaction) Migrate(client datastore.ClientInterface) error
- func (m *Transaction) Save(ctx context.Context) (err error)
- func (m *Transaction) UpdateTransactionMetadata(xPubID string, metadata Metadata) error
- type TransactionBase
- type TransactionConfig
- type TransactionDirection
- type TransactionInput
- type TransactionOutput
- type TransactionService
- type UTXOService
- type Utxo
- func (m *Utxo) BeforeCreating(_ context.Context) error
- func (m *Utxo) GenerateID() string
- func (m *Utxo) GetID() string
- func (m *Utxo) GetModelName() string
- func (m *Utxo) GetModelTableName() string
- func (m *Utxo) Migrate(client datastore.ClientInterface) error
- func (m *Utxo) Save(ctx context.Context) (err error)
- type UtxoPointer
- type XPubService
- type Xpub
- func (m *Xpub) AfterCreated(ctx context.Context) error
- func (m *Xpub) AfterUpdated(ctx context.Context) error
- func (m *Xpub) BeforeCreating(_ context.Context) error
- func (m *Xpub) ChildModels() (childModels []ModelInterface)
- func (m *Xpub) GetID() string
- func (m *Xpub) GetModelName() string
- func (m *Xpub) GetModelTableName() string
- func (m *Xpub) IncrementBalance(ctx context.Context, balanceIncrement int64) error
- func (m *Xpub) IncrementNextNum(ctx context.Context, chain uint32) (uint32, error)
- func (m *Xpub) Migrate(client datastore.ClientInterface) error
- func (m *Xpub) RemovePrivateData()
- func (m *Xpub) Save(ctx context.Context) error
- type XpubMetadata
- func (XpubMetadata) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (x *XpubMetadata) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (x *XpubMetadata) Scan(value interface{}) error
- func (x *XpubMetadata) UnmarshalBSONValue(t bsontype.Type, data []byte) error
- func (x XpubMetadata) Value() (driver.Value, error)
- type XpubOutputValue
Constants ¶
const ( // AuthHeader is the header to use for authentication (raw xPub) AuthHeader = "auth_xpub" // AuthAccessKey is the header to use for access key authentication (access public key) AuthAccessKey = "auth_key" // AuthSignature is the given signature (body + timestamp) AuthSignature = "auth_signature" // AuthHeaderHash hash of the body coming from the request AuthHeaderHash = "auth_hash" // AuthHeaderNonce random nonce for the request AuthHeaderNonce = "auth_nonce" // AuthHeaderTime the time of the request, only valid for 30 seconds AuthHeaderTime = "auth_time" // AuthSignatureTTL is the max TTL for a signature to be valid AuthSignatureTTL = 20 * time.Second )
const ( // ResolutionTypeBasic is for the "deprecated" way to resolve an address from a Paymail ResolutionTypeBasic = "basic_resolution" // ResolutionTypeP2P is the current way to resolve a Paymail (prior to P4) ResolutionTypeP2P = "p2p" )
Types of resolution methods
const (
// MetadataField is the field name used for metadata (params)
MetadataField = "metadata"
)
const (
// ReferenceIDField is used for Paymail
ReferenceIDField = "reference_id"
)
const ValueTypeString = "string"
ValueTypeString is the value type "string"
Variables ¶
var ( // AllModelNames is a list of all models AllModelNames = []ModelName{ ModelAccessKey, ModelBlockHeader, ModelDestination, ModelIncomingTransaction, ModelMetadata, ModelPaymailAddress, ModelPaymailAddress, ModelSyncTransaction, ModelTransaction, ModelUtxo, ModelXPub, } )
var ( // BaseModels is the list of models for loading the engine and AutoMigration (defaults) BaseModels = []interface{}{ &Xpub{ Model: *NewBaseModel(ModelXPub), }, &AccessKey{ Model: *NewBaseModel(ModelAccessKey), }, &DraftTransaction{ Model: *NewBaseModel(ModelDraftTransaction), }, &IncomingTransaction{ Model: *NewBaseModel(ModelIncomingTransaction), }, &Transaction{ Model: *NewBaseModel(ModelTransaction), }, &BlockHeader{ Model: *NewBaseModel(ModelBlockHeader), }, &SyncTransaction{ Model: *NewBaseModel(ModelSyncTransaction), }, &Destination{ Model: *NewBaseModel(ModelDestination), }, &Utxo{ Model: *NewBaseModel(ModelUtxo), }, } )
var ErrAccessKeyRevoked = errors.New("access key has been revoked")
ErrAccessKeyRevoked is when the access key has been revoked
var ErrAuhHashMismatch = errors.New("auth hash and body hash do not match")
ErrAuhHashMismatch is when the auth hash does not match the body hash
var ErrAuthAccessKeyNotFound = errors.New("auth access key could not be found")
ErrAuthAccessKeyNotFound is when the auth access key could not be found in the database
var ErrCannotConvertToIDs = errors.New("cannot convert value to type IDs")
ErrCannotConvertToIDs is the error when the conversion fails from interface into type IDs
var ErrChangeStrategyNotImplemented = errors.New("change strategy nominations not implemented yet")
ErrChangeStrategyNotImplemented is a temporary error until the feature is supported
var ErrDatastoreRequired = errors.New("datastore is required")
ErrDatastoreRequired is when a datastore function is called without a datastore present
var ErrDraftIDMismatch = errors.New("transaction draft id does not match utxo draft reservation id")
ErrDraftIDMismatch is when the reference ID does not match the reservation id
var ErrDraftNotFound = errors.New("corresponding draft transaction not found")
ErrDraftNotFound is when the requested draft transaction was not found
var ErrInvalidLockingScript = errors.New("invalid locking script")
ErrInvalidLockingScript is when a locking script cannot be decoded
var ErrInvalidOpReturnOutput = errors.New("invalid op_return output")
ErrInvalidOpReturnOutput is when a locking script is not a valid op_return
var ErrInvalidScriptOutput = errors.New("invalid script output")
ErrInvalidScriptOutput is when a locking script is not a valid bitcoin script
var ErrInvalidTransactionID = errors.New("invalid transaction id")
ErrInvalidTransactionID is when a transaction id cannot be decoded
var ErrMissingAccessKey = errors.New("missing access key")
ErrMissingAccessKey is when the access key is missing
var ErrMissingAddressResolutionURL = errors.New("missing address resolution url from capabilities")
ErrMissingAddressResolutionURL is when the paymail resolution url is missing from capabilities
var ErrMissingAuthHeader = errors.New("missing authentication header")
ErrMissingAuthHeader is when the authentication header is missing from the request
var ErrMissingBlockHeaderHash = errors.New("block header hash is empty or id is missing")
ErrMissingBlockHeaderHash is when the hash is missing or invalid and creates an empty id
var ErrMissingBody = errors.New("missing body")
ErrMissingBody is when the body is missing
var ErrMissingDestination = errors.New("destination could not be found")
ErrMissingDestination is an error when a destination could not be found
var ErrMissingFieldHash = errors.New("missing required field: hash")
ErrMissingFieldHash is an error when missing the hex field of a transaction
var ErrMissingFieldHex = errors.New("missing required field: hex")
ErrMissingFieldHex is an error when missing the hex field of a transaction
var ErrMissingFieldID = errors.New("missing required field: id")
ErrMissingFieldID is an error when missing the id field
var ErrMissingFieldSatoshis = errors.New("missing required field: satoshis")
ErrMissingFieldSatoshis is when the field is required but missing
var ErrMissingFieldScriptPubKey = errors.New("missing required field: script_pub_key")
ErrMissingFieldScriptPubKey is when the field is required but missing
var ErrMissingFieldTransactionID = errors.New("missing required field: transaction_id")
ErrMissingFieldTransactionID is when the field is required but missing
var ErrMissingFieldXpubID = errors.New("missing required field: xpub_id")
ErrMissingFieldXpubID is when the field is required but missing
var ErrMissingLockingScript = errors.New("could not find locking script")
ErrMissingLockingScript is when the field is required but missing
var ErrMissingPaymail = errors.New("missing paymail")
ErrMissingPaymail missing paymail
var ErrMissingPaymailAddress = errors.New("missing alias in paymail")
ErrMissingPaymailAddress missing alias in paymail
var ErrMissingPaymailDomain = errors.New("missing domain in paymail")
ErrMissingPaymailDomain missing domain in paymail
var ErrMissingPaymailExternalXPub = errors.New("missing external xPub in paymail")
ErrMissingPaymailExternalXPub missing external xPub in paymail
var ErrMissingPaymailID = errors.New("missing id in paymail")
ErrMissingPaymailID missing id in paymail
var ErrMissingPaymailXPubID = errors.New("missing xpub_id in paymail")
ErrMissingPaymailXPubID missing xpub_id in paymail
var ErrMissingRequiredXpub = errors.New("xpub was not found but was expected")
ErrMissingRequiredXpub is when the xpub should exist but was not found
var ErrMissingSignature = errors.New("signature missing")
ErrMissingSignature is when the signature is missing from the request
var ErrMissingTransaction = errors.New("transaction could not be found")
ErrMissingTransaction is an error when a transaction could not be found
var ErrMissingTransactionOutputs = errors.New("draft transaction configuration has no outputs")
ErrMissingTransactionOutputs is when the draft transaction has not outputs
var ErrMissingTxHex = errors.New("transaction hex is empty or id is missing")
ErrMissingTxHex is when the hex is missing or invalid and creates an empty id
var ErrMissingUtxo = errors.New("utxo could not be found")
ErrMissingUtxo is an error when a utxo could not be found
var ErrMissingXPriv = errors.New("missing xPriv key")
ErrMissingXPriv is when the xPriv is missing
var ErrMissingXpub = errors.New("could not find xpub")
ErrMissingXpub is when the field is required but missing
var ErrNoMatchingOutputs = errors.New("transaction outputs do not match any known destinations")
ErrNoMatchingOutputs is when the transaction does not match any known destinations
var ErrNotAdminKey = errors.New("xpub provided is not an admin key")
ErrNotAdminKey is when the xpub being used is not considered an admin key
var ErrNotEnoughUtxos = errors.New("could not select enough outputs to satisfy transaction")
ErrNotEnoughUtxos is when a draft transaction cannot be created because of lack of utxos
var ErrOutputValueNotRecognized = errors.New("output value is unrecognized")
ErrOutputValueNotRecognized is when there is an invalid output value given, or missing value
var ErrOutputValueTooLow = errors.New("output value is too low")
ErrOutputValueTooLow is when the satoshis output is too low on a transaction
var ErrPaymailAddressIsInvalid = errors.New("paymail address is invalid")
ErrPaymailAddressIsInvalid is when the paymail address is NOT alias@domain.com
var ErrResolutionFailed = errors.New("failed to return a resolution for paymail address")
ErrResolutionFailed is when the paymail resolution failed unexpectedly
var ErrSignatureExpired = errors.New("signature has expired")
ErrSignatureExpired is when the signature TTL expired
var ErrSignatureInvalid = errors.New("signature invalid")
ErrSignatureInvalid is when the signature failed to be valid
var ErrTaskManagerNotLoaded = errors.New("taskmanager must be loaded")
ErrTaskManagerNotLoaded is when the taskmanager was not loaded
var ErrTransactionNotParsed = errors.New("transaction is not parsed")
ErrTransactionNotParsed is when the transaction is not parsed but was expected
var ErrUnknownAccessKey = errors.New("unknown access key")
ErrUnknownAccessKey is when the access key is unknown or not found
var ErrUnknownLockingScript = errors.New("could not recognize locking script")
ErrUnknownLockingScript is when the field is unknown
var ErrUnsupportedDestinationType = errors.New("unsupported destination type")
ErrUnsupportedDestinationType is a destination type that is not currently supported
var ErrUtxoAlreadySpent = errors.New("utxo has already been spent")
ErrUtxoAlreadySpent is when the utxo is already spent, but is trying to be used
var ErrUtxoNotReserved = errors.New("transaction utxo has not been reserved for spending")
ErrUtxoNotReserved is when the utxo is not reserved, but a transaction tries to spend it
var ErrXpubIDMisMatch = errors.New("xpub_id mismatch")
ErrXpubIDMisMatch is when the xPubID does not match
Functions ¶
func CreateSignature ¶
func CreateSignature(xPriv *bip32.ExtendedKey, bodyString string) (string, error)
CreateSignature will create a signature for the given key & body contents
func DisplayModels ¶
func DisplayModels(models interface{}) interface{}
DisplayModels process the (slice) of model(s) for display
func Get ¶
func Get( ctx context.Context, model ModelInterface, conditions map[string]interface{}, _ bool, timeout time.Duration, forceWriteDB bool, ) error
Get will retrieve a model from the Cachestore or Datastore using the provided conditions
use bypassCache to skip checking the Cachestore for the record
func GetXpubFromRequest ¶
GetXpubFromRequest gets the stored xPub from the request if found
func GetXpubHashFromRequest ¶
GetXpubHashFromRequest gets the stored xPub hash from the request if found
func GetXpubIDFromRequest ¶ added in v0.2.14
GetXpubIDFromRequest gets the stored xPubID from the request if found
func IsAdminRequest ¶ added in v0.2.14
IsAdminRequest gets the stored xPub from the request if found
func MarshalIDs ¶
MarshalIDs will unmarshal the custom type
func MarshalMetadata ¶
MarshalMetadata will marshal the custom type
func Save ¶
func Save(ctx context.Context, model ModelInterface) (err error)
Save will Save the model(s) into the Datastore
func SetSignature ¶
SetSignature will set the signature on the header for the request
Types ¶
type AccessKey ¶
type AccessKey struct { // Base model Model `bson:",inline"` // Model specific fields ID string `json:"id" toml:"id" yaml:"id" gorm:"<-:create;type:char(64);primaryKey;comment:This is the unique access key id" bson:"_id"` XpubID string `` /* 129-byte string literal not displayed */ RevokedAt utils.NullTime `json:"revoked_at" toml:"revoked_at" yaml:"revoked_at" gorm:"<-;comment:When the key was revoked" bson:"revoked_at,omitempty"` // Private fields Key string `json:"key" gorm:"-" bson:"-"` // Used on "CREATE", shown to the user "once" only }
AccessKey is an object representing an access key model
An AccessKey is a private key with a corresponding public key The public key is hashed and saved in this model for retrieval. When a request is made with an access key, the public key is sent in the headers, together with a signature (like normally done with xPriv signing)
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*AccessKey) BeforeCreating ¶
BeforeCreating will fire before the model is being inserted into the Datastore
func (*AccessKey) GetModelName ¶
GetModelName will get the name of the current model
func (*AccessKey) GetModelTableName ¶
GetModelTableName will get the db table name of the current model
func (*AccessKey) Migrate ¶
func (m *AccessKey) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*AccessKey) RegisterTasks ¶
RegisterTasks will register the model specific tasks on client initialization
type AccessKeyService ¶ added in v0.2.14
type AccessKeyService interface { GetAccessKey(ctx context.Context, xPubID, pubAccessKey string) (*AccessKey, error) GetAccessKeys(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error) GetAccessKeysCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error) GetAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) NewAccessKey(ctx context.Context, rawXpubKey string, opts ...ModelOps) (*AccessKey, error) RevokeAccessKey(ctx context.Context, rawXpubKey, id string, opts ...ModelOps) (*AccessKey, error) }
AccessKeyService is the access key actions
type AdminInterface ¶ added in v0.2.18
type AdminInterface interface { GetStats(ctx context.Context, opts ...ModelOps) (*AdminStats, error) GetPaymailAddresses(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*PaymailAddress, error) GetPaymailAddressesCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) GetXPubs(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Xpub, error) GetXPubsCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) }
AdminInterface is the bux admin interface comprised of all services available for admins
type AdminStats ¶ added in v0.2.18
type AdminStats struct { Balance int64 `json:"balance"` Destinations int64 `json:"destinations"` Transactions int64 `json:"transactions"` Paymails int64 `json:"paymails"` Utxos int64 `json:"utxos"` XPubs int64 `json:"xpubs"` TransactionsPerDay map[string]int64 `json:"transactions_per_day"` }
AdminStats are statistics about the bux server
type AuthPayload ¶
type AuthPayload struct { AuthHash string `json:"auth_hash"` AuthNonce string `json:"auth_nonce"` AuthTime int64 `json:"auth_time"` BodyContents string `json:"body_contents"` Signature string `json:"signature"` // contains filtered or unexported fields }
AuthPayload is the authentication payload for checking or creating a signature
type BlockHeader ¶ added in v0.2.14
type BlockHeader struct { // Base model Model `bson:",inline"` // Model specific fields ID string `json:"id" toml:"id" yaml:"id" gorm:"<-:create;type:char(64);primaryKey;comment:This is the block hash" bson:"_id"` Height uint32 `json:"height" toml:"height" yaml:"height" gorm:"<-create;uniqueIndex;comment:This is the block height" bson:"height"` Time uint32 `json:"time" toml:"time" yaml:"time" gorm:"<-create;index;comment:This is the time the block was mined" bson:"time"` Nonce uint32 `json:"nonce" toml:"nonce" yaml:"nonce" gorm:"<-create;comment:This is the nonce" bson:"nonce"` Version uint32 `json:"version" toml:"version" yaml:"version" gorm:"<-create;comment:This is the version" bson:"version"` HashPreviousBlock string `` /* 191-byte string literal not displayed */ HashMerkleRoot string `` /* 169-byte string literal not displayed */ Bits string `json:"bits" toml:"bits" yaml:"bits" gorm:"<-:create;comment:This is the block difficulty" bson:"bits"` Synced utils.NullTime `` /* 158-byte string literal not displayed */ }
BlockHeader is an object representing the BitCoin block header
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*BlockHeader) AfterCreated ¶ added in v0.2.14
func (m *BlockHeader) AfterCreated(_ context.Context) error
AfterCreated will fire after the model is created in the Datastore
func (*BlockHeader) BeforeCreating ¶ added in v0.2.14
func (m *BlockHeader) BeforeCreating(_ context.Context) error
BeforeCreating will fire before the model is being inserted into the Datastore
func (*BlockHeader) Display ¶ added in v0.2.14
func (m *BlockHeader) Display() interface{}
Display filter the model for display
func (*BlockHeader) GetHash ¶ added in v0.2.14
func (m *BlockHeader) GetHash() string
GetHash will get the hash of the block header
func (*BlockHeader) GetID ¶ added in v0.2.14
func (m *BlockHeader) GetID() string
GetID will return the id of the field (hash)
func (*BlockHeader) GetModelName ¶ added in v0.2.14
func (m *BlockHeader) GetModelName() string
GetModelName will get the name of the current model
func (*BlockHeader) GetModelTableName ¶ added in v0.2.14
func (m *BlockHeader) GetModelTableName() string
GetModelTableName will get the db table name of the current model
func (*BlockHeader) Migrate ¶ added in v0.2.14
func (m *BlockHeader) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
type BlockHeaderService ¶ added in v0.2.14
type BlockHeaderService interface { RecordBlockHeader(ctx context.Context, hash string, height uint32, bh bc.BlockHeader, opts ...ModelOps) (*BlockHeader, error) GetBlockHeaders(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*BlockHeader, error) GetBlockHeadersCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) GetUnsyncedBlockHeaders(ctx context.Context) ([]*BlockHeader, error) GetLastBlockHeader(ctx context.Context) (*BlockHeader, error) GetBlockHeaderByHeight(ctx context.Context, height uint32) (*BlockHeader, error) }
BlockHeaderService is the block header actions
type ChangeStrategy ¶
type ChangeStrategy string
ChangeStrategy strategy to use for change
const ( // ChangeStrategyDefault is a strategy that divides the satoshis among the change destinations ChangeStrategyDefault ChangeStrategy = "default" // ChangeStrategyRandom is a strategy randomizing the output of satoshis among the change destinations ChangeStrategyRandom ChangeStrategy = "random" // ChangeStrategyNominations is a strategy using coin nominations for the outputs (10, 25, 50, 100, 250 etc.) ChangeStrategyNominations ChangeStrategy = "nominations" )
Types of change destination strategies
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the bux client & options
func (*Client) AuthenticateRequest ¶
func (c *Client) AuthenticateRequest(ctx context.Context, req *http.Request, adminXPubs []string, adminRequired, requireSigning, signingDisabled bool) (*http.Request, error)
AuthenticateRequest will parse the incoming request for the associated authentication header, and it will check the Key/Signature
Sets req.Context(xpub) and req.Context(xpub_hash)
func (*Client) Cachestore ¶
func (c *Client) Cachestore() cachestore.ClientInterface
Cachestore will return the Cachestore IF: exists and is enabled
func (*Client) Chainstate ¶
func (c *Client) Chainstate() chainstate.ClientInterface
Chainstate will return the Chainstate service IF: exists and is enabled
func (*Client) Datastore ¶
func (c *Client) Datastore() datastore.ClientInterface
Datastore will return the Datastore if it exists
func (*Client) DefaultModelOptions ¶
DefaultModelOptions will set any default model options (from Client options->model)
func (*Client) DefaultSyncConfig ¶ added in v0.2.14
func (c *Client) DefaultSyncConfig() *SyncConfig
DefaultSyncConfig will return the default sync config from the client defaults (for chainstate)
func (*Client) DeletePaymailAddress ¶ added in v0.2.14
DeletePaymailAddress will delete a paymail address
func (*Client) EnableNewRelic ¶
func (c *Client) EnableNewRelic()
EnableNewRelic will enable NewRelic tracing
func (*Client) GetAccessKey ¶ added in v0.2.14
GetAccessKey will get an existing access key from the Datastore
func (*Client) GetAccessKeys ¶ added in v0.2.14
func (c *Client) GetAccessKeys(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error)
GetAccessKeys will get all the access keys from the Datastore
func (*Client) GetAccessKeysByXPubID ¶ added in v0.2.18
func (c *Client) GetAccessKeysByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*AccessKey, error)
GetAccessKeysByXPubID will get all existing access keys from the Datastore
metadataConditions is the metadata to match to the access keys being returned
func (*Client) GetAccessKeysByXPubIDCount ¶ added in v0.2.18
func (c *Client) GetAccessKeysByXPubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetAccessKeysByXPubIDCount will get a count of all existing access keys from the Datastore
func (*Client) GetAccessKeysCount ¶ added in v0.2.18
func (c *Client) GetAccessKeysCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetAccessKeysCount will get a count of all the access keys from the Datastore
func (*Client) GetBlockHeaderByHeight ¶ added in v0.2.14
GetBlockHeaderByHeight get the block header by height
func (*Client) GetBlockHeaders ¶ added in v0.2.18
func (c *Client) GetBlockHeaders(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*BlockHeader, error)
GetBlockHeaders will get all the block headers from the Datastore
func (*Client) GetBlockHeadersCount ¶ added in v0.2.18
func (c *Client) GetBlockHeadersCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetBlockHeadersCount will get a count of all the block headers from the Datastore
func (*Client) GetDestinationByAddress ¶
func (c *Client) GetDestinationByAddress(ctx context.Context, xPubID, address string) (*Destination, error)
GetDestinationByAddress will get a destination for an address
func (*Client) GetDestinationByID ¶ added in v0.2.14
GetDestinationByID will get a destination by id
func (*Client) GetDestinationByLockingScript ¶
func (c *Client) GetDestinationByLockingScript(ctx context.Context, xPubID, lockingScript string) (*Destination, error)
GetDestinationByLockingScript will get a destination for a locking script
func (*Client) GetDestinations ¶
func (c *Client) GetDestinations(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Destination, error)
GetDestinations will get all the destinations from the Datastore
func (*Client) GetDestinationsByXpubID ¶ added in v0.2.18
func (c *Client) GetDestinationsByXpubID(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Destination, error)
GetDestinationsByXpubID will get destinations based on an xPub
metadataConditions are the search criteria used to find destinations
func (*Client) GetDestinationsByXpubIDCount ¶ added in v0.2.18
func (c *Client) GetDestinationsByXpubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}) (int64, error)
GetDestinationsByXpubIDCount will get a count of all destinations based on an xPub
func (*Client) GetDestinationsCount ¶ added in v0.2.18
func (c *Client) GetDestinationsCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetDestinationsCount will get a count of all the destinations from the Datastore
func (*Client) GetDraftTransactions ¶ added in v0.2.18
func (c *Client) GetDraftTransactions(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*DraftTransaction, error)
GetDraftTransactions will get all the draft transactions from the Datastore
func (*Client) GetDraftTransactionsCount ¶ added in v0.2.18
func (c *Client) GetDraftTransactionsCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetDraftTransactionsCount will get a count of all the draft transactions from the Datastore
func (*Client) GetLastBlockHeader ¶ added in v0.2.14
func (c *Client) GetLastBlockHeader(ctx context.Context) (*BlockHeader, error)
GetLastBlockHeader get last block header
func (*Client) GetOrStartTxn ¶
GetOrStartTxn will check for an existing NewRelic transaction, if not found, it will make a new transaction
func (*Client) GetPaymailAddress ¶ added in v0.2.14
func (c *Client) GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error)
GetPaymailAddress will get a paymail address model
func (*Client) GetPaymailAddresses ¶ added in v0.2.14
func (c *Client) GetPaymailAddresses(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*PaymailAddress, error)
GetPaymailAddresses will get all the paymail addresses from the Datastore
func (*Client) GetPaymailAddressesByXPubID ¶ added in v0.2.14
func (c *Client) GetPaymailAddressesByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*PaymailAddress, error)
GetPaymailAddressesByXPubID will get all the paymail addresses for an xPubID from the Datastore
func (*Client) GetPaymailAddressesCount ¶ added in v0.2.18
func (c *Client) GetPaymailAddressesCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetPaymailAddressesCount will get a count of all the paymail addresses from the Datastore
func (*Client) GetPaymailConfig ¶ added in v0.2.14
func (c *Client) GetPaymailConfig() *PaymailServerOptions
GetPaymailConfig will return the Paymail server config if it exists
func (*Client) GetTaskPeriod ¶
GetTaskPeriod will return the period for a given task name
func (*Client) GetTransaction ¶
GetTransaction will get a transaction from the Datastore
ctx is the context testTxID is the transaction ID
func (*Client) GetTransactions ¶
func (c *Client) GetTransactions(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Transaction, error)
GetTransactions will get all the transactions from the Datastore
func (*Client) GetTransactionsByXpubID ¶ added in v0.2.18
func (c *Client) GetTransactionsByXpubID(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Transaction, error)
GetTransactionsByXpubID will get all transactions for a given xpub from the Datastore
ctx is the context rawXpubKey is the raw xPub key metadataConditions is added to the request for searching conditions is added the request for searching
func (*Client) GetTransactionsByXpubIDCount ¶ added in v0.2.18
func (c *Client) GetTransactionsByXpubIDCount(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}) (int64, error)
GetTransactionsByXpubIDCount will get the count of all transactions matching the search criteria
func (*Client) GetTransactionsCount ¶ added in v0.2.18
func (c *Client) GetTransactionsCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetTransactionsCount will get a count of all the transactions from the Datastore
func (*Client) GetUnsyncedBlockHeaders ¶ added in v0.2.14
func (c *Client) GetUnsyncedBlockHeaders(ctx context.Context) ([]*BlockHeader, error)
GetUnsyncedBlockHeaders get all unsynced block headers
func (*Client) GetUtxo ¶
func (c *Client) GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error)
GetUtxo will get a single utxo based on an xPub, the tx ID and the outputIndex
func (*Client) GetUtxos ¶
func (c *Client) GetUtxos(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Utxo, error)
GetUtxos will get all the utxos from the Datastore
func (*Client) GetUtxosByXpubID ¶ added in v0.2.18
func (c *Client) GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Utxo, error)
GetUtxosByXpubID will get utxos based on an xPub
func (*Client) GetUtxosCount ¶ added in v0.2.18
func (c *Client) GetUtxosCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetUtxosCount will get a count of all the utxos from the Datastore
func (*Client) GetXPubs ¶ added in v0.2.18
func (c *Client) GetXPubs(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Xpub, error)
GetXPubs gets all xpubs matching the conditions
func (*Client) GetXPubsCount ¶ added in v0.2.18
func (c *Client) GetXPubsCount(ctx context.Context, metadataConditions *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error)
GetXPubsCount gets a count of all xpubs matching the conditions
func (*Client) GetXpub ¶
GetXpub will get an existing xPub from the Datastore
xPubKey is the raw public xPub
func (*Client) GetXpubByID ¶
GetXpubByID will get an existing xPub from the Datastore
func (*Client) HTTPClient ¶ added in v0.2.14
func (c *Client) HTTPClient() HTTPInterface
HTTPClient will return the http interface to use in the client
func (*Client) ImportBlockHeadersFromURL ¶ added in v0.2.14
ImportBlockHeadersFromURL will the URL where to import block headers from
func (*Client) ImportXpub ¶ added in v0.1.1
func (c *Client) ImportXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*ImportResults, error)
ImportXpub will import a given xPub and all related destinations and transactions
func (*Client) IsITCEnabled ¶
IsITCEnabled will return the flag (bool)
func (*Client) IsIUCEnabled ¶ added in v0.1.1
IsIUCEnabled will return the flag (bool)
func (*Client) IsMempoolMonitoringEnabled ¶ added in v0.2.14
IsMempoolMonitoringEnabled will return whether mempool monitoring is on
func (*Client) IsNewRelicEnabled ¶
IsNewRelicEnabled will return the flag (bool)
func (*Client) ModifyTaskPeriod ¶
ModifyTaskPeriod will modify a cron task's duration period from the default
func (*Client) NewAccessKey ¶
func (c *Client) NewAccessKey(ctx context.Context, rawXpubKey string, opts ...ModelOps) (*AccessKey, error)
NewAccessKey will create a new access key for the given xpub
opts are options and can include "metadata"
func (*Client) NewDestination ¶
func (c *Client) NewDestination(ctx context.Context, xPubKey string, chain uint32, destinationType string, monitor bool, opts ...ModelOps) (*Destination, error)
NewDestination will get a new destination for an existing xPub
xPubKey is the raw public xPub
func (*Client) NewDestinationForLockingScript ¶
func (c *Client) NewDestinationForLockingScript(ctx context.Context, xPubID, lockingScript string, monitor bool, opts ...ModelOps) (*Destination, error)
NewDestinationForLockingScript will create a new destination based on a locking script
func (*Client) NewPaymailAddress ¶ added in v0.2.14
func (c *Client) NewPaymailAddress(ctx context.Context, xPubKey, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error)
NewPaymailAddress will create a new paymail address
func (*Client) NewTransaction ¶
func (c *Client) NewTransaction(ctx context.Context, rawXpubKey string, config *TransactionConfig, opts ...ModelOps) (*DraftTransaction, error)
NewTransaction will create a new draft transaction and return it
ctx is the context rawXpubKey is the raw xPub key config is the TransactionConfig metadata is added to the model opts are additional model options to be applied
func (*Client) NewXpub ¶
NewXpub will parse the xPub and Save it into the Datastore
xPubKey is the raw public xPub opts are options and can include "metadata"
func (*Client) Notifications ¶ added in v0.2.14
func (c *Client) Notifications() notifications.ClientInterface
Notifications will return the Notifications if it exists
func (*Client) PaymailClient ¶
func (c *Client) PaymailClient() paymail.ClientInterface
PaymailClient will return the Paymail if it exists
func (*Client) RecordBlockHeader ¶ added in v0.2.14
func (c *Client) RecordBlockHeader(ctx context.Context, hash string, height uint32, bh bc.BlockHeader, opts ...ModelOps) (*BlockHeader, error)
RecordBlockHeader will Save a block header into the Datastore
hash is the hash of the block header bh is the block header data opts are model options and can include "metadata"
func (*Client) RecordMonitoredTransaction ¶ added in v0.2.14
func (c *Client) RecordMonitoredTransaction(ctx context.Context, txHex string, opts ...ModelOps) (*Transaction, error)
RecordMonitoredTransaction will parse the transaction and Save it into the Datastore
This function will try to record the transaction directly, without checking draft ids etc.
func (*Client) RecordTransaction ¶
func (c *Client) RecordTransaction(ctx context.Context, xPubKey, txHex, draftID string, opts ...ModelOps) (*Transaction, error)
RecordTransaction will parse the transaction and Save it into the Datastore
Internal (known) transactions: there is a corresponding `draft_transaction` via `draft_id` External (known) transactions: there are output(s) related to the destination `reference_id`, tx is valid (mempool/on-chain) External (unknown) transactions: no reference id but some output(s) match known outputs, tx is valid (mempool/on-chain) Unknown transactions: no matching outputs, tx will be disregarded
xPubKey is the raw public xPub txHex is the raw transaction hex draftID is the unique draft id from a previously started New() transaction (draft_transaction.ID) opts are model options and can include "metadata"
func (*Client) RevokeAccessKey ¶
func (c *Client) RevokeAccessKey(ctx context.Context, rawXpubKey, id string, opts ...ModelOps) (*AccessKey, error)
RevokeAccessKey will revoke an access key by its id
opts are options and can include "metadata"
func (*Client) SetNotificationsClient ¶ added in v0.2.14
func (c *Client) SetNotificationsClient(client notifications.ClientInterface)
SetNotificationsClient will overwrite the notification's client with the given client
func (*Client) Taskmanager ¶
func (c *Client) Taskmanager() taskmanager.ClientInterface
Taskmanager will return the Taskmanager if it exists
func (*Client) UpdateDestinationMetadataByAddress ¶ added in v0.2.14
func (c *Client) UpdateDestinationMetadataByAddress(ctx context.Context, xPubID, address string, metadata Metadata) (*Destination, error)
UpdateDestinationMetadataByAddress will update the metadata in an existing destination by address
func (*Client) UpdateDestinationMetadataByID ¶ added in v0.2.14
func (c *Client) UpdateDestinationMetadataByID(ctx context.Context, xPubID, id string, metadata Metadata) (*Destination, error)
UpdateDestinationMetadataByID will update the metadata in an existing destination by id
func (*Client) UpdateDestinationMetadataByLockingScript ¶ added in v0.2.14
func (c *Client) UpdateDestinationMetadataByLockingScript(ctx context.Context, xPubID, lockingScript string, metadata Metadata) (*Destination, error)
UpdateDestinationMetadataByLockingScript will update the metadata in an existing destination by locking script
func (*Client) UpdatePaymailAddress ¶ added in v0.2.14
func (c *Client) UpdatePaymailAddress(ctx context.Context, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error)
UpdatePaymailAddress will update optional fields of the paymail address
func (*Client) UpdatePaymailAddressMetadata ¶ added in v0.2.14
func (c *Client) UpdatePaymailAddressMetadata(ctx context.Context, address string, metadata Metadata, opts ...ModelOps) (*PaymailAddress, error)
UpdatePaymailAddressMetadata will update the metadata in an existing paymail address
func (*Client) UpdateTransactionMetadata ¶ added in v0.2.14
func (c *Client) UpdateTransactionMetadata(ctx context.Context, xPubID, id string, metadata Metadata) (*Transaction, error)
UpdateTransactionMetadata will update the metadata in an existing transaction
type ClientInterface ¶
type ClientInterface interface { AccessKeyService AdminInterface ClientServices DestinationService DraftTransactionService PaymailService TransactionService BlockHeaderService UTXOService XPubService AddModels(ctx context.Context, autoMigrate bool, models ...interface{}) error AuthenticateRequest(ctx context.Context, req *http.Request, adminXPubs []string, adminRequired, requireSigning, signingDisabled bool) (*http.Request, error) Close(ctx context.Context) error Debug(on bool) DefaultModelOptions(opts ...ModelOps) []ModelOps DefaultSyncConfig() *SyncConfig EnableNewRelic() GetOrStartTxn(ctx context.Context, name string) context.Context GetPaymailConfig() *PaymailServerOptions GetTaskPeriod(name string) time.Duration ImportBlockHeadersFromURL() string IsDebug() bool IsITCEnabled() bool IsIUCEnabled() bool IsNewRelicEnabled() bool ModifyTaskPeriod(name string, period time.Duration) error SetNotificationsClient(notifications.ClientInterface) UserAgent() string Version() string }
ClientInterface is the client (bux engine) interface comprised of all services
type ClientOps ¶
type ClientOps func(c *clientOptions)
ClientOps allow functional options to be supplied that overwrite default client options.
func WithAutoMigrate ¶
func WithAutoMigrate(migrateModels ...interface{}) ClientOps
WithAutoMigrate will enable auto migrate database mode (given models)
Pointers of structs (IE: &models.Xpub{})
func WithBroadcastMiners ¶ added in v0.2.14
func WithBroadcastMiners(miners []*chainstate.Miner) ClientOps
WithBroadcastMiners will set a list of miners for broadcasting
func WithChainstateOptions ¶ added in v0.2.14
WithChainstateOptions will set chainstate defaults
func WithCronService ¶ added in v0.2.14
func WithCronService(cronService taskmanager.CronService) ClientOps
WithCronService will set the custom cron service provider
func WithCustomCachestore ¶
func WithCustomCachestore(cacheStore cachestore.ClientInterface) ClientOps
WithCustomCachestore will set the cachestore
func WithCustomChainstate ¶
func WithCustomChainstate(chainState chainstate.ClientInterface) ClientOps
WithCustomChainstate will set the chainstate
func WithCustomDatastore ¶
func WithCustomDatastore(dataStore datastore.ClientInterface) ClientOps
WithCustomDatastore will set the datastore
func WithCustomNotifications ¶ added in v0.2.14
func WithCustomNotifications(customNotifications notifications.ClientInterface) ClientOps
WithCustomNotifications will set a custom notifications interface
func WithCustomTaskManager ¶
func WithCustomTaskManager(taskManager taskmanager.ClientInterface) ClientOps
WithCustomTaskManager will set the taskmanager
func WithDebugging ¶
func WithDebugging() ClientOps
WithDebugging will set debugging in any applicable configuration
func WithEncryption ¶ added in v0.2.14
WithEncryption will set the encryption key and encrypt values using this key
func WithFreeCache ¶ added in v0.2.14
func WithFreeCache() ClientOps
WithFreeCache will set the cache client for both Read & Write clients
func WithFreeCacheConnection ¶ added in v0.2.14
WithFreeCacheConnection will set the cache client to an active FreeCache connection
func WithHTTPClient ¶ added in v0.2.14
func WithHTTPClient(httpClient HTTPInterface) ClientOps
WithHTTPClient will set the custom http interface
func WithITCDisabled ¶
func WithITCDisabled() ClientOps
WithITCDisabled will disable (ITC) incoming transaction checking
func WithIUCDisabled ¶ added in v0.1.1
func WithIUCDisabled() ClientOps
WithIUCDisabled will disable checking the input utxos
func WithImportBlockHeaders ¶ added in v0.2.14
WithImportBlockHeaders will import block headers on startup
func WithLogger ¶
WithLogger will set the custom logger interface
func WithMatterCloudAPIKey ¶ added in v0.1.1
WithMatterCloudAPIKey will set the API key
func WithModels ¶
func WithModels(models ...interface{}) ClientOps
WithModels will add additional models (will NOT migrate using datastore)
Pointers of structs (IE: &models.Xpub{})
func WithMongoConnection ¶
WithMongoConnection will set the Datastore to an existing connection for MongoDB
func WithMongoDB ¶
func WithMongoDB(config *datastore.MongoDBConfig) ClientOps
WithMongoDB will set the Datastore to use MongoDB
func WithMonitoring ¶ added in v0.2.14
func WithMonitoring(ctx context.Context, monitorOptions *chainstate.MonitorOptions) ClientOps
WithMonitoring will create a new monitorConfig interface with the given options
func WithMonitoringInterface ¶ added in v0.2.14
func WithMonitoringInterface(monitor chainstate.MonitorService) ClientOps
WithMonitoringInterface will set the interface to use for monitoring the blockchain
func WithNewRelic ¶
func WithNewRelic(app *newrelic.Application) ClientOps
WithNewRelic will set the NewRelic application client
func WithNotifications ¶ added in v0.2.14
WithNotifications will set the notifications config
func WithNowNodesAPIKey ¶ added in v0.1.1
WithNowNodesAPIKey will set the API key
func WithPaymailClient ¶
func WithPaymailClient(client paymail.ClientInterface) ClientOps
WithPaymailClient will set a custom paymail client
func WithPaymailServerConfig ¶ added in v0.2.14
func WithPaymailServerConfig(config *server.Configuration, defaultFromPaymail, defaultNote string) ClientOps
WithPaymailServerConfig will set the custom server configuration for Paymail
This will allow overriding the Configuration.actions (paymail service provider)
func WithPaymailSupport ¶ added in v0.2.14
func WithPaymailSupport(domains []string, defaultFromPaymail, defaultNote string, domainValidation, senderValidation bool) ClientOps
WithPaymailSupport will set the configuration for Paymail support (as a server)
func WithQueryMiners ¶ added in v0.2.14
func WithQueryMiners(miners []*chainstate.Miner) ClientOps
WithQueryMiners will set a list of miners for querying transactions
func WithRedis ¶
func WithRedis(config *cachestore.RedisConfig) ClientOps
WithRedis will set the redis cache client for both Read & Write clients
This will load new redis connections using the given parameters
func WithRedisConnection ¶
func WithRedisConnection(activeClient *cache.Client) ClientOps
WithRedisConnection will set the cache client to an active redis connection
func WithSQLConfigs ¶ added in v0.2.14
WithSQLConfigs will load multiple connections (replica & master)
func WithSQLConnection ¶
WithSQLConnection will set the Datastore to an existing connection for MySQL or PostgreSQL
func WithSQLite ¶
func WithSQLite(config *datastore.SQLiteConfig) ClientOps
WithSQLite will set the Datastore to use SQLite
func WithTaskQ ¶
func WithTaskQ(config *taskq.QueueOptions, factory taskmanager.Factory) ClientOps
WithTaskQ will set the task manager to use TaskQ & in-memory
func WithTaskQUsingRedis ¶
func WithTaskQUsingRedis(config *taskq.QueueOptions, redisOptions *redis.Options) ClientOps
WithTaskQUsingRedis will set the task manager to use TaskQ & Redis
func WithUserAgent ¶
WithUserAgent will overwrite the default useragent
func WithWhatsOnChainAPIKey ¶ added in v0.1.1
WithWhatsOnChainAPIKey will set the API key
type ClientServices ¶ added in v0.2.14
type ClientServices interface { Cachestore() cachestore.ClientInterface Chainstate() chainstate.ClientInterface Datastore() datastore.ClientInterface HTTPClient() HTTPInterface Logger() logger.Interface Notifications() notifications.ClientInterface PaymailClient() paymail.ClientInterface Taskmanager() taskmanager.ClientInterface }
ClientServices is the client related services
type Destination ¶
type Destination struct { // Base model Model `bson:",inline"` // Model specific fields ID string `` /* 129-byte string literal not displayed */ XpubID string `` /* 129-byte string literal not displayed */ LockingScript string `` /* 159-byte string literal not displayed */ Type string `json:"type" toml:"type" yaml:"type" gorm:"<-:create;type:text;comment:Type of output" bson:"type"` Chain uint32 `` /* 153-byte string literal not displayed */ Num uint32 `` /* 145-byte string literal not displayed */ Address string `` /* 135-byte string literal not displayed */ DraftID string `` /* 167-byte string literal not displayed */ Monitor utils.NullTime `` /* 167-byte string literal not displayed */ }
Destination is an object representing a BitCoin destination (address, script, etc)
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*Destination) AfterCreated ¶ added in v0.2.14
func (m *Destination) AfterCreated(_ context.Context) error
AfterCreated will fire after the model is created in the Datastore
func (*Destination) AfterDeleted ¶ added in v0.2.14
func (m *Destination) AfterDeleted(_ context.Context) error
AfterDeleted will fire after the model is deleted in the Datastore
func (*Destination) AfterUpdated ¶ added in v0.2.14
func (m *Destination) AfterUpdated(_ context.Context) error
AfterUpdated will fire after the model is updated in the Datastore
func (*Destination) BeforeCreating ¶
func (m *Destination) BeforeCreating(_ context.Context) error
BeforeCreating will fire before the model is being inserted into the Datastore
func (*Destination) GetModelName ¶
func (m *Destination) GetModelName() string
GetModelName will get the name of the current model
func (*Destination) GetModelTableName ¶
func (m *Destination) GetModelTableName() string
GetModelTableName will get the db table name of the current model
func (*Destination) Migrate ¶
func (m *Destination) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
type DestinationService ¶
type DestinationService interface { GetDestinationByID(ctx context.Context, xPubID, id string) (*Destination, error) GetDestinationByAddress(ctx context.Context, xPubID, address string) (*Destination, error) GetDestinationByLockingScript(ctx context.Context, xPubID, lockingScript string) (*Destination, error) GetDestinations(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Destination, error) GetDestinationsCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) GetDestinationsByXpubID(ctx context.Context, xPubID string, usingMetadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Destination, error) GetDestinationsByXpubIDCount(ctx context.Context, xPubID string, usingMetadata *Metadata, conditions *map[string]interface{}) (int64, error) NewDestination(ctx context.Context, xPubKey string, chain uint32, destinationType string, monitor bool, opts ...ModelOps) (*Destination, error) NewDestinationForLockingScript(ctx context.Context, xPubID, lockingScript string, monitor bool, opts ...ModelOps) (*Destination, error) UpdateDestinationMetadataByID(ctx context.Context, xPubID, id string, metadata Metadata) (*Destination, error) UpdateDestinationMetadataByLockingScript(ctx context.Context, xPubID, lockingScript string, metadata Metadata) (*Destination, error) UpdateDestinationMetadataByAddress(ctx context.Context, xPubID, address string, metadata Metadata) (*Destination, error) }
DestinationService is the destination actions
type DraftStatus ¶
type DraftStatus string
DraftStatus draft transaction status
const ( // DraftStatusDraft is when the transaction is a draft DraftStatusDraft DraftStatus = statusDraft // DraftStatusCanceled is when the draft is canceled DraftStatusCanceled DraftStatus = statusCanceled // DraftStatusExpired is when the draft has expired DraftStatusExpired DraftStatus = statusExpired // DraftStatusComplete is when the draft transaction is complete DraftStatusComplete DraftStatus = statusComplete )
func (*DraftStatus) Scan ¶
func (t *DraftStatus) Scan(value interface{}) error
Scan will scan the value into Struct, implements sql.Scanner interface
type DraftTransaction ¶
type DraftTransaction struct { // Base model Model `bson:",inline"` // Standard transaction model base fields TransactionBase `bson:",inline"` // Model specific fields XpubID string `` /* 129-byte string literal not displayed */ ExpiresAt time.Time `json:"expires_at" toml:"expires_at" yaml:"expires_at" gorm:"<-:create;comment:Time when the draft expires" bson:"expires_at"` Configuration TransactionConfig `` /* 152-byte string literal not displayed */ Status DraftStatus `` /* 128-byte string literal not displayed */ FinalTxID string `` /* 157-byte string literal not displayed */ }
DraftTransaction is an object representing the draft BitCoin transaction prior to the final transaction
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*DraftTransaction) AfterUpdated ¶
func (m *DraftTransaction) AfterUpdated(ctx context.Context) error
AfterUpdated will fire after a successful update into the Datastore
func (*DraftTransaction) BeforeCreating ¶
func (m *DraftTransaction) BeforeCreating(ctx context.Context) (err error)
BeforeCreating will fire before the model is being inserted into the Datastore
func (*DraftTransaction) GetID ¶
func (m *DraftTransaction) GetID() string
GetID will get the model ID
func (*DraftTransaction) GetModelName ¶
func (m *DraftTransaction) GetModelName() string
GetModelName will get the name of the current model
func (*DraftTransaction) GetModelTableName ¶
func (m *DraftTransaction) GetModelTableName() string
GetModelTableName will get the db table name of the current model
func (*DraftTransaction) Migrate ¶
func (m *DraftTransaction) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*DraftTransaction) RegisterTasks ¶
func (m *DraftTransaction) RegisterTasks() error
RegisterTasks will register the model specific tasks on client initialization
func (*DraftTransaction) Save ¶
func (m *DraftTransaction) Save(ctx context.Context) (err error)
Save will Save the model into the Datastore
func (*DraftTransaction) SignInputs ¶ added in v0.2.14
func (m *DraftTransaction) SignInputs(xPriv *bip32.ExtendedKey) (signedHex string, err error)
SignInputs will sign all the inputs using the given xPriv key
func (*DraftTransaction) SignInputsWithKey ¶ added in v0.2.14
func (m *DraftTransaction) SignInputsWithKey(xPrivKey string) (signedHex string, err error)
SignInputsWithKey will sign all the inputs using a key (string) (helper method)
type DraftTransactionService ¶ added in v0.2.18
type DraftTransactionService interface { GetDraftTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*DraftTransaction, error) GetDraftTransactionsCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) }
DraftTransactionService is the draft transactions actions
type HTTPInterface ¶ added in v0.2.14
HTTPInterface is the HTTP client interface
type IDs ¶
type IDs []string
IDs are string ids saved as an array
func UnmarshalIDs ¶
UnmarshalIDs will marshal the custom type
func (IDs) GormDBDataType ¶
GormDBDataType the gorm data type for metadata
type ImportResults ¶ added in v0.1.1
type ImportResults struct { ExternalAddresses int `json:"external_addresses"` InternalAddresses int `json:"internal_addresses"` AddressesWithTransactions []string `json:"addresses_with_transactions"` Key string `json:"key"` TransactionsFound int `json:"transactions_found"` TransactionsImported int `json:"transactions_imported"` }
ImportResults are the results from the import
type IncomingTransaction ¶
type IncomingTransaction struct { // Base model Model `bson:",inline"` // Standard transaction model base fields TransactionBase `bson:",inline"` // Model specific fields Status SyncStatus `` /* 145-byte string literal not displayed */ StatusMessage string `` /* 159-byte string literal not displayed */ }
IncomingTransaction is an object representing the incoming (external) transaction (for pre-processing)
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*IncomingTransaction) AfterCreated ¶
func (m *IncomingTransaction) AfterCreated(ctx context.Context) error
AfterCreated will fire after the model is created
func (*IncomingTransaction) BeforeCreating ¶
func (m *IncomingTransaction) BeforeCreating(ctx context.Context) error
BeforeCreating will fire before the model is being inserted into the Datastore
func (*IncomingTransaction) GetID ¶
func (m *IncomingTransaction) GetID() string
GetID will get the ID
func (*IncomingTransaction) GetModelName ¶
func (m *IncomingTransaction) GetModelName() string
GetModelName will get the name of the current model
func (*IncomingTransaction) GetModelTableName ¶
func (m *IncomingTransaction) GetModelTableName() string
GetModelTableName will get the db table name of the current model
func (*IncomingTransaction) Migrate ¶
func (m *IncomingTransaction) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*IncomingTransaction) RegisterTasks ¶
func (m *IncomingTransaction) RegisterTasks() error
RegisterTasks will register the model specific tasks on client initialization
type MapProtocol ¶
type MapProtocol struct { App string `json:"app,omitempty"` // Application name Keys map[string]interface{} `json:"keys,omitempty"` // Keys to set Type string `json:"type,omitempty"` // Type of action }
MapProtocol is a specific MAP protocol interface for an op_return
type Metadata ¶
type Metadata map[string]interface{}
Metadata is an object representing the metadata about the related record (standard across all tables)
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func UnmarshalMetadata ¶
UnmarshalMetadata will unmarshal the custom type
func (Metadata) GormDBDataType ¶
GormDBDataType the gorm data type for metadata
func (*Metadata) MarshalBSONValue ¶
MarshalBSONValue method is called by bson.Marshal in Mongo for type = Metadata
func (*Metadata) UnmarshalBSONValue ¶
UnmarshalBSONValue method is called by bson.Unmarshal in Mongo for type = Metadata
type Model ¶
type Model struct { CreatedAt time.Time `` /* 134-byte string literal not displayed */ UpdatedAt time.Time `` /* 138-byte string literal not displayed */ Metadata Metadata `gorm:"type:json;comment:The JSON metadata for the record" json:"metadata,omitempty" bson:"metadata,omitempty"` // https://gorm.io/docs/indexes.html // DeletedAt gorm.DeletedAt `json:"deleted_at" toml:"deleted_at" yaml:"deleted_at" (@mrz: this was the original type) DeletedAt utils.NullTime `` /* 144-byte string literal not displayed */ // contains filtered or unexported fields }
Model is the generic model field(s) and interface(s)
gorm: https://gorm.io/docs/models.html
func NewBaseModel ¶
NewBaseModel create an empty base model
func (*Model) AfterCreated ¶
AfterCreated will fire after the model is created in the Datastore
func (*Model) AfterDeleted ¶
AfterDeleted will fire after a successful delete in the Datastore
func (*Model) AfterUpdated ¶
AfterUpdated will fire after a successful update into the Datastore
func (*Model) BeforeUpdating ¶
BeforeUpdating will fire before updating a model in the Datastore
func (*Model) ChildModels ¶
func (m *Model) ChildModels() []ModelInterface
ChildModels will return any child models
func (*Model) Client ¶
func (m *Model) Client() ClientInterface
Client will return the current client
func (*Model) GetID ¶ added in v0.2.14
GetID will get the model id, if overwritten in the actual model
func (*Model) GetOptions ¶
GetOptions will get the options that are set on that model
func (*Model) RegisterTasks ¶
RegisterTasks will register the model specific tasks on client initialization
func (*Model) SetOptions ¶
SetOptions will set the options on the model
func (*Model) SetRecordTime ¶
SetRecordTime will set the record timestamps (created is true for a new record)
func (*Model) UpdateMetadata ¶ added in v0.2.14
UpdateMetadata will update the metadata on the model any key set to nil will be removed, other keys updated or added
type ModelInterface ¶
type ModelInterface interface { AfterCreated(ctx context.Context) (err error) AfterDeleted(ctx context.Context) (err error) AfterUpdated(ctx context.Context) (err error) BeforeCreating(ctx context.Context) (err error) BeforeUpdating(ctx context.Context) (err error) ChildModels() []ModelInterface Client() ClientInterface DebugLog(text string) Display() interface{} GetID() string GetModelName() string GetModelTableName() string GetOptions(isNewRecord bool) (opts []ModelOps) IsNew() bool Migrate(client datastore.ClientInterface) error Name() string New() NotNew() RawXpub() string RegisterTasks() error Save(ctx context.Context) (err error) SetOptions(opts ...ModelOps) SetRecordTime(bool) UpdateMetadata(metadata Metadata) }
ModelInterface is the interface that all models share
type ModelName ¶
type ModelName string
ModelName is the model name type
const ( ModelAccessKey ModelName = "access_key" ModelBlockHeader ModelName = "block_header" ModelDestination ModelName = "destination" ModelDraftTransaction ModelName = "draft_transaction" ModelIncomingTransaction ModelName = "incoming_transaction" ModelMetadata ModelName = "metadata" ModelNameEmpty ModelName = "empty" ModelPaymailAddress ModelName = "paymail_address" ModelSyncTransaction ModelName = "sync_transaction" ModelTransaction ModelName = "transaction" ModelUtxo ModelName = "utxo" ModelXPub ModelName = "xpub" )
All the base models
type ModelOps ¶
type ModelOps func(m *Model)
ModelOps allow functional options to be supplied that overwrite default model options
func WithClient ¶
func WithClient(client ClientInterface) ModelOps
WithClient will set the Client on the model
func WithEncryptionKey ¶ added in v0.2.14
WithEncryptionKey will set the encryption key on the model (if needed)
func WithMetadata ¶
WithMetadata will add the metadata record to the model
func WithMetadatas ¶
WithMetadatas will add multiple metadata records to the model
func WithPageSize ¶ added in v0.2.14
WithPageSize will set the pageSize to use on the model in queries
type MonitorEventHandler ¶ added in v0.2.14
type MonitorEventHandler struct {
// contains filtered or unexported fields
}
MonitorEventHandler for handling transaction events from a monitor
func NewMonitorHandler ¶ added in v0.2.14
func NewMonitorHandler(ctx context.Context, buxClient ClientInterface, monitor chainstate.MonitorService) MonitorEventHandler
NewMonitorHandler create a new monitor handler
func (*MonitorEventHandler) GetWhatsOnChain ¶ added in v0.2.14
func (h *MonitorEventHandler) GetWhatsOnChain() whatsonchain.ClientInterface
GetWhatsOnChain returns the WhatsOnChain client interface
func (*MonitorEventHandler) OnConnect ¶ added in v0.2.14
func (h *MonitorEventHandler) OnConnect(client *centrifuge.Client, e centrifuge.ConnectEvent)
OnConnect event when connected
func (*MonitorEventHandler) OnDisconnect ¶ added in v0.2.14
func (h *MonitorEventHandler) OnDisconnect(_ *centrifuge.Client, _ centrifuge.DisconnectEvent)
OnDisconnect when disconnected
func (*MonitorEventHandler) OnError ¶ added in v0.2.14
func (h *MonitorEventHandler) OnError(_ *centrifuge.Client, e centrifuge.ErrorEvent)
OnError on error event
func (*MonitorEventHandler) OnJoin ¶ added in v0.2.14
func (h *MonitorEventHandler) OnJoin(_ *centrifuge.Subscription, e centrifuge.JoinEvent)
OnJoin event when joining a server
func (*MonitorEventHandler) OnLeave ¶ added in v0.2.14
func (h *MonitorEventHandler) OnLeave(_ *centrifuge.Subscription, e centrifuge.LeaveEvent)
OnLeave event when leaving a server
func (*MonitorEventHandler) OnMessage ¶ added in v0.2.14
func (h *MonitorEventHandler) OnMessage(_ *centrifuge.Client, e centrifuge.MessageEvent)
OnMessage on new message event
func (*MonitorEventHandler) OnPublish ¶ added in v0.2.14
func (h *MonitorEventHandler) OnPublish(subscription *centrifuge.Subscription, e centrifuge.PublishEvent)
OnPublish on publish event
func (*MonitorEventHandler) OnServerJoin ¶ added in v0.2.14
func (h *MonitorEventHandler) OnServerJoin(_ *centrifuge.Client, e centrifuge.ServerJoinEvent)
OnServerJoin event when joining a server
func (*MonitorEventHandler) OnServerLeave ¶ added in v0.2.14
func (h *MonitorEventHandler) OnServerLeave(_ *centrifuge.Client, e centrifuge.ServerLeaveEvent)
OnServerLeave event when leaving a server
func (*MonitorEventHandler) OnServerPublish ¶ added in v0.2.14
func (h *MonitorEventHandler) OnServerPublish(_ *centrifuge.Client, e centrifuge.ServerPublishEvent)
OnServerPublish on server publish event
func (*MonitorEventHandler) OnServerSubscribe ¶ added in v0.2.14
func (h *MonitorEventHandler) OnServerSubscribe(_ *centrifuge.Client, e centrifuge.ServerSubscribeEvent)
OnServerSubscribe on server subscribe event
func (*MonitorEventHandler) OnServerUnsubscribe ¶ added in v0.2.14
func (h *MonitorEventHandler) OnServerUnsubscribe(_ *centrifuge.Client, e centrifuge.ServerUnsubscribeEvent)
OnServerUnsubscribe on the unsubscribe event
func (*MonitorEventHandler) OnSubscribeError ¶ added in v0.2.14
func (h *MonitorEventHandler) OnSubscribeError(_ *centrifuge.Subscription, e centrifuge.SubscribeErrorEvent)
OnSubscribeError is for an error
func (*MonitorEventHandler) OnSubscribeSuccess ¶ added in v0.2.14
func (h *MonitorEventHandler) OnSubscribeSuccess(_ *centrifuge.Subscription, e centrifuge.SubscribeSuccessEvent)
OnSubscribeSuccess on subscribe success
func (*MonitorEventHandler) OnUnsubscribe ¶ added in v0.2.14
func (h *MonitorEventHandler) OnUnsubscribe(_ *centrifuge.Subscription, e centrifuge.UnsubscribeEvent)
OnUnsubscribe will unsubscribe
func (*MonitorEventHandler) ProcessBlockHeaders ¶ added in v0.2.14
func (h *MonitorEventHandler) ProcessBlockHeaders(ctx context.Context, client *centrifuge.Client) error
ProcessBlockHeaders processes all missing block headers
func (*MonitorEventHandler) ProcessBlocks ¶ added in v0.2.14
func (h *MonitorEventHandler) ProcessBlocks(ctx context.Context, client *centrifuge.Client) error
ProcessBlocks processes all transactions in blocks that have not yet been synced
func (*MonitorEventHandler) RecordBlockHeader ¶ added in v0.2.14
func (h *MonitorEventHandler) RecordBlockHeader(_ context.Context, _ bc.BlockHeader) error
RecordBlockHeader records a block header into bux
func (*MonitorEventHandler) RecordTransaction ¶ added in v0.2.14
func (h *MonitorEventHandler) RecordTransaction(ctx context.Context, txHex string) error
RecordTransaction records a transaction into bux
func (*MonitorEventHandler) SetMonitor ¶ added in v0.2.14
func (h *MonitorEventHandler) SetMonitor(monitor *chainstate.Monitor)
SetMonitor sets the monitor for the given handler
type OpReturn ¶
type OpReturn struct { Hex string `json:"hex,omitempty"` // Full hex HexParts []string `json:"hex_parts,omitempty"` // Hex into parts Map *MapProtocol `json:"map,omitempty"` // MAP protocol StringParts []string `json:"string_parts,omitempty"` // String parts }
OpReturn is the op_return definition for the output
type ParamRequestKey ¶ added in v0.2.14
type ParamRequestKey string
ParamRequestKey for context key
const ( // ParamXPubKey the request parameter for the xpub string ParamXPubKey ParamRequestKey = "xpub" // ParamXPubHashKey the request parameter for the xpub ID ParamXPubHashKey ParamRequestKey = "xpub_hash" // ParamAdminRequest the request parameter whether this is an admin request ParamAdminRequest ParamRequestKey = "auth_admin" // ParamAuthSigned the request parameter that says whether the request was signed ParamAuthSigned ParamRequestKey = "auth_signed" )
type PaymailAddress ¶ added in v0.2.14
type PaymailAddress struct { // Base model Model `bson:",inline"` // Model specific fields ID string `` // Unique identifier /* 127-byte string literal not displayed */ XpubID string `` // Related xPub ID /* 129-byte string literal not displayed */ Alias string `json:"alias" toml:"alias" yaml:"alias" gorm:"<-;type:varchar(64);comment:This is alias@" bson:"alias"` // Alias part of the paymail Domain string `json:"domain" toml:"domain" yaml:"domain" gorm:"<-;type:varchar(255);comment:This is @domain.com" bson:"domain"` // Domain of the paymail PublicName string `` // Full username /* 160-byte string literal not displayed */ Avatar string `json:"avatar" toml:"avatar" yaml:"avatar" gorm:"<-;type:text;comment:This is avatar url" bson:"avatar"` // This is the url of the user (public profile) ExternalXpubKey string `` // PublicKey hex encoded /* 204-byte string literal not displayed */ // contains filtered or unexported fields }
PaymailAddress is an "external model example" - this model is not part of the standard models loaded and runtime
This model must be included at runtime via WithAutoMigrate() etc...
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*PaymailAddress) BeforeCreating ¶ added in v0.2.14
func (m *PaymailAddress) BeforeCreating(_ context.Context) (err error)
BeforeCreating is called before the model is saved to the DB
func (*PaymailAddress) GetExternalXpub ¶ added in v0.2.14
func (m *PaymailAddress) GetExternalXpub() (*bip32.ExtendedKey, error)
GetExternalXpub will get the external xPub
func (*PaymailAddress) GetID ¶ added in v0.2.14
func (m *PaymailAddress) GetID() string
GetID will get the ID
func (*PaymailAddress) GetIdentityXpub ¶ added in v0.2.14
func (m *PaymailAddress) GetIdentityXpub() (*bip32.ExtendedKey, error)
GetIdentityXpub will get the identity related to the xPub
func (*PaymailAddress) GetModelName ¶ added in v0.2.14
func (m *PaymailAddress) GetModelName() string
GetModelName returns the model name
func (*PaymailAddress) GetModelTableName ¶ added in v0.2.14
func (m *PaymailAddress) GetModelTableName() string
GetModelTableName returns the model db table name
func (*PaymailAddress) Migrate ¶ added in v0.2.14
func (m *PaymailAddress) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
type PaymailDefaultServiceProvider ¶ added in v0.2.14
type PaymailDefaultServiceProvider struct {
// contains filtered or unexported fields
}
PaymailDefaultServiceProvider is an interface for overriding the paymail actions in go-paymail/server
This is an example and the default functionality for all the basic Paymail actions
func (*PaymailDefaultServiceProvider) CreateAddressResolutionResponse ¶ added in v0.2.14
func (p *PaymailDefaultServiceProvider) CreateAddressResolutionResponse(ctx context.Context, alias, domain string, _ bool, requestMetadata *server.RequestMetadata) (*paymail.ResolutionPayload, error)
CreateAddressResolutionResponse will create the address resolution response
func (*PaymailDefaultServiceProvider) CreateP2PDestinationResponse ¶ added in v0.2.14
func (p *PaymailDefaultServiceProvider) CreateP2PDestinationResponse(ctx context.Context, alias, domain string, satoshis uint64, requestMetadata *server.RequestMetadata) (*paymail.PaymentDestinationPayload, error)
CreateP2PDestinationResponse will create a p2p destination response
func (*PaymailDefaultServiceProvider) GetPaymailByAlias ¶ added in v0.2.14
func (p *PaymailDefaultServiceProvider) GetPaymailByAlias(ctx context.Context, alias, domain string, requestMetadata *server.RequestMetadata) (*paymail.AddressInformation, error)
GetPaymailByAlias will get a paymail address and information by alias
func (*PaymailDefaultServiceProvider) RecordTransaction ¶ added in v0.2.14
func (p *PaymailDefaultServiceProvider) RecordTransaction(ctx context.Context, p2pTx *paymail.P2PTransaction, requestMetadata *server.RequestMetadata) (*paymail.P2PTransactionPayload, error)
RecordTransaction will record the transaction
type PaymailP4 ¶
type PaymailP4 struct { Alias string `json:"alias" toml:"alias" yaml:"alias" bson:"alias,omitempty"` // Alias of the paymail {alias}@domain.com Domain string `json:"domain" toml:"domain" yaml:"domain" bson:"domain,omitempty"` // Domain of the paymail alias@{domain.com} FromPaymail string `json:"from_paymail,omitempty" toml:"from_paymail" yaml:"from_paymail" bson:"from_paymail,omitempty"` // From paymail address: alias@domain.com Note string `json:"note,omitempty" toml:"note" yaml:"note" bson:"note,omitempty"` // Friendly readable note to the paymail receiver PubKey string `json:"pub_key,omitempty" toml:"pub_key" yaml:"pub_key" bson:"pub_key,omitempty"` // Used for validating the signature ReceiveEndpoint string `json:"receive_endpoint,omitempty" toml:"receive_endpoint" yaml:"receive_endpoint" bson:"receive_endpoint,omitempty"` // P2P endpoint when notifying ReferenceID string `json:"reference_id,omitempty" toml:"reference_id" yaml:"reference_id" bson:"reference_id,omitempty"` // Reference ID saved from P2P request ResolutionType string `json:"resolution_type" toml:"resolution_type" yaml:"resolution_type" bson:"resolution_type,omitempty"` // Type of address resolution (basic vs p2p) }
PaymailP4 paymail configuration for the p2p payments on this output
type PaymailServerOptions ¶ added in v0.2.14
type PaymailServerOptions struct { *server.Configuration // Server configuration if Paymail is enabled DefaultFromPaymail string // IE: from@domain.com DefaultNote string // IE: some note for address resolution // contains filtered or unexported fields }
PaymailServerOptions is the options for the Paymail server
type PaymailService ¶ added in v0.2.14
type PaymailService interface { GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error) GetPaymailAddressesByXPubID(ctx context.Context, xPubID string, metadataConditions *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*PaymailAddress, error) NewPaymailAddress(ctx context.Context, key, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error) DeletePaymailAddress(ctx context.Context, address string, opts ...ModelOps) error UpdatePaymailAddress(ctx context.Context, address, publicName, avatar string, opts ...ModelOps) (*PaymailAddress, error) UpdatePaymailAddressMetadata(ctx context.Context, address string, metadata Metadata, opts ...ModelOps) (*PaymailAddress, error) }
PaymailService is the paymail actions
type ScriptOutput ¶
type ScriptOutput struct { Address string `json:"address,omitempty"` // Hex encoded locking script Satoshis uint64 `json:"satoshis,omitempty"` // Number of satoshis for that output Script string `json:"script"` // Hex encoded locking script ScriptType string `json:"script_type"` // The type of output }
ScriptOutput is the actual script record (could be several for one output record)
type SyncConfig ¶
type SyncConfig struct { Broadcast bool `json:"broadcast" toml:"broadcast" yaml:"broadcast"` // Transaction should be broadcasted PaymailP2P bool `json:"paymail_p2p" toml:"paymail_p2p" yaml:"paymail_p2p"` // Transaction will be sent to all related paymail providers if P2P is detected SyncOnChain bool `json:"sync_on_chain" toml:"sync_on_chain" yaml:"sync_on_chain"` // Transaction should be checked that it's on-chain }
SyncConfig is the configuration used for syncing a transaction (on-chain)
func (*SyncConfig) Scan ¶
func (t *SyncConfig) Scan(value interface{}) error
Scan will scan the value into Struct, implements sql.Scanner interface
type SyncResult ¶ added in v0.2.15
type SyncResult struct { Action string `json:"action"` // type: broadcast, sync etc ExecutedAt time.Time `json:"executed_at"` // Time it was executed Provider string `json:"provider,omitempty"` // Provider used for attempt(s) StatusMessage string `json:"status_message"` // Success or failure message }
SyncResult is the complete attempt/result to sync (multiple providers and strategies)
type SyncResults ¶
type SyncResults struct { LastMessage string `json:"last_message"` // Last message (success or failure) Results []*SyncResult `json:"results"` // Each result of a sync task }
SyncResults is the results from all sync attempts (broadcast or sync)
func (*SyncResults) Scan ¶
func (t *SyncResults) Scan(value interface{}) error
Scan will scan the value into Struct, implements sql.Scanner interface
type SyncStatus ¶
type SyncStatus string
SyncStatus sync status
const ( // SyncStatusPending is when the sync is pending (blocked by other constraints) SyncStatusPending SyncStatus = statusPending // SyncStatusReady is when the sync is ready (waiting for workers) SyncStatusReady SyncStatus = statusReady // SyncStatusProcessing is when the sync is processing (worker is running task) SyncStatusProcessing SyncStatus = statusProcessing // SyncStatusCanceled is when the sync is canceled SyncStatusCanceled SyncStatus = statusCanceled // SyncStatusSkipped is when the sync is skipped SyncStatusSkipped SyncStatus = statusSkipped // SyncStatusError is when the sync has an error SyncStatusError SyncStatus = statusError // SyncStatusComplete is when the sync is complete SyncStatusComplete SyncStatus = statusComplete )
func (*SyncStatus) Scan ¶
func (t *SyncStatus) Scan(value interface{}) error
Scan will scan the value into Struct, implements sql.Scanner interface
func (SyncStatus) String ¶
func (t SyncStatus) String() string
String is the string version of the status
type SyncTransaction ¶
type SyncTransaction struct { // Base model Model `bson:",inline"` // Model specific fields ID string `json:"id" toml:"id" yaml:"id" gorm:"<-:create;type:char(64);primaryKey;comment:This is the unique transaction id" bson:"_id"` Configuration SyncConfig `` /* 152-byte string literal not displayed */ LastAttempt utils.NullTime `` /* 140-byte string literal not displayed */ Results SyncResults `json:"results" toml:"results" yaml:"results" gorm:"<-;type:text;comment:This is the results struct in JSON" bson:"results"` BroadcastStatus SyncStatus `` /* 172-byte string literal not displayed */ P2PStatus SyncStatus `` /* 177-byte string literal not displayed */ SyncStatus SyncStatus `` /* 156-byte string literal not displayed */ }
SyncTransaction is an object representing the chain-state sync configuration and results for a given transaction
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*SyncTransaction) BeforeCreating ¶
func (m *SyncTransaction) BeforeCreating(_ context.Context) error
BeforeCreating will fire before the model is being inserted into the Datastore
func (*SyncTransaction) GetModelName ¶
func (m *SyncTransaction) GetModelName() string
GetModelName will get the name of the current model
func (*SyncTransaction) GetModelTableName ¶
func (m *SyncTransaction) GetModelTableName() string
GetModelTableName will get the db table name of the current model
func (*SyncTransaction) Migrate ¶
func (m *SyncTransaction) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*SyncTransaction) RegisterTasks ¶
func (m *SyncTransaction) RegisterTasks() error
RegisterTasks will register the model specific tasks on client initialization
type Transaction ¶
type Transaction struct { // Base model Model `bson:",inline"` // Standard transaction model base fields TransactionBase `bson:",inline"` // Model specific fields XpubInIDs IDs `json:"xpub_in_ids,omitempty" toml:"xpub_in_ids" yaml:"xpub_in_ids" gorm:"<-:create;type:json" bson:"xpub_in_ids,omitempty"` XpubOutIDs IDs `` /* 126-byte string literal not displayed */ BlockHash string `` /* 170-byte string literal not displayed */ BlockHeight uint64 `` /* 176-byte string literal not displayed */ Fee uint64 `json:"fee" toml:"fee" yaml:"fee" gorm:"<-create;type:bigint" bson:"fee,omitempty"` NumberOfInputs uint32 `` /* 130-byte string literal not displayed */ NumberOfOutputs uint32 `` /* 134-byte string literal not displayed */ DraftID string `` /* 149-byte string literal not displayed */ TotalValue uint64 `json:"total_value" toml:"total_value" yaml:"total_value" gorm:"<-create;type:bigint" bson:"total_value,omitempty"` XpubMetadata XpubMetadata `json:"-" toml:"xpub_metadata" gorm:"<-;type:json;xpub_id specific metadata" bson:"xpub_metadata,omitempty"` XpubOutputValue XpubOutputValue `json:"-" toml:"xpub_output_value" gorm:"<-create;type:json;xpub_id specific value" bson:"xpub_output_value,omitempty"` // Virtual Fields OutputValue int64 `json:"output_value" toml:"-" yaml:"-" gorm:"-" bson:"-,omitempty"` Status SyncStatus `json:"status" toml:"-" yaml:"-" gorm:"-" bson:"-"` Direction TransactionDirection `json:"direction" toml:"-" yaml:"-" gorm:"-" bson:"-"` // contains filtered or unexported fields }
Transaction is an object representing the BitCoin transaction
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*Transaction) AfterCreated ¶
func (m *Transaction) AfterCreated(ctx context.Context) error
AfterCreated will fire after the model is created in the Datastore
func (*Transaction) AfterDeleted ¶ added in v0.2.14
func (m *Transaction) AfterDeleted(_ context.Context) error
AfterDeleted will fire after the model is deleted in the Datastore
func (*Transaction) AfterUpdated ¶ added in v0.2.14
func (m *Transaction) AfterUpdated(_ context.Context) error
AfterUpdated will fire after the model is updated in the Datastore
func (*Transaction) BeforeCreating ¶
func (m *Transaction) BeforeCreating(ctx context.Context) error
BeforeCreating will fire before the model is being inserted into the Datastore
func (*Transaction) ChildModels ¶
func (m *Transaction) ChildModels() (childModels []ModelInterface)
ChildModels will get any related sub models
func (*Transaction) Display ¶
func (m *Transaction) Display() interface{}
Display filter the model for display
func (*Transaction) GetModelName ¶
func (m *Transaction) GetModelName() string
GetModelName will get the name of the current model
func (*Transaction) GetModelTableName ¶
func (m *Transaction) GetModelTableName() string
GetModelTableName will get the db table name of the current model
func (*Transaction) IsXpubAssociated ¶
func (m *Transaction) IsXpubAssociated(rawXpubKey string) bool
IsXpubAssociated will check if this key is associated to this transaction
func (*Transaction) IsXpubIDAssociated ¶ added in v0.2.14
func (m *Transaction) IsXpubIDAssociated(xPubID string) bool
IsXpubIDAssociated will check if an xPub ID is associated
func (*Transaction) Migrate ¶
func (m *Transaction) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*Transaction) Save ¶
func (m *Transaction) Save(ctx context.Context) (err error)
Save will Save the model into the Datastore
func (*Transaction) UpdateTransactionMetadata ¶ added in v0.2.14
func (m *Transaction) UpdateTransactionMetadata(xPubID string, metadata Metadata) error
UpdateTransactionMetadata will update the transaction metadata by xPubID
type TransactionBase ¶
type TransactionBase struct { ID string `` /* 142-byte string literal not displayed */ Hex string `json:"hex" toml:"hex" yaml:"hex" gorm:"<-:create;type:text;comment:This is the raw transaction hex" bson:"hex"` // contains filtered or unexported fields }
TransactionBase is the same fields share between multiple transaction models
type TransactionConfig ¶
type TransactionConfig struct { // Conditions (utxo strategy) // NlockTime uint32 ChangeDestinations []*Destination `json:"change_destinations" toml:"change_destinations" yaml:"change_destinations" bson:"change_destinations"` ChangeDestinationsStrategy ChangeStrategy `` /* 143-byte string literal not displayed */ ChangeMinimumSatoshis uint64 `json:"change_minimum_satoshis" toml:"change_minimum_satoshis" yaml:"change_minimum_satoshis" bson:"change_minimum_satoshis"` ChangeNumberOfDestinations int `` /* 147-byte string literal not displayed */ ChangeSatoshis uint64 `json:"change_satoshis" toml:"change_satoshis" yaml:"change_satoshis" bson:"change_satoshis"` // The satoshis used for change ExpiresIn time.Duration `json:"expires_in" toml:"expires_in" yaml:"expires_in" bson:"expires_in"` // The expiration time for the draft and utxos Fee uint64 `json:"fee" toml:"fee" yaml:"fee" bson:"fee"` // The fee used for the transaction FeeUnit *utils.FeeUnit `json:"fee_unit" toml:"fee_unit" yaml:"fee_unit" bson:"fee_unit"` // Fee unit to use (overrides minercraft if set) FromUtxos []*UtxoPointer `json:"from_utxos" toml:"from_utxos" yaml:"from_utxos" bson:"from_utxos"` // use these utxos for the transaction IncludeUtxos []*UtxoPointer `json:"include_utxos" toml:"include_utxos" yaml:"include_utxos" bson:"include_utxos"` // include these utxos for the transaction, among others necessary if more is needed for fees Inputs []*TransactionInput `json:"inputs" toml:"inputs" yaml:"inputs" bson:"inputs"` // All transaction inputs Outputs []*TransactionOutput `json:"outputs" toml:"outputs" yaml:"outputs" bson:"outputs"` // All transaction outputs SendAllTo string `json:"send_all_to,omitempty" toml:"send_all_to" yaml:"send_all_to" bson:"send_all_to"` // Send ALL utxos to address Sync *SyncConfig `json:"sync" toml:"sync" yaml:"sync" bson:"sync"` // Sync config for broadcasting and on-chain sync }
TransactionConfig is the configuration used to start a transaction
func (*TransactionConfig) Scan ¶
func (t *TransactionConfig) Scan(value interface{}) error
Scan will scan the value into Struct, implements sql.Scanner interface
type TransactionDirection ¶
type TransactionDirection string
TransactionDirection String describing the direction of the transaction (in / out)
const ( // TransactionDirectionIn The transaction is coming in to the wallet of the xpub TransactionDirectionIn TransactionDirection = "incoming" // TransactionDirectionOut The transaction is going out of to the wallet of the xpub TransactionDirectionOut TransactionDirection = "outgoing" // TransactionDirectionReconcile The transaction is an internal reconciliation transaction TransactionDirectionReconcile TransactionDirection = "reconcile" )
type TransactionInput ¶
type TransactionInput struct { Utxo Destination Destination `json:"destination" toml:"destination" yaml:"destination" bson:"destination"` }
TransactionInput is an input on the transaction config
type TransactionOutput ¶
type TransactionOutput struct { OpReturn *OpReturn `json:"op_return,omitempty" toml:"op_return" yaml:"op_return" bson:"op_return,omitempty"` // Add op_return data as an output PaymailP4 *PaymailP4 `json:"paymail_p4,omitempty" toml:"paymail_p4" yaml:"paymail_p4" bson:"paymail_p4,omitempty"` // Additional information for P4 or Paymail Satoshis uint64 `json:"satoshis" toml:"satoshis" yaml:"satoshis" bson:"satoshis"` // Set the specific satoshis to send (when applicable) Script string `json:"script,omitempty" toml:"script" yaml:"script" bson:"script,omitempty"` // custom (non-standard) script output Scripts []*ScriptOutput `json:"scripts" toml:"scripts" yaml:"scripts" bson:"scripts"` // Add script outputs To string `json:"to,omitempty" toml:"to" yaml:"to" bson:"to,omitempty"` // To address, paymail, handle UseForChange bool `json:"use_for_change,omitempty" toml:"use_for_change" yaml:"use_for_change" bson:"use_for_change,omitempty"` // if set, no change destinations will be created, but all outputs flagged will get the change }
TransactionOutput is an output on the transaction config
type TransactionService ¶
type TransactionService interface { GetTransaction(ctx context.Context, xPubID, txID string) (*Transaction, error) GetTransactions(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Transaction, error) GetTransactionsCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) GetTransactionsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Transaction, error) GetTransactionsByXpubIDCount(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}) (int64, error) NewTransaction(ctx context.Context, rawXpubKey string, config *TransactionConfig, opts ...ModelOps) (*DraftTransaction, error) RecordTransaction(ctx context.Context, xPubKey, txHex, draftID string, opts ...ModelOps) (*Transaction, error) RecordMonitoredTransaction(ctx context.Context, txHex string, opts ...ModelOps) (*Transaction, error) UpdateTransactionMetadata(ctx context.Context, xPubID, id string, metadata Metadata) (*Transaction, error) }
TransactionService is the transaction actions
type UTXOService ¶
type UTXOService interface { GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error) GetUtxos(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*Utxo, error) GetUtxosCount(ctx context.Context, metadata *Metadata, conditions *map[string]interface{}, opts ...ModelOps) (int64, error) GetUtxosByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions *map[string]interface{}, queryParams *datastore.QueryParams) ([]*Utxo, error) }
UTXOService is the utxo actions
type Utxo ¶
type Utxo struct { // Base model Model `bson:",inline"` // Standard utxo model base fields UtxoPointer `bson:",inline"` // Model specific fields ID string `` /* 135-byte string literal not displayed */ XpubID string `` /* 129-byte string literal not displayed */ Satoshis uint64 `` /* 143-byte string literal not displayed */ ScriptPubKey string `` /* 149-byte string literal not displayed */ Type string `json:"type" toml:"type" yaml:"type" gorm:"<-:create;type:varchar(32);comment:Type of output" bson:"type"` DraftID utils.NullString `` /* 148-byte string literal not displayed */ ReservedAt utils.NullTime `json:"reserved_at" toml:"reserved_at" yaml:"reserved_at" gorm:"<-;comment:When it was reserved" bson:"reserved_at,omitempty"` SpendingTxID utils.NullString `` /* 172-byte string literal not displayed */ }
Utxo is an object representing a BitCoin unspent transaction
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*Utxo) BeforeCreating ¶
BeforeCreating will fire before the model is being inserted into the Datastore
func (*Utxo) GenerateID ¶
GenerateID will generate the id of the UTXO record based on the format: <txid>|<output_index>
func (*Utxo) GetModelName ¶
GetModelName will get the name of the current model
func (*Utxo) GetModelTableName ¶
GetModelTableName will get the db table name of the current model
type UtxoPointer ¶
type UtxoPointer struct { TransactionID string `` /* 174-byte string literal not displayed */ OutputIndex uint32 `` /* 165-byte string literal not displayed */ }
UtxoPointer is the actual pointer (index) for the UTXO
type XPubService ¶
type XPubService interface { GetXpub(ctx context.Context, xPubKey string) (*Xpub, error) GetXpubByID(ctx context.Context, xPubID string) (*Xpub, error) ImportXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*ImportResults, error) NewXpub(ctx context.Context, xPubKey string, opts ...ModelOps) (*Xpub, error) UpdateXpubMetadata(ctx context.Context, xPubID string, metadata Metadata) (*Xpub, error) }
XPubService is the xPub actions
type Xpub ¶
type Xpub struct { // Base model Model `bson:",inline"` // Model specific fields ID string `json:"id" toml:"id" yaml:"hash" gorm:"<-:create;type:char(64);primaryKey;comment:This is the sha256(xpub) hash" bson:"_id"` CurrentBalance uint64 `` /* 149-byte string literal not displayed */ NextInternalNum uint32 `` /* 181-byte string literal not displayed */ NextExternalNum uint32 `` /* 181-byte string literal not displayed */ // contains filtered or unexported fields }
Xpub is an object representing an HD-Key or extended public key (xPub for short)
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*Xpub) AfterCreated ¶
AfterCreated will fire after the model is created in the Datastore
func (*Xpub) AfterUpdated ¶
AfterUpdated will fire after a successful update into the Datastore
func (*Xpub) BeforeCreating ¶
BeforeCreating will fire before the model is being inserted into the Datastore
func (*Xpub) ChildModels ¶
func (m *Xpub) ChildModels() (childModels []ModelInterface)
ChildModels will get any related sub models
func (*Xpub) GetModelName ¶
GetModelName will get the name of the current model
func (*Xpub) GetModelTableName ¶
GetModelTableName will get the db table name of the current model
func (*Xpub) IncrementBalance ¶
IncrementBalance will atomically update the balance of the xPub
func (*Xpub) IncrementNextNum ¶
IncrementNextNum will atomically update the num of the given chain of the xPub and return it
func (*Xpub) Migrate ¶
func (m *Xpub) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*Xpub) RemovePrivateData ¶ added in v0.2.14
func (m *Xpub) RemovePrivateData()
RemovePrivateData unset all fields that are sensitive
type XpubMetadata ¶
XpubMetadata XpubId specific metadata
func (XpubMetadata) GormDBDataType ¶
GormDBDataType the gorm data type for metadata
func (*XpubMetadata) MarshalBSONValue ¶
func (x *XpubMetadata) MarshalBSONValue() (bsontype.Type, []byte, error)
MarshalBSONValue method is called by bson.Marshal in Mongo for type = XpubMetadata
func (*XpubMetadata) Scan ¶
func (x *XpubMetadata) Scan(value interface{}) error
Scan scan value into Json, implements sql.Scanner interface
func (*XpubMetadata) UnmarshalBSONValue ¶
func (x *XpubMetadata) UnmarshalBSONValue(t bsontype.Type, data []byte) error
UnmarshalBSONValue method is called by bson.Unmarshal in Mongo for type = XpubMetadata
type XpubOutputValue ¶
XpubOutputValue Xpub specific output value of the transaction
func (XpubOutputValue) GormDBDataType ¶
GormDBDataType the gorm data type for metadata
func (*XpubOutputValue) Scan ¶
func (x *XpubOutputValue) Scan(value interface{}) error
Scan scan value into Json, implements sql.Scanner interface
Source Files ¶
- action_access_key.go
- action_blockheader.go
- action_destination.go
- action_draft_transaction.go
- action_paymails.go
- action_transaction.go
- action_utxo.go
- action_xpub.go
- admin_actions_stats.go
- admin_interface.go
- authentication.go
- authentication_internal.go
- bux.go
- client.go
- client_internal.go
- client_options.go
- client_paymail.go
- definitions.go
- errors.go
- import.go
- interface.go
- locks.go
- model_access_keys.go
- model_block_headers.go
- model_destinations.go
- model_draft_transactions.go
- model_get.go
- model_ids.go
- model_incoming_transactions.go
- model_metadata.go
- model_options.go
- model_paymails.go
- model_save.go
- model_sync_config.go
- model_sync_results.go
- model_sync_status.go
- model_sync_transactions.go
- model_transaction_config.go
- model_transaction_status.go
- model_transactions.go
- model_transactions_output.go
- model_transactions_service.go
- model_utxos.go
- model_xpubs.go
- models.go
- models_internal.go
- monitor.go
- monitor_event_handler.go
- paymail.go
- paymail_service_provider.go
- tasks.go
Directories ¶
Path | Synopsis |
---|---|
Package cachestore is the caching (key->value) service abstraction layer
|
Package cachestore is the caching (key->value) service abstraction layer |
Package chainstate is the on-chain data service abstraction layer
|
Package chainstate is the on-chain data service abstraction layer |
Package datastore is the database service abstraction layer
|
Package datastore is the database service abstraction layer |
examples
|
|
Package taskmanager is the task/job management service layer for concurrent and asynchronous tasks
|
Package taskmanager is the task/job management service layer for concurrent and asynchronous tasks |
Package tester is a generic testing package with helpful methods for all packages
|
Package tester is a generic testing package with helpful methods for all packages |
Package utils is used for generic methods and values that are used across all packages
|
Package utils is used for generic methods and values that are used across all packages |