mmgen-wallet/scripts/tx-v2-to-v3.py

34 lines
973 B
Python
Raw Normal View History

#!/usr/bin/env python3
# Convert MMGen 'v2' transaction file (amounts as BTCAmt())
# to MMGen 'v3' (amounts as strings)
# v3 tx files were introduced with MMGen version 0.9.7
import sys,os
repo_root = os.path.split(os.path.abspath(os.path.dirname(sys.argv[0])))[0]
sys.path = [repo_root] + sys.path
2023-10-03 14:27:56 +00:00
from mmgen.cfg import Config
opts_data = {
'text': {
'desc': "Convert MMGen transaction file from v2 format to v3 format",
'usage': "<tx file>",
'options': """
-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
"""
}
}
2023-04-04 16:04:10 +00:00
cfg = Config(opts_data=opts_data)
import asyncio
from mmgen.tx import CompletedTX
if len(cfg._args) != 1:
2023-04-04 16:04:10 +00:00
cfg._opts.usage()
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)