Drain notification registeration channel.

This prevents a hang when attempting to set the wallet (and register
for wallet notifications) when the process is interrupted and the rpc
server begins shutting down.
Refactor Wallet.txToPairs into smaller functions

Also add a unit test for one of them.