mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
* new feature: Wallet Receive Page closes #965 * Conserve addresses by waiting till address is spent before generating each run * fix tests * Filter by cryptocode before matching outpoint * fix build * fix edge case issue * use address in keypathinfo directly * rebase fixes * rebase fixes * remove duplicate code * fix messy condition * fixes * fix e2e * fix
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NBitcoin;
|
|
using NBXplorer.DerivationStrategy;
|
|
using NBXplorer.Models;
|
|
|
|
namespace BTCPayServer.Services.Wallets
|
|
{
|
|
public class WalletReceiveStateService
|
|
{
|
|
private readonly ConcurrentDictionary<WalletId, KeyPathInformation> _walletReceiveState =
|
|
new ConcurrentDictionary<WalletId, KeyPathInformation>();
|
|
|
|
public void Remove(WalletId walletId)
|
|
{
|
|
_walletReceiveState.TryRemove(walletId, out _);
|
|
}
|
|
|
|
public KeyPathInformation Get(WalletId walletId)
|
|
{
|
|
if (_walletReceiveState.ContainsKey(walletId))
|
|
{
|
|
return _walletReceiveState[walletId];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public void Set(WalletId walletId, KeyPathInformation information)
|
|
{
|
|
_walletReceiveState.AddOrReplace(walletId, information);
|
|
}
|
|
|
|
public IEnumerable<KeyValuePair<WalletId, KeyPathInformation>> GetByDerivation(string cryptoCode,
|
|
DerivationStrategyBase derivationStrategyBase)
|
|
{
|
|
return _walletReceiveState.Where(pair =>
|
|
pair.Key.CryptoCode.Equals(cryptoCode, StringComparison.InvariantCulture) &&
|
|
pair.Value.DerivationStrategy == derivationStrategyBase);
|
|
}
|
|
}
|
|
}
|