Commit 9ef368fa authored by Jeremy Bokobza's avatar Jeremy Bokobza

updating the wallet tip before and after the chain download

parent 722acfb5
......@@ -37,11 +37,18 @@ namespace Breeze.Wallet
/// <inheritdoc />
public async Task Initialize()
{
this.walletTip = this.chain.GetBlock(this.walletManager.WalletTipHash);
if (this.walletTip == null)
throw new WalletException("the wallet tip was not found in the main chain");
// get the chain headers. This needs to be up-to-date before we really do anything
await this.WaitForChainDownloadAsync();
// if there is no wallet created yet, the wallet tip is the chain tip.
this.walletTip = !this.walletManager.Wallets.Any() ? this.chain.Tip : this.chain.GetBlock(this.walletManager.WalletTipHash);
if (!this.walletManager.Wallets.Any())
{
this.walletTip = this.chain.Tip;
}
// subscribe to receiving blocks and transactions
BlockSubscriber sub = new BlockSubscriber(this.signals.Blocks, new BlockObserver(this));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment