Don't create empty transactions when reading corrupted wallet

The current transaction loading code is not exception safe. An exception during deserialization causes an empty transaction to be left behind in the wallet.

Fix this by building the transaction separately and adding it only to the wallet at the end.

Fixes #3333.
Should also be backported to 0.8.7 if we roll one.