func New(host string, port int, macaroonPath string, tlsCertPath string) (*Lnd, error) {

	tlsCreds, err := credentials.NewClientTLSFromFile(tlsCertPath, "")
	if err != nil {
		fmt.Println("Cannot get node tls credentials", err)
		return nil, err
	}

	macaroonBytes, err := ioutil.ReadFile(macaroonPath)
	if err != nil {
		fmt.Println("Cannot read macaroon file", err)
		return nil, err
	}

	mac := &macaroon.Macaroon{}
	if err = mac.UnmarshalBinary(macaroonBytes); err != nil {
		fmt.Println("Cannot unmarshal macaroon", err)
		return nil, err
	}

	opts := []grpc.DialOption{
		grpc.WithTransportCredentials(tlsCreds),
		grpc.WithBlock(),
		grpc.WithPerRPCCredentials(macaroons.NewMacaroonCredential(mac)),
	}

	target := fmt.Sprintf("%s:%d", host, port)
	conn, err := grpc.Dial(target, opts...)
	if err != nil {
		fmt.Println("Cannot dial to lnd", err)
		return nil, err
	}

	return &Lnd{lnrpc.NewLightningClient(conn)}, nil
}
// New return a new lnd
New return a new lnd
// New return a new lnd
func New(host string, port int, macaroonPath string, tlsCertPath string) (*Lnd, error) {
	tlsCreds, err := credentials.NewClientTLSFromFile(tlsCertPath, "")
	if err != nil {
		fmt.Println("Cannot get node tls credentials", err)
		return nil, err
	}
	macaroonBytes, err := ioutil.ReadFile(macaroonPath)
	if err != nil {
		fmt.Println("Cannot read macaroon file", err)
		return nil, err
	}
	mac := &macaroon.Macaroon{}
	if err = mac.UnmarshalBinary(macaroonBytes); err != nil {
		fmt.Println("Cannot unmarshal macaroon", err)
		return nil, err
	}
	opts := []grpc.DialOption{
		grpc.WithTransportCredentials(tlsCreds),
		grpc.WithBlock(),
		grpc.WithPerRPCCredentials(macaroons.NewMacaroonCredential(mac)),
	}
	target := fmt.Sprintf("%s:%d", host, port)
	conn, err := grpc.Dial(target, opts...)
	if err != nil {
		fmt.Println("Cannot dial to lnd", err)
		return nil, err
	}
	return &Lnd{lnrpc.NewLightningClient(conn)}, nil
}
func New ( host string , port int , macaroonPath string , tlsCertPath string ) ( * Lnd , error ) { tlsCreds , err := credentials . NewClientTLSFromFile ( tlsCertPath , " " ) if err != nil { fmt . Println ( " " , err ) return nil , err } macaroonBytes , err := ioutil . ReadFile ( macaroonPath ) if err != nil { fmt . Println ( " " , err ) return nil , err } mac := & macaroon . Macaroon { } if err = mac . UnmarshalBinary ( macaroonBytes ) ; err != nil { fmt . Println ( " " , err ) return nil , err } opts := [ ] grpc . DialOption { grpc . WithTransportCredentials ( tlsCreds ) , grpc . WithBlock ( ) , grpc . WithPerRPCCredentials ( macaroons . NewMacaroonCredential ( mac ) ) , } target := fmt . Sprintf ( " " , host , port ) conn , err := grpc . Dial ( target , opts ... ) if err != nil { fmt . Println ( " " , err ) return nil , err } return & Lnd { lnrpc . NewLightningClient ( conn ) } , nil }
New return a new lnd
New return a new lnd