Skip to content

Commit

Permalink
comments; handle transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
chadlagore committed Aug 12, 2017
1 parent 90e8ccc commit 19ddb85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func createTransaction(ctx *ishell.Context, app *App) {
emoji.Print(":credit_card:")
ctx.Println(" Enter recipient wallet address")
toAddress := shell.ReadLine()
// TODO: Error handling address input.

// Get amount from user.
emoji.Print(":dollar:")
ctx.Println(" Enter amount to send: ")
amount, err := strconv.ParseUint(shell.ReadLine(), 10, 64)
Expand All @@ -130,7 +130,7 @@ func createTransaction(ctx *ishell.Context, app *App) {
return
}

// TODO: Check if we have enough coins to make the purchase.
// Make payment.
err = app.Pay(toAddress, amount)
if err != nil {
emoji.Println(":disappointed: Transaction failed!")
Expand Down
5 changes: 4 additions & 1 deletion app/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func getCurrentUser() *User {

// Pay pays an amount of coin to an address `to`.
func (a *App) Pay(to string, amount uint64) error {
// Two atomic steps must occur.
// Three atomic steps must occur.

// 1. A legitimate transaction must be built.
tbody := blockchain.TxBody{
Expand All @@ -50,6 +50,9 @@ func (a *App) Pay(to string, amount uint64) error {
Resource: txn,
})
a.CurrentUser.Wallet.SetPending(txn)

// 3. The transaction must be added to the pool.
a.HandleTransaction(txn)
} else {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions blockchain/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ func (a Address) Key() *ecdsa.PublicKey {
type Account interface {
Public() Address
Sign(digest Hash, random io.Reader) (Signature, error)
Debit(amount uint64) error
Credit(amount uint64) error
}

// Wallet is an account that can sign and hold a balance.
Expand Down

0 comments on commit 19ddb85

Please sign in to comment.