import get payjoin client code
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -67,7 +67,14 @@ namespace WalletWasabi.Fluent.ViewModels
global.BitcoinStore.SmartHeaderChain,
global.Synchronizer);
- _walletManagerViewModel = new WalletManagerViewModel(global.WalletManager, global.UiConfig, _global.BitcoinStore, _global.LegalChecker, _global.TransactionBroadcaster);
+ _walletManagerViewModel = new WalletManagerViewModel(
+ _global.WalletManager,
+ _global.UiConfig,
+ _global.Config,
+ _global.BitcoinStore,
+ _global.LegalChecker,
+ _global.TransactionBroadcaster,
+ _global.HttpClientFactory);
_addWalletPage = new AddWalletPageViewModel(
_walletManagerViewModel,

MODIFY
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
WalletWasabi.Fluent/ViewModels/WalletManagerViewModel.cs
@@ -19,6 +19,7 @@ using WalletWasabi.Logging;
using WalletWasabi.Services;
using WalletWasabi.Stores;
using WalletWasabi.Wallets;
+using WalletWasabi.WebClients.Wasabi;
namespace WalletWasabi.Fluent.ViewModels
{
@@ -27,7 +28,9 @@ namespace WalletWasabi.Fluent.ViewModels
private readonly Dictionary<Wallet, WalletViewModelBase> _walletDictionary;
private readonly Dictionary<WalletViewModelBase, List<NavBarItemViewModel>> _walletActionsDictionary;
private readonly ReadOnlyObservableCollection<NavBarItemViewModel> _items;
+ private readonly Config _config;
private readonly TransactionBroadcaster _transactionBroadcaster;
+ private readonly HttpClientFactory _httpClientFactory;
private NavBarItemViewModel? _currentSelection;
[AutoNotify] private WalletViewModelBase? _selectedWallet;
[AutoNotify(SetterModifier = AccessModifier.Private)] private bool _isLoadingWallet;
@@ -36,8 +39,8 @@ namespace WalletWasabi.Fluent.ViewModels
[AutoNotify] private ObservableCollection<WalletViewModelBase> _wallets;
[AutoNotify] private bool _anyWalletStarted;
- public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, BitcoinStore bitcoinStore,
- LegalChecker legalChecker, TransactionBroadcaster broadcaster)
+ public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, Config config, BitcoinStore bitcoinStore,
+ LegalChecker legalChecker, TransactionBroadcaster broadcaster, HttpClientFactory httpClientFactory)
{
WalletManager = walletManager;
BitcoinStore = bitcoinStore;
@@ -47,7 +50,9 @@ namespace WalletWasabi.Fluent.ViewModels
_actions = new ObservableCollection<NavBarItemViewModel>();
_wallets = new ObservableCollection<WalletViewModelBase>();
_loggedInAndSelectedAlwaysFirst = true;
+ _config = config;
_transactionBroadcaster = broadcaster;
+ _httpClientFactory = httpClientFactory;
static Func<WalletViewModelBase, bool> SelectedWalletFilter(WalletViewModelBase? selected)
{
@@ -266,7 +271,7 @@ namespace WalletWasabi.Fluent.ViewModels
if (wallet.KeyManager.IsHardwareWallet || !wallet.KeyManager.IsWatchOnly)
{
- actions.Add(new SendViewModel(walletViewModel, _transactionBroadcaster));
+ actions.Add(new SendViewModel(walletViewModel, _transactionBroadcaster, _config, _httpClientFactory));
}
actions.Add(new ReceiveViewModel(walletViewModel, WalletManager, BitcoinStore));

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -24,11 +24,15 @@ using WalletWasabi.Fluent.Validation;
using WalletWasabi.Fluent.ViewModels.Dialogs;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Navigation;
+using WalletWasabi.Gui;
using WalletWasabi.Gui.Converters;
-using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Models;
+using WalletWasabi.Tor.Http;
using WalletWasabi.Userfacing;
+using WalletWasabi.WebClients.PayJoin;
+using WalletWasabi.WebClients.Wasabi;
+using Constants = WalletWasabi.Helpers.Constants;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
@@ -42,7 +46,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
public partial class SendViewModel : NavBarItemViewModel
{
private readonly WalletViewModel _owner;
+ private readonly Config _config;
+ private readonly HttpClientFactory _httpClientFactory;
private readonly TransactionInfo _transactionInfo;
+
[AutoNotify] private string _to;
[AutoNotify] private decimal _amountBtc;
[AutoNotify] private decimal _exchangeRate;
@@ -63,10 +70,12 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
private bool _updatingCurrentValue;
private double _lastXAxisCurrentValue;
- public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster) : base(NavigationMode.Normal)
+ public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster, Config config, HttpClientFactory httpClientFactory) : base(NavigationMode.Normal)
{
_to = "";
_owner = walletVm;
+ _config = config;
+ _httpClientFactory = httpClientFactory;
_transactionInfo = new TransactionInfo();
_labels = new ObservableCollection<string>();
_lastXAxisCurrentValue = _xAxisCurrentValue;
@@ -179,6 +188,34 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
Navigate().To(new PrivacyControlViewModel(wallet, transactionInfo, broadcaster));
}
+ private IPayjoinClient? GetPayjoinClient()
+ {
+ if (!string.IsNullOrWhiteSpace(_payJoinEndPoint) &&
+ Uri.IsWellFormedUriString(_payJoinEndPoint, UriKind.Absolute))
+ {
+ var payjoinEndPointUri = new Uri(_payJoinEndPoint);
+ if (!_config.UseTor)
+ {
+ if (payjoinEndPointUri.DnsSafeHost.EndsWith(".onion", StringComparison.OrdinalIgnoreCase))
+ {
+ Logger.LogWarning("PayJoin server is an onion service but Tor is disabled. Ignoring...");
+ return null;
+ }
+
+ if (_config.Network == Network.Main && payjoinEndPointUri.Scheme != Uri.UriSchemeHttps)
+ {
+ Logger.LogWarning("PayJoin server is not exposed as an onion service nor https. Ignoring...");
+ return null;
+ }
+ }
+
+ IHttpClient httpClient = _httpClientFactory.NewHttpClient(() => payjoinEndPointUri, isolateStream: false);
+ return new PayjoinClient(payjoinEndPointUri, httpClient);
+ }
+
+ return null;
+ }
+
private TimeSpan CalculateConfirmationTime(double targetBlock)
{
var timeInMinutes = Math.Ceiling(targetBlock) * 10;

import get payjoin client code