Skip to content

Commit

Permalink
Merge branch 'development' into blockchanges
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSnow committed Jul 10, 2015
2 parents 69ac67e + 692c84d commit a78f568
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package factom

import (
"strconv"
"strings"
"encoding/json"
"fmt"
Expand All @@ -27,16 +28,25 @@ func ECBalance(key string) (int64, error) {
}
resp.Body.Close()

type Balance struct {
Balance int64
}
type x struct {
Response string
Success bool
}
b := new(x)
if err := json.Unmarshal(body, b); err != nil {
return 0, fmt.Errorf("Error getting the balance of %s",key)
}

b := new(Balance)
if err := json.Unmarshal(body, b); err != nil {
return 0, err
}

return b.Balance, nil
if !b.Success {
return 0, fmt.Errorf(b.Response)
}

v,err := strconv.ParseInt(b.Response,10,64)
if err != nil {
return 0, fmt.Errorf("Error getting the balance of %s",key)
}

return v, nil
}

func FctBalance(key string) (int64, error) {
Expand All @@ -52,16 +62,25 @@ func FctBalance(key string) (int64, error) {
}
resp.Body.Close()

type Balance struct {
Balance int64
type x struct {
Response string
Success bool
}

b := new(Balance)
b := new(x)
if err := json.Unmarshal(body, b); err != nil {
return 0, err
return 0, fmt.Errorf("Error getting the balance of %s",key)
}

if !b.Success {
return 0, fmt.Errorf(b.Response)
}

v,err := strconv.ParseInt(b.Response,10,64)
if err != nil {
return 0, fmt.Errorf("Error getting the balance of %s",key)
}

return b.Balance, nil
return v, nil
}

func GenerateFactoidAddress(name string) (string, error) {
Expand Down

0 comments on commit a78f568

Please sign in to comment.