func BankCommand(ctx context.Context, client proto.WalletServiceClient) cli.Command {
	bankExecutor := func(args []string) error {
		walletFile, err := wallet.ReadWallet()
		if err != nil {
			return err
		}
		if len(walletFile) == 0 {
			fmt.Println("No credentials in wallet.")
			return nil
		}

		balanceRequest := &proto.BalanceRequest{PublicKeys: convertKeys(walletFile.GetKeys())}
		response, err := client.GetBalance(ctx, balanceRequest)

		if err != nil {
			panic(err)
		}

		for pubKey, w := range response.Wallets {
			if len(args) == 1 || args[1] != "full" {
				pubKey = pubKey[:6]
			}
			fmt.Printf("Public key %s:", pubKey)
			if len(w.Currencies) > 0 {
				fmt.Print("\n")
				for currency, amount := range w.Currencies {
					fmt.Printf("  - %s: %s\n", currency, wallet.DecimalAmount{Value: amount.Value, Decimal: int8(amount.Decimal)})
				}
			} else {
				fmt.Print(" no currency\n")
			}
		}
		return nil
	}
	return cli.CreateCommand("bank", "Display the current balance in each of the local wallets", bankExecutor, nil)
}
// BankCommand creates the bank command, returning to the
// user the current balance of all their local wallets
//
// syntax: bank [full]
BankCommand creates the bank command, returning to the
user the current balance of all their local wallets

bank [full]
// BankCommand creates the bank command returning to the // user the current balance of all their local wallets // // syntax : bank [ full ]
func BankCommand(ctx context.Context, client proto.WalletServiceClient) cli.Command {
	bankExecutor := func(args []string) error {
		walletFile, err := wallet.ReadWallet()
		if err != nil {
			return err
		}
		if len(walletFile) == 0 {
			fmt.Println("No credentials in wallet.")
			return nil
		}
		balanceRequest := &proto.BalanceRequest{PublicKeys: convertKeys(walletFile.GetKeys())}
		response, err := client.GetBalance(ctx, balanceRequest)
		if err != nil {
			panic(err)
		}
		for pubKey, w := range response.Wallets {
			if len(args) == 1 || args[1] != "full" {
				pubKey = pubKey[:6]
			}
			fmt.Printf("Public key %s:", pubKey)
			if len(w.Currencies) > 0 {
				fmt.Print("\n")
				for currency, amount := range w.Currencies {
					fmt.Printf("  - %s: %s\n", currency, wallet.DecimalAmount{Value: amount.Value, Decimal: int8(amount.Decimal)})
				}
			} else {
				fmt.Print(" no currency\n")
			}
		}
		return nil
	}
	return cli.CreateCommand("bank", "Display the current balance in each of the local wallets", bankExecutor, nil)
}
func BankCommand ( ctx context . Context , client proto . WalletServiceClient ) cli . Command { bankExecutor := func ( args [ ] string ) error { walletFile , err := wallet . ReadWallet ( ) if err != nil { return err } if len ( walletFile ) == 0 { fmt . Println ( " " ) return nil } balanceRequest := & proto . BalanceRequest { PublicKeys : convertKeys ( walletFile . GetKeys ( ) ) } response , err := client . GetBalance ( ctx , balanceRequest ) if err != nil { panic ( err ) } for pubKey , w := range response . Wallets { if len ( args ) == 1 || args [ 1 ] != " " { pubKey = pubKey [ : 6 ] } fmt . Printf ( " " , pubKey ) if len ( w . Currencies ) > 0 { fmt . Print ( " \n " ) for currency , amount := range w . Currencies { fmt . Printf ( " \n " , currency , wallet . DecimalAmount { Value : amount . Value , Decimal : int8 ( amount . Decimal ) } ) } } else { fmt . Print ( " \n " ) } } return nil } return cli . CreateCommand ( " " , " " , bankExecutor , nil ) }
BankCommand creates the bank command, returning to the
user the current balance of all their local wallets
BankCommand creates the bank command returning to the user the current balance of all their local wallets