Use Dummy filter instead of empty
MODIFY
WalletWasabi.Tests/UnitTests/AllFeeEstimateTests.cs
WalletWasabi.Tests/UnitTests/AllFeeEstimateTests.cs
+using NBitcoin;
using NBitcoin.RPC;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using WalletWasabi.Blockchain.Analysis.FeesEstimation;
+using WalletWasabi.Blockchain.Blocks;
using Xunit;
namespace WalletWasabi.Tests.UnitTests

MODIFY
WalletWasabi/Blockchain/BlockFilters/IndexBuilderService.cs
WalletWasabi/Blockchain/BlockFilters/IndexBuilderService.cs
@@ -20,6 +20,7 @@ namespace WalletWasabi.Blockchain.BlockFilters
{
public class IndexBuilderService
{
+ private static byte[][] DummyScript { get; } = new byte[][] { ByteHelpers.FromHex("0009BBE4C2D17185643765C265819BF5261755247D") };
public RPCClient RpcClient { get; }
public BlockNotifier BlockNotifier { get; }
public string IndexFilePath { get; }
@@ -238,12 +239,27 @@ namespace WalletWasabi.Blockchain.BlockFilters
}
}
- GolombRiceFilter filter = new GolombRiceFilterBuilder()
+ GolombRiceFilter filter;
+ if (scripts.Any())
+ {
+ filter = new GolombRiceFilterBuilder()
.SetKey(block.GetHash())
.SetP(20)
.SetM(1 << 20)
.AddEntries(scripts.Select(x => x.ToCompressedBytes()))
.Build();
+ }
+ else
+ {
+ // We cannot have empty filters, because there was a bug in GolombRiceFilterBuilder that evaluates empty filters to true.
+ // And this must be fixed in a backwards compatible way, so we create a fake filter with a random scp instead.
+ filter = new GolombRiceFilterBuilder()
+ .SetKey(block.GetHash())
+ .SetP(20)
+ .SetM(1 << 20)
+ .AddEntries(DummyScript)
+ .Build();
+ }
var smartHeader = new SmartHeader(block.GetHash(), block.Header.HashPrevBlock, heightToRequest, block.Header.BlockTime);
var filterModel = new FilterModel(smartHeader, filter);

MODIFY
WalletWasabi/Blockchain/BlockFilters/StartingFilters.cs
WalletWasabi/Blockchain/BlockFilters/StartingFilters.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.Blockchain.BlockFilters
}
else if (network == Network.RegTest)
{
- return FilterModel.FromLine($"{startingHeader.Height}:{startingHeader.BlockHash}:00:{startingHeader.PrevHash}:{startingHeader.BlockTime.ToUnixTimeSeconds()}");
+ return FilterModel.FromLine($"{startingHeader.Height}:{startingHeader.BlockHash}:01053a58:{startingHeader.PrevHash}:{startingHeader.BlockTime.ToUnixTimeSeconds()}");
}
else
{

Use Dummy filter instead of empty