Fix assertion crash when using SPV clients

Ported from @rnicoll's dogecoin pull #597