Example #1
0
        // ReSharper disable once UnusedParameter.Local
        private void BwListCompleted <TMessage, TResponse>(object sender, RunWorkerCompletedEventArgs e,
                                                           TableSheet <TMessage> tableSheet) where TMessage : IMessage where TResponse : IMessage
        {
            if (e.Result == null)
            {
                Utilities.RemoveLoadingMark(tableSheet.Ws);
                if (e.Error != null && e.Error.GetType() == typeof(RpcException))
                {
                    _excelAddIn.ConnectSheet.DisplayRpcError((RpcException)e.Error);
                    _excelAddIn.ConnectSheet.Ws.Activate();
                }
                return;
            }

            try
            {
                var response        = (TResponse)e.Result;
                var fieldDescriptor = response.Descriptor.Fields.InDeclarationOrder().FirstOrDefault(f => f.IsRepeated);
                if (fieldDescriptor == null)
                {
                    return;
                }

                var data = (RepeatedField <TMessage>)fieldDescriptor.Accessor.GetValue(response);
                tableSheet.Update(data);
            }
            catch (System.Reflection.TargetInvocationException exception)
            {
                var rpcException = (RpcException)exception.InnerException;
                _excelAddIn.ConnectSheet.DisplayError("Connect error", rpcException?.Status.Detail);
                _excelAddIn.ConnectSheet.Ws.Activate();
            }
        }
        public void InitializePaymentRequest()
        {
            Ws.Activate();
            _payReqLabelCell           = Ws.Cells[StartRow, StartColumn];
            _payReqLabelCell.Value2    = "Payment request:";
            _payReqLabelCell.Font.Bold = true;
            _payReqLabelCell.Columns.AutoFit();

            _payReqInputCell = Ws.Cells[StartRow, StartColumn + 1];
            _payReqInputCell.Interior.Color = Color.AliceBlue;
            Formatting.WideTableColumn(_payReqInputCell);

            _payReqRange = Ws.Range[_payReqLabelCell, _payReqInputCell];
            Formatting.UnderlineBorder(_payReqRange);

            Ws.Change += WsOnChangeParsePayReq;

            PaymentRequestTable = new VerticalTableSheet <PayReq>(Ws, LApp, PayReq.Descriptor);
            PaymentRequestTable.SetupVerticalTable("Decoded Payment Request", StartRow + 2);

            PotentialRoutesTable = new TableSheet <Route>(Ws, LApp, Route.Descriptor, "hops");
            PotentialRoutesTable.SetupTable("Potential Routes", MaxRoutes, StartRow = PaymentRequestTable.EndRow + 2);

            var    sendPaymentButtonRow = PotentialRoutesTable.EndRow + 4;
            Button sendPaymentButton    = Utilities.CreateButton("sendPayment", Ws, Ws.Cells[sendPaymentButtonRow, StartColumn], "Send Payment");

            sendPaymentButton.Click += SendPaymentButtonOnClick;
            _errorData = Ws.Cells[sendPaymentButtonRow + 3, StartColumn + 1];

            _sendStatusRange             = Ws.Cells[sendPaymentButtonRow + 3, StartColumn];
            _sendStatusRange.Font.Italic = true;

            Button clearPaymentInfoButton = Utilities.CreateButton("clearPaymentInfo", Ws, Ws.Cells[sendPaymentButtonRow + 3, StartColumn], "Clear");

            clearPaymentInfoButton.Click += ClearPaymentInfoButtonOnClick;

            var paymentResponseDataStartRow = sendPaymentButtonRow + 5;

            _paymentPreimageLabel             = Ws.Cells[paymentResponseDataStartRow, StartColumn];
            _paymentPreimageLabel.Value2      = "Proof of Payment";
            _paymentPreimageLabel.Font.Italic = true;
            Formatting.WideTableColumn(_paymentPreimageLabel);

            _paymentPreimageCell = Ws.Cells[paymentResponseDataStartRow, StartColumn + 1];
            _paymentPreimageCell.Interior.Color = Color.PaleGreen;
            _paymentPreimageCell.RowHeight      = 14.3;
            _paymentPreimageCell.WrapText       = true;

            RouteTakenTable = new VerticalTableSheet <Route>(Ws, LApp, Route.Descriptor, new List <string> {
                "hops"
            });
            RouteTakenTable.SetupVerticalTable("Payment Summary", paymentResponseDataStartRow + 3);

            HopTable = new TableSheet <Hop>(Ws, LApp, Hop.Descriptor, "chan_id");
            HopTable.SetupTable("Route", 4, RouteTakenTable.EndRow + 2);

            _payReqInputCell.Columns.ColumnWidth = PayReqColumnWidth;
            Utilities.RemoveLoadingMark(Ws);
        }
        public PeersSheet(Worksheet ws, AsyncLightningApp lApp)
        {
            LApp = lApp;

            PeersForm  = new MessageForm <ConnectPeerRequest, ConnectPeerResponse>(ws, LApp, LApp.LndClient.ConnectPeer, ConnectPeerRequest.Descriptor, "Connect to a peer");
            PeersTable = new TableSheet <Peer>(ws, LApp, Peer.Descriptor, "pub_key");
            PeersTable.SetupTable("Peers", startRow: PeersForm.EndRow + 2);

            ws.Change += WsOnChange;
        }
