github.com/0chain/gosdk@v1.17.11/zcncore/wallet.go (about)

     1  //go:build !mobile
     2  // +build !mobile
     3  
     4  package zcncore
     5  
     6  import (
     7  	"github.com/0chain/gosdk/core/common"
     8  	"github.com/0chain/gosdk/core/zcncrypto"
     9  )
    10  
    11  // GetWallet get a wallet object from a wallet string
    12  func GetWallet(walletStr string) (*zcncrypto.Wallet, error) {
    13  	return getWallet(walletStr)
    14  }
    15  
    16  // GetWalletBalance retrieve wallet balance from sharders
    17  //   - id: client id
    18  func GetWalletBalance(clientId string) (common.Balance, int64, error) {
    19  	return getWalletBalance(clientId)
    20  }
    21  
    22  func SignWith0Wallet(hash string, w *zcncrypto.Wallet) (string, error) {
    23  	sigScheme := zcncrypto.NewSignatureScheme(_config.chain.SignatureScheme)
    24  	err := sigScheme.SetPrivateKey(w.Keys[0].PrivateKey)
    25  	if err != nil {
    26  		return "", err
    27  	}
    28  	return sigScheme.Sign(hash)
    29  }