write signed transactions for wally wallets, plus several bug fixes

Fixed several bugs related to signing transactions for wally wallets, and also added code to write the datastore after signing.