write signed transactions for wally wallets, plus several bug fixes

Fixed several bugs related to signing transactions for wally wallets, and then also added code to write the datastore after signing. However there is still a bug where you cannot write multiple signatures in a row, which is necessary for multisig transactions.