func optionMenu(lnClient *lndwrapper.Lnd, addressDB *ldrlib.DB) {

	//Present a menu to the User
	for true {
		fmt.Println("====================================================")
		fmt.Println("Welcome to the Lightning Distributed Routing Client")
		fmt.Println("====================================================")
		fmt.Print("\nThis software is still in its early stages of development. Use it at your own risk.\n\n")
		fmt.Println("1 - Find Route Auto")
		fmt.Println("2 - Find Route Manual")
		fmt.Println("3 - Connect to Peer")
		fmt.Println("4 - Send Payment")
		fmt.Println("5 - Print Routing Table")
		fmt.Println("6 - Find routing node lightning's public key")
		fmt.Println("0 - Exit")

		//Read from command line
		reader := bufio.NewReader(os.Stdin)
		readText, _ := reader.ReadString('\n')
		menuOptionString := strings.TrimSuffix(readText, "\n")
		menuOption, err := strconv.Atoi(menuOptionString)
		if err != nil {
			log.Fatal(err)
		}

		switch menuOption {
		case 1:

			fmt.Println("Receiver's LDR address:")
			address := getValidAddressFromUser()
			route, err := ldrlib.GetRouteAuto(lnClient, addressDB, address)
			if err != nil {
				log.Fatal(err)
			}
			ldrlib.PrintRoute(route)
		case 2:
			fmt.Println("Receiver's LDR address:")
			address := getValidAddressFromUser()
			fmt.Println("Receiver's IP address: (e.g. '192.1.3.56:8695)")
			fmt.Println("PS: 8695 is the default port.")
			readText, _ = reader.ReadString('\n')
			ipAddress := strings.TrimSuffix(readText, "\n")
			route, err := ldrlib.GetRouteManual(lnClient, addressDB, address, ipAddress)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Println("Got Route!")
			ldrlib.PrintRoute(route)
		case 3:
			//Get an address from the user
			fmt.Println("Enter the IP 'address:port' of the peer you're trying to connect to, e.g. '192.1.3.56:8695")
			fmt.Println("PS: 8695 is the default port.")
			readText, _ = reader.ReadString('\n')
			address := strings.TrimSuffix(readText, "\n")
			ldrlib.ConnectToPeer(lnClient, addressDB, address)
		case 4:
		case 5:
			fmt.Println("Printing routing table")
			addressDB.PrintRoutingTable()
		case 6:
			fmt.Println("LDR address for which you want the associated node's public key:")
			address := getValidAddressFromUser()
			if !addressDB.IsAddressRegistered(address) {
				fmt.Println(address, "is not a registered address")
			} else {
				pubKeyArray := addressDB.GetAddressNode(address)
				fmt.Println(ldrlib.PubKeyArrayToString(pubKeyArray))
			}
		case 0:
			addressDB.SaveRoutingDBToFile()
			os.Exit(0)
		}
	}
}
// Present an option menu to the user
Present an option menu to the user
// Present an option menu to the user
func optionMenu(lnClient *lndwrapper.Lnd, addressDB *ldrlib.DB) {
	for true {
		fmt.Println("====================================================")
		fmt.Println("Welcome to the Lightning Distributed Routing Client")
		fmt.Println("====================================================")
		fmt.Print("\nThis software is still in its early stages of development. Use it at your own risk.\n\n")
		fmt.Println("1 - Find Route Auto")
		fmt.Println("2 - Find Route Manual")
		fmt.Println("3 - Connect to Peer")
		fmt.Println("4 - Send Payment")
		fmt.Println("5 - Print Routing Table")
		fmt.Println("6 - Find routing node lightning's public key")
		fmt.Println("0 - Exit")
		reader := bufio.NewReader(os.Stdin)
		readText, _ := reader.ReadString('\n')
		menuOptionString := strings.TrimSuffix(readText, "\n")
		menuOption, err := strconv.Atoi(menuOptionString)
		if err != nil {
			log.Fatal(err)
		}
		switch menuOption {
		case 1:
			fmt.Println("Receiver's LDR address:")
			address := getValidAddressFromUser()
			route, err := ldrlib.GetRouteAuto(lnClient, addressDB, address)
			if err != nil {
				log.Fatal(err)
			}
			ldrlib.PrintRoute(route)
		case 2:
			fmt.Println("Receiver's LDR address:")
			address := getValidAddressFromUser()
			fmt.Println("Receiver's IP address: (e.g. '192.1.3.56:8695)")
			fmt.Println("PS: 8695 is the default port.")
			readText, _ = reader.ReadString('\n')
			ipAddress := strings.TrimSuffix(readText, "\n")
			route, err := ldrlib.GetRouteManual(lnClient, addressDB, address, ipAddress)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Println("Got Route!")
			ldrlib.PrintRoute(route)
		case 3:
			fmt.Println("Enter the IP 'address:port' of the peer you're trying to connect to, e.g. '192.1.3.56:8695")
			fmt.Println("PS: 8695 is the default port.")
			readText, _ = reader.ReadString('\n')
			address := strings.TrimSuffix(readText, "\n")
			ldrlib.ConnectToPeer(lnClient, addressDB, address)
		case 4:
		case 5:
			fmt.Println("Printing routing table")
			addressDB.PrintRoutingTable()
		case 6:
			fmt.Println("LDR address for which you want the associated node's public key:")
			address := getValidAddressFromUser()
			if !addressDB.IsAddressRegistered(address) {
				fmt.Println(address, "is not a registered address")
			} else {
				pubKeyArray := addressDB.GetAddressNode(address)
				fmt.Println(ldrlib.PubKeyArrayToString(pubKeyArray))
			}
		case 0:
			addressDB.SaveRoutingDBToFile()
			os.Exit(0)
		}
	}
}
func optionMenu ( lnClient * lndwrapper . Lnd , addressDB * ldrlib . DB ) { for true { fmt . Println ( " " ) fmt . Println ( " " ) fmt . Println ( " " ) fmt . Print ( " \n \n \n " ) fmt . Println ( " " ) fmt . Println ( " " ) fmt . Println ( " " ) fmt . Println ( " " ) fmt . Println ( " " ) fmt . Println ( " " ) fmt . Println ( " " ) reader := bufio . NewReader ( os . Stdin ) readText , _ := reader . ReadString ( '\n' ) menuOptionString := strings . TrimSuffix ( readText , " \n " ) menuOption , err := strconv . Atoi ( menuOptionString ) if err != nil { log . Fatal ( err ) } switch menuOption { case 1 : fmt . Println ( " " ) address := getValidAddressFromUser ( ) route , err := ldrlib . GetRouteAuto ( lnClient , addressDB , address ) if err != nil { log . Fatal ( err ) } ldrlib . PrintRoute ( route ) case 2 : fmt . Println ( " " ) address := getValidAddressFromUser ( ) fmt . Println ( " " ) fmt . Println ( " " ) readText , _ = reader . ReadString ( '\n' ) ipAddress := strings . TrimSuffix ( readText , " \n " ) route , err := ldrlib . GetRouteManual ( lnClient , addressDB , address , ipAddress ) if err != nil { log . Fatal ( err ) } fmt . Println ( " " ) ldrlib . PrintRoute ( route ) case 3 : fmt . Println ( " " ) fmt . Println ( " " ) readText , _ = reader . ReadString ( '\n' ) address := strings . TrimSuffix ( readText , " \n " ) ldrlib . ConnectToPeer ( lnClient , addressDB , address ) case 4 : case 5 : fmt . Println ( " " ) addressDB . PrintRoutingTable ( ) case 6 : fmt . Println ( " " ) address := getValidAddressFromUser ( ) if ! addressDB . IsAddressRegistered ( address ) { fmt . Println ( address , " " ) } else { pubKeyArray := addressDB . GetAddressNode ( address ) fmt . Println ( ldrlib . PubKeyArrayToString ( pubKeyArray ) ) } case 0 : addressDB . SaveRoutingDBToFile ( ) os . Exit ( 0 ) } } }
Present an option menu to the user
Present an option menu to the user
//Present a menu to the User //Read from command line //Get an address from the user