fix watch-only wallets
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
WalletWasabi/WabiSabi/Client/CoinJoinManager.cs
@@ -433,11 +433,25 @@ public class CoinJoinManager : BackgroundService
/// </summary>
private async Task MarkDestinationsUsedAsync(ImmutableList<Script> outputs)
{
- var hashSet = outputs.ToHashSet();
+ var scripts = outputs.ToHashSet();
var wallets = await WalletProvider.GetWalletsAsync().ConfigureAwait(false);
foreach (var k in wallets)
{
- k.KeyChain.TrySetScriptStates(KeyState.Used, hashSet);
+ var kc = k.KeyChain;
+ var state = KeyState.Used;
+
+ // Watch only wallets have no key chains.
+ if (kc is null && k is Wallet w)
+ {
+ foreach (var hdPubKey in w.KeyManager.GetKeys(key => scripts.Any(key.ContainsScript)))
+ {
+ hdPubKey.SetKeyState(state);
+ }
+ }
+ else
+ {
+ k.KeyChain?.TrySetScriptStates(state, scripts);
+ }
}
}

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinTrackerFactory.cs
WalletWasabi/WabiSabi/Client/CoinJoinTrackerFactory.cs
@@ -42,6 +42,11 @@ public class CoinJoinTrackerFactory
}
}
+ if (wallet.KeyChain is null)
+ {
+ throw new NotSupportedException("Wallet has no key chain.");
+ }
+
var coinJoinClient = new CoinJoinClient(
HttpClientFactory,
wallet.KeyChain,

MODIFY
WalletWasabi/Wallets/IWallet.cs
WalletWasabi/Wallets/IWallet.cs
@@ -12,7 +12,12 @@ public interface IWallet
string Identifier { get; }
bool IsUnderPlebStop { get; }
bool IsMixable { get; }
- IKeyChain KeyChain { get; }
+
+ /// <summary>
+ /// Watch only wallets have no key chains.
+ /// </summary>
+ IKeyChain? KeyChain { get; }
+
IDestinationProvider DestinationProvider { get; }
public int AnonScoreTarget { get; }
public bool ConsolidationMode { get; }

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -42,7 +42,12 @@ public class Wallet : BackgroundService, IWallet
HandleFiltersLock = new AsyncLock();
KeyManager.AssertCleanKeysIndexed();
+
+ if (!KeyManager.IsWatchOnly)
+ {
KeyChain = new KeyChain(KeyManager, Kitchen);
+ }
+
DestinationProvider = new InternalDestinationProvider(KeyManager);
}
@@ -516,7 +521,7 @@ public class Wallet : BackgroundService, IWallet
&& !KeyManager.IsWatchOnly // that are not watch-only wallets
&& Kitchen.HasIngredients;
- public IKeyChain KeyChain { get; }
+ public IKeyChain? KeyChain { get; }
public IDestinationProvider DestinationProvider { get; }
public int AnonScoreTarget => KeyManager.AnonScoreTarget;

fix watch-only wallets