new CR global constant

This commit is contained in:
The MMGen Project 2026-09-15 10:50:57 +00:00
commit 9482ecc705
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 15 additions and 11 deletions

View file

@ -59,6 +59,8 @@ class GlobalConstants(Lockable):
min_screen_width = 80
min_time_precision = 18
CR = '\r'
# core_coins must match CoinProtocol.coins
core_coins = ('btc', 'bch', 'ltc', 'eth', 'etc', 'zec', 'xmr', 'rune')
rpc_coins = ('btc', 'bch', 'ltc', 'eth', 'etc', 'xmr', 'rune')
@ -258,7 +260,7 @@ class Config(Lockable):
xmrwallet_compat = False
priority = 0
test_suite = False # 30 references
test_suite = False # 25 references
# external use:
_opts = None

View file

@ -12,6 +12,7 @@
proto.btc.misc: miscellaneous functions for Bitcoin base protocol
"""
from ...cfg import gc
from ...util import msg, msg_r
async def scantxoutset(cfg, rpc, descriptor_list):
@ -27,9 +28,8 @@ async def scantxoutset(cfg, rpc, descriptor_list):
async def do_status():
CR = '\n' if cfg.test_suite else '\r'
sleep_secs = 0.1 if cfg.test_suite else 2
m = f'{CR}Scanning UTXO set: '
m = f'{gc.CR}Scanning UTXO set: '
msg_r(m + '0% completed ')
while True:

View file

@ -12,6 +12,7 @@
proto.btc.tw.ctl: Bitcoin base protocol tracking wallet control class
"""
from ....cfg import gc
from ....tw.ctl import TwCtl, write_mode
from ....util import msg, msg_r, rmsg, die, suf, fmt_list
@ -61,7 +62,6 @@ class BitcoinTwCtl(TwCtl):
start = start or 0
endless = stop is None
CR = '\n' if self.cfg.test_suite else '\r'
if not (start >= 0 and (stop if stop is not None else start) >= start):
die(1, f'{start} {stop}: invalid range')
@ -69,7 +69,7 @@ class BitcoinTwCtl(TwCtl):
async def do_scan(chunks, tip):
res = None
for a, b in chunks:
msg_r(f'{CR}Scanning blocks {a}-{b} ')
msg_r(f'{gc.CR}Scanning blocks {a}-{b} ')
res = await self.rpc.call('rescanblockchain', a, b, timeout=7200)
if res['start_height'] != a or res['stop_height'] != b:
die(1, f'\nAn error occurred in block range {a}-{b}')
@ -119,9 +119,8 @@ class BitcoinTwCtl(TwCtl):
len(blocks),
suf(blocks)))
self.cfg._util.vmsg(f'Blocks to rescan: {fmt_list(blocks, fmt="bare")}')
CR = '\n' if self.cfg.test_suite else '\r'
for n, block in enumerate(blocks):
msg_r(f'{CR}Rescanning block: {block} ({n+1}/{len(blocks)})')
msg_r(f'{gc.CR}Rescanning block: {block} ({n+1}/{len(blocks)})')
# httplib seems to require fresh connection here, so specify timeout
await self.rpc.call('rescanblockchain', block, block, timeout=60)
msg(f'\nAddress balance{suf(coin_addrs)} updated successfully')

View file

@ -13,6 +13,7 @@ wallet.dieroll: dieroll wallet class
"""
import time
from ..cfg import gc
from ..util import msg, msg_r, die, fmt, remove_whitespace
from ..util2 import block_format
from ..seed import Seed
@ -97,10 +98,9 @@ class wallet(wallet):
CUR_HIDE = '\033[?25l'
CUR_SHOW = '\033[?25h'
cr = '\n' if self.cfg.test_suite else '\r'
prompt_fs = f'\b\b\b {cr}Enter die roll #{{}}: {CUR_SHOW}'
prompt_fs = f'\b\b\b {gc.CR}Enter die roll #{{}}: {CUR_SHOW}'
clear_line = '' if self.cfg.test_suite else '\r' + ' ' * 25
invalid_msg = CUR_HIDE + cr + 'Invalid entry' + ' ' * 11
invalid_msg = CUR_HIDE + gc.CR + 'Invalid entry' + ' ' * 11
from ..term import get_char
def get_digit(n):

View file

@ -12,6 +12,7 @@
wallet.unenc: unencrypted wallet base class
"""
from ..cfg import gc
from ..color import blue, yellow
from ..util import msg, msg_r, capfirst, is_int
from .base import wallet
@ -43,7 +44,7 @@ class wallet(wallet):
r = get_char('\r'+prompt)
if is_int(r) and 1 <= int(r) <= len(ok_lens):
break
msg_r(('\r', '\n')[self.cfg.test_suite] + ' '*len(prompt) + '\r')
msg_r(gc.CR + ' ' * len(prompt) + '\r')
return ok_lens[int(r)-1]
while True:

View file

@ -12,6 +12,8 @@ test.overlay.fakemods.mmgen.cfg: overlay setup for cfg.py
from .cfg_orig import *
GlobalConstants.CR = '\n'
for k, v in {
# NB: check carefully that none of these attrs are required by Config(), Opts()
# or anything they import or call before the lock is set in Config()