diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..b013baa6 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,188 @@ +# This file contains all available configuration options +# Modified for linting src/ + +# options for analysis running +run: + # default concurrency is a available CPU number + concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + deadline: 15m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + # list of build tags, all linters use it. Default is empty list. + build-tags: + + # which dirs to skip: they won't be analyzed; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but next dirs are always skipped independently + # from this option's value: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs: + - /usr/local/go/src + + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. If it's not please let us know. + skip-files: + + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" + format: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + + +# all available settings of specific linters +linters-settings: + errcheck: + # report about not checking of errors in type assetions: `a := b.(MyStruct)`; + # default is false: such cases aren't reported by default. + check-type-assertions: false + + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; + # default is false: such cases aren't reported by default. + check-blank: true + govet: + # report about shadowed variables + check-shadowing: true + + # Obtain type information from installed (to $GOPATH/pkg) package files: + # golangci-lint will execute `go install -i` and `go test -i` for analyzed packages + # before analyzing them. + # By default this option is disabled and govet gets type information by loader from source code. + # Loading from source code is slow, but it's done only once for all linters. + # Go-installing of packages first time is much slower than loading them from source code, + # therefore this option is disabled by default. + # But repeated installation is fast in go >= 1.10 because of build caching. + # Enable this option only if all conditions are met: + # 1. you use only "fast" linters (--fast e.g.): no program loading occurs + # 2. you use go >= 1.10 + # 3. you do repeated runs (false for CI) or cache $GOPATH/pkg or `go env GOCACHE` dir in CI. + use-installed-packages: false + golint: + # minimal confidence for issues, default is 0.8 + min-confidence: 0.8 + gofmt: + # simplify code: gofmt with `-s` option, true by default + simplify: true + gocyclo: + # minimal code complexity to report, 30 by default (but we recommend 10-20) + min-complexity: 10 + maligned: + # print struct with more effective memory layout or not, false by default + suggest-new: true + dupl: + # tokens count to trigger issue, 150 by default + threshold: 100 + goconst: + # minimal length of string constant, 3 by default + min-len: 3 + # minimal occurrences count to trigger, 3 by default + min-occurrences: 3 + depguard: + list-type: blacklist + include-go-root: false + packages: + - github.com/pkg/errors + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + lll: + # max line length, lines longer will be reported. Default is 120. + # '\t' is counted as 1 character by default, and can be changed with the tab-width option + line-length: 120 + # tab width in spaces. Default to 1. + tab-width: 1 + unused: + # treat code as a program (not a library) and report unused exported identifiers; default is false. + # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find funcs usages. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + check-exported: false + unparam: + # call graph construction algorithm (cha, rta). In general, use cha for libraries, + # and rta for programs with main packages. Default is cha. + algo: cha + + # Inspect exported functions, default is false. Set to true if no external program/library imports your code. + # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find external interfaces. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + check-exported: false + nakedret: + # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 + max-func-lines: 30 + prealloc: + # XXX: we don't recommend using this linter before doing performance profiling. + # For most programs usage of prealloc will be a premature optimization. + + # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. + # True by default. + simple: true + range-loops: true # Report preallocation suggestions on range loops, true by default + for-loops: false # Report preallocation suggestions on for loops, false by default + + +linters: + enable: + - varcheck + - unparam + - structcheck + - errcheck + - gosimple + - staticcheck + - unused + - ineffassign + - typecheck + - gosec + - megacheck + - misspell + - depguard + enable-all: false + disable: + disable-all: true + presets: + fast: false + + +issues: + # List of regexps of issue texts to exclude, empty list by default. + # But independently from this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. To list all + # excluded by default patterns execute `golangci-lint run --help` + exclude: + + # Independently from option `exclude` we use default exclude patterns, + # it can be disabled by this option. To list all + # excluded by default patterns execute `golangci-lint run --help`. + # Default value for this option is true. + exclude-use-default: false + + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same: 0 + + # Show only new issues: if there are unstaged changes or untracked files, + # only those changes are analyzed, else only changes in HEAD~ are analyzed. + # It's a super-useful option for integration of golangci-lint into existing + # large codebase. It's not practical to fix all existing issues at the moment + # of integration: much better don't allow issues in new code. + # Default is false. + new: false diff --git a/.travis.yml b/.travis.yml index 1f7a0e1f..85fb2d4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,7 @@ matrix: - make install-deps script: + - make lint - make clean - make build - make test @@ -52,8 +53,10 @@ matrix: install: - choco install make -y - travis_wait make install-deps-Windows + - make install-linters script: + - make lint - make build - make test @@ -64,6 +67,7 @@ matrix: - make install-deps script: + - make lint - make clean - make build - make test diff --git a/.travis/install-golangci-lint.sh b/.travis/install-golangci-lint.sh new file mode 100755 index 00000000..ee94ad03 --- /dev/null +++ b/.travis/install-golangci-lint.sh @@ -0,0 +1,387 @@ +#!/bin/sh +set -e +# Code generated by godownloader on 2019-05-02T19:05:24Z. DO NOT EDIT. +# + +usage() { + this=$1 + cat </dev/null +} +echoerr() { + echo "$@" 1>&2 +} +log_prefix() { + echo "$0" +} +_logp=6 +log_set_priority() { + _logp="$1" +} +log_priority() { + if test -z "$1"; then + echo "$_logp" + return + fi + [ "$1" -le "$_logp" ] +} +log_tag() { + case $1 in + 0) echo "emerg" ;; + 1) echo "alert" ;; + 2) echo "crit" ;; + 3) echo "err" ;; + 4) echo "warning" ;; + 5) echo "notice" ;; + 6) echo "info" ;; + 7) echo "debug" ;; + *) echo "$1" ;; + esac +} +log_debug() { + log_priority 7 || return 0 + echoerr "$(log_prefix)" "$(log_tag 7)" "$@" +} +log_info() { + log_priority 6 || return 0 + echoerr "$(log_prefix)" "$(log_tag 6)" "$@" +} +log_err() { + log_priority 3 || return 0 + echoerr "$(log_prefix)" "$(log_tag 3)" "$@" +} +log_crit() { + log_priority 2 || return 0 + echoerr "$(log_prefix)" "$(log_tag 2)" "$@" +} +uname_os() { + os=$(uname -s | tr '[:upper:]' '[:lower:]') + case "$os" in + msys_nt*) os="windows" ;; + esac + echo "$os" +} +uname_arch() { + arch=$(uname -m) + case $arch in + x86_64) arch="amd64" ;; + x86) arch="386" ;; + i686) arch="386" ;; + i386) arch="386" ;; + aarch64) arch="arm64" ;; + armv5*) arch="armv5" ;; + armv6*) arch="armv6" ;; + armv7*) arch="armv7" ;; + esac + echo ${arch} +} +uname_os_check() { + os=$(uname_os) + case "$os" in + darwin) return 0 ;; + dragonfly) return 0 ;; + freebsd) return 0 ;; + linux) return 0 ;; + android) return 0 ;; + nacl) return 0 ;; + netbsd) return 0 ;; + openbsd) return 0 ;; + plan9) return 0 ;; + solaris) return 0 ;; + windows) return 0 ;; + esac + log_crit "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib" + return 1 +} +uname_arch_check() { + arch=$(uname_arch) + case "$arch" in + 386) return 0 ;; + amd64) return 0 ;; + arm64) return 0 ;; + armv5) return 0 ;; + armv6) return 0 ;; + armv7) return 0 ;; + ppc64) return 0 ;; + ppc64le) return 0 ;; + mips) return 0 ;; + mipsle) return 0 ;; + mips64) return 0 ;; + mips64le) return 0 ;; + s390x) return 0 ;; + amd64p32) return 0 ;; + esac + log_crit "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib" + return 1 +} +untar() { + tarball=$1 + case "${tarball}" in + *.tar.gz | *.tgz) tar -xzf "${tarball}" ;; + *.tar) tar -xf "${tarball}" ;; + *.zip) unzip "${tarball}" ;; + *) + log_err "untar unknown archive format for ${tarball}" + return 1 + ;; + esac +} +http_download_curl() { + local_file=$1 + source_url=$2 + header=$3 + if [ -z "$header" ]; then + code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url") + else + code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url") + fi + if [ "$code" != "200" ]; then + log_debug "http_download_curl received HTTP status $code" + return 1 + fi + return 0 +} +http_download_wget() { + local_file=$1 + source_url=$2 + header=$3 + if [ -z "$header" ]; then + wget -q -O "$local_file" "$source_url" + else + wget -q --header "$header" -O "$local_file" "$source_url" + fi +} +http_download() { + log_debug "http_download $2" + if is_command curl; then + http_download_curl "$@" + return + elif is_command wget; then + http_download_wget "$@" + return + fi + log_crit "http_download unable to find wget or curl" + return 1 +} +http_copy() { + tmp=$(mktemp) + http_download "${tmp}" "$1" "$2" || return 1 + body=$(cat "$tmp") + rm -f "${tmp}" + echo "$body" +} +github_release() { + owner_repo=$1 + version=$2 + test -z "$version" && version="latest" + giturl="https://github.com/${owner_repo}/releases/${version}" + json=$(http_copy "$giturl" "Accept:application/json") + test -z "$json" && return 1 + version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//') + test -z "$version" && return 1 + echo "$version" +} +hash_sha256() { + TARGET=${1:-/dev/stdin} + if is_command gsha256sum; then + hash=$(gsha256sum "$TARGET") || return 1 + echo "$hash" | cut -d ' ' -f 1 + elif is_command sha256sum; then + hash=$(sha256sum "$TARGET") || return 1 + echo "$hash" | cut -d ' ' -f 1 + elif is_command shasum; then + hash=$(shasum -a 256 "$TARGET" 2>/dev/null) || return 1 + echo "$hash" | cut -d ' ' -f 1 + elif is_command openssl; then + hash=$(openssl -dst openssl dgst -sha256 "$TARGET") || return 1 + echo "$hash" | cut -d ' ' -f a + else + log_crit "hash_sha256 unable to find command to compute sha-256 hash" + return 1 + fi +} +hash_sha256_verify() { + TARGET=$1 + checksums=$2 + if [ -z "$checksums" ]; then + log_err "hash_sha256_verify checksum file not specified in arg2" + return 1 + fi + BASENAME=${TARGET##*/} + want=$(grep "${BASENAME}" "${checksums}" 2>/dev/null | tr '\t' ' ' | cut -d ' ' -f 1) + if [ -z "$want" ]; then + log_err "hash_sha256_verify unable to find checksum for '${TARGET}' in '${checksums}'" + return 1 + fi + got=$(hash_sha256 "$TARGET") + if [ "$want" != "$got" ]; then + log_err "hash_sha256_verify checksum for '$TARGET' did not verify ${want} vs $got" + return 1 + fi +} +cat /dev/null <= len(it.networks) { - return false - } - return true + return !((it.current + 1) >= len(it.networks)) } func NewSkycoinPexNodeIterator(network []core.PexNode) *SkycoinPexNodeIterator { diff --git a/src/coin/skycoin/models/wallet.go b/src/coin/skycoin/models/wallet.go index f34de596..d157111d 100644 --- a/src/coin/skycoin/models/wallet.go +++ b/src/coin/skycoin/models/wallet.go @@ -57,10 +57,7 @@ func (it *SkycoinWalletIterator) Next() bool { } func (it *SkycoinWalletIterator) HasNext() bool { - if (it.current + 1) >= len(it.wallets) { - return false - } - return true + return !((it.current + 1) >= len(it.wallets)) } func NewSkycoinWalletIterator(wallets []core.Wallet) *SkycoinWalletIterator { @@ -95,14 +92,17 @@ func (wltSrv *SkycoinRemoteWallet) ListWallets() core.WalletIterator { } func (wltSrv *SkycoinRemoteWallet) CreateWallet(label string, seed string, IsEncrypted bool, pwd core.PasswordReader, scanAddressesN int) (core.Wallet, error) { - wlt := &RemoteWallet{} + wlt := &RemoteWallet{} //nolint megacheck False negative c, err := NewSkycoinApiClient(wltSrv.poolSection) if err != nil { return nil, err } defer ReturnSkycoinClient(c) if IsEncrypted { - password, _ := pwd("Enter your password") + password, err := pwd("Enter your password") + if err != nil { + return nil, err + } wltOpt := api.CreateWalletOptions{} wltOpt.Type = WalletTypeDeterministic wltOpt.Seed = seed @@ -140,7 +140,10 @@ func (wltSrv *SkycoinRemoteWallet) Encrypt(walletName string, pwd core.PasswordR return } defer ReturnSkycoinClient(c) - password, _ := pwd("Insert password") + password, err := pwd("Insert password") + if err != nil { + return + } _, err = c.EncryptWallet(walletName, password) if err != nil { return @@ -153,7 +156,10 @@ func (wltSrv *SkycoinRemoteWallet) Decrypt(walletName string, pwd core.PasswordR return } defer ReturnSkycoinClient(c) - password, _ := pwd("Insert password") + password, err := pwd("Insert password") + if err != nil { + return + } _, err = c.DecryptWallet(walletName, password) if err != nil { return @@ -190,10 +196,13 @@ func (wltSrv *SkycoinRemoteWallet) GetWallet(id string) core.Wallet { func NewWalletNode(nodeAddress string) *WalletNode { pool := core.GetMultiPool() - sections, _ := pool.ListSections() + sections, err := pool.ListSections() + if err != nil { + return nil + } cont := 1 var sect string - for true { + for { find := false sect = fmt.Sprintf("skycoin-%d", cont) for _, sec := range sections { @@ -208,7 +217,10 @@ func NewWalletNode(nodeAddress string) *WalletNode { } } - pool.CreateSection(sect, NewSkycoinConnectionFactory(nodeAddress)) + err = pool.CreateSection(sect, NewSkycoinConnectionFactory(nodeAddress)) + if err != nil { + return nil + } return &WalletNode{ NodeAddress: nodeAddress, poolSection: sect, @@ -345,7 +357,10 @@ func (wlt *RemoteWallet) SetLabel(name string) { return } defer ReturnSkycoinClient(c) - _ = c.UpdateWallet(wlt.Id, name) + err = c.UpdateWallet(wlt.Id, name) + if err != nil { + return + } } func (wlt *RemoteWallet) GetId() string { @@ -517,7 +532,10 @@ func (wlt *RemoteWallet) GenAddresses(addrType core.AddressType, startIndex, cou return nil } defer ReturnSkycoinClient(c) - password, _ := pwd("Insert password") + password, err := pwd("Insert password") + if err != nil { + return nil + } wltR, err := c.Wallet(wlt.Id) if err != nil { return nil @@ -526,7 +544,7 @@ func (wlt *RemoteWallet) GenAddresses(addrType core.AddressType, startIndex, cou for _, entry := range wltR.Entries[startIndex:int(util.Min(len(wltR.Entries), int(startIndex+count)))] { addresses = append(addresses, walletEntryToAddress(entry, wlt.poolSection)) } - //Checking if all the neccesary addresses exists + //Checking if all the necessary addresses exists if uint32(len(wltR.Entries)) < (startIndex + count) { difference := (startIndex + count) - uint32(len(wltR.Entries)) newAddrs, err := c.NewWalletAddress(wlt.Id, int(difference), password) @@ -652,7 +670,11 @@ func (wltSrv *SkycoinLocalWallet) GetWallet(id string) core.Wallet { } func (wltSrv *SkycoinLocalWallet) CreateWallet(label string, seed string, IsEncrypted bool, pwd core.PasswordReader, scanAddressesN int) (core.Wallet, error) { - password, _ := pwd("Insert Password") + password, err := pwd("Insert Password") + + if err != nil { + return nil, err + } passwordByte := []byte(password) opts := wallet.Options{ @@ -664,7 +686,6 @@ func (wltSrv *SkycoinLocalWallet) CreateWallet(label string, seed string, IsEncr } wltName := wltSrv.newUnicWalletFilename() var wlt wallet.Wallet - var err error if scanAddressesN > 0 { wlt, err = wallet.NewWalletScanAhead(wltName, opts, &TransactionFinder{}) if err != nil { @@ -718,7 +739,10 @@ func (wltSrv *SkycoinLocalWallet) Encrypt(walletName string, password core.Passw return } - pwd, _ := password("Insert Password") + pwd, err := password("Insert Password") + if err != nil { + return + } pwdBytes := []byte(pwd) if err := wallet.Lock(wlt, pwdBytes, "scrypt-chacha20poly1305"); err != nil { @@ -741,6 +765,9 @@ func (wltSrv *SkycoinLocalWallet) Decrypt(walletName string, password core.Passw return } pwd, err := password("Insert Password") + if err != nil { + return + } pwdBytes := []byte(pwd) unlockedWallet, err := wallet.Unlock(wlt, pwdBytes) @@ -750,8 +777,6 @@ func (wltSrv *SkycoinLocalWallet) Decrypt(walletName string, password core.Passw if err := wallet.Save(unlockedWallet, wltSrv.walletDir); err != nil { return } - return - } func (wltSrv *SkycoinLocalWallet) IsEncrypted(walletName string) (bool, error) { diff --git a/src/coin/skycoin/params.go b/src/coin/skycoin/params.go deleted file mode 100644 index 1f52de3f..00000000 --- a/src/coin/skycoin/params.go +++ /dev/null @@ -1,27 +0,0 @@ -package skycoin - -import ( - "github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin/params" - skyparams "github.com/skycoin/skycoin/src/params" -) - -var ( - SkycoinMainNetParams = params.SkyFiberParams{ - Distribution: skyparams.MainNetDistribution, - } -) - -const ( - SkycoinTicker = params.SkycoinTicker - SkycoinName = params.SkycoinName - SkycoinFamily = params.SkycoinFamily - SkycoinDescription = params.SkycoinDescription - CoinHoursTicker = params.CoinHoursTicker - CoinHoursName = params.CoinHoursName - CoinHoursFamily = params.CoinHoursFamily - CoinHoursDescription = params.CoinHoursDescription - CalculatedHoursTicker = params.CalculatedHoursTicker - CalculatedHoursName = params.CalculatedHoursName - CalculatedHoursFamily = params.CalculatedHoursFamily - CalculatedHoursDescription = params.CalculatedHoursDescription -) diff --git a/src/coin/skycoin/params/params.go b/src/coin/skycoin/params/params.go index 8be1975f..3ecb12e4 100644 --- a/src/coin/skycoin/params/params.go +++ b/src/coin/skycoin/params/params.go @@ -14,6 +14,7 @@ var ( } ) +// Constparams const ( SkycoinTicker = "SKY" SkycoinName = "Skycoin" @@ -24,7 +25,7 @@ const ( CoinHoursFamily = "SkyFiber" CoinHoursDescription = "Coin Hours is the parallel asset used for transaction fee, for creating scarcity, and to increase transaction privacy" CalculatedHoursTicker = "SKYCHC" - CalculatedHoursName = "Calculated Hours" + CalculatedHoursName = "Calculated Hours" CalculatedHoursFamily = "SkyFiber" CalculatedHoursDescription = "Calculated Hours are Coin Hours calculated considering the time since an output was created" ) diff --git a/src/core/network.go b/src/core/network.go index 4e649f0f..346e696b 100644 --- a/src/core/network.go +++ b/src/core/network.go @@ -135,7 +135,7 @@ func (ps *PoolSection) Put(obj interface{}) { func newMultiConnectionPool(capacity int) *MultiConnectionsPool { return &MultiConnectionsPool{ capacity: capacity, - sections: make(map[string]*PoolSection, 0), + sections: make(map[string]*PoolSection), } } func GetMultiPool() MultiPool { diff --git a/src/main/config.go b/src/main/config.go index f53ac880..bb467379 100644 --- a/src/main/config.go +++ b/src/main/config.go @@ -93,7 +93,10 @@ func (cm *ConfigManager) EditNode(node string) { func (cm *ConfigManager) Save() error { - jsonFormat, _ := json.Marshal(cm.getConfigManagerJson()) + jsonFormat, err := json.Marshal(cm.getConfigManagerJson()) + if err != nil { + return err + } return ioutil.WriteFile(getConfigFileDir(), jsonFormat, 0644) } @@ -168,7 +171,7 @@ func configFileExist() bool { func loadConfigFromFile() *ConfigManager { cm := new(configManagerJson) fileDir := getConfigFileDir() - dat, err := ioutil.ReadFile(fileDir) + dat, err := ioutil.ReadFile(fileDir) //nolint gosec if err != nil { @@ -196,11 +199,20 @@ func getDefaultConfigManager() *ConfigManager { cm.node = "https://staging.node.skycoin.net" cm.sourceList = []*WalletSource{getDefaultWalletSource()} - jsonFormat, _ := json.Marshal(cm.getConfigManagerJson()) + jsonFormat, err := json.Marshal(cm.getConfigManagerJson()) + if err != nil { + return nil + } - os.MkdirAll(filepath.Dir(getConfigFileDir()), 0755) + err = os.MkdirAll(filepath.Dir(getConfigFileDir()), 0750) + if err != nil { + return nil + } - ioutil.WriteFile(getConfigFileDir(), jsonFormat, 0644) + err = ioutil.WriteFile(getConfigFileDir(), jsonFormat, 0644) + if err != nil { + return nil + } return cm diff --git a/src/models/walletsManager.go b/src/models/walletsManager.go index 365059c6..5620063d 100644 --- a/src/models/walletsManager.go +++ b/src/models/walletsManager.go @@ -4,12 +4,12 @@ import ( "errors" "sync" - "github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin" "github.com/fibercrypto/FiberCryptoWallet/src/util" "github.com/sirupsen/logrus" "github.com/therecipe/qt/qml" sky "github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin/models" + "github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin/params" "github.com/fibercrypto/FiberCryptoWallet/src/core" qtcore "github.com/therecipe/qt/core" ) @@ -511,12 +511,12 @@ func fromWalletToQWallet(wlt core.Wallet, isEncrypted bool) *QWallet { } //TODO: report possible error - accuracy, _ := util.AltcoinQuotient(skycoin.SkycoinTicker) + accuracy, _ := util.AltcoinQuotient(params.SkycoinTicker) floatBl := float64(bl) / float64(accuracy) qWallet.SetSky(floatBl) - bl, err = wlt.GetCryptoAccount().GetBalance(skycoin.CoinHoursTicker) - accuracy, _ = util.AltcoinQuotient(skycoin.SkycoinTicker) + bl, err = wlt.GetCryptoAccount().GetBalance(params.CoinHoursTicker) + accuracy, _ = util.AltcoinQuotient(params.SkycoinTicker) if err != nil { bl = 0 } diff --git a/src/util/pluginutil.go b/src/util/pluginutil.go index d563ed97..71d3fa55 100644 --- a/src/util/pluginutil.go +++ b/src/util/pluginutil.go @@ -1,8 +1,9 @@ package util import ( - "math" "errors" + "math" + "github.com/fibercrypto/FiberCryptoWallet/src/core" ) diff --git a/src/util/util.go b/src/util/util.go index 93fd42c1..c6d600ab 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -64,7 +64,7 @@ func FormatCoins(n uint64, quotient uint64) string { func RemoveZeros(s string) string { index := 0 temp := 0 - for true { + for { temp = index for _, c := range s[index:] { if string(c) != "0" {