public async Task StartBtcdRpc(BtcdRpcOptions options) { var certificateTask = ReadFileAsync(options.CertificatePath); var client = WalletLoaderService.NewClient(_channel); var request = new StartBtcdRpcRequest { NetworkAddress = options.NetworkAddress, Username = options.RpcUser, Password = ByteString.CopyFromUtf8(options.RpcPassword), Certificate = ByteString.CopyFrom(await certificateTask), }; await client.StartBtcdRpcAsync(request, cancellationToken: _tokenSource.Token); }
private async void Connect() { try { ConnectCommand.Executable = false; if (string.IsNullOrWhiteSpace(BtcdNetworkAddress)) { MessageBox.Show("Network address is required"); return; } if (string.IsNullOrWhiteSpace(BtcdRpcUsername)) { MessageBox.Show("RPC username is required"); return; } if (BtcdRpcPassword.Length == 0) { MessageBox.Show("RPC password may not be empty"); return; } if (!File.Exists(BtcdCertificateFile)) { MessageBox.Show("Certificate file not found"); return; } var btcdOptions = new BtcdRpcOptions(BtcdNetworkAddress, BtcdRpcUsername, BtcdRpcPassword, BtcdCertificateFile); try { await App.Current.WalletRpcClient.StartBtcdRpc(btcdOptions); } catch (Exception ex) when (ErrorHandling.IsTransient(ex) || ErrorHandling.IsClientError(ex)) { MessageBox.Show("Unable to start btcd RPC.\n\nCheck connection settings and try again.", "Error"); MessageBox.Show(ex.Message); return; } var walletExists = await App.Current.WalletRpcClient.WalletExistsAsync(); if (!walletExists) { _wizard.CurrentDialog = new DisplaySeedDialog(Wizard); } else { // TODO: Determine whether the public encryption is enabled and a prompt for the // public passphrase prompt is needed before the wallet can be opened. If it // does not, then the wallet can be opened directly here instead of creating // another dialog. _wizard.CurrentDialog = new PromptPublicPassphraseDialog(Wizard); //await _walletClient.OpenWallet("public"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } finally { ConnectCommand.Executable = true; } }