Skip to content

Add null check to walletsync#209

Merged
dangershony merged 1 commit intoblock-core:masterfrom
xandronus:walletsync-fix
Aug 27, 2020
Merged

Add null check to walletsync#209
dangershony merged 1 commit intoblock-core:masterfrom
xandronus:walletsync-fix

Conversation

@xandronus
Copy link
Copy Markdown
Contributor

When I was resyncing my wallet I got this exception:

Blockcore.AsyncWork.AsyncProvider[0]
      Unhandled exception for async delegate worker WalletSyncManager-blocksQueue.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Blockcore.Features.ColdStaking.ColdStakingManager.ProcessTransaction(Transaction transaction, Nullable`1 blockHeight, Block block, Boolean isPropagated) in C:\source\block-core\blockcore\src\Features\Blockcore.Features.ColdStaking\ColdStakingManager.cs:line 635
   at Blockcore.Features.Wallet.WalletManager.ProcessBlock(Block block, ChainedHeader chainedHeader) in C:\source\block-core\blockcore\src\Features\Blockcore.Features.Wallet\WalletManager.cs:line 1103
   at Blockcore.Features.Wallet.WalletSyncManager.OnProcessBlockAsync(Block block, CancellationToken cancellationToken) in C:\source\block-core\blockcore\src\Features\Blockcore.Features.Wallet\WalletSyncManager.cs:line 240
   at Blockcore.AsyncWork.AsyncQueue`1.ConsumerAsync() in C:\source\block-core\blockcore\src\Blockcore\AsyncWork\AsyncQueue.cs:line 151

Looks like ExtractScriptPubKeyParameters can return null so added null check and wallet was successfully able to sync.

{
var data = TxNullDataTemplate.Instance.ExtractScriptPubKeyParameters(script);
if (data.Length == 1)
if (data != null && data.Length == 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah interesting, in what cases you happen to come across that it can be null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was on testnet so might have been malformed transactions or something

@dangershony dangershony merged commit bfcb5aa into block-core:master Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants