github.com/0chain/gosdk@v1.17.11/zcncore/wallet_mobile.go (about) 1 //go:build mobile 2 // +build mobile 3 4 package zcncore 5 6 import ( 7 "github.com/0chain/gosdk/core/zcncrypto" 8 ) 9 10 // Wallet interface to gather all wallet related functions 11 type Wallet interface { 12 // Sign sign the hash 13 Sign(hash string) (string, error) 14 } 15 16 type wallet struct { 17 zcncrypto.Wallet 18 } 19 20 // Sign sign the given string using the wallet's private key 21 func (w *wallet) Sign(hash string) (string, error) { 22 sigScheme := zcncrypto.NewSignatureScheme(_config.chain.SignatureScheme) 23 err := sigScheme.SetPrivateKey(w.Keys[0].PrivateKey) 24 if err != nil { 25 return "", err 26 } 27 return sigScheme.Sign(hash) 28 } 29 30 // GetWalletBalance retrieve wallet balance from sharders 31 // - id: client id 32 func GetWalletBalance(id string) (int64, error) { 33 balance, _, err := getWalletBalance(id) 34 if err != nil { 35 return 0, err 36 } 37 return int64(balance), nil 38 }