Prepare IndexDownloader
MODIFY
MagicalCryptoWallet.Backend/Controllers/BlockchainController.cs
MagicalCryptoWallet.Backend/Controllers/BlockchainController.cs
@@ -193,7 +193,9 @@ namespace MagicalCryptoWallet.Backend.Controllers
/// <remarks>
/// Sample request:
///
- /// GET /filters/00000000000000000044d076d9c43b5888551027ec70043211365301665da2e8
+ /// Main: GET /filters/0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
+ /// TestNet: GET /filters/00000000000f0d5edcaeba823db17f366be49a80d91d15b77747c2e017b8c20a
+ /// RegTest: GET /filters/0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
///
/// </remarks>
/// <param name="bestKnownBlockHash">The best block hash the client knows its filter.</param>
@@ -214,10 +216,11 @@ namespace MagicalCryptoWallet.Backend.Controllers
var knownHash = new uint256(bestKnownBlockHash);
- var filters = Global.IndexBuilderService.GetFilters(knownHash);
+ IEnumerable<string> filters = Global.IndexBuilderService.GetFilters(knownHash);
+
if(filters.Count() == 0)
{
- return NotFound($"Provided {nameof(bestKnownBlockHash)} is not found: {bestKnownBlockHash}.");
+ return NotFound($"Provided {nameof(bestKnownBlockHash)} is not found: {bestKnownBlockHash} or it is the tip.");
}
return Ok(filters);

MODIFY
MagicalCryptoWallet/Services/IndexBuilderService.cs
MagicalCryptoWallet/Services/IndexBuilderService.cs
@@ -91,28 +91,28 @@ namespace MagicalCryptoWallet.Services
}
}
- public Height StartingHeight // First possible bech32 transaction ever.
+ public static Height GetStartingHeight(Network network) // First possible bech32 transaction ever.
{
- get
- {
- if (RpcClient.Network == Network.Main)
+ if (network == Network.Main)
{
return new Height(481824);
}
- else if (RpcClient.Network == Network.TestNet)
+ else if (network == Network.TestNet)
{
return new Height(828575);
}
- else if (RpcClient.Network == Network.RegTest)
+ else if (network == Network.RegTest)
{
return new Height(0);
}
else
{
- throw new NotSupportedException($"{RpcClient.Network} is not supported.");
- }
+ throw new NotSupportedException($"{network} is not supported.");
}
}
+ public Height StartingHeight => GetStartingHeight(RpcClient.Network);
+ public static FilterModel GetStartingFilter(Network network) => IndexDownloader.GetStartingFilter(network);
+ public FilterModel StartingFilter => GetStartingFilter(RpcClient.Network);
private long _running;
public bool IsRunning => Interlocked.Read(ref _running) == 1;
@@ -238,8 +238,6 @@ namespace MagicalCryptoWallet.Services
}
}
- Bech32UtxoSetHistory.ClearActionHistory(); //reset history.
-
var scripts = new HashSet<Script>();
foreach (var tx in block.Transactions)

Prepare IndexDownloader