Files
BTCPayServerPlugins/Plugins/BTCPayServer.Plugins.Wabisabi/LocalisedUTXOLocker.cs
2023-01-16 13:13:18 +01:00

33 lines
852 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Payments.PayJoin;
using NBitcoin;
namespace BTCPayServer.Plugins.Wabisabi;
public class LocalisedUTXOLocker: IUTXOLocker
{
private HashSet<OutPoint> _locked = new();
public Task<bool> TryLock(OutPoint outpoint)
{
return Task.FromResult(_locked.Add(outpoint));
}
public Task<bool> TryUnlock(params OutPoint[] outPoints)
{
return Task.FromResult(_locked.RemoveWhere( outPoints.Contains) > 0);
}
public Task<bool> TryLockInputs(OutPoint[] outPoints)
{
throw new NotImplementedException();
}
public Task<HashSet<OutPoint>> FindLocks(OutPoint[] outpoints)
{
return Task.FromResult(_locked.Where(point => outpoints.Contains(point)).ToHashSet());
}
}