Update NBitcoin w/ changes in GRFilters again
This commit updates the NBitcoin version and makes the required
changes to adapt the code to the new filters version.
MODIFY
WalletWasabi/Backend/Models/FilterModel.cs
WalletWasabi/Backend/Models/FilterModel.cs
@@ -26,11 +26,7 @@ namespace WalletWasabi.Backend.Models
if(Filter != null) // bech found here
{
builder.Append(":");
- builder.Append(Filter.N);
- builder.Append(":");
- builder.Append(Filter.Data.Length);
- builder.Append(":");
- builder.Append(ByteHelpers.ToHex(Filter.Data.ToByteArray()));
+ builder.Append(Filter.ToString());
}
return builder.ToString();
@@ -52,17 +48,11 @@ namespace WalletWasabi.Backend.Models
}
else
{
- var n = int.Parse(parts[1]);
- var fba = new FastBitArray(ByteHelpers.FromHex(parts[3]));
- fba.Length = int.Parse(parts[2]);
-
- var filter = new GolombRiceFilter(fba, n);
-
return new FilterModel
{
BlockHeight = Guard.NotNull(nameof(height), height),
BlockHash = new uint256(parts[0]),
- Filter = filter
+ Filter = GolombRiceFilter.Parse(parts[1])
};
}
}

DELETE
WalletWasabi/ClientSideFilter/README.md
-# Gcs - Golomb compressed set
-
-[![Build Status](https://travis-ci.org/lontivero/Gcs.svg?branch=master)](https://travis-ci.org/lontivero/Gcs)
-
-Library for creating, storing and querying Golomb Compressed Sets (Gcs), a statistical
-compressed data-structure. The idea behind this implementation is using it in a new
-kind of Bitcoin light client, similar to SPV clients, that uses Gcs instead of bloom
-filters.
-
-This projects is based on the [original BIP (Bitcoin Improvement Proposal)](https://github.com/Roasbeef/bips/blob/master/Gcs_light_client.mediawiki)
-and [the Olaoluwa Osuntokun's reference implementation](https://github.com/Roasbeef/btcutil/tree/Gcs/Gcs)
-
-## Privacy considerations
-Using client-side filters (Gcs) instead of server-side filter for a cryptocurrency light wallet improves the user
-privacy given that servers cannot infer (at least no so easily) the transactions in which he is interestd on. This project
-will be used as part of the [privacy-oriented HiddenWallet](https://github.com/nopara73/HiddenWallet) Bitcoin wallet project.
-
-## How to use it
-
-
-```c#
-var cities = new[] { "New York", "Amsterdam", "Paris", "Buenos Aires", "La Habana" }
-var citiesAsByteArray = from city in cities select Encoding.ASCII.GetBytes(city);
-
-// A random key
-var key = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
-
-// The false possitive rate (FPR) is calculated as FPR = 1/(2**P)
-var P = 16
-var filter = GolombRiceFilter.Build(key, P, citiesAsByteArray);
-
-// The filter should match all ther values that were added
-foreach(var city in citiesAsByteArray)
-{
- Assert.IsTrue(filter.Match(city, key));
-}
-
-// The filter should NOT match any extra value
-Assert.IsFalse(filter.Match(Encoding.ASCII.GetBytes("Porto Alegre"), key));
-Assert.IsFalse(filter.Match(Encoding.ASCII.GetBytes("Madrid"), key));
-```
-
-## Support
-
-### [Contributions Spent On](https://github.com/nopara73/HiddenWallet/blob/master/HiddenWallet.Documentation/DonationsSpentOn.md)
-
-bc1q32xe73texphk3cgu33cyw7dajky9u76qltcv6m
-[![QR Code](https://i.imgur.com/8JGnzJ7.png)](https://chainflyer.bitflyer.jp/Address/bc1q32xe73texphk3cgu33cyw7dajky9u76qltcv6m)

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -8,14 +8,6 @@ namespace NBitcoin
{
public static class NBitcoinExtensions
{
- public static byte[] ToByteArray(this FastBitArray me)
- {
- var byteCount = me.Length==0 ? 0 : (me.Length-1)/ 8 + 1;
- var bytes = new byte[byteCount];
- me.CopyTo(bytes, 0);
- return bytes;
- }
-
public static TxoRef ToTxoRef(this OutPoint me) => new TxoRef(me);
public static IEnumerable<TxoRef> ToTxoRefs(this TxInList me)

MODIFY
WalletWasabi/Services/IndexBuilderService.cs
WalletWasabi/Services/IndexBuilderService.cs
@@ -311,15 +311,13 @@ namespace WalletWasabi.Services
}
}
- // https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
- // The parameter k MUST be set to the first 16 bytes of the hash of the block for which the filter
- // is constructed.This ensures the key is deterministic while still varying from block to block.
- var key = block.GetHash().ToBytes().Take(16).ToArray();
-
GolombRiceFilter filter = null;
if (scripts.Count != 0)
{
- filter = GolombRiceFilter.Build(key, scripts.Select(x => x.ToCompressedBytes()));
+ filter = new GolombRiceFilterBuilder()
+ .SetKey(block.GetHash())
+ .AddEntries(scripts.Select(x => x.ToCompressedBytes()))
+ .Build();
}
var filterModel = new FilterModel

MODIFY
WalletWasabi/Services/IndexDownloader.cs
WalletWasabi/Services/IndexDownloader.cs
@@ -38,11 +38,11 @@ namespace WalletWasabi.Services
{
if (network == Network.Main)
{
- return FilterModel.FromLine("0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893:2:43:11288322B003", GetStartingHeight(network));
+ return FilterModel.FromLine("0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893:02832810ec08a0", GetStartingHeight(network));
}
else if (network == Network.TestNet)
{
- return FilterModel.FromLine("00000000000f0d5edcaeba823db17f366be49a80d91d15b77747c2e017b8c20a:1:21:6E081E", GetStartingHeight(network));
+ return FilterModel.FromLine("00000000000f0d5edcaeba823db17f366be49a80d91d15b77747c2e017b8c20a:017821b8", GetStartingHeight(network));
}
else if (network == Network.RegTest)
{

MODIFY
WalletWasabi/WalletWasabi.csproj
WalletWasabi/WalletWasabi.csproj
<ItemGroup>
<PackageReference Include="ConcurrentHashSet" Version="1.0.2" />
- <PackageReference Include="NBitcoin" Version="4.1.1.5" />
+ <PackageReference Include="NBitcoin" Version="4.1.1.7" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="1.0.2" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.2" />
</ItemGroup>

Update NBitcoin w/ changes in GRFilters again

This commit updates the NBitcoin version and makes the required
changes to adapt the code to the new filters version.