Documentation ¶
Index ¶
- func LookupAccount(db *gorm.DB, account string) *gorm.DB
- func LookupBeneficiary(db *gorm.DB, beneficiary string) *gorm.DB
- func MigrateDB(db *gorm.DB) (err error)
- type Account
- type Identity
- type LogLevelDecoder
- type Server
- func (s *Server) AccountStatus(ctx context.Context, req *pb.AccountRequest) (rep *pb.AccountReply, err error)
- func (s *Server) LiveUpdates(stream pb.TRISADemo_LiveUpdatesServer) (err error)
- func (s *Server) Serve() (err error)
- func (s *Server) Shutdown() (err error)
- func (s *Server) Transfer(ctx context.Context, req *pb.TransferRequest) (rep *pb.TransferReply, err error)
- type Settings
- type TRISA
- func (s *TRISA) ConfirmAddress(ctx context.Context, in *protocol.Address) (out *protocol.AddressConfirmation, err error)
- func (s *TRISA) KeyExchange(ctx context.Context, in *protocol.SigningKey) (out *protocol.SigningKey, err error)
- func (s *TRISA) Serve() (err error)
- func (s *TRISA) Shutdown() (err error)
- func (s *TRISA) Status(ctx context.Context, in *protocol.HealthCheck) (out *protocol.ServiceState, err error)
- func (s *TRISA) Transfer(ctx context.Context, in *protocol.SecureEnvelope) (out *protocol.SecureEnvelope, err error)
- func (s *TRISA) TransferStream(stream protocol.TRISANetwork_TransferStreamServer) (err error)
- type Transaction
- type UpdateManager
- func (u *UpdateManager) Add(client string, stream pb.TRISADemo_LiveUpdatesServer) (err error)
- func (u *UpdateManager) Broadcast(requestID uint64, update string, cat pb.MessageCategory) (err error)
- func (u *UpdateManager) Del(client string)
- func (u *UpdateManager) Send(client string, msg *pb.Message) (err error)
- func (u *UpdateManager) SendTransferError(client string, id uint64, err *pb.Error) error
- type VASP
- type Wallet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LookupAccount ¶
LookupAccount by email address or wallet address.
func LookupBeneficiary ¶
LookupBeneficiary by email address or wallet address.
Types ¶
type Account ¶
type Account struct { gorm.Model Name string `gorm:"not null"` Email string `gorm:"uniqueIndex;not null"` WalletAddress string `gorm:"uniqueIndex;not null;column:wallet_address"` Wallet Wallet `gorm:"foreignKey:WalletAddress;references:Address"` Balance decimal.Decimal `gorm:"type:numeric(15,2);default:0.0"` Completed uint64 `gorm:"not null;default:0"` Pending uint64 `gorm:"not null;default:0"` IVMS101 string `gorm:"column:ivms101;not null"` }
Account contains details about the transactions that are served by the local VASP. It also contains the IVMS 101 data for KYC verification, in this table it is just stored as a JSON string rather than breaking it down to the field level. Only customers of the VASP have accounts.
func (Account) BalanceFloat ¶
BalanceFloat converts the balance decmial into an exact two precision float32 for use with the protocol buffers.
func (Account) LoadIdentity ¶
LoadIdentity returns the ivms101.Person for the Account.
func (Account) Transactions ¶
func (a Account) Transactions(db *gorm.DB) (records []Transaction, err error)
Transactions returns an ordered list of transactions associated with the account ordered by the timestamp of the transaction, listing any pending transactions at the top. This function may also support pagination and limiting functions, which is why we're using it rather than having a direct relationship on the model.
type Identity ¶
type Identity struct { gorm.Model WalletAddress string `gorm:"not null;column:wallet_address"` Email string `gorm:"uniqueIndex"` Provider string `gorm:"not null"` }
Identity holds raw data for an originator or a beneficiary that was sent as part of the transaction process. This should not be stored in the wallet since the wallet is a representation of the local VASPs knowledge about customers and bercause the identity information could change between transactions. This intermediate table is designed to more closely mimic data storage as part of a blockchain transaction.
type LogLevelDecoder ¶
LogLevelDecoder deserializes the log level from a config string.
func (*LogLevelDecoder) Decode ¶
func (ll *LogLevelDecoder) Decode(value string) error
Decode implements envconfig.Decoder
type Server ¶
type Server struct { pb.UnimplementedTRISADemoServer pb.UnimplementedTRISAIntegrationServer // contains filtered or unexported fields }
Server implements the GRPC TRISAIntegration and TRISADemo services.
func New ¶
New creates a rVASP server with the specified configuration and prepares it to listen for and serve GRPC requests.
func (*Server) AccountStatus ¶
func (s *Server) AccountStatus(ctx context.Context, req *pb.AccountRequest) (rep *pb.AccountReply, err error)
AccountStatus is a demo RPC to allow demo clients to fetch their recent transactions.
func (*Server) LiveUpdates ¶
func (s *Server) LiveUpdates(stream pb.TRISADemo_LiveUpdatesServer) (err error)
LiveUpdates is a demo bidirectional RPC that allows demo clients to explicitly show the message interchange between VASPs during the InterVASP protocol. The demo client connects to both sides of a transaction and can push commands to the stream; any messages received by the VASP as they perform the protocol are sent down to the UI.
func (*Server) Transfer ¶
func (s *Server) Transfer(ctx context.Context, req *pb.TransferRequest) (rep *pb.TransferReply, err error)
Transfer accepts a transfer request from a beneficiary and begins the InterVASP protocol to perform identity verification prior to establishing the transaction in the blockchain between crypto wallet addresses.
type Settings ¶
type Settings struct { Name string `envconfig:"RVASP_NAME"` BindAddr string `envconfig:"RVASP_BIND_ADDR" default:":4434"` TRISABindAddr string `envconfig:"RVASP_TRISA_BIND_ADDR" default:":4435"` DatabaseDSN string `envconfig:"RVASP_DATABASE"` CertPath string `envconfig:"RVASP_CERT_PATH"` TrustChainPath string `envconfig:"RVASP_TRUST_CHAIN_PATH"` DirectoryServiceURL string `envconfig:"RVASP_DIRECTORY_SERVICE_URL" default:"api.vaspdirectory.net:443"` ConsoleLog bool `envconfig:"RVASP_CONSOLE_LOG" default:"false"` LogLevel LogLevelDecoder `envconfig:"RVASP_LOG_LEVEL" default:"info"` }
Settings uses envconfig to load required settings from the environment and validate them in preparation for running the rVASP.
TODO: also store separate signing key instead of using the cert key.
type TRISA ¶
type TRISA struct { protocol.UnimplementedTRISANetworkServer protocol.UnimplementedTRISAHealthServer // contains filtered or unexported fields }
TRISA implements the GRPC TRISANetwork and TRISAHealth services.
func (*TRISA) ConfirmAddress ¶
func (s *TRISA) ConfirmAddress(ctx context.Context, in *protocol.Address) (out *protocol.AddressConfirmation, err error)
ConfirmAddress allows the rVASP to respond to proof-of-control requests.
func (*TRISA) KeyExchange ¶
func (s *TRISA) KeyExchange(ctx context.Context, in *protocol.SigningKey) (out *protocol.SigningKey, err error)
KeyExchange facilitates signing key exchange between VASPs.
func (*TRISA) Serve ¶
Serve initializes the GRPC server and returns any errors during intitialization, it then kicks off a go routine to handle requests. Not thread safe, should not be called multiple times.
func (*TRISA) Status ¶
func (s *TRISA) Status(ctx context.Context, in *protocol.HealthCheck) (out *protocol.ServiceState, err error)
Status returns a directory health check status as online and requests half an hour checks.
func (*TRISA) Transfer ¶
func (s *TRISA) Transfer(ctx context.Context, in *protocol.SecureEnvelope) (out *protocol.SecureEnvelope, err error)
Transfer enables a quick one-off transaction between peers.
func (*TRISA) TransferStream ¶
func (s *TRISA) TransferStream(stream protocol.TRISANetwork_TransferStreamServer) (err error)
TransferStream allows for high-throughput transactions.
type Transaction ¶
type Transaction struct { gorm.Model Envelope string `gorm:"not null"` AccountID uint `gorm:"not null"` Account Account `gorm:"foreignKey:AccountID"` OriginatorID uint `gorm:"column:originator_id;not null"` Originator Identity `gorm:"foreignKey:OriginatorID"` BeneficiaryID uint `gorm:"column:beneficiary_id;not null"` Beneficiary Identity `gorm:"foreignKey:BeneficiaryID"` Amount decimal.Decimal `gorm:"type:numeric(15,2)"` Debit bool `gorm:"not null"` Completed bool `gorm:"not null;default:false"` Timestamp time.Time `gorm:"not null"` Identity string `gorm:"not null"` }
Transaction holds exchange information to send money from one account to another. It also contains the decrypted identity payload that was sent as part of the TRISA protocol and the envelope ID that uniquely identifies the message chain.
func (Transaction) AmountFloat ¶
func (t Transaction) AmountFloat() float32
AmountFloat converts the amount decmial into an exact two precision float32 for use with the protocol buffers.
func (Transaction) Proto ¶
func (t Transaction) Proto() *pb.Transaction
Proto converts the transaction into a protocol buffer transaction
func (Transaction) TableName ¶
func (Transaction) TableName() string
TableName explicitly defines the name of the table for the model
type UpdateManager ¶
UpdateManager sends update messages to all connected clients.
func NewUpdateManager ¶
func NewUpdateManager() *UpdateManager
NewUpdateManager creates a new update manager ready to work. For thread safety, this is the only object that can send messages on update streams.
func (*UpdateManager) Add ¶
func (u *UpdateManager) Add(client string, stream pb.TRISADemo_LiveUpdatesServer) (err error)
Add a new client update stream.
func (*UpdateManager) Broadcast ¶
func (u *UpdateManager) Broadcast(requestID uint64, update string, cat pb.MessageCategory) (err error)
Broadcast a message to all streams.
func (*UpdateManager) Del ¶
func (u *UpdateManager) Del(client string)
Del an old client update stream. No-op if client odesn't exist.
func (*UpdateManager) Send ¶
func (u *UpdateManager) Send(client string, msg *pb.Message) (err error)
Send a message to a specific stream
func (*UpdateManager) SendTransferError ¶
SendTransferError to client
type VASP ¶
type VASP struct { gorm.Model Name string `gorm:"uniqueIndex;size:255;not null"` LegalName *string `gorm:"column:legal_name;null"` URL *string `gorm:"null"` Country *string `gorm:"null"` Endpoint *string `gorm:"null"` PubKey *string `gorm:"null"` NotAfter *time.Time `gorm:"null"` IsLocal bool `gorm:"column:is_local;default:false"` IVMS101 string `gorm:"column:ivms101"` }
VASP is a record of known partner VASPs and caches TRISA protocol information. This table also contains IVMS101 data that identifies the VASP (but only for the local VASP - we assume that VASPs do not have IVMS101 data on each other and have to use the directory service for that). TODO: modify VASP ID to a GUID
func (VASP) LoadIdentity ¶
LoadIdentity returns the ivms101.Person for the VASP.
type Wallet ¶
type Wallet struct { gorm.Model Address string `gorm:"uniqueIndex"` Email string `gorm:"uniqueIndex"` ProviderID uint `gorm:"not null"` Provider VASP `gorm:"foreignKey:ProviderID"` }
Wallet is a mapping of wallet IDs to VASPs to determine where to send transactions. Provider lookups can happen by wallet address or by email.
Directories ¶
Path | Synopsis |
---|---|
* Package jsonpb uses protojson (not the deprecated jsonpb module) to set defaults for * marshaling and unmarshaling rVASP protobuf messages to and from JSON format.
|
* Package jsonpb uses protojson (not the deprecated jsonpb module) to set defaults for * marshaling and unmarshaling rVASP protobuf messages to and from JSON format. |
pb
|
|