Alex Fandrianto | 8b6e1ea | 2014-06-16 13:47:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | Package bank implements an application to manipulate virtual money. The client's |
| 3 | Veyron Identity determines the account they can manipulate. New identity's make |
| 4 | a new account. Clients can deposit, withdraw, transfer, or query their balance |
| 5 | in virtual currency. |
| 6 | */ |
| 7 | package bank |
| 8 | |
| 9 | import "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. |
| 13 | type 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 |
| 19 | type 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 | } |