Skip to content
This repository has been archived by the owner on Jun 4, 2018. It is now read-only.

Commit

Permalink
Allow removal of the public passphrase.
Browse files Browse the repository at this point in the history
Once removed, it will no longer be prompted for.
  • Loading branch information
jrick committed May 11, 2017
1 parent 3ad89b2 commit 04bf974
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
29 changes: 28 additions & 1 deletion Paymetheus.Rpc/WalletClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Paymetheus.Rpc
{
public sealed class WalletClient : IDisposable
{
private static readonly SemanticVersion RequiredRpcServerVersion = new SemanticVersion(4, 9, 0);
private static readonly SemanticVersion RequiredRpcServerVersion = new SemanticVersion(4, 9, 2);

public static void Initialize()
{
Expand Down Expand Up @@ -270,6 +270,33 @@ public async Task ImportScriptAsync(byte[] scriptBytes, bool rescan, int scanFro
await client.ImportScriptAsync(request, cancellationToken: _tokenSource.Token);
}

private async Task ChangePassphrase(ChangePassphraseRequest.Types.Key which, string oldPassphrase, string newPassphrase)
{
if (oldPassphrase == null)
throw new ArgumentNullException(nameof(oldPassphrase));
if (newPassphrase == null)
throw new ArgumentNullException(nameof(newPassphrase));

var client = new WalletService.WalletServiceClient(_channel);
var request = new ChangePassphraseRequest
{
Key = which,
OldPassphrase = ByteString.CopyFromUtf8(oldPassphrase),
NewPassphrase = ByteString.CopyFromUtf8(newPassphrase),
};
await client.ChangePassphraseAsync(request, cancellationToken: _tokenSource.Token);
}

public Task ChangePrivatePassphrase(string oldPassphrase, string newPassphrase)
{
return ChangePassphrase(ChangePassphraseRequest.Types.Key.Private, oldPassphrase, newPassphrase);
}

public Task ChangePublicPassphrase(string oldPassphrase, string newPassphrase)
{
return ChangePassphrase(ChangePassphraseRequest.Types.Key.Public, oldPassphrase, newPassphrase);
}

public async Task RenameAccountAsync(Account account, string newAccountName)
{
if (newAccountName == null)
Expand Down
7 changes: 7 additions & 0 deletions Paymetheus/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>

<Style x:Key="wizardCheckBoxStyle" TargetType="CheckBox">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="0 6 0 12"/>
</Style>

<Style x:Key="shellDescriptionTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="#FF0C1E3E"/>
Expand Down
10 changes: 5 additions & 5 deletions Paymetheus/PublicPassphrasePromptView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
</ResourceDictionary>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Height="185" Width="480">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="480">
<TextBlock Name="PublicPassphraseTextBlock" Text="Public Passphrase" VerticalAlignment="Top" HorizontalAlignment="left" Width="480" Height="40" Padding="0 0 0 0" Style="{StaticResource wizardMediumHeaderTextBlockStyle}"/>
<Label Margin="0 0 0 0">
<TextBlock Width="480" Margin="-5 -5 0 0" TextWrapping="Wrap" HorizontalAlignment="Left" TextAlignment="Left" Style="{StaticResource wizardDefaultTextBlockStyle}">
A public passphrase is only required to open the wallet when the optional
public data encryption feature is enabled.
Simply continue by opening the wallet with an empty passphrase if public
data encryption is disabled.
Some public data in the wallet has been encrypted. Please enter your public passphrase below to continue.
<LineBreak/>
Public data encryption can be optionally removed to avoid this prompt in the future.
</TextBlock>
</Label>
<CheckBox Content="Remove public data encryption" IsChecked="{Binding RemovePublicEncryption}" Style="{StaticResource wizardCheckBoxStyle}"/>
<Border Padding="5" CornerRadius="5" Background="White" Height="35" Width="480" VerticalAlignment="Top" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
<PasswordBox x:Name="PasswordBoxPublicPassphrase" BorderThickness="0" Background="{x:Null}" PasswordChanged="PasswordBoxPublicPassphrase_PasswordChanged"/>
</Border>
Expand Down
5 changes: 5 additions & 0 deletions Paymetheus/ViewModels/StartupWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ public PromptPublicPassphraseDialog(StartupWizard wizard) : base(wizard)
}

public string PublicPassphrase { get; set; } = "";
public bool RemovePublicEncryption { get; set; } = false;

public DelegateCommand OpenWalletCommand { get; }
private async void OpenWallet()
Expand All @@ -415,6 +416,10 @@ private async void OpenWallet()
{
OpenWalletCommand.Executable = false;
await App.Current.Synchronizer.WalletRpcClient.OpenWallet(PublicPassphrase);
if (RemovePublicEncryption)
{
await App.Current.Synchronizer.WalletRpcClient.ChangePublicPassphrase(PublicPassphrase, "");
}
Wizard.CurrentDialog = new OpenExistingWalletActivityProgress(Wizard);
}
catch (RpcException ex) when (ex.Status.StatusCode == StatusCode.InvalidArgument)
Expand Down

0 comments on commit 04bf974

Please sign in to comment.