Documentation
¶
Index ¶
- Constants
- func ValidStatus(status string) bool
- type APIKey
- type APIKeyPage
- type Account
- type AccountsPage
- type Contact
- type ContactsPage
- type Counterparty
- func (c *Counterparty) Contacts() ([]*Contact, error)
- func (c *Counterparty) HasContact(email string) (bool, error)
- func (c *Counterparty) Params() []any
- func (c *Counterparty) Scan(scanner Scanner) error
- func (c *Counterparty) ScanSummary(scanner Scanner) error
- func (c *Counterparty) SetContacts(contacts []*Contact)
- type CounterpartyPage
- type CounterpartySourceInfo
- type CryptoAddress
- type CryptoAddressPage
- type EnvelopeStorage
- type Model
- type PageInfo
- type Permission
- type PreparedTransaction
- type Role
- type Scanner
- type SearchQuery
- type SecureEnvelope
- type SecureEnvelopePage
- type Sunrise
- type SunrisePage
- type Transaction
- func (t *Transaction) NumEnvelopes() int64
- func (t *Transaction) Params() []any
- func (t *Transaction) Scan(scanner Scanner) error
- func (t *Transaction) ScanWithCount(scanner Scanner) error
- func (t *Transaction) SecureEnvelopes() ([]*SecureEnvelope, error)
- func (t *Transaction) SetNumEnvelopes(count int64)
- func (t *Transaction) SetSecureEnvelopes(envelopes []*SecureEnvelope)
- func (t *Transaction) Update(other *Transaction)
- type TransactionPage
- type TravelAddressFactory
- type User
- type UserPage
- type VASPCategories
Constants ¶
const ( SourceDirectorySync = "gds" SourceUserEntry = "user" SourcePeer = "peer" ProtocolTRISA = "trisa" ProtocolTRP = "trp" ProtocolSunrise = "sunrise" FieldCommonName = "common_name" FieldName = "name" FieldLEI = "lei" )
const ( SourceUnknown = "unknown" SourceLocal = "local" SourceRemote = "remote" StatusUnspecified = "unspecified" StatusDraft = "draft" StatusPending = "pending" StatusReview = "review" StatusRepair = "repair" StatusAccepted = "accepted" StatusCompleted = "completed" StatusRejected = "rejected" DirectionOut = "out" DirectionOutgoing = DirectionOut DirectionIn = "in" DirectionIncoming = DirectionIn DirectionAny = "any" CounterpartyUnknown = "unknown" VirtualAssetUnknown = "UNK" )
const DefaultPageSize = uint32(50)
Variables ¶
This section is empty.
Functions ¶
func ValidStatus ¶
Types ¶
type APIKey ¶
type APIKey struct { Model Description sql.NullString ClientID string Secret string LastSeen sql.NullTime // contains filtered or unexported fields }
func (APIKey) Permissions ¶
func (*APIKey) ScanSummary ¶
func (*APIKey) SetPermissions ¶
type APIKeyPage ¶
type Account ¶
type Account struct { Model CustomerID sql.NullString // Account ID of internal user record (optional) FirstName sql.NullString // First name (forename) of user LastName sql.NullString // Last name (surname) of user TravelAddress sql.NullString // Generated TravelAddress for this user IVMSRecord *ivms101.Person // IVMS101 record for the account // contains filtered or unexported fields }
Account holds information about a user account for the local VASP including identifying information to link the account to the user record and IVMS101 data. Accounts automatically generate a TravelAddress for creating travel rule transactions with the specified VASPs. Accounts can also be associated with one or more wallet addresses for specific crypto currencies and networks.
func (*Account) CryptoAddresses ¶
func (a *Account) CryptoAddresses() ([]*CryptoAddress, error)
Returns associated crypto addresses if they are cached on the account model, returns an ErrMissingAssociation error if they are not cached.
func (*Account) ScanSummary ¶
ScanSummary scans only the summary information into the account model.
func (*Account) SetCryptoAddresses ¶
func (a *Account) SetCryptoAddresses(addresses []*CryptoAddress)
Used by store implementations to cache associated crypto addresses on the account.
type AccountsPage ¶
type Contact ¶ added in v0.28.0
type Contact struct { Model Name string // The full name of the contact Email string // A unique address for the contact (professional email) must be lowercase Role string // A description of what the contact does at the counterparty CounterpartyID ulid.ULID // Reference to the counterparty the contact is associated with // contains filtered or unexported fields }
func (*Contact) Address ¶ added in v0.28.0
Return the RFC 5322 address as implemented by the net/mail package.
func (*Contact) Counterparty ¶ added in v0.28.0
func (c *Contact) Counterparty() (*Counterparty, error)
Returns the associated counterparty if it is cached on the model, otherwise returns an ErrMissingAssociation error.
func (*Contact) Params ¶ added in v0.28.0
Get complete named params of the counterparty from the model.
func (*Contact) SetCounterparty ¶ added in v0.28.0
func (c *Contact) SetCounterparty(counterparty *Counterparty)
type ContactsPage ¶ added in v0.28.0
type Counterparty ¶
type Counterparty struct { Model Source string // either directory or locally created DirectoryID sql.NullString // the directory ID associated with the counterparty (directory only) RegisteredDirectory sql.NullString // the registered directory of the counterparty (directory only) Protocol string // either TRISA or TRP; the protocol to use to send travel rule information CommonName string // common name - a unique name to identify the endpoint Endpoint string // the full endpoint to connect to the counterparty on Name string // the counterparty's legal entity name Website sql.NullString // website with more information about the counterparty Country sql.NullString // country the counterparty is associated with BusinessCategory sql.NullString // the business category of the counterparty VASPCategories VASPCategories // the categories of how the VASP handles crypto assets VerifiedOn sql.NullTime // the datetime the VASP was verified in the directory (directory only) IVMSRecord *ivms101.LegalPerson // IVMS101 record for the counterparty LEI sql.NullString // Legal Entity Identifier for the counterparty (generally for TRP) // contains filtered or unexported fields }
TODO: how to incorporate the TRIXO form into this model?
func (*Counterparty) Contacts ¶ added in v0.28.0
func (c *Counterparty) Contacts() ([]*Contact, error)
Returns the associated contacts if they are cached on the counterparty, otherwise returns an ErrMissingAssociation error if not.
func (*Counterparty) HasContact ¶ added in v0.28.0
func (c *Counterparty) HasContact(email string) (bool, error)
Lookup an email address in the counterparty contacts to see if it exists.
func (*Counterparty) Params ¶
func (c *Counterparty) Params() []any
Get complete named params of the counterparty from the model.
func (*Counterparty) Scan ¶
func (c *Counterparty) Scan(scanner Scanner) error
Scan a complete SELECT into the counterparty model
func (*Counterparty) ScanSummary ¶
func (c *Counterparty) ScanSummary(scanner Scanner) error
Scan a partial SELECT into the counterparty model
func (*Counterparty) SetContacts ¶ added in v0.28.0
func (c *Counterparty) SetContacts(contacts []*Contact)
Used by store implementation to cache associated contacts on the counterparty.
type CounterpartyPage ¶
type CounterpartyPage struct { Counterparties []*Counterparty `json:"counterparties"` Page *PageInfo `json:"page"` }
type CounterpartySourceInfo ¶
type CounterpartySourceInfo struct { ID ulid.ULID Source string // either directory or locally created DirectoryID sql.NullString // the directory ID associated with the counterparty (directory only) RegisteredDirectory sql.NullString // the registered directory of the counterparty (directory only) Protocol string // either TRISA or TRP; the protocol to use to send travel rule information }
func (*CounterpartySourceInfo) Scan ¶
func (c *CounterpartySourceInfo) Scan(scanner Scanner) error
type CryptoAddress ¶
type CryptoAddress struct { Model AccountID ulid.ULID // Reference to account the crypto address belongs to CryptoAddress string // The actual crypto address of the wallet Network string // The network associated with the crypto address in SIP0044 encoding AssetType sql.NullString // The asset type with the crypto address (optional) Tag sql.NullString // The memo or destination tag associated with the address (optional) TravelAddress sql.NullString // Generated TravelAddress for this wallet address // contains filtered or unexported fields }
func (*CryptoAddress) Account ¶
func (a *CryptoAddress) Account() (*Account, error)
Returns associated account if it is cached on the crypto address model, returns an ErrMissingAssociation error if they are not cached.
func (*CryptoAddress) Params ¶
func (a *CryptoAddress) Params() []any
Get the complete named params of the crypto address from the model.
func (*CryptoAddress) Scan ¶
func (a *CryptoAddress) Scan(scanner Scanner) error
Scans a complete SELECT into the CryptoAddress model
func (*CryptoAddress) SetAccount ¶
func (a *CryptoAddress) SetAccount(account *Account)
Used by store implementations to cache associated account on the crypto address.
type CryptoAddressPage ¶
type CryptoAddressPage struct { CryptoAddresses []*CryptoAddress `json:"crypto_addresses"` Page *PageInfo `json:"page"` }
type EnvelopeStorage ¶ added in v0.14.0
type EnvelopeStorage interface {
AddEnvelope(*SecureEnvelope) error
}
EnvelopeStorage is a subset of the PreparedTransaction interface that focuses on the database interactions with SecureEnvelopes. This sub-interface makes it easier to write tests, though in practice the PreparedTransaction is passed in for this.
type Model ¶
type Model struct { ID ulid.ULID `json:"id"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` }
Model is the base model for all models stored in the database.
type PageInfo ¶
type PageInfo struct { PageSize uint32 `json:"page_size"` NextPageID ulid.ULID `json:"next_page_id"` PrevPageID ulid.ULID `json:"prev_page_id"` }
func PageInfoFrom ¶
type Permission ¶
type Permission struct { ID int64 Title string Description string Created time.Time Modified time.Time }
func (*Permission) Params ¶
func (p *Permission) Params() []any
func (*Permission) Scan ¶
func (p *Permission) Scan(scanner Scanner) error
type PreparedTransaction ¶
type PreparedTransaction interface { Created() bool // Returns true if the transaction was newly created, false if it already existed Fetch() (*Transaction, error) // Fetches the current transaction record from the database Update(*Transaction) error // Update the transaction with new information; e.g. data from decryption AddCounterparty(*Counterparty) error // Add counterparty by database ULID, counterparty name, or registered directory ID; if the counterparty doesn't exist, it is created UpdateCounterparty(*Counterparty) error // Update the counterparty with new information LookupCounterparty(field, value string) (*Counterparty, error) // Lookup a counterparty by field and value AddEnvelope(*SecureEnvelope) error // Associate a secure envelope with the prepared transaction CreateSunrise(*Sunrise) error // Create a sunrise message sent to the counterparty for the transaction UpdateSunrise(*Sunrise) error // Update the sunrise message Rollback() error // Rollback the prepared transaction and conclude it Commit() error // Commit the prepared transaction and conclude it }
PreparedTransaction allows you to manage the creation/modification of a transaction w.r.t a secure envelope. It is unified in a single interface to allow backend stores that have database transactions to perform all operations in a single transaction without concurrency issues.
type Role ¶
type Role struct { ID int64 Title string Description string IsDefault bool Created time.Time Modified time.Time // contains filtered or unexported fields }
func (Role) Permissions ¶
func (r Role) Permissions() ([]*Permission, error)
func (*Role) SetPermissions ¶
func (r *Role) SetPermissions(permissions []*Permission)
type Scanner ¶
Scanner is an interface for *sql.Rows and *sql.Row so that models can implement how they scan fields into their struct without having to specify every field every time.
type SearchQuery ¶ added in v0.23.0
type SecureEnvelope ¶
type SecureEnvelope struct { Model EnvelopeID uuid.UUID // Also a foreign key reference to the Transaction Direction string // Either "out" outgoing or "in" incoming Remote sql.NullString // The common name of the remote peer this message was going to or coming from ReplyTo ulid.NullULID // If this envelope is a response, a reference to the original request envelope IsError bool // If the envelope contains an error/rejection rather than a payload EncryptionKey []byte // The encryption key, encrypted with the public key of the local node. Note this may differ from the value in the envelope for outgoing messages HMACSecret []byte // The hmac secret, encrypted with the public key of the local node. Note that this may differ from the value in the envelope for outgoing messages ValidHMAC sql.NullBool // If the hmac has been validated against the payload and non-repudiation properties are satisfied Timestamp time.Time // The timestamp of the envelope as defined by the envelope PublicKey sql.NullString // The signature of the public key that sealed the encryption key and hmac secret, may differ from the value in the envelope for ougoing envelopes. TransferState int32 // The transfer state of the secure envelope Envelope *api.SecureEnvelope // The secure envelope protocol buffer stored as a BLOB // contains filtered or unexported fields }
func FromEnvelope ¶
func FromEnvelope(env *envelope.Envelope) *SecureEnvelope
FromEnvelope creates a SecureEnvelope model from a trisa wrapped secure envelope protocol buffer; this is primarily used for testing and should not be relied on for production work without testing and verification that the complete model is present.
func (*SecureEnvelope) Params ¶
func (e *SecureEnvelope) Params() []any
func (*SecureEnvelope) Scan ¶
func (e *SecureEnvelope) Scan(scanner Scanner) error
func (*SecureEnvelope) SetTransaction ¶
func (e *SecureEnvelope) SetTransaction(tx *Transaction)
func (*SecureEnvelope) Transaction ¶
func (e *SecureEnvelope) Transaction() (*Transaction, error)
type SecureEnvelopePage ¶
type SecureEnvelopePage struct { Envelopes []*SecureEnvelope `json:"envelopes"` Page *PageInfo `json:"page"` }
type Sunrise ¶ added in v0.28.0
type Sunrise struct { Model EnvelopeID uuid.UUID // A foreign key reference to the Transaction Email string // Email address of recipients the token is sent to (might be a comma separated list) Expiration time.Time // The timestamp that the sunrise verification token is no longer valid Signature *sunrise.SignedToken // The signed token produced by the sunrise package for verification purposes Status string // The status of the sunrise message (should be similar to the status of the transaction) SentOn sql.NullTime // The timestamp that the email message was sent VerifiedOn sql.NullTime // The last timestamp that the user verified the token }
func (*Sunrise) IsExpired ¶ added in v0.28.0
IsExpired returns true if the message expiration is before the current time and if the status is not in a final state (e.g. completed or rejected). If the status is in a final state, then the message is not considered expired no matter the exiration timestamp.
func (*Sunrise) Params ¶ added in v0.28.0
Get the complete named params of the sunrise message from the model.
func (*Sunrise) ScanSummary ¶ added in v0.28.0
Scans a partial SELECT into the Sunrise model for listing the sunrise model
type SunrisePage ¶ added in v0.28.0
type Transaction ¶
type Transaction struct { ID uuid.UUID // Transaction IDs are UUIDs not ULIDs per the TRISA spec, this is also used for the envelope ID Source string // Either "local" meaning the transaction was created by the user, or "remote" meaning it is an incoming message Status string // Can be "unspecified", "started", "pending", "review", "repair", "accepted", "completed", or "rejected" Counterparty string // The name of the counterparty in the transaction CounterpartyID ulid.NullULID // A reference to the counterparty in the database, if any Originator sql.NullString // Full name of the originator natural person or account OriginatorAddress sql.NullString // The crypto address of the originator Beneficiary sql.NullString // Full name of the beneficiary natural person or account BeneficiaryAddress sql.NullString // The crypto address of the beneficiary VirtualAsset string // A representation of the network/asset type Amount float64 // The amount of the transaction Archived bool // If the transaction is archived or not ArchivedOn sql.NullTime // The timestamp the transaction was archived LastUpdate sql.NullTime // The last time a TRISA RPC occurred for this transaction Created time.Time // Timestamp the transaction was created Modified time.Time // Timestamp the transaction was last modified, including when a new secure envelope was received // contains filtered or unexported fields }
func (*Transaction) NumEnvelopes ¶
func (t *Transaction) NumEnvelopes() int64
func (*Transaction) Params ¶
func (t *Transaction) Params() []any
func (*Transaction) Scan ¶
func (t *Transaction) Scan(scanner Scanner) error
func (*Transaction) ScanWithCount ¶
func (t *Transaction) ScanWithCount(scanner Scanner) error
func (*Transaction) SecureEnvelopes ¶
func (t *Transaction) SecureEnvelopes() ([]*SecureEnvelope, error)
func (*Transaction) SetNumEnvelopes ¶
func (t *Transaction) SetNumEnvelopes(count int64)
func (*Transaction) SetSecureEnvelopes ¶
func (t *Transaction) SetSecureEnvelopes(envelopes []*SecureEnvelope)
func (*Transaction) Update ¶
func (t *Transaction) Update(other *Transaction)
Update the transaction t with values from other if the field in other is non-zero; e.g. if a nullable field is valid or an empty string is empty. This method skips the ID and Modified fields.
type TransactionPage ¶
type TransactionPage struct { Transactions []*Transaction `json:"transactions"` Page *PageInfo `json:"page"` }
type TravelAddressFactory ¶
Factory function that can create travel addresses from models or IDs. This function should be able to handle any model defined in this package or a ULID or UUID.
func NewTravelAddressFactory ¶
func NewTravelAddressFactory(endpoint, protocol string) (TravelAddressFactory, error)
Create a travel address factory with the endpoint and protocol.
type User ¶
type User struct { Model Name sql.NullString Email string Password string RoleID int64 LastLogin sql.NullTime // contains filtered or unexported fields }
func (User) Permissions ¶
func (*User) ScanSummary ¶
func (*User) SetPermissions ¶
type VASPCategories ¶
type VASPCategories []string
VASPCategories allows the string list to be stored in the database as a JSON array.
func (*VASPCategories) Scan ¶
func (c *VASPCategories) Scan(src interface{}) error