Add txn broadcast logic
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
+using System;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using NBitcoin;
using ReactiveUI;
+using Splat;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionBuilding;
+using WalletWasabi.Blockchain.Transactions;
+using WalletWasabi.CoinJoin.Client.Clients.Queuing;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Fluent.ViewModels.Dialogs;
using WalletWasabi.Fluent.ViewModels.Navigation;
+using WalletWasabi.Gui;
+using WalletWasabi.Gui.Controls.WalletExplorer;
+using WalletWasabi.Gui.Models.StatusBarStatuses;
+using WalletWasabi.Gui.ViewModels;
+using WalletWasabi.Hwi;
+using WalletWasabi.Hwi.Exceptions;
using WalletWasabi.Userfacing;
using WalletWasabi.Wallets;
@@ -76,9 +87,43 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
if (passwordValid)
{
- // dequeue any joining coins.
+ // Dequeue any coin-joining coins.
+ await wallet.ChaumianClient.DequeueAllCoinsFromMixAsync(DequeueReason.TransactionBuilding);
// Broadcast transaction.
+ var signedTransaction = _transaction.Transaction;
+
+ // If it's a hardware wallet and still has a private key then it's password.
+ if (wallet.KeyManager.IsHardwareWallet && !_transaction.Signed)
+ {
+ try
+ {
+ var client = new HwiClient(wallet.Network);
+
+ using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3));
+ PSBT signedPsbt = null;
+ try
+ {
+ signedPsbt = await client.SignTxAsync(wallet.KeyManager.MasterFingerprint.Value,
+ _transaction.Psbt, cts.Token);
+ }
+ catch (HwiException ex) when (ex.ErrorCode is not HwiErrorCode.ActionCanceled)
+ {
+ await PinPadViewModel.UnlockAsync();
+ signedPsbt = await client.SignTxAsync(wallet.KeyManager.MasterFingerprint.Value,
+ _transaction.Psbt, cts.Token);
+ }
+
+ signedTransaction = signedPsbt.ExtractSmartTransaction(_transaction.Transaction);
+ }
+ catch (Exception _)
+ {
+ // probably throw something here?
+ }
+ }
+
+ await Locator.Current.GetService<Global>().TransactionBroadcaster
+ .SendTransactionAsync(signedTransaction);
}
else
{

Add txn broadcast logic