2015-12-17 03:42:52 +03:00
|
|
|
package main
|
|
|
|
|
2015-12-30 03:23:27 +03:00
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"net"
|
2015-12-30 05:59:16 +03:00
|
|
|
"os"
|
2015-12-30 03:23:27 +03:00
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/grpclog"
|
|
|
|
|
|
|
|
"li.lan/labs/plasma/lnwallet"
|
|
|
|
"li.lan/labs/plasma/rpcprotos"
|
|
|
|
)
|
|
|
|
|
2015-12-17 03:42:52 +03:00
|
|
|
//lightning == terrestrial plasma
|
|
|
|
|
2015-12-30 03:23:27 +03:00
|
|
|
var (
|
|
|
|
rpcport = flag.Int("port", 10000, "The port for the rpc server")
|
|
|
|
)
|
|
|
|
|
2015-12-17 03:42:52 +03:00
|
|
|
func main() {
|
2015-12-30 03:23:27 +03:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
// Create, and start the lnwallet, which handles the core payment channel
|
|
|
|
// logic, and exposes control via proxy state machines.
|
|
|
|
// TODO(roasbeef): accept config via cli flags, move to real config file
|
|
|
|
// afterwards
|
|
|
|
config := &lnwallet.Config{PrivatePass: []byte("hello"), DataDir: "test_wal"}
|
|
|
|
lnwallet, err := lnwallet.NewLightningWallet(config)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("unable to create wallet: %v\n", err)
|
2015-12-30 05:59:16 +03:00
|
|
|
os.Exit(1)
|
2015-12-30 03:23:27 +03:00
|
|
|
}
|
|
|
|
if err := lnwallet.Startup(); err != nil {
|
|
|
|
fmt.Printf("unable to start wallet: %v\n", err)
|
2015-12-30 05:59:16 +03:00
|
|
|
os.Exit(1)
|
2015-12-30 03:23:27 +03:00
|
|
|
}
|
|
|
|
|
2015-12-30 05:59:16 +03:00
|
|
|
fmt.Println("wallet open")
|
|
|
|
|
2015-12-30 03:23:27 +03:00
|
|
|
// Initialize, and register our implementation of the gRPC server.
|
|
|
|
var opts []grpc.ServerOption
|
|
|
|
rpcServer := newRpcServer(lnwallet)
|
|
|
|
grpcServer := grpc.NewServer(opts...)
|
|
|
|
lnrpc.RegisterLightningServer(grpcServer, rpcServer)
|
|
|
|
|
|
|
|
// Finally, start the grpc server listening for HTTP/2 connections.
|
|
|
|
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *rpcport))
|
|
|
|
if err != nil {
|
|
|
|
grpclog.Fatalf("failed to listen: %v", err)
|
|
|
|
fmt.Printf("failed to listen: %v", err)
|
2015-12-30 05:59:16 +03:00
|
|
|
os.Exit(1)
|
2015-12-30 03:23:27 +03:00
|
|
|
}
|
|
|
|
grpcServer.Serve(lis)
|
2015-12-17 03:42:52 +03:00
|
|
|
}
|