tx-v2-to-v3.py 962 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. # Convert MMGen 'v2' transaction file (amounts as BTCAmt())
  3. # to MMGen 'v3' (amounts as strings)
  4. # v3 tx files were introduced with MMGen version 0.9.7
  5. import sys,os
  6. repo_root = os.path.split(os.path.abspath(os.path.dirname(sys.argv[0])))[0]
  7. sys.path = [repo_root] + sys.path
  8. from mmgen.common import *
  9. opts_data = {
  10. 'text': {
  11. 'desc': "Convert MMGen transaction file from v2 format to v3 format",
  12. 'usage': "<tx file>",
  13. 'options': """
  14. -h, --help Print this help message
  15. -d, --outdir=d Output files to directory 'd' instead of working dir
  16. -q, --quiet Write (and overwrite) files without prompting
  17. -S, --stdout Write data to STDOUT instead of file
  18. """
  19. }
  20. }
  21. cmd_args = opts.init(opts_data)
  22. import asyncio
  23. from mmgen.tx import CompletedTX
  24. if len(cmd_args) != 1:
  25. opts.usage()
  26. tx = asyncio.run(CompletedTX(cmd_args[0],quiet_open=True))
  27. tx.file.write(ask_tty=False,ask_overwrite=not opt.quiet,ask_write=not opt.quiet)