diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs index 3cd37f7..8ad21b3 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/Smartifier.cs @@ -149,7 +149,8 @@ public class Smartifier utxoLabels.TryGetValue(coin.OutPoint, out var labels); var unsmartTx = await CachedTransactions[coin.OutPoint.Hash]; var pubKey = DerivationScheme.GetChild(coin.KeyPath).GetExtPubKeys().First().PubKey; - var kp = _accountKeyPath.Derive(coin.KeyPath).KeyPath; + //if there is no account key path, it most likely means this is a watch only wallet. Fake the key path + var kp = _accountKeyPath?.Derive(coin.KeyPath).KeyPath ?? new KeyPath(0); var hdPubKey = new HdPubKey(pubKey, kp, new SmartLabel(labels.labels ?? new HashSet()), current == 1 ? KeyState.Clean : KeyState.Used); diff --git a/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs b/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs index 59ad6fd..ab3c2f0 100644 --- a/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs +++ b/Plugins/BTCPayServer.Plugins.Wabisabi/WalletProvider.cs @@ -93,26 +93,30 @@ public class WalletProvider : PeriodicRunner,IWalletProvider var enabled = store.GetEnabledPaymentIds(_networkProvider).Contains(paymentMethod.PaymentId); var derivationStrategy = paymentMethod.AccountDerivation; BTCPayKeyChain keychain; + var accountKeyPath = paymentMethod.AccountKeySettings.FirstOrDefault()?.GetRootedKeyPath(); if (isHotWallet && enabled) { var masterKey = await explorerClient.GetMetadataAsync(derivationStrategy, WellknownMetadataKeys.MasterHDKey); var accountKey = await explorerClient.GetMetadataAsync(derivationStrategy, WellknownMetadataKeys.AccountHDKey); - var accountKeyPath = await explorerClient.GetMetadataAsync(derivationStrategy, + var accountKeyPath2 = await explorerClient.GetMetadataAsync(derivationStrategy, WellknownMetadataKeys.AccountKeyPath); - + accountKeyPath = accountKeyPath2 ?? accountKeyPath; + var smartifier = new Smartifier(_serviceProvider.GetRequiredService(), + explorerClient, derivationStrategy, name, UtxoLocker, accountKeyPath); if (masterKey is null || accountKey is null || accountKeyPath is null) { - - keychain = new BTCPayKeyChain(explorerClient, derivationStrategy, null, null, null); + keychain = new BTCPayKeyChain(explorerClient, derivationStrategy, null, null, smartifier); }else - keychain = new BTCPayKeyChain(explorerClient, derivationStrategy, masterKey, accountKey, new Smartifier(_serviceProvider.GetRequiredService(),explorerClient, derivationStrategy, name, UtxoLocker, accountKeyPath)); + keychain = new BTCPayKeyChain(explorerClient, derivationStrategy, masterKey, accountKey, smartifier); } else { - keychain = new BTCPayKeyChain(explorerClient, derivationStrategy, null, null, null); + var smartifier = new Smartifier(_serviceProvider.GetRequiredService(), explorerClient, + derivationStrategy, name, UtxoLocker, accountKeyPath); + keychain = new BTCPayKeyChain(explorerClient, derivationStrategy, null, null, smartifier); }