Documentation ¶
Overview ¶
Package engine 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 bitcoin-sv (https://github.com/bitcoin-sv)
Index ¶
- Constants
- Variables
- func DisplayModels(models interface{}) interface{}
- func Get(ctx context.Context, model ModelInterface, conditions map[string]interface{}, ...) error
- func Save(ctx context.Context, model ModelInterface) (err error)
- func ToBeef(ctx context.Context, tx *Transaction, store TransactionGetter) (string, error)
- func ToEfHex(ctx context.Context, tx *Transaction, store TransactionGetter) (efHex string, ok bool)
- 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) Save(ctx context.Context) error
- type AccessKeyService
- type AdminService
- type AdminStats
- type BUMP
- type BUMPLeaf
- type BUMPs
- type ChangeStrategy
- type Client
- func (c *Client) AcceptContact(ctx context.Context, xPubID, paymail string) error
- func (c *Client) AddContactRequest(ctx context.Context, fullName, paymailAdress, requesterXPubID string, ...) (*Contact, error)
- func (c *Client) AddModels(ctx context.Context, autoMigrate bool, models ...interface{}) error
- func (c *Client) AdminChangeContactStatus(ctx context.Context, id string, status ContactStatus) (*Contact, error)
- func (c *Client) AuthenticateAccessKey(ctx context.Context, pubAccessKey string) (*AccessKey, error)
- func (c *Client) Cachestore() cachestore.ClientInterface
- func (c *Client) Chainstate() chainstate.ClientInterface
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) Cluster() cluster.ClientInterface
- func (c *Client) ConfirmContact(ctx context.Context, xPubID, paymail string) 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) DeleteContact(ctx context.Context, id string) error
- 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) GetContacts(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, ...) ([]*Contact, error)
- func (c *Client) GetContactsByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata, ...) (int64, error)
- func (c *Client) GetContactsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, ...) ([]*Contact, error)
- func (c *Client) GetContactsCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, ...) (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) GetDraftTransactionByID(ctx context.Context, id string, opts ...ModelOps) (*DraftTransaction, 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) GetModelNames() []string
- 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) (*AdminStats, error)
- func (c *Client) GetTransaction(ctx context.Context, xPubID, txID string) (*Transaction, error)
- func (c *Client) GetTransactionByHex(ctx context.Context, hex string) (*Transaction, error)
- func (c *Client) GetTransactions(ctx context.Context, metadataConditions *Metadata, ...) ([]*Transaction, error)
- func (c *Client) GetTransactionsByIDs(ctx context.Context, txIDs []string) ([]*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) GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error)
- func (c *Client) GetUtxoByTransactionID(ctx context.Context, 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) IsDebug() bool
- func (c *Client) IsEncryptionKeySet() bool
- func (c *Client) IsIUCEnabled() bool
- func (c *Client) IsMigrationEnabled() bool
- func (c *Client) IsNewRelicEnabled() bool
- func (c *Client) Logger() *zerolog.Logger
- func (c *Client) Metrics() (metrics *metrics.Metrics, enabled bool)
- 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, opts ...ModelOps) (*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.Notifications
- func (c *Client) PaymailClient() paymail.ClientInterface
- func (c *Client) RecordRawTransaction(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) RejectContact(ctx context.Context, xPubID, paymail string) error
- func (c *Client) RevertTransaction(ctx context.Context, id string) error
- func (c *Client) RevokeAccessKey(ctx context.Context, rawXpubKey, id string, opts ...ModelOps) (*AccessKey, error)
- func (c *Client) SubscribeWebhook(ctx context.Context, url, tokenHeader, token string) error
- func (c *Client) Taskmanager() taskmanager.TaskEngine
- func (c *Client) UnReserveUtxos(ctx context.Context, xPubID, draftID string) error
- func (c *Client) UnconfirmContact(ctx context.Context, xPubID, paymail string) error
- func (c *Client) UnsubscribeWebhook(ctx context.Context, url string) error
- func (c *Client) UpdateContact(ctx context.Context, id, fullName string, metadata *Metadata) (*Contact, error)
- 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) UpdateTransaction(ctx context.Context, callbackResp *broadcast.SubmittedTx) 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) UpsertContact(ctx context.Context, ...) (*Contact, error)
- func (c *Client) UserAgent() string
- func (c *Client) Version() string
- type ClientInterface
- type ClientOps
- func WithAutoMigrate(migrateModels ...interface{}) ClientOps
- func WithBroadcastClient(broadcastClient broadcast.Client) ClientOps
- func WithCallback(callbackURL string, callbackToken string) ClientOps
- func WithChainstateOptions(broadcasting, broadcastInstant, paymailP2P, syncOnChain bool) ClientOps
- func WithClusterClient(clusterClient cluster.ClientInterface) ClientOps
- func WithClusterKeyPrefix(prefix string) ClientOps
- func WithClusterRedis(redisOptions *redis.Options) ClientOps
- func WithCronCustomPeriod(cronJobName string, period time.Duration) ClientOps
- func WithCustomCachestore(cacheStore cachestore.ClientInterface) ClientOps
- func WithCustomChainstate(chainState chainstate.ClientInterface) ClientOps
- func WithCustomDatastore(dataStore datastore.ClientInterface) ClientOps
- func WithDebugging() ClientOps
- func WithEncryption(key string) ClientOps
- func WithExcludedProviders(providers []string) ClientOps
- func WithFeeQuotes(enabled bool) ClientOps
- func WithFeeUnit(feeUnit *utils.FeeUnit) ClientOps
- func WithFreeCache() ClientOps
- func WithFreeCacheConnection(client *freecache.Cache) ClientOps
- func WithHTTPClient(httpClient HTTPInterface) ClientOps
- func WithIUCDisabled() ClientOps
- func WithLogger(customLogger *zerolog.Logger) ClientOps
- func WithMetrics(collector metrics.Collector) ClientOps
- func WithMigrationDisabled() ClientOps
- func WithModels(models ...interface{}) ClientOps
- func WithNewRelic(app *newrelic.Application) ClientOps
- func WithNotifications() ClientOps
- func WithPaymailBeefSupport(blockHeadersServiceURL, blockHeadersServiceAuthToken string) ClientOps
- func WithPaymailClient(client paymail.ClientInterface) ClientOps
- func WithPaymailPikeContactSupport() ClientOps
- func WithPaymailPikePaymentSupport() ClientOps
- func WithPaymailServerConfig(config *server.Configuration, defaultFromPaymail string) ClientOps
- func WithPaymailSupport(domains []string, defaultFromPaymail string, ...) 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 WithTaskqConfig(config *taskq.QueueOptions) ClientOps
- func WithUserAgent(userAgent string) ClientOps
- type ClientService
- type Contact
- func (m *Contact) Accept() error
- func (m *Contact) BeforeCreating(_ context.Context) (err error)
- func (m *Contact) BeforeUpdating(_ context.Context) (err error)
- func (m *Contact) Confirm() error
- func (m *Contact) Delete()
- func (m *Contact) GetID() string
- func (m *Contact) GetModelName() string
- func (m *Contact) GetModelTableName() string
- func (m *Contact) Migrate(client datastore.ClientInterface) error
- func (m *Contact) Reject() error
- func (m *Contact) Save(ctx context.Context) (err error)
- func (m *Contact) Unconfirm() error
- func (m *Contact) UpdatePubKey(pk string) (updated bool)
- type ContactService
- type ContactStatus
- type Destination
- func (m *Destination) AfterCreated(ctx context.Context) error
- func (m *Destination) AfterDeleted(ctx context.Context) error
- func (m *Destination) AfterUpdated(ctx 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(_ 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) 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 EnumStringMapper
- type HTTPInterface
- type IDs
- 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 MockTransactionStore
- 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) 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) 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 WithMetadataFromJSON(jsonData []byte) ModelOps
- func WithMetadatas(metadata map[string]interface{}) ModelOps
- func WithPageSize(pageSize int) ModelOps
- func WithXPub(rawXpubKey string) ModelOps
- type ModelService
- type OpReturn
- type PaymailAddress
- func (m *PaymailAddress) AfterCreated(_ context.Context) error
- func (m *PaymailAddress) BeforeCreating(_ context.Context) (err 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) GetNextXpub(ctx context.Context) (*bip32.ExtendedKey, error)
- func (m *PaymailAddress) GetPubKey() (string, error)
- func (m *PaymailAddress) Migrate(client datastore.ClientInterface) error
- func (m *PaymailAddress) RotatePubKey(ctx context.Context) error
- func (m *PaymailAddress) Save(ctx context.Context) (err error)
- func (m *PaymailAddress) String() string
- type PaymailDefaultServiceProvider
- func (p *PaymailDefaultServiceProvider) AddContact(ctx context.Context, requesterPaymailAddress string, ...) (err error)
- 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, _ *server.RequestMetadata) (*paymail.AddressInformation, error)
- func (p *PaymailDefaultServiceProvider) RecordTransaction(ctx context.Context, p2pTx *paymail.P2PTransaction, ...) (*paymail.P2PTransactionPayload, error)
- func (p *PaymailDefaultServiceProvider) VerifyMerkleRoots(ctx context.Context, merkleRoots []*spv.MerkleRootConfirmationRequestItem) (err error)
- type PaymailP4
- type PaymailPayloadFormat
- type PaymailServant
- func (s *PaymailServant) AddContactRequest(ctx context.Context, receiverPaymail *paymail.SanitisedPaymail, ...) (*paymail.PikeContactRequestResponse, error)
- func (s *PaymailServant) GetPkiForPaymail(ctx context.Context, sPaymail *paymail.SanitisedPaymail) (*paymail.PKIResponse, error)
- func (s *PaymailServant) GetSanitizedPaymail(addr string) (*paymail.SanitisedPaymail, error)
- type PaymailServerOptions
- type PaymailService
- type PikeContactServiceProvider
- type PikePaymentServiceProvider
- type ScriptOutput
- type SyncConfig
- type SyncResult
- type SyncResults
- type SyncStatus
- type SyncTransaction
- func (m *SyncTransaction) AfterCreated(_ context.Context) error
- func (m *SyncTransaction) BeforeCreating(_ context.Context) error
- func (m *SyncTransaction) BeforeUpdating(_ 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) 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(_ 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 TransactionGetter
- 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 Webhook
- func (m *Webhook) BanUntil(bannedTo time.Time)
- func (m *Webhook) Banned() bool
- func (m *Webhook) BeforeCreating(_ context.Context) error
- func (m *Webhook) Deleted() bool
- func (m *Webhook) GetID() string
- func (m *Webhook) GetModelName() string
- func (m *Webhook) GetModelTableName() string
- func (m *Webhook) GetTokenHeader() string
- func (m *Webhook) GetTokenValue() string
- func (m *Webhook) GetURL() string
- func (m *Webhook) Migrate(client datastore.ClientInterface) error
- func (m *Webhook) Refresh(tokenHeader, tokenValue string)
- func (m *Webhook) Save(ctx context.Context) error
- type WebhooksRepository
- func (wr *WebhooksRepository) Create(ctx context.Context, url, tokenHeader, tokenValue string) error
- func (wr *WebhooksRepository) Delete(ctx context.Context, model notifications.ModelWebhook) error
- func (wr *WebhooksRepository) GetAll(ctx context.Context) ([]notifications.ModelWebhook, error)
- func (wr *WebhooksRepository) GetByURL(ctx context.Context, url string) (notifications.ModelWebhook, error)
- func (wr *WebhooksRepository) Save(ctx context.Context, model notifications.ModelWebhook) error
- 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) GetNextExternalDerivationNum(ctx context.Context) (uint32, error)
- func (m *Xpub) GetNextInternalDerivationNum(ctx context.Context) (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 ( CronJobNameDraftTransactionCleanUp = "draft_transaction_clean_up" CronJobNameSyncTransactionBroadcast = "sync_transaction_broadcast" CronJobNameSyncTransactionSync = "sync_transaction_sync" CronJobNameCalculateMetrics = "calculate_metrics" )
Cron job names to be used in WithCronCustomPeriod
const ( // BIP32DerivationMethod is the BIP32 derivation method BIP32DerivationMethod = "BIP32" // PIKEDerivationMethod is the PIKE derivation method PIKEDerivationMethod = "PIKE" )
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 ReferenceIDLength = 16
ReferenceIDLength determine the length of the reference ID
Variables ¶
var AllModelNames = []ModelName{ ModelAccessKey, ModelDestination, ModelMetadata, ModelPaymailAddress, ModelPaymailAddress, ModelSyncTransaction, ModelTransaction, ModelUtxo, ModelXPub, ModelContact, ModelWebhook, }
AllModelNames is a list of all models
var BaseModels = []interface{}{ &Xpub{ Model: *NewBaseModel(ModelXPub), }, &AccessKey{ Model: *NewBaseModel(ModelAccessKey), }, &DraftTransaction{ Model: *NewBaseModel(ModelDraftTransaction), }, &Transaction{ Model: *NewBaseModel(ModelTransaction), }, &SyncTransaction{ Model: *NewBaseModel(ModelSyncTransaction), }, &Destination{ Model: *NewBaseModel(ModelDestination), }, &Utxo{ Model: *NewBaseModel(ModelUtxo), }, &Contact{ Model: *NewBaseModel(ModelContact), }, &Webhook{ Model: *NewBaseModel(ModelWebhook), }, }
BaseModels is the list of models for loading the engine and AutoMigration (defaults)
var ErrMissingFieldHex = spverrors.Newf("missing required field: hex")
ErrMissingFieldHex is an error when missing the hex field of a transaction
var ErrNoMatchingOutputs = spverrors.Newf("transaction outputs do not match any known destinations")
ErrNoMatchingOutputs is when the transaction does not match any known destinations
Functions ¶
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 Save ¶
func Save(ctx context.Context, model ModelInterface) (err error)
Save will save the model(s) into the Datastore
func ToBeef ¶
func ToBeef(ctx context.Context, tx *Transaction, store TransactionGetter) (string, error)
ToBeef generates BEEF Hex for transaction
func ToEfHex ¶
func ToEfHex(ctx context.Context, tx *Transaction, store TransactionGetter) (efHex string, ok bool)
ToEfHex generates Extended Format hex of transaction
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 customTypes.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
type AccessKeyService ¶
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 AdminService ¶
type AdminService 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) }
AdminService is the SPV Wallet Engine admin service interface comprised of all services available for admins
type AdminStats ¶
type AdminStats struct { Balance int64 `json:"balance"` Destinations int64 `json:"destinations"` PaymailAddresses int64 `json:"paymail_addresses"` Transactions int64 `json:"transactions"` TransactionsPerDay map[string]interface{} `json:"transactions_per_day"` Utxos int64 `json:"utxos"` UtxosPerType map[string]interface{} `json:"utxos_per_type"` XPubs int64 `json:"xpubs"` }
AdminStats are statistics about the SPV Wallet server
type BUMP ¶
type BUMP struct { BlockHeight uint64 `json:"blockHeight,string"` Path [][]BUMPLeaf `json:"path"` // contains filtered or unexported fields }
BUMP represents BUMP (BSV Unified Merkle Path) format
func CalculateMergedBUMP ¶
CalculateMergedBUMP calculates Merged BUMP from a slice of BUMPs
type BUMPLeaf ¶
type BUMPLeaf struct { Offset uint64 `json:"offset,string"` Hash string `json:"hash,omitempty"` TxID bool `json:"txid,omitempty"` Duplicate bool `json:"duplicate,omitempty"` }
BUMPLeaf represents each BUMP path element
type BUMPs ¶
type BUMPs []*BUMP
BUMPs represents a slice of BUMPs - BSV Unified Merkle Paths
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 SPV Wallet Engine client & options
func (*Client) AcceptContact ¶
AcceptContact marks the contact invitation as accepted, which makes it unconfirmed contact.
func (*Client) AddContactRequest ¶
func (c *Client) AddContactRequest(ctx context.Context, fullName, paymailAdress, requesterXPubID string, opts ...ModelOps) (*Contact, error)
AddContactRequest adds a new contact invitation if contact not exits or just checking if contact has still the same pub key if contact exists.
func (*Client) AdminChangeContactStatus ¶
func (c *Client) AdminChangeContactStatus(ctx context.Context, id string, status ContactStatus) (*Contact, error)
AdminChangeContactStatus changes the status of the contact, should be used only by the admin.
func (*Client) AuthenticateAccessKey ¶
func (c *Client) AuthenticateAccessKey(ctx context.Context, pubAccessKey string) (*AccessKey, error)
AuthenticateAccessKey check if access key exists
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) Cluster ¶
func (c *Client) Cluster() cluster.ClientInterface
Cluster will return the cluster coordinator client
func (*Client) ConfirmContact ¶
ConfirmContact marks the contact as confirmed.
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 ¶
func (c *Client) DefaultSyncConfig() *SyncConfig
DefaultSyncConfig will return the default sync config from the client defaults (for chainstate)
func (*Client) DeleteContact ¶
DeleteContact deletes the contact.
func (*Client) DeletePaymailAddress ¶
DeletePaymailAddress will delete a paymail address
func (*Client) EnableNewRelic ¶
func (c *Client) EnableNewRelic()
EnableNewRelic will enable NewRelic tracing
func (*Client) GetAccessKey ¶
GetAccessKey will get an existing access key from the Datastore
func (*Client) GetAccessKeys ¶
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 ¶
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 ¶
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 ¶
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) GetContacts ¶
func (c *Client) GetContacts(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Contact, error)
GetContacts returns the contact filtered by conditions.
func (*Client) GetContactsByXPubIDCount ¶
func (c *Client) GetContactsByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps) (int64, error)
GetContactsByXPubIDCount returns the number of contacts by xpubID.
func (*Client) GetContactsByXpubID ¶
func (c *Client) GetContactsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Contact, error)
GetContactsByXpubID returns the contacts by xpubID.
func (*Client) GetContactsCount ¶
func (c *Client) GetContactsCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps) (int64, error)
GetContactsCount returns the number of contacts.
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 ¶
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 ¶
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 ¶
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 ¶
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) GetDraftTransactionByID ¶
func (c *Client) GetDraftTransactionByID(ctx context.Context, id string, opts ...ModelOps) (*DraftTransaction, error)
GetDraftTransactionByID will get a draft transaction from the Datastore
func (*Client) GetDraftTransactions ¶
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 ¶
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) GetModelNames ¶
GetModelNames will return the model names that have been loaded
func (*Client) GetOrStartTxn ¶
GetOrStartTxn will check for an existing NewRelic transaction, if not found, it will make a new transaction
func (*Client) GetPaymailAddress ¶
func (c *Client) GetPaymailAddress(ctx context.Context, address string, opts ...ModelOps) (*PaymailAddress, error)
GetPaymailAddress will get a paymail address model
func (*Client) GetPaymailAddresses ¶
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 ¶
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 ¶
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 ¶
func (c *Client) GetPaymailConfig() *PaymailServerOptions
GetPaymailConfig will return the Paymail server config if it exists
func (*Client) GetTransaction ¶
GetTransaction will get a transaction by its ID from the Datastore
func (*Client) GetTransactionByHex ¶
GetTransactionByHex will get a transaction from the Datastore by its full hex string uses GetTransaction
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) GetTransactionsByIDs ¶
GetTransactionsByIDs returns array of transactions by their IDs from the Datastore
func (*Client) GetTransactionsByXpubID ¶
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 ¶
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 ¶
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) 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) GetUtxoByTransactionID ¶
func (c *Client) GetUtxoByTransactionID(ctx context.Context, txID string, outputIndex uint32) (*Utxo, error)
GetUtxoByTransactionID will get a single utxo based on 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 ¶
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 ¶
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 ¶
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 ¶
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
xPubID is the hash of the xPub
func (*Client) HTTPClient ¶
func (c *Client) HTTPClient() HTTPInterface
HTTPClient will return the http interface to use in the client
func (*Client) IsEncryptionKeySet ¶
IsEncryptionKeySet will return the flag (bool) if the encryption key has been set
func (*Client) IsIUCEnabled ¶
IsIUCEnabled will return the flag (bool)
func (*Client) IsMigrationEnabled ¶
IsMigrationEnabled will return the flag (bool)
func (*Client) IsNewRelicEnabled ¶
IsNewRelicEnabled will return the flag (bool)
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, 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, opts ...ModelOps, ) (*Destination, error)
NewDestinationForLockingScript will create a new destination based on a locking script
func (*Client) NewPaymailAddress ¶
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 ¶
func (c *Client) Notifications() *notifications.Notifications
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) RecordRawTransaction ¶
func (c *Client) RecordRawTransaction(ctx context.Context, txHex string, opts ...ModelOps, ) (*Transaction, error)
RecordRawTransaction will parse the transaction and save it into the Datastore directly, without any checks or broadcast but SPV Wallet Engine will ask network for information if transaction was mined The transaction is treat as external incoming transaction - transaction without a draft Only use this function when you know what you are doing!
txHex is the raw transaction hex opts are model options and can include "metadata"
func (*Client) RecordTransaction ¶
func (c *Client) RecordTransaction(ctx context.Context, xPubKey, txHex, draftID string, opts ...ModelOps) (*Transaction, error)
RecordTransaction will parse the outgoing transaction and save it into the Datastore 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) RejectContact ¶
RejectContact marks the contact invitation as rejected.
func (*Client) RevertTransaction ¶
RevertTransaction will revert a transaction created in the SPV Wallet Engine database, but only if it has not yet been synced on-chain and the utxos have not been spent. All utxos that are reverted will be marked as deleted (and spent)
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) SubscribeWebhook ¶
SubscribeWebhook adds URL to the list of subscribed webhooks
func (*Client) Taskmanager ¶
func (c *Client) Taskmanager() taskmanager.TaskEngine
Taskmanager will return the Taskmanager if it exists
func (*Client) UnReserveUtxos ¶
UnReserveUtxos remove the reservation on the utxos for the given draft ID
func (*Client) UnconfirmContact ¶
UnconfirmContact marks the contact as unconfirmed.
func (*Client) UnsubscribeWebhook ¶
UnsubscribeWebhook removes URL from the list of subscribed webhooks
func (*Client) UpdateContact ¶
func (c *Client) UpdateContact(ctx context.Context, id, fullName string, metadata *Metadata) (*Contact, error)
UpdateContact updates the contact data.
func (*Client) UpdateDestinationMetadataByAddress ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) UpdateTransaction ¶
UpdateTransaction will update the broadcast callback transaction info, like: block height, block hash, status, bump.
func (*Client) UpdateTransactionMetadata ¶
func (c *Client) UpdateTransactionMetadata(ctx context.Context, xPubID, id string, metadata Metadata, ) (*Transaction, error)
UpdateTransactionMetadata will update the metadata in an existing transaction
func (*Client) UpdateXpubMetadata ¶
func (c *Client) UpdateXpubMetadata(ctx context.Context, xPubID string, metadata Metadata) (*Xpub, error)
UpdateXpubMetadata will update the metadata in an existing xPub
xPubID is the hash of the xP
type ClientInterface ¶
type ClientInterface interface { AccessKeyService AdminService ClientService DestinationService DraftTransactionService ModelService PaymailService TransactionService UTXOService XPubService ContactService AuthenticateAccessKey(ctx context.Context, pubAccessKey string) (*AccessKey, error) Close(ctx context.Context) error Debug(on bool) DefaultSyncConfig() *SyncConfig EnableNewRelic() GetOrStartTxn(ctx context.Context, name string) context.Context IsDebug() bool IsEncryptionKeySet() bool IsIUCEnabled() bool IsMigrationEnabled() bool IsNewRelicEnabled() bool UserAgent() string Version() string Metrics() (metrics *metrics.Metrics, enabled bool) SubscribeWebhook(ctx context.Context, url, tokenHeader, token string) error UnsubscribeWebhook(ctx context.Context, url string) error }
ClientInterface is the client (spv wallet engine) interface comprised of all services/actions
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 WithBroadcastClient ¶
WithBroadcastClient will set broadcast client
func WithCallback ¶
WithCallback set callback settings
func WithChainstateOptions ¶
WithChainstateOptions will set chainstate defaults
func WithClusterClient ¶
func WithClusterClient(clusterClient cluster.ClientInterface) ClientOps
WithClusterClient will set the cluster options on the client
func WithClusterKeyPrefix ¶
WithClusterKeyPrefix will set the cluster key prefix to use for all keys in the cluster coordinator
func WithClusterRedis ¶
func WithClusterRedis(redisOptions *redis.Options) ClientOps
WithClusterRedis will set the cluster coordinator to use redis
func WithCronCustomPeriod ¶
WithCronCustomPeriod will set the custom cron jobs period which will override the default
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 WithDebugging ¶
func WithDebugging() ClientOps
WithDebugging will set debugging in any applicable configuration
func WithEncryption ¶
WithEncryption will set the encryption key and encrypt values using this key
func WithExcludedProviders ¶
WithExcludedProviders will set a list of excluded providers
func WithFeeQuotes ¶
WithFeeQuotes will find the lowest fee instead of using the fee set by the WithFeeUnit function
func WithFeeUnit ¶
WithFeeUnit will set the fee unit to use for broadcasting
func WithFreeCache ¶
func WithFreeCache() ClientOps
WithFreeCache will set the cache client for both Read & Write clients
func WithFreeCacheConnection ¶
WithFreeCacheConnection will set the cache client to an active FreeCache connection
func WithHTTPClient ¶
func WithHTTPClient(httpClient HTTPInterface) ClientOps
WithHTTPClient will set the custom http interface
func WithIUCDisabled ¶
func WithIUCDisabled() ClientOps
WithIUCDisabled will disable checking the input utxos
func WithLogger ¶
WithLogger will set the custom logger interface
func WithMetrics ¶
WithMetrics will set the metrics with a collector interface
func WithMigrationDisabled ¶
func WithMigrationDisabled() ClientOps
WithMigrationDisabled will disable all migrations from running in the Datastore
func WithModels ¶
func WithModels(models ...interface{}) ClientOps
WithModels will add additional models (will NOT migrate using datastore)
Pointers of structs (IE: &models.Xpub{})
func WithNewRelic ¶
func WithNewRelic(app *newrelic.Application) ClientOps
WithNewRelic will set the NewRelic application client
func WithNotifications ¶
func WithNotifications() ClientOps
WithNotifications will set the notifications config
func WithPaymailBeefSupport ¶
WithPaymailBeefSupport will enable Paymail BEEF format support (as a server) and create a Block Headers Service client for Merkle Roots verification.
func WithPaymailClient ¶
func WithPaymailClient(client paymail.ClientInterface) ClientOps
WithPaymailClient will set a custom paymail client
func WithPaymailPikeContactSupport ¶
func WithPaymailPikeContactSupport() ClientOps
WithPaymailPikeContactSupport will enable Paymail Pike Contact support
func WithPaymailPikePaymentSupport ¶
func WithPaymailPikePaymentSupport() ClientOps
WithPaymailPikePaymentSupport will enable Paymail Pike Payment support
func WithPaymailServerConfig ¶
func WithPaymailServerConfig(config *server.Configuration, defaultFromPaymail string) ClientOps
WithPaymailServerConfig will set the custom server configuration for Paymail
This will allow overriding the Configuration.actions (paymail service provider)
func WithPaymailSupport ¶
func WithPaymailSupport(domains []string, defaultFromPaymail string, domainValidation, senderValidation bool) ClientOps
WithPaymailSupport will set the configuration for Paymail support (as a server)
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 ¶
WithSQLConfigs will load multiple connections (replica & master)
func WithSQLConnection ¶
WithSQLConnection will set the Datastore to an existing connection for PostgreSQL
func WithSQLite ¶
func WithSQLite(config *datastore.SQLiteConfig) ClientOps
WithSQLite will set the Datastore to use SQLite
func WithTaskqConfig ¶
func WithTaskqConfig(config *taskq.QueueOptions) ClientOps
WithTaskqConfig will set the task manager to use TaskQ & in-memory
func WithUserAgent ¶
WithUserAgent will overwrite the default useragent
type ClientService ¶
type ClientService interface { Cachestore() cachestore.ClientInterface Cluster() cluster.ClientInterface Chainstate() chainstate.ClientInterface Datastore() datastore.ClientInterface HTTPClient() HTTPInterface Logger() *zerolog.Logger Notifications() *notifications.Notifications PaymailClient() paymail.ClientInterface Taskmanager() taskmanager.TaskEngine }
ClientService is the client related services
type Contact ¶
type Contact struct { // Base model Model `bson:",inline"` // Model specific fields ID string `json:"id" toml:"id" yaml:"id" gorm:"<-:create;type:char(36);primaryKey;comment:This is the unique contact id" bson:"_id"` OwnerXpubID string `` /* 175-byte string literal not displayed */ FullName string `json:"full_name" toml:"full_name" yaml:"full_name" gorm:"<-create;comment:This is the contact's full name" bson:"full_name"` Paymail string `` /* 128-byte string literal not displayed */ PubKey string `json:"pub_key" toml:"pub_key" yaml:"pub_key" gorm:"<-:create;index;comment:This is the related public key" bson:"pub_key"` Status ContactStatus `` /* 145-byte string literal not displayed */ }
Contact is a model that represents a known contacts of the user and invitations to contact.
func (*Contact) Accept ¶
Accept marks the contact invitation as accepted, what means that the contact invitation is treated as normal contact.
func (*Contact) BeforeCreating ¶
BeforeCreating is called before the model is saved to the DB
func (*Contact) BeforeUpdating ¶
BeforeUpdating is called before the model is updated in the DB
func (*Contact) GetModelName ¶
GetModelName returns name of the model
func (*Contact) GetModelTableName ¶
GetModelTableName returns the model db table name
func (*Contact) Migrate ¶
func (m *Contact) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*Contact) UpdatePubKey ¶
UpdatePubKey updates the contact's public key
type ContactService ¶
type ContactService interface { UpsertContact(ctx context.Context, fullName, paymailAdress, requesterXPubID, requesterPaymail string, opts ...ModelOps) (*Contact, error) AddContactRequest(ctx context.Context, fullName, paymailAdress, requesterXPubID string, opts ...ModelOps) (*Contact, error) AdminChangeContactStatus(ctx context.Context, id string, status ContactStatus) (*Contact, error) UpdateContact(ctx context.Context, id, fullName string, metadata *Metadata) (*Contact, error) DeleteContact(ctx context.Context, id string) error AcceptContact(ctx context.Context, xPubID, paymail string) error RejectContact(ctx context.Context, xPubID, paymail string) error ConfirmContact(ctx context.Context, xPubID, paymail string) error UnconfirmContact(ctx context.Context, xPubID, paymail string) error GetContacts(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Contact, error) GetContactsByXpubID(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, queryParams *datastore.QueryParams) ([]*Contact, error) GetContactsByXPubIDCount(ctx context.Context, xPubID string, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps) (int64, error) GetContactsCount(ctx context.Context, metadata *Metadata, conditions map[string]interface{}, opts ...ModelOps) (int64, error) }
ContactService is the service for managing contacts
type ContactStatus ¶
type ContactStatus string
ContactStatus represents statuses of contact model.
const ( // ContactNotConfirmed is a status telling that the contact model as not confirmed yet. ContactNotConfirmed ContactStatus = "unconfirmed" // ContactAwaitAccept is a status telling that the contact model as invitation to add to contacts. ContactAwaitAccept ContactStatus = "awaiting" // ContactConfirmed is a status telling that the contact model as confirmed. ContactConfirmed ContactStatus = "confirmed" // ContactRejected is a status telling that the contact invitation was rejected by user. ContactRejected ContactStatus = "rejected" )
func (*ContactStatus) Scan ¶
func (t *ContactStatus) Scan(value interface{}) error
Scan will scan the value into Struct, implements sql.Scanner interface
func (ContactStatus) String ¶
func (t ContactStatus) String() string
String is the string version of the status
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 */ PaymailExternalDerivationNum *uint32 `` /* 276-byte string literal not displayed */ Address string `` /* 135-byte string literal not displayed */ DraftID string `` /* 167-byte string literal not displayed */ DerivationMethod string `` /* 201-byte string literal not displayed */ SenderXpub string `` /* 165-byte string literal not displayed */ OutputIndex uint32 `` /* 179-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 ¶
func (m *Destination) AfterCreated(ctx context.Context) error
AfterCreated will fire after the model is created in the Datastore
func (*Destination) AfterDeleted ¶
func (m *Destination) AfterDeleted(ctx context.Context) error
AfterDeleted will fire after the model is deleted in the Datastore
func (*Destination) AfterUpdated ¶
func (m *Destination) AfterUpdated(ctx 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, opts ...ModelOps) (*Destination, error) NewDestinationForLockingScript(ctx context.Context, xPubID, lockingScript string, 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(_ 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) Save ¶
func (m *DraftTransaction) Save(ctx context.Context) (err error)
Save will save the model into the Datastore
func (*DraftTransaction) SignInputs ¶
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 ¶
func (m *DraftTransaction) SignInputsWithKey(xPrivKey string) (signedHex string, err error)
SignInputsWithKey will sign all the inputs using a key (string) (helper method)
type DraftTransactionService ¶
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 EnumStringMapper ¶
EnumStringMapper is a helper struct that maps strings to "enum" like constants.
func NewEnumStringMapper ¶
func NewEnumStringMapper[T fmt.Stringer](elements ...T) EnumStringMapper[T]
NewEnumStringMapper creates a new EnumStringMapper.
func (*EnumStringMapper[T]) Get ¶
func (m *EnumStringMapper[T]) Get(key string) (T, bool)
Get returns the "enum" value for the given string.
type HTTPInterface ¶
HTTPInterface is the HTTP client interface
type IDs ¶
type IDs []string
IDs are string ids saved as an array
func (IDs) GormDBDataType ¶
GormDBDataType the gorm data type for metadata
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 (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 MockTransactionStore ¶
type MockTransactionStore struct {
Transactions map[string]*Transaction
}
MockTransactionStore is a mock implementation of TransactionGetter.
func NewMockTransactionStore ¶
func NewMockTransactionStore() *MockTransactionStore
NewMockTransactionStore creates new mock transaction store.
func (*MockTransactionStore) AddToStore ¶
func (m *MockTransactionStore) AddToStore(tx *Transaction)
AddToStore adds transaction to store.
func (*MockTransactionStore) GetTransactionsByIDs ¶
func (m *MockTransactionStore) GetTransactionsByIDs(_ context.Context, txIDs []string) ([]*Transaction, error)
GetTransactionsByIDs returns transactions by IDs.
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 customTypes.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) GetOptions ¶
GetOptions will get the options that are set on that model
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 ¶
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 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 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" ModelDestination ModelName = "destination" ModelDraftTransaction ModelName = "draft_transaction" ModelMetadata ModelName = "metadata" ModelNameEmpty ModelName = "empty" ModelPaymailAddress ModelName = "paymail_address" ModelSyncTransaction ModelName = "sync_transaction" ModelTransaction ModelName = "transaction" ModelUtxo ModelName = "utxo" ModelXPub ModelName = "xpub" ModelContact ModelName = "contact" ModelWebhook ModelName = "webhook" )
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 ¶
WithEncryptionKey will set the encryption key on the model (if needed)
func WithMetadata ¶
WithMetadata will add the metadata record to the model
func WithMetadataFromJSON ¶
WithMetadataFromJSON will add the metadata record to the model
func WithMetadatas ¶
WithMetadatas will add multiple metadata records to the model
func WithPageSize ¶
WithPageSize will set the pageSize to use on the model in queries
type ModelService ¶
type ModelService interface { AddModels(ctx context.Context, autoMigrate bool, models ...interface{}) error DefaultModelOptions(opts ...ModelOps) []ModelOps GetModelNames() []string }
ModelService is the "model" related services
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 PaymailAddress ¶
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 */ ExternalXpubKeyNum uint32 `` /* 180-byte string literal not displayed */ PubKeyNum uint32 `` /* 148-byte string literal not displayed */ XpubDerivationSeq uint32 `` /* 228-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) AfterCreated ¶
func (m *PaymailAddress) AfterCreated(_ context.Context) error
AfterCreated will fire after the model is created in the Datastore
func (*PaymailAddress) BeforeCreating ¶
func (m *PaymailAddress) BeforeCreating(_ context.Context) (err error)
BeforeCreating is called before the model is saved to the DB
func (*PaymailAddress) GetIdentityXpub ¶
func (m *PaymailAddress) GetIdentityXpub() (*bip32.ExtendedKey, error)
GetIdentityXpub will get the identity related to the xPub
func (*PaymailAddress) GetModelName ¶
func (m *PaymailAddress) GetModelName() string
GetModelName returns the model name
func (*PaymailAddress) GetModelTableName ¶
func (m *PaymailAddress) GetModelTableName() string
GetModelTableName returns the model db table name
func (*PaymailAddress) GetNextXpub ¶
func (m *PaymailAddress) GetNextXpub(ctx context.Context) (*bip32.ExtendedKey, error)
GetNextXpub will get the next child xPub for external operations.
func (*PaymailAddress) GetPubKey ¶
func (m *PaymailAddress) GetPubKey() (string, error)
GetPubKey will get the public key for the paymail address.
func (*PaymailAddress) Migrate ¶
func (m *PaymailAddress) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*PaymailAddress) RotatePubKey ¶
func (m *PaymailAddress) RotatePubKey(ctx context.Context) error
RotatePubKey will rotate the public key
func (*PaymailAddress) Save ¶
func (m *PaymailAddress) Save(ctx context.Context) (err error)
Save the model
func (*PaymailAddress) String ¶
func (m *PaymailAddress) String() string
type PaymailDefaultServiceProvider ¶
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) AddContact ¶
func (p *PaymailDefaultServiceProvider) AddContact( ctx context.Context, requesterPaymailAddress string, contact *paymail.PikeContactRequestPayload, ) (err error)
AddContact will add a contact to the paymail address
func (*PaymailDefaultServiceProvider) CreateAddressResolutionResponse ¶
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 ¶
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 ¶
func (p *PaymailDefaultServiceProvider) GetPaymailByAlias( ctx context.Context, alias, domain string, _ *server.RequestMetadata, ) (*paymail.AddressInformation, error)
GetPaymailByAlias will get a paymail address and information by alias
func (*PaymailDefaultServiceProvider) RecordTransaction ¶
func (p *PaymailDefaultServiceProvider) RecordTransaction(ctx context.Context, p2pTx *paymail.P2PTransaction, requestMetadata *server.RequestMetadata, ) (*paymail.P2PTransactionPayload, error)
RecordTransaction will record the transaction TODO: rename to HandleReceivedP2pTransaction
func (*PaymailDefaultServiceProvider) VerifyMerkleRoots ¶
func (p *PaymailDefaultServiceProvider) VerifyMerkleRoots( ctx context.Context, merkleRoots []*spv.MerkleRootConfirmationRequestItem, ) (err error)
VerifyMerkleRoots will verify the merkle roots by checking them in external header service - Block Headers Service
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) Format PaymailPayloadFormat `json:"format,omitempty" toml:"format" yaml:"format" bson:"format,omitempty"` // Use beef format for the transaction }
PaymailP4 paymail configuration for the p2p payments on this output
type PaymailPayloadFormat ¶
type PaymailPayloadFormat uint32
PaymailPayloadFormat is the format of the paymail payload
const ( BasicPaymailPayloadFormat PaymailPayloadFormat = iota BeefPaymailPayloadFormat )
Types of Paymail payload formats
func (PaymailPayloadFormat) String ¶
func (format PaymailPayloadFormat) String() string
type PaymailServant ¶
type PaymailServant struct {
// contains filtered or unexported fields
}
PaymailServant is a service that aims to make easier paymail operations
func (*PaymailServant) AddContactRequest ¶
func (s *PaymailServant) AddContactRequest(ctx context.Context, receiverPaymail *paymail.SanitisedPaymail, contactData *paymail.PikeContactRequestPayload) (*paymail.PikeContactRequestResponse, error)
AddContactRequest sends a contact invitation via PIKE capability
func (*PaymailServant) GetPkiForPaymail ¶
func (s *PaymailServant) GetPkiForPaymail(ctx context.Context, sPaymail *paymail.SanitisedPaymail) (*paymail.PKIResponse, error)
GetPkiForPaymail retrieves the PKI for a paymail address
func (*PaymailServant) GetSanitizedPaymail ¶
func (s *PaymailServant) GetSanitizedPaymail(addr string) (*paymail.SanitisedPaymail, error)
GetSanitizedPaymail validates and returns the sanitized version of paymail address (alias@domain.tld)
type PaymailServerOptions ¶
type PaymailServerOptions struct { *server.Configuration // Server configuration if Paymail is enabled DefaultFromPaymail string // IE: from@domain.com // contains filtered or unexported fields }
PaymailServerOptions is the options for the Paymail server
type PaymailService ¶
type PaymailService interface { DeletePaymailAddress(ctx context.Context, address string, opts ...ModelOps) error GetPaymailConfig() *PaymailServerOptions 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) 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 & services
type PikeContactServiceProvider ¶
type PikeContactServiceProvider struct {
// contains filtered or unexported fields
}
PikeContactServiceProvider is an interface for handling the pike contact actions in go-paymail/server
func (*PikeContactServiceProvider) AddContact ¶
func (p *PikeContactServiceProvider) AddContact( ctx context.Context, requesterPaymailAddress string, contact *paymail.PikeContactRequestPayload, ) (err error)
AddContact is a method to add a new contact to the pike contact list
type PikePaymentServiceProvider ¶
type PikePaymentServiceProvider struct {
// contains filtered or unexported fields
}
PikePaymentServiceProvider is an interface for handling the pike payment actions in go-paymail/server
func (*PikePaymentServiceProvider) CreatePikeOutputResponse ¶
func (p *PikePaymentServiceProvider) CreatePikeOutputResponse( ctx context.Context, alias, domain, senderPubKey string, satoshis uint64, requestMetadata *server.RequestMetadata, ) (*paymail.PikePaymentOutputsResponse, error)
CreatePikeOutputResponse is a method to create new output templates, save destinations and return formatted response
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 BroadcastInstant bool `json:"broadcast_instant" toml:"broadcast_instant" yaml:"broadcast_instant"` // Transaction should be broadcasted instantly (ASAP) 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 ¶
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 {
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 */ 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 */ // contains filtered or unexported fields }
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 GetSyncTransactionByID ¶
func GetSyncTransactionByID(ctx context.Context, id string, opts ...ModelOps) (*SyncTransaction, error)
GetSyncTransactionByID will get a sync transaction
func GetSyncTransactionByTxID ¶
func GetSyncTransactionByTxID(ctx context.Context, txID string, opts ...ModelOps) (*SyncTransaction, error)
GetSyncTransactionByTxID will get a sync transaction by it's transaction id.
func (*SyncTransaction) AfterCreated ¶
func (m *SyncTransaction) AfterCreated(_ context.Context) error
AfterCreated will fire after the model is created in the Datastore
func (*SyncTransaction) BeforeCreating ¶
func (m *SyncTransaction) BeforeCreating(_ context.Context) error
BeforeCreating will fire before the model is being inserted into the Datastore
func (*SyncTransaction) BeforeUpdating ¶
func (m *SyncTransaction) BeforeUpdating(_ context.Context) error
BeforeUpdating will fire before the model is being updated
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
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:"<-;type:json" bson:"xpub_in_ids,omitempty"` XpubOutIDs IDs `json:"xpub_out_ids,omitempty" toml:"xpub_out_ids" yaml:"xpub_out_ids" gorm:"<-;type:json" bson:"xpub_out_ids,omitempty"` 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 `json:"number_of_inputs" toml:"number_of_inputs" yaml:"number_of_inputs" gorm:"<-;type:int" bson:"number_of_inputs,omitempty"` NumberOfOutputs uint32 `` /* 128-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:"<-;type:json;xpub_id specific value" bson:"xpub_output_value,omitempty"` BUMP BUMP `json:"bump" toml:"bump" yaml:"bump" gorm:"<-;type:text;comment:BSV Unified Merkle Path (BUMP) Format" bson:"bump,omitempty"` TxStatus string `` /* 141-byte string literal not displayed */ // 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:"-"` XPubID string `gorm:"-" bson:"-"` // XPub of the user registering this transaction // 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 ¶
func (m *Transaction) AfterDeleted(_ context.Context) error
AfterDeleted will fire after the model is deleted in the Datastore
func (*Transaction) AfterUpdated ¶
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(_ 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 ¶
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 ¶
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 { 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 (auto generated) FeeUnit *utils.FeeUnit `json:"fee_unit" toml:"fee_unit" yaml:"fee_unit" bson:"fee_unit"` // Fee unit to use (overrides chainstate if set) FromUtxos []*UtxoPointer `json:"from_utxos" toml:"from_utxos" yaml:"from_utxos" bson:"from_utxos"` // Use these specific 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 *TransactionOutput `json:"send_all_to,omitempty" toml:"send_all_to" yaml:"send_all_to" bson:"send_all_to"` // Send ALL utxos to the output 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 TransactionGetter ¶
type TransactionGetter interface {
GetTransactionsByIDs(ctx context.Context, txIDs []string) ([]*Transaction, error)
}
TransactionGetter interface for getting transactions by their IDs
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) GetTransactionsByIDs(ctx context.Context, txIDs []string) ([]*Transaction, error) GetTransactionByHex(ctx context.Context, hex 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) RecordRawTransaction(ctx context.Context, txHex string, opts ...ModelOps) (*Transaction, error) UpdateTransaction(ctx context.Context, txInfo *broadcast.SubmittedTx) error UpdateTransactionMetadata(ctx context.Context, xPubID, id string, metadata Metadata) (*Transaction, error) RevertTransaction(ctx context.Context, id string) error }
TransactionService is the transaction actions
type UTXOService ¶
type UTXOService interface { GetUtxo(ctx context.Context, xPubKey, txID string, outputIndex uint32) (*Utxo, error) GetUtxoByTransactionID(ctx context.Context, 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) UnReserveUtxos(ctx context.Context, xPubID, draftID string) 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 customTypes.NullString `` /* 148-byte string literal not displayed */ ReservedAt customTypes.NullTime `json:"reserved_at" toml:"reserved_at" yaml:"reserved_at" gorm:"<-;comment:When it was reserved" bson:"reserved_at,omitempty"` SpendingTxID customTypes.NullString `` /* 172-byte string literal not displayed */ // Virtual field holding the original transaction the utxo originated from // This is needed when signing a new transaction that spends the utxo Transaction *Transaction `json:"transaction,omitempty" toml:"-" yaml:"-" gorm:"-" bson:"-"` }
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 Webhook ¶
type Webhook struct { // Base model Model `bson:",inline"` URL string `` /* 130-byte string literal not displayed */ TokenHeader string `` /* 144-byte string literal not displayed */ Token string `json:"token" toml:"token" yaml:"token" gorm:"<-create;comment:This is optional token to be sent" bson:"token"` BannedTo customTypes.NullTime `json:"banned_to" toml:"banned_to" yaml:"banned_to" gorm:"comment:The time until the webhook will be banned" bson:"banned_to"` }
Webhook stores information about subscriptions to notifications via webhooks
Gorm related models & indexes: https://gorm.io/docs/models.html - https://gorm.io/docs/indexes.html
func (*Webhook) BeforeCreating ¶
BeforeCreating will fire before the model is being inserted into the Datastore
func (*Webhook) GetModelName ¶
GetModelName will get the name of the current model
func (*Webhook) GetModelTableName ¶
GetModelTableName will get the db table name of the current model
func (*Webhook) GetTokenHeader ¶
GetTokenHeader returns the token header of the webhook
func (*Webhook) GetTokenValue ¶
GetTokenValue returns the token value of the webhook
func (*Webhook) Migrate ¶
func (m *Webhook) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
type WebhooksRepository ¶
type WebhooksRepository struct {
// contains filtered or unexported fields
}
WebhooksRepository is the repository for webhooks. It implements the WebhooksRepository interface
func (*WebhooksRepository) Create ¶
func (wr *WebhooksRepository) Create(ctx context.Context, url, tokenHeader, tokenValue string) error
Create makes a new webhook instance and saves it to the database, it will fail if the webhook already exists in the database
func (*WebhooksRepository) Delete ¶
func (wr *WebhooksRepository) Delete(ctx context.Context, model notifications.ModelWebhook) error
Delete stores a model in the database
func (*WebhooksRepository) GetAll ¶
func (wr *WebhooksRepository) GetAll(ctx context.Context) ([]notifications.ModelWebhook, error)
GetAll gets all webhooks from the database
func (*WebhooksRepository) GetByURL ¶
func (wr *WebhooksRepository) GetByURL(ctx context.Context, url string) (notifications.ModelWebhook, error)
GetByURL gets a webhook by its URL. If the webhook does not exist, it returns a nil pointer and no error
func (*WebhooksRepository) Save ¶
func (wr *WebhooksRepository) Save(ctx context.Context, model notifications.ModelWebhook) error
Save stores a model in the database
type XPubService ¶
type XPubService interface { GetXpub(ctx context.Context, xPubKey string) (*Xpub, error) GetXpubByID(ctx context.Context, xPubID string) (*Xpub, 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:"id" 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 `` /* 248-byte string literal not displayed */ NextExternalNum uint32 `` /* 249-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) GetNextExternalDerivationNum ¶
GetNextExternalDerivationNum will return the next external derivation number
func (*Xpub) GetNextInternalDerivationNum ¶
GetNextInternalDerivationNum will return the next internal derivation number
func (*Xpub) Migrate ¶
func (m *Xpub) Migrate(client datastore.ClientInterface) error
Migrate model specific migration on startup
func (*Xpub) RemovePrivateData ¶
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_contact.go
- action_destination.go
- action_draft_transaction.go
- action_paymails.go
- action_transaction.go
- action_utxo.go
- action_xpub.go
- admin_actions_stats.go
- authentication.go
- beef_bump.go
- beef_fixtures.go
- beef_tx.go
- beef_tx_bytes.go
- beef_tx_mock.go
- beef_tx_sorting.go
- client.go
- client_internal.go
- client_options.go
- client_paymail.go
- cron_job_declarations.go
- cron_job_definitions.go
- db_model_transactions.go
- definitions.go
- ef_tx.go
- errors.go
- interface.go
- locks.go
- model_access_keys.go
- model_bump.go
- model_contact.go
- model_contact_status.go
- model_destinations.go
- model_draft_transactions.go
- model_get.go
- model_ids.go
- model_metadata.go
- model_options.go
- model_paymail_addresses.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_webhook.go
- model_xpubs.go
- models.go
- models_internal.go
- paymail.go
- paymail_servant.go
- paymail_service_provider.go
- pike_service_provider.go
- record_tx.go
- record_tx_strategy_external_incoming_tx.go
- record_tx_strategy_internal_incoming_tx.go
- record_tx_strategy_outgoing_tx.go
- spv_wallet_engine.go
- sync_tx_repository.go
- sync_tx_service.go
- tx_repository.go
- tx_service.go
- utils.go
Directories ¶
Path | Synopsis |
---|---|
Package chainstate is the on-chain data service abstraction layer
|
Package chainstate is the on-chain data service abstraction layer |
Package cluster is for clustering SPV Wallet Engine(s) or servers to work together for chainstate monitoring and other tasks
|
Package cluster is for clustering SPV Wallet Engine(s) or servers to work together for chainstate monitoring and other tasks |
Package datastore is the database service abstraction layer
|
Package datastore is the database service abstraction layer |
customtypes
Package customtypes encapsulates our custom database field types
|
Package customtypes encapsulates our custom database field types |
examples
|
|
Package metrics provides a way to track metrics in the application.
|
Package metrics provides a way to track metrics in the application. |
Package pike provides functionality to work with Pay-to-PubKey-Hash (P2PKH) scripts in a blockchain context.
|
Package pike provides functionality to work with Pay-to-PubKey-Hash (P2PKH) scripts in a blockchain context. |
script
|
|
template
Package template provides a collection of functions and types for working with script templates.
|
Package template provides a collection of functions and types for working with script templates. |
Package taskmanager is the task/job management service layer for concurrent and asynchronous tasks with cron scheduling.
|
Package taskmanager is the task/job management service layer for concurrent and asynchronous tasks with cron scheduling. |
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 |
types
|
|
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 |