Implement Import Transaction to Broadcaster
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterView.xaml
<TextBlock DockPanel.Dock="Top" Text="PSBT or Transaction Hex" FontWeight="Bold" />
<DockPanel DockPanel.Dock="Bottom" LastChildFill="True">
+
<Button DockPanel.Dock="Right" Command="{Binding BroadcastTransactionCommand}">
<StackPanel Orientation="Horizontal">
<controls:Spinner Height="20" Width="20" IsVisible="{Binding IsBusy}" Margin="0 0 8 0" />
</StackPanel>
</Button>
+ <Button Margin="0 0 10 0" DockPanel.Dock="Right" Command="{Binding ImportTransactionCommand}" Content="Import Transaction" />
+
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding WarningMessage}" Classes="warningMessage" />
<TextBlock Text="{Binding SuccessMessage}" Classes="validationMessage" Foreground="Green" />
</StackPanel>
</DockPanel>
- <controls:MultiTextBox Text="{Binding TransactionString}" PasteOnClick="True" IsReadOnly="{Binding IsBusy}" Margin="0 8" Watermark="Click here to copy from clipboard!" TextWrapping="Wrap" AcceptsReturn="True" />
+ <controls:MultiTextBox Text="{Binding TransactionString, Mode=TwoWay}" PasteOnClick="True" IsReadOnly="{Binding IsBusy}" Margin="0 8" Watermark="Click here to copy from clipboard!" TextWrapping="Wrap" AcceptsReturn="True" />
</DockPanel>
</Grid>
</controls:GroupBox>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
using Avalonia;
+using Avalonia.Controls;
using AvalonStudio.Documents;
+using AvalonStudio.Extensibility;
using NBitcoin;
using ReactiveUI;
using System;
+using System.IO;
+using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
@@ -23,6 +27,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private CompositeDisposable Disposables { get; set; }
public ReactiveCommand<Unit, Unit> PasteCommand { get; set; }
public ReactiveCommand<Unit, Unit> BroadcastTransactionCommand { get; set; }
+ public ReactiveCommand<Unit, Unit> ImportTransactionCommand { get; set; }
public string TransactionString
{
@@ -68,6 +73,57 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
await OnDoTransactionBroadcastAsync();
});
+ ImportTransactionCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ try
+ {
+ var ofd = new OpenFileDialog();
+ var selected = await ofd.ShowAsync(Application.Current.MainWindow);
+ if (selected != null && selected.Any())
+ {
+ var path = selected.First();
+ var psbtBytes = await File.ReadAllBytesAsync(path);
+ PSBT psbt = null;
+ Transaction transaction = null;
+ try
+ {
+ psbt = PSBT.Load(psbtBytes, Global.Network);
+ }
+ catch
+ {
+ var text = await File.ReadAllTextAsync(path);
+ try
+ {
+ psbt = PSBT.Parse(text, Global.Network);
+ }
+ catch
+ {
+ transaction = Transaction.Parse(text, Global.Network);
+ }
+ }
+
+ if (psbt != null)
+ {
+ if (!psbt.IsAllFinalized())
+ {
+ psbt.Finalize();
+ }
+
+ TransactionString = psbt.ToBase64();
+ }
+ else
+ {
+ TransactionString = transaction.ToHex();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ SetWarningMessage(ex.ToTypeMessageString());
+ Logging.Logger.LogError<TransactionBroadcasterViewModel>(ex);
+ }
+ }, outputScheduler: RxApp.MainThreadScheduler);
+
Observable.Merge(PasteCommand.ThrownExceptions)
.Merge(BroadcastTransactionCommand.ThrownExceptions)
.Subscribe(OnException);

Implement Import Transaction to Broadcaster