blob: bbefdadd0c3bd2f5d1330e24232273f40b9afe76 [file] [log] [blame]
Alex Fandrianto8b6e1ea2014-06-16 13:47:30 -07001/*
2Package bank implements an application to manipulate virtual money. The client's
3Veyron Identity determines the account they can manipulate. New identity's make
4a new account. Clients can deposit, withdraw, transfer, or query their balance
5in virtual currency.
6*/
7package bank
8
9import "veyron2/security"
10
11// Bank allows clients to store virtual money. Certain implementations can use persistent storage.
12// Uses the client's Veyron Identity to determine account access.
13type Bank interface {
14 // Connect causes the bank to bless a new user (string) and return their bank account number (int64). Existing users are not blessed (""), but still receive their account number (int64).
15 Connect() (newIdentity string, accountNumber int64, err error) {security.WriteLabel}
16}
17
18// The BankAccount can only be accessed by blessed users
19type BankAccount interface {
20 // Deposit adds the amount given to this account.
21 Deposit(amount int64) error {security.WriteLabel}
22 // Withdraw reduces the amount given from this account.
23 Withdraw(amount int64) error {security.WriteLabel}
24 // Transfer moves the amount given to the receiver's account.
25 Transfer(receiver int64, amount int64) error {security.WriteLabel}
26 // Balance returns the amount stored in this account.
27 Balance() (int64, error) {security.ReadLabel}
28}