2018-10-30 16:23:12 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-02-17 15:35:45 +03:00
|
|
|
|
2023-10-11 12:58:51 +00:00
|
|
|
"""
|
|
|
|
|
Convert an MMGen 'v2' transaction file (amounts as BTCAmt()) to 'v3' (amounts as
|
|
|
|
|
strings). Version 3 TX files were introduced with MMGen version 0.9.7
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import sys,os,asyncio
|
2018-02-17 15:35:45 +03:00
|
|
|
|
2023-10-03 14:27:56 +00:00
|
|
|
from mmgen.cfg import Config
|
2023-10-11 12:58:51 +00:00
|
|
|
from mmgen.tx import CompletedTX
|
|
|
|
|
|
|
|
|
|
repo_root = os.path.split(os.path.abspath(os.path.dirname(sys.argv[0])))[0]
|
|
|
|
|
sys.path = [repo_root] + sys.path
|
2018-02-17 15:35:45 +03:00
|
|
|
|
2019-03-26 12:59:30 +00:00
|
|
|
opts_data = {
|
|
|
|
|
'text': {
|
|
|
|
|
'desc': "Convert MMGen transaction file from v2 format to v3 format",
|
|
|
|
|
'usage': "<tx file>",
|
|
|
|
|
'options': """
|
2018-02-17 15:35:45 +03:00
|
|
|
-h, --help Print this help message
|
|
|
|
|
-d, --outdir=d Output files to directory 'd' instead of working dir
|
|
|
|
|
-q, --quiet Write (and overwrite) files without prompting
|
|
|
|
|
-S, --stdout Write data to STDOUT instead of file
|
|
|
|
|
"""
|
2019-03-26 12:59:30 +00:00
|
|
|
}
|
2018-02-17 15:35:45 +03:00
|
|
|
}
|
|
|
|
|
|
2023-04-04 16:04:10 +00:00
|
|
|
cfg = Config(opts_data=opts_data)
|
2018-02-17 15:35:45 +03:00
|
|
|
|
2023-03-28 18:14:37 +00:00
|
|
|
if len(cfg._args) != 1:
|
2023-04-04 16:04:10 +00:00
|
|
|
cfg._opts.usage()
|
2018-02-17 15:35:45 +03:00
|
|
|
|
2023-03-28 18:14:37 +00:00
|
|
|
tx = asyncio.run(CompletedTX(cfg._args[0],quiet_open=True))
|
|
|
|
|
tx.file.write(ask_tty=False,ask_overwrite=not cfg.quiet,ask_write=not cfg.quiet)
|