quick action for txn broadcast
MODIFY
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
WalletWasabi.Fluent/Helpers/TransactionHelpers.cs
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Threading.Tasks;
using NBitcoin;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Blockchain.TransactionOutputs;
+using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Fluent.ViewModels.Wallets.Send;
+using WalletWasabi.Models;
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.PayJoin;
@@ -55,5 +59,36 @@ namespace WalletWasabi.Fluent.Helpers
isPayJoin ? transactionInfo.PayJoinClient : null);
}
+
+ public static async Task<SmartTransaction> ParseTransactionAsync(string path, Network network)
+ {
+ var psbtBytes = await File.ReadAllBytesAsync(path);
+ PSBT psbt;
+
+ try
+ {
+ psbt = PSBT.Load(psbtBytes, network);
+ }
+ catch
+ {
+ var text = await File.ReadAllTextAsync(path);
+ text = text.Trim();
+ try
+ {
+ psbt = PSBT.Parse(text, network);
+ }
+ catch
+ {
+ return new SmartTransaction(Transaction.Parse(text, network), Height.Unknown);
+ }
+ }
+
+ if (!psbt.IsAllFinalized())
+ {
+ psbt.Finalize();
+ }
+
+ return psbt.ExtractSmartTransaction();
+ }
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/TransactionBroadcasting/LoadTransactionViewModel.cs
WalletWasabi.Fluent/ViewModels/TransactionBroadcasting/LoadTransactionViewModel.cs
@@ -46,7 +46,7 @@ namespace WalletWasabi.Fluent.ViewModels.TransactionBroadcasting
var path = await FileDialogHelper.ShowOpenFileDialogAsync("Import Transaction", new[] { "psbt", "*" });
if (path is { })
{
- FinalTransaction = await ParseTransactionAsync(path);
+ FinalTransaction = await TransactionHelpers.ParseTransactionAsync(path, Network);
}
}
catch (Exception ex)
@@ -93,36 +93,5 @@ namespace WalletWasabi.Fluent.ViewModels.TransactionBroadcasting
public ICommand PasteCommand { get; }
public ICommand ImportTransactionCommand { get; }
-
- private async Task<SmartTransaction> ParseTransactionAsync(string path)
- {
- var psbtBytes = await File.ReadAllBytesAsync(path);
- PSBT psbt;
-
- try
- {
- psbt = PSBT.Load(psbtBytes, Network);
- }
- catch
- {
- var text = await File.ReadAllTextAsync(path);
- text = text.Trim();
- try
- {
- psbt = PSBT.Parse(text, Network);
- }
- catch
- {
- return new SmartTransaction(Transaction.Parse(text, Network), Height.Unknown);
- }
- }
-
- if (!psbt.IsAllFinalized())
- {
- psbt.Finalize();
- }
-
- return psbt.ExtractSmartTransaction();
- }
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/HardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/HardwareWalletViewModel.cs
using System;
using System.Reactive.Disposables;
using ReactiveUI;
+using WalletWasabi.Fluent.Helpers;
+using WalletWasabi.Fluent.ViewModels.TransactionBroadcasting;
+using WalletWasabi.Logging;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets
@@ -10,6 +13,24 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
internal HardwareWalletViewModel(Wallet wallet) : base(wallet)
{
PsbtWorkflowEnabled = Services.UiConfig.UsePsbtWorkflow;
+
+ BroadcastPsbtCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ try
+ {
+ var path = await FileDialogHelper.ShowOpenFileDialogAsync("Import Transaction", new[] { "psbt", "*" });
+ if (path is { })
+ {
+ var txn = await TransactionHelpers.ParseTransactionAsync(path, wallet.Network);
+ Navigate(NavigationTarget.DialogScreen).To(new BroadcastTransactionViewModel(wallet.Network, txn));
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex);
+ await ShowErrorAsync(Title, ex.ToUserFriendlyString(), "It was not possible to load the transaction.");
+ }
+ });
}
protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -186,6 +186,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
public ICommand SendCommand { get; }
+ public ICommand BroadcastPsbtCommand { get; set; }
+
public ICommand ReceiveCommand { get; }
public ICommand WalletInfoCommand { get; }

MODIFY
WalletWasabi.Fluent/Views/Wallets/WalletView.axaml
WalletWasabi.Fluent/Views/Wallets/WalletView.axaml
<TextBlock Text="Send" />
</StackPanel>
</Button>
+ <Button Classes="function" Command="{Binding BroadcastPsbtCommand}" IsVisible="{Binding PsbtWorkflowEnabled}">
+ <StackPanel Orientation="Horizontal" Spacing="15">
+ <PathIcon Data="{StaticResource live_regular}" />
+ <TextBlock Text="Broadcast" />
+ </StackPanel>
+ </Button>
<Button Classes="function" Command="{Binding ReceiveCommand}">
<StackPanel Orientation="Horizontal" Spacing="15">
<PathIcon Data="{StaticResource wallet_action_receive}" />

quick action for txn broadcast