github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/api/scan.go (about) 1 package api 2 3 import ( 4 "math/big" 5 6 "github.com/NebulousLabs/Sia/types" 7 ) 8 9 // scanAmount scans a types.Currency from a string. 10 func scanAmount(amount string) (types.Currency, bool) { 11 // use SetString manually to ensure that amount does not contain 12 // multiple values, which would confuse fmt.Scan 13 i, ok := new(big.Int).SetString(amount, 10) 14 if !ok { 15 return types.Currency{}, ok 16 } 17 return types.NewCurrency(i), true 18 } 19 20 // scanAddress scans a types.UnlockHash from a string. 21 func scanAddress(addrStr string) (addr types.UnlockHash, err error) { 22 err = addr.LoadString(addrStr) 23 if err != nil { 24 return types.UnlockHash{}, err 25 } 26 return addr, nil 27 }