From 6ef6506c3d91377734c1a7edd247098010e97fd0 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 5 Jul 2016 18:55:52 -0700 Subject: [PATCH] cmd/lnshell: remove the now obsolete lnshell --- cmd/lnshell/commands.go | 86 -------------------------------------- cmd/lnshell/lnshellmain.go | 83 ------------------------------------ 2 files changed, 169 deletions(-) delete mode 100644 cmd/lnshell/commands.go delete mode 100644 cmd/lnshell/lnshellmain.go diff --git a/cmd/lnshell/commands.go b/cmd/lnshell/commands.go deleted file mode 100644 index dc4e1506..00000000 --- a/cmd/lnshell/commands.go +++ /dev/null @@ -1,86 +0,0 @@ -package main - -import ( - "fmt" - "time" - - "github.com/lightningnetwork/lnd/lnrpc" - "google.golang.org/grpc" -) - -// connects via grpc to the ln node. default (hardcoded?) local:10K -func RpcConnect(args []string) error { - // client := getClient(ctx) - opts := []grpc.DialOption{grpc.WithInsecure()} - conn, err := grpc.Dial("localhost:10000", opts...) - if err != nil { - return err - } - state, err := conn.State() - if err != nil { - return err - } - fmt.Printf("connection state: %s\n", state.String()) - time.Sleep(time.Second * 2) - // lnClient := lnrpc.NewLightningClient(conn) - // lnClient.NewAddress(nil, nil, nil) // crashes - - state, err = conn.State() - if err != nil { - return err - } - fmt.Printf("connection state: %s\n", state.String()) - - err = conn.Close() - if err != nil { - return err - } - return nil -} - -func LnConnect(args []string) error { - if len(args) == 0 { - return fmt.Errorf("need: lnc pubkeyhash@hostname or pkh (via pbx)") - } - - req := &lnrpc.ConnectPeerRequest{args[0]} - resp, err := z.ConnectPeer(stub, req) - if err != nil { - return err - } - - fmt.Printf("connected. remote lnid is %x\n", resp.LnID) - return nil -} - -// For testing. Syntax: lnhi hello world -/*func LnChat(args []string) error { - var err error - if len(args) < 2 { - return fmt.Errorf("too short, need: lnhi 32hexcharLNID message.\n") - } - req := new(lnrpc.LnChatRequest) - req.DestID, err = hex.DecodeString(args[0]) - if err != nil { - return err - } - if len(req.DestID) != 16 { - return fmt.Errorf("requested destination %x is %d bytes, expenct 16\n", - req.DestID, len(req.DestID)) - } - - var chat string - for _, s := range args[1:] { - chat += s + " " - } - - fmt.Printf("will send to %x text message: %s\n", req.DestID, chat) - - req.Msg = chat - _, err = z.LNChat(stub, req) - if err != nil { - return err - } - fmt.Printf("got response but there's nothing in it\n") - return nil -}*/ diff --git a/cmd/lnshell/lnshellmain.go b/cmd/lnshell/lnshellmain.go deleted file mode 100644 index 0ed2d388..00000000 --- a/cmd/lnshell/lnshellmain.go +++ /dev/null @@ -1,83 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "log" - "os" - "strings" - - "github.com/lightningnetwork/lnd/lnrpc" - "golang.org/x/net/context" - "google.golang.org/grpc" -) - -var z lnrpc.LightningClient -var stub context.Context - -func main() { - fmt.Printf("LNShell v0.0. \n") - fmt.Printf("Connects to LN daemon, default on 127.0.0.1:10000.\n") - err := shellPrompt() - if err != nil { - log.Fatal(err) - } - return -} - -func shellPrompt() error { - stub = context.Background() - opts := []grpc.DialOption{grpc.WithInsecure()} - conn, err := grpc.Dial("localhost:10000", opts...) - if err != nil { - return err - } - z = lnrpc.NewLightningClient(conn) - - for { - reader := bufio.NewReaderSize(os.Stdin, 4000) - fmt.Printf("->") - msg, err := reader.ReadString('\n') - if err != nil { - return err - } - cmdslice := strings.Fields(msg) - if len(cmdslice) < 1 { - continue - } - fmt.Printf("entered command: %s\n", msg) - err = Shellparse(cmdslice) - if err != nil { - return err - } - } -} - -func Shellparse(cmdslice []string) error { - var err error - var args []string - cmd := cmdslice[0] - if len(cmdslice) > 1 { - args = cmdslice[1:] - } - if cmd == "exit" || cmd == "quit" { - return fmt.Errorf("User exit") - } - - /*if cmd == "lnhi" { - err = LnChat(args) - if err != nil { - fmt.Printf("LN chat error: %s\n", err) - } - return nil - }*/ - if cmd == "lnc" { - err = LnConnect(args) - if err != nil { - fmt.Printf("LN connect error: %s\n", err) - } - return nil - } - fmt.Printf("Command not recognized.\n") - return nil -}