Adds generics to the db_channel macro, fixes the bug where it needed at least one key.
Before we yield a block for scanning, we save all of the contained script public keys. Then, when we want the address credited for creating an output, we read the script public key of the spent output from the database. Fixes #559.