Example #4
0
        public void SetupWorkbook(Workbook wb)
        {
            Wb   = wb;
            LApp = new AsyncLightningApp(this);

            CreateSheet(SheetNames.Mnemonic);
            MnemonicSheet = new MnemonicSheet(Wb.Sheets[SheetNames.Mnemonic]);

            CreateSheet(SheetNames.Connect);
            ConnectSheet = new ConnectSheet(Wb.Sheets[SheetNames.Connect], LApp);
            ConnectSheet.PopulateConfig();

            CreateSheet(SheetNames.Peers);
            PeersSheet = new PeersSheet(Wb.Sheets[SheetNames.Peers], LApp);

            CreateSheet(SheetNames.Balances);
            BalancesSheet = new BalancesSheet(Wb.Sheets[SheetNames.Balances], LApp);

            CreateSheet(SheetNames.Transactions);
            TransactionsSheet = new TransactionsSheet(Wb.Sheets[SheetNames.Transactions], LApp);

            CreateSheet(SheetNames.Channels);
            ChannelsSheet = new ChannelsSheet(Wb.Sheets[SheetNames.Channels], LApp);

            CreateSheet(SheetNames.Payments);
            PaymentsSheet = new TableSheet <Payment>(Wb.Sheets[SheetNames.Payments], LApp, Payment.Descriptor, "payment_hash");
            PaymentsSheet.SetupTable("Payments");

            CreateSheet(SheetNames.SendPayment);
            SendPaymentSheet = new SendPaymentSheet(Wb.Sheets[SheetNames.SendPayment], LApp);
            SendPaymentSheet.InitializePaymentRequest();

            CreateSheet(SheetNames.NodeLog);
            NodesSheet = new NodeSheet(Wb.Sheets[SheetNames.NodeLog]);

            MarkLightningPowerWorkbook();
            ConnectSheet.Ws.Activate();

            Application.SheetActivate += Workbook_SheetActivate;
        }
        public ChannelsSheet(Worksheet ws, AsyncLightningApp lApp)
        {
            LApp            = lApp;
            OpenChannelForm = new MessageForm <OpenChannelRequest, ChannelPoint>(ws, lApp, lApp.LndClient.OpenChannel,
                                                                                 OpenChannelRequest.Descriptor, "Open a new channel");

            PendingOpenChannelsTable = new TableSheet <PendingOpenChannel>(ws, lApp, PendingOpenChannel.Descriptor, "channel_point", true);
            PendingOpenChannelsTable.SetupTable("Pending open", 5, OpenChannelForm.EndRow + 2);

            OpenChannelsTable = new TableSheet <Channel>(ws, lApp, Channel.Descriptor, "chan_id");
            OpenChannelsTable.SetupTable("Open", 10, PendingOpenChannelsTable.EndRow + 2);

            PendingClosingChannelsTable = new TableSheet <ClosedChannel>(ws, lApp, ClosedChannel.Descriptor, "channel_point", true);
            PendingClosingChannelsTable.SetupTable("Pending closing", 5, OpenChannelsTable.EndRow + 2, StartColumn);

            PendingForceClosingChannelsTable = new TableSheet <ForceClosedChannel>(ws, lApp, ForceClosedChannel.Descriptor, "channel_point", true);
            PendingForceClosingChannelsTable.SetupTable("Pending force closing", 5, PendingClosingChannelsTable.EndRow + 2, StartColumn);

            WaitingCloseChannelsTable = new TableSheet <WaitingCloseChannel>(ws, lApp, WaitingCloseChannel.Descriptor, "channel_point", true);
            WaitingCloseChannelsTable.SetupTable("Waiting for closing transaction to confirm", 5, PendingForceClosingChannelsTable.EndRow + 2, StartColumn);

            ClosedChannelsTable = new TableSheet <ChannelCloseSummary>(ws, lApp, ChannelCloseSummary.Descriptor, "chan_id");
            ClosedChannelsTable.SetupTable("Closed", 5, WaitingCloseChannelsTable.EndRow + 2);

            EndRow    = WaitingCloseChannelsTable.EndRow;
            EndColumn = new List <int>
            {
                PendingOpenChannelsTable.EndColumn,
                PendingClosingChannelsTable.EndColumn,
                PendingForceClosingChannelsTable.EndColumn,
                WaitingCloseChannelsTable.EndColumn,
                ClosedChannelsTable.EndColumn,
                OpenChannelsTable.EndColumn
            }.Max();

            ws.Change += WsOnChange;
        }
 public TransactionsSheet(Worksheet ws, AsyncLightningApp lApp)
 {
     SendCoinsForm     = new MessageForm <SendCoinsRequest, SendCoinsResponse>(ws, lApp, lApp.LndClient.SendCoins, SendCoinsRequest.Descriptor, "Send on-chain bitcoins");
     TransactionsTable = new TableSheet <Transaction>(ws, lApp, Transaction.Descriptor, "tx_hash");
     TransactionsTable.SetupTable("Transactions", startRow: SendCoinsForm.EndRow + 2);
 }