Fix wallet transaction serialisation.

This fixes what seems like "trivial" bugs in code that has never been tested.  With this, saving/loading wallets with transactions in them works.