mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-11 14:48:14 +01:00
add functions to rpc.proto, start lnshell
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
6647bdd2b8
commit
8a50faaf47
63
cmd/lnshell/commands.go
Normal file
63
cmd/lnshell/commands.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"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 {
|
||||
fmt.Printf("lnconnect, %d args\n", len(args))
|
||||
return nil
|
||||
}
|
||||
|
||||
// LnListen listens on the default port for incoming connections
|
||||
func LnListen(args []string) error {
|
||||
|
||||
fmt.Printf("will start TCP port listener\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
// For testing. Syntax: lnhi hello world
|
||||
func LnChat(args []string) error {
|
||||
|
||||
var chat string
|
||||
for _, s := range args {
|
||||
chat += s + " "
|
||||
}
|
||||
// msg := append([]byte{lnwire.MSGID_TEXTCHAT}, []byte(chat)...)
|
||||
|
||||
fmt.Printf("will send text message: %s\n", chat)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user