2019-03-02 18:27:53 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
#
|
2024-10-18 10:32:06 +00:00
|
|
|
# MMGen Wallet, a terminal-based cryptocurrency wallet
|
2026-02-11 13:02:12 +00:00
|
|
|
# Copyright (C)2013-2026 The MMGen Project <mmgen@tuta.io>
|
2019-03-02 18:27:53 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
"""
|
2025-03-29 09:30:15 +00:00
|
|
|
test.cmdtest_d.ref: Reference file tests for the cmdtest.py test suite
|
2019-03-02 18:27:53 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
2023-10-03 14:27:57 +00:00
|
|
|
|
2023-10-03 14:27:57 +00:00
|
|
|
from mmgen.util import capfirst
|
2022-02-08 13:03:32 +00:00
|
|
|
from mmgen.wallet import get_wallet_cls
|
2023-10-03 14:27:57 +00:00
|
|
|
from ..include.common import (
|
|
|
|
|
imsg_r,
|
|
|
|
|
ok,
|
|
|
|
|
joinpath,
|
|
|
|
|
cmp_or_die,
|
|
|
|
|
ref_kafile_pass,
|
|
|
|
|
read_from_file,
|
|
|
|
|
sample_text
|
|
|
|
|
)
|
2025-03-29 09:30:15 +00:00
|
|
|
from .include.common import (
|
2023-10-03 14:27:57 +00:00
|
|
|
dfl_words_file,
|
|
|
|
|
ref_dir,
|
|
|
|
|
chksum_pat,
|
|
|
|
|
pwfile,
|
|
|
|
|
ref_bw_file_spc,
|
|
|
|
|
ref_enc_fn,
|
2025-03-29 09:30:15 +00:00
|
|
|
cleanup_env,
|
2023-10-03 14:27:57 +00:00
|
|
|
tool_enc_passwd,
|
|
|
|
|
skip
|
|
|
|
|
)
|
2019-03-02 18:27:53 +00:00
|
|
|
|
2025-03-29 09:30:15 +00:00
|
|
|
from .base import CmdTestBase
|
|
|
|
|
from .shared import CmdTestShared
|
2019-03-02 18:27:53 +00:00
|
|
|
|
|
|
|
|
wpasswd = 'reference password'
|
|
|
|
|
|
2024-10-18 10:32:14 +00:00
|
|
|
class CmdTestRef(CmdTestBase, CmdTestShared):
|
2019-10-24 16:21:09 +00:00
|
|
|
'saved reference address, password and transaction files'
|
2019-03-02 18:27:53 +00:00
|
|
|
tmpdir_nums = [8]
|
2024-10-18 10:32:14 +00:00
|
|
|
networks = ('btc', 'btc_tn', 'ltc', 'ltc_tn')
|
|
|
|
|
passthru_opts = ('daemon_data_dir', 'rpc_port', 'coin', 'testnet')
|
2022-08-04 13:44:31 +00:00
|
|
|
need_daemon = True
|
2019-03-02 18:27:53 +00:00
|
|
|
sources = {
|
|
|
|
|
'ref_addrfile': '98831F3A{}[1,31-33,500-501,1010-1011]{}.addrs',
|
|
|
|
|
'ref_segwitaddrfile':'98831F3A{}-S[1,31-33,500-501,1010-1011]{}.addrs',
|
|
|
|
|
'ref_bech32addrfile':'98831F3A{}-B[1,31-33,500-501,1010-1011]{}.addrs',
|
|
|
|
|
'ref_keyaddrfile': '98831F3A{}[1,31-33,500-501,1010-1011]{}.akeys.mmenc',
|
2023-04-18 18:35:53 +00:00
|
|
|
'ref_viewkeyaddrfile': '98831F3A-XMR-M[1-3].vkeys',
|
|
|
|
|
|
2019-10-15 12:51:40 +00:00
|
|
|
'ref_passwdfile_b32_24': '98831F3A-фубар@crypto.org-b32-24[1,4,1100].pws',
|
|
|
|
|
'ref_passwdfile_b32_12': '98831F3A-фубар@crypto.org-b32-12[1,4,1100].pws',
|
|
|
|
|
'ref_passwdfile_b58_10': '98831F3A-фубар@crypto.org-b58-10[1,4,1100].pws',
|
|
|
|
|
'ref_passwdfile_b58_20': '98831F3A-фубар@crypto.org-b58-20[1,4,1100].pws',
|
2019-10-15 13:58:07 +00:00
|
|
|
'ref_passwdfile_hex_32': '98831F3A-фубар@crypto.org-hex-32[1,4,1100].pws',
|
|
|
|
|
'ref_passwdfile_hex_48': '98831F3A-фубар@crypto.org-hex-48[1,4,1100].pws',
|
2019-10-15 12:51:40 +00:00
|
|
|
'ref_passwdfile_hex_64': '98831F3A-фубар@crypto.org-hex-64[1,4,1100].pws',
|
2019-10-16 17:12:57 +00:00
|
|
|
'ref_passwdfile_bip39_12': '98831F3A-фубар@crypto.org-bip39-12[1,4,1100].pws',
|
|
|
|
|
'ref_passwdfile_bip39_18': '98831F3A-фубар@crypto.org-bip39-18[1,4,1100].pws',
|
|
|
|
|
'ref_passwdfile_bip39_24': '98831F3A-фубар@crypto.org-bip39-24[1,4,1100].pws',
|
2020-02-12 10:38:11 +00:00
|
|
|
'ref_passwdfile_xmrseed_25': '98831F3A-фубар@crypto.org-xmrseed-25[1,4,1100].pws',
|
2019-10-16 17:12:57 +00:00
|
|
|
'ref_passwdfile_hex2bip39_12': '98831F3A-фубар@crypto.org-hex2bip39-12[1,4,1100].pws',
|
2019-03-02 18:27:53 +00:00
|
|
|
'ref_tx_file': { # data shared with ref_altcoin, autosign
|
2024-10-18 10:32:14 +00:00
|
|
|
'btc': (
|
|
|
|
|
'0B8D5A[15.31789,14,tl=1320969600].rawtx',
|
|
|
|
|
'0C7115[15.86255,14,tl=1320969600].testnet.rawtx'
|
|
|
|
|
),
|
|
|
|
|
'ltc': (
|
|
|
|
|
'AF3CDF-LTC[620.76194,1453,tl=1320969600].rawtx',
|
|
|
|
|
'A5A1E0-LTC[1454.64322,1453,tl=1320969600].testnet.rawtx'
|
|
|
|
|
),
|
|
|
|
|
'bch': (
|
|
|
|
|
'460D4D-BCH[10.19764,tl=1320969600].rawtx',
|
|
|
|
|
'359FD5-BCH[6.68868,tl=1320969600].testnet.rawtx'
|
|
|
|
|
),
|
|
|
|
|
'eth': (
|
|
|
|
|
'88FEFD-ETH[23.45495,40000].rawtx',
|
2025-03-17 10:16:18 +00:00
|
|
|
'76CF8C-ETH[99.99895,50000].regtest.rawtx'
|
2024-10-18 10:32:14 +00:00
|
|
|
),
|
|
|
|
|
'mm1': (
|
|
|
|
|
'5881D2-MM1[1.23456,50000].rawtx',
|
|
|
|
|
'6BDB25-MM1[1.23456,50000].testnet.rawtx'
|
|
|
|
|
),
|
|
|
|
|
'etc': (
|
|
|
|
|
'ED3848-ETC[1.2345,40000].rawtx',
|
|
|
|
|
''
|
|
|
|
|
)
|
2019-03-02 18:27:53 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
chk_data = {
|
2019-05-12 12:29:35 +00:00
|
|
|
'ref_subwallet_sid': {
|
|
|
|
|
'98831F3A:32L':'D66B4885',
|
|
|
|
|
'98831F3A:1S':'20D95B09',
|
|
|
|
|
},
|
2019-03-02 18:27:53 +00:00
|
|
|
'ref_addrfile_chksum': {
|
2024-10-18 10:32:14 +00:00
|
|
|
'btc': ('6FEF 6FB9 7B13 5D91', '424E 4326 CFFE 5F51'),
|
|
|
|
|
'ltc': ('AD52 C3FE 8924 AAF0', '4EBE 2E85 E969 1B30'),
|
2019-03-02 18:27:53 +00:00
|
|
|
},
|
|
|
|
|
'ref_segwitaddrfile_chksum': {
|
2024-10-18 10:32:14 +00:00
|
|
|
'btc': ('06C1 9C87 F25C 4EE6', '072C 8B07 2730 CB7A'),
|
|
|
|
|
'ltc': ('63DF E42A 0827 21C3', '5DD1 D186 DBE1 59F2'),
|
2019-03-02 18:27:53 +00:00
|
|
|
},
|
|
|
|
|
'ref_bech32addrfile_chksum': {
|
2024-10-18 10:32:14 +00:00
|
|
|
'btc': ('9D2A D4B6 5117 F02E', '0527 9C39 6C1B E39A'),
|
|
|
|
|
'ltc': ('FF1C 7939 5967 AB82', 'ED3D 8AA4 BED4 0B40'),
|
2019-03-02 18:27:53 +00:00
|
|
|
},
|
|
|
|
|
'ref_keyaddrfile_chksum': {
|
2024-10-18 10:32:14 +00:00
|
|
|
'btc': ('9F2D D781 1812 8BAD', '88CC 5120 9A91 22C2'),
|
|
|
|
|
'ltc': ('B804 978A 8796 3ED4', '98B5 AC35 F334 0398'),
|
2019-03-02 18:27:53 +00:00
|
|
|
},
|
2024-10-18 10:32:14 +00:00
|
|
|
'ref_passwdfile_b32_12_chksum': '7252 CD8D EF0D 3DB1',
|
|
|
|
|
'ref_passwdfile_b32_24_chksum': '8D56 3845 A072 A5B9',
|
|
|
|
|
'ref_passwdfile_b58_10_chksum': '534F CC1A 6701 9FED',
|
|
|
|
|
'ref_passwdfile_b58_20_chksum': 'DDD9 44B0 CA28 183F',
|
|
|
|
|
'ref_passwdfile_hex_32_chksum': '05C7 3678 E25E BC32',
|
|
|
|
|
'ref_passwdfile_hex_48_chksum': '7DBB FFD0 633E DE6F',
|
|
|
|
|
'ref_passwdfile_hex_64_chksum': 'F11D CB0A 8AE3 4D21',
|
|
|
|
|
'ref_passwdfile_bip39_12_chksum': 'BF57 02A3 5229 CF18',
|
|
|
|
|
'ref_passwdfile_bip39_18_chksum': '31D3 1656 B7DC 27CF',
|
|
|
|
|
'ref_passwdfile_bip39_24_chksum': 'E565 3A59 7D91 4671',
|
|
|
|
|
'ref_passwdfile_xmrseed_25_chksum': 'B488 21D3 4539 968D',
|
2019-10-16 17:12:57 +00:00
|
|
|
'ref_passwdfile_hex2bip39_12_chksum': '93AD 4AE2 03D1 8A0A',
|
2019-03-02 18:27:53 +00:00
|
|
|
}
|
|
|
|
|
cmd_group = ( # TODO: move to tooltest2
|
2024-10-18 10:32:14 +00:00
|
|
|
('ref_words_to_subwallet_chk1', 'subwallet generation from reference words file (long subseed)'),
|
|
|
|
|
('ref_words_to_subwallet_chk2', 'subwallet generation from reference words file (short subseed)'),
|
|
|
|
|
('ref_subwallet_addrgen1', 'subwallet address file generation (long subseed)'),
|
|
|
|
|
('ref_subwallet_addrgen2', 'subwallet address file generation (short subseed)'),
|
|
|
|
|
('ref_subwallet_keygen1', 'subwallet key-address file generation (long subseed)'),
|
|
|
|
|
('ref_subwallet_keygen2', 'subwallet key-address file generation (short subseed)'),
|
|
|
|
|
('ref_addrfile_chk', 'saved reference address file'),
|
|
|
|
|
('ref_segwitaddrfile_chk', 'saved reference address file (segwit)'),
|
|
|
|
|
('ref_bech32addrfile_chk', 'saved reference address file (bech32)'),
|
|
|
|
|
('ref_keyaddrfile_chk', 'saved reference key-address file'),
|
|
|
|
|
|
|
|
|
|
('ref_passwdfile_chk_b58_20', 'saved reference password file (base58, 20 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_b58_10', 'saved reference password file (base58, 10 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_b32_24', 'saved reference password file (base32, 24 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_b32_12', 'saved reference password file (base32, 12 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_hex_32', 'saved reference password file (hexadecimal, 32 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_hex_48', 'saved reference password file (hexadecimal, 48 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_hex_64', 'saved reference password file (hexadecimal, 64 chars)'),
|
|
|
|
|
('ref_passwdfile_chk_bip39_12', 'saved reference password file (BIP39, 12 words)'),
|
|
|
|
|
('ref_passwdfile_chk_bip39_18', 'saved reference password file (BIP39, 18 words)'),
|
|
|
|
|
('ref_passwdfile_chk_bip39_24', 'saved reference password file (BIP39, 24 words)'),
|
|
|
|
|
('ref_passwdfile_chk_xmrseed_25', 'saved reference password file (Monero new-style mnemonic, 25 words)'),
|
|
|
|
|
('ref_passwdfile_chk_hex2bip39_12', 'saved reference password file (hex-to-BIP39, 12 words)'),
|
2019-10-15 12:51:40 +00:00
|
|
|
|
2019-03-02 18:27:53 +00:00
|
|
|
# Create the fake inputs:
|
|
|
|
|
# ('txcreate8', 'transaction creation (8)'),
|
2024-10-18 10:32:14 +00:00
|
|
|
('ref_tx_chk', 'signing saved reference tx file'),
|
|
|
|
|
('ref_brain_chk_spc3', 'saved brainwallet (non-standard spacing)'),
|
|
|
|
|
('ref_dieroll_chk_seedtruncate', 'saved dieroll wallet with extra entropy bits'),
|
|
|
|
|
('ref_tool_decrypt', 'decryption of saved MMGen-encrypted file'),
|
2019-03-02 18:27:53 +00:00
|
|
|
)
|
|
|
|
|
|
2020-05-28 09:53:34 +00:00
|
|
|
@property
|
|
|
|
|
def nw_desc(self):
|
2021-09-29 21:17:57 +00:00
|
|
|
return '{} {}'.format(
|
|
|
|
|
self.proto.coin,
|
2024-10-18 10:32:14 +00:00
|
|
|
('Mainnet','Testnet')[self.proto.testnet])
|
2020-05-28 09:53:34 +00:00
|
|
|
|
2019-03-02 18:27:53 +00:00
|
|
|
def _get_ref_subdir_by_coin(self,coin):
|
2024-10-18 10:32:14 +00:00
|
|
|
return {
|
|
|
|
|
'btc': '',
|
|
|
|
|
'bch': '',
|
|
|
|
|
'ltc': 'litecoin',
|
|
|
|
|
'eth': 'ethereum',
|
|
|
|
|
'etc': 'ethereum_classic',
|
|
|
|
|
'xmr': 'monero',
|
|
|
|
|
'zec': 'zcash',
|
|
|
|
|
'dash': 'dash'
|
|
|
|
|
}[coin.lower()]
|
2019-03-02 18:27:53 +00:00
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def ref_subdir(self):
|
2020-05-28 09:53:34 +00:00
|
|
|
return self._get_ref_subdir_by_coin(self.proto.coin)
|
2019-03-02 18:27:53 +00:00
|
|
|
|
2019-05-12 12:29:35 +00:00
|
|
|
def ref_words_to_subwallet_chk1(self):
|
|
|
|
|
return self.ref_words_to_subwallet_chk('32L')
|
|
|
|
|
|
|
|
|
|
def ref_words_to_subwallet_chk2(self):
|
|
|
|
|
return self.ref_words_to_subwallet_chk('1S')
|
|
|
|
|
|
2024-10-18 10:32:14 +00:00
|
|
|
def ref_words_to_subwallet_chk(self, ss_idx):
|
2019-05-12 12:29:35 +00:00
|
|
|
wf = dfl_words_file
|
2022-02-08 13:03:32 +00:00
|
|
|
ocls = get_wallet_cls('words')
|
2024-10-18 10:32:14 +00:00
|
|
|
args = ['-d', self.tr.trash_dir, '-o', ocls.fmt_codes[-1], wf, ss_idx]
|
2019-05-12 12:29:35 +00:00
|
|
|
|
2024-10-08 12:55:58 +00:00
|
|
|
t = self.spawn(
|
|
|
|
|
'mmgen-subwalletgen',
|
|
|
|
|
self.testnet_opt + args,
|
|
|
|
|
extra_desc = '(generate subwallet)',
|
|
|
|
|
no_passthru_opts = True)
|
2021-09-29 21:17:57 +00:00
|
|
|
t.expect(f'Generating subseed {ss_idx}')
|
|
|
|
|
chk_sid = self.chk_data['ref_subwallet_sid'][f'98831F3A:{ss_idx}']
|
2019-10-24 16:21:09 +00:00
|
|
|
fn = t.written_to_file(capfirst(ocls.desc))
|
2024-10-18 10:32:14 +00:00
|
|
|
assert chk_sid in fn, f'incorrect filename: {fn} (does not contain {chk_sid})'
|
2019-05-12 12:29:35 +00:00
|
|
|
ok()
|
|
|
|
|
|
2024-10-08 12:55:58 +00:00
|
|
|
t = self.spawn(
|
|
|
|
|
'mmgen-walletchk',
|
|
|
|
|
self.testnet_opt + [fn],
|
|
|
|
|
extra_desc = '(check subwallet)',
|
|
|
|
|
no_passthru_opts = True)
|
2024-10-18 10:32:14 +00:00
|
|
|
t.expect(r'Valid MMGen native mnemonic data for Seed ID ([0-9A-F]*)\b', regex=True)
|
2019-05-12 12:29:35 +00:00
|
|
|
sid = t.p.match.group(1)
|
2024-10-18 10:32:14 +00:00
|
|
|
assert sid == chk_sid, f'subseed ID {sid} does not match expected value {chk_sid}'
|
2019-05-12 12:29:35 +00:00
|
|
|
return t
|
|
|
|
|
|
2024-10-18 10:32:14 +00:00
|
|
|
def ref_subwallet_addrgen(self, ss_idx, target='addr'):
|
2019-05-14 10:45:53 +00:00
|
|
|
wf = dfl_words_file
|
2024-10-18 10:32:14 +00:00
|
|
|
args = ['-d', self.tr.trash_dir, '--subwallet='+ss_idx, wf, '1-10']
|
|
|
|
|
t = self.spawn(f'mmgen-{target}gen', args)
|
2021-09-29 21:17:57 +00:00
|
|
|
t.expect(f'Generating subseed {ss_idx}')
|
|
|
|
|
chk_sid = self.chk_data['ref_subwallet_sid'][f'98831F3A:{ss_idx}']
|
2024-10-18 10:32:14 +00:00
|
|
|
assert chk_sid == t.expect_getend('Checksum for .* data ', regex=True)[:8]
|
2019-05-14 10:45:53 +00:00
|
|
|
if target == 'key':
|
2024-10-18 10:32:14 +00:00
|
|
|
t.expect('Encrypt key list? (y/N): ', 'n')
|
|
|
|
|
fn = t.written_to_file(('Addresses', 'Secret keys')[target=='key'])
|
|
|
|
|
assert chk_sid in fn, f'incorrect filename: {fn} (does not contain {chk_sid})'
|
2019-05-14 10:45:53 +00:00
|
|
|
return t
|
|
|
|
|
|
|
|
|
|
def ref_subwallet_addrgen1(self):
|
|
|
|
|
return self.ref_subwallet_addrgen('32L')
|
|
|
|
|
|
|
|
|
|
def ref_subwallet_addrgen2(self):
|
|
|
|
|
return self.ref_subwallet_addrgen('1S')
|
|
|
|
|
|
|
|
|
|
def ref_subwallet_keygen1(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_subwallet_addrgen('32L', target='key')
|
2019-05-14 10:45:53 +00:00
|
|
|
|
|
|
|
|
def ref_subwallet_keygen2(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_subwallet_addrgen('1S', target='key')
|
2019-05-14 10:45:53 +00:00
|
|
|
|
2019-10-15 12:51:40 +00:00
|
|
|
def ref_addrfile_chk(
|
|
|
|
|
self,
|
2023-10-11 12:58:51 +00:00
|
|
|
ftype = 'addr',
|
|
|
|
|
coin = None,
|
|
|
|
|
subdir = None,
|
|
|
|
|
pfx = None,
|
|
|
|
|
mmtype = None,
|
|
|
|
|
id_key = None,
|
|
|
|
|
pat = None):
|
2020-05-28 09:53:34 +00:00
|
|
|
|
|
|
|
|
pat = pat or f'{self.nw_desc}.*Legacy'
|
2021-09-29 21:17:57 +00:00
|
|
|
af_key = f'ref_{ftype}file' + ('_' + id_key if id_key else '')
|
2024-10-18 10:32:14 +00:00
|
|
|
af_fn = CmdTestRef.sources[af_key].format(pfx or self.altcoin_pfx, '' if coin else self.tn_ext)
|
|
|
|
|
af = joinpath(ref_dir, (subdir or self.ref_subdir, '')[ftype=='passwd'], af_fn)
|
2023-10-11 12:58:52 +00:00
|
|
|
coin_arg = [] if coin is None else ['--coin='+coin]
|
2024-10-18 10:32:14 +00:00
|
|
|
tool_cmd = ftype.replace('segwit', '').replace('bech32', '')+'file_chksum'
|
|
|
|
|
t = self.spawn('mmgen-tool', coin_arg + ['--verbose', '-p1', tool_cmd, af])
|
2019-03-02 18:27:53 +00:00
|
|
|
if ftype == 'keyaddr':
|
2024-10-18 10:32:14 +00:00
|
|
|
t.do_decrypt_ka_data(pw=ref_kafile_pass, have_yes_opt=True)
|
|
|
|
|
chksum_key = '_'.join([af_key, 'chksum'] + ([coin.lower()] if coin else []) + ([mmtype] if mmtype else []))
|
2019-10-15 12:51:40 +00:00
|
|
|
rc = self.chk_data[chksum_key]
|
2020-05-28 09:53:34 +00:00
|
|
|
ref_chksum = rc if (ftype == 'passwd' or coin) else rc[self.proto.base_coin.lower()][self.proto.testnet]
|
2019-10-15 12:51:40 +00:00
|
|
|
if pat:
|
2024-10-18 10:32:14 +00:00
|
|
|
t.expect(pat, regex=True)
|
|
|
|
|
t.expect(chksum_pat, regex=True)
|
2019-03-02 18:27:53 +00:00
|
|
|
m = t.p.match.group(0)
|
2024-10-18 10:32:14 +00:00
|
|
|
cmp_or_die(ref_chksum, m)
|
2019-03-02 18:27:53 +00:00
|
|
|
return t
|
|
|
|
|
|
|
|
|
|
def ref_segwitaddrfile_chk(self):
|
2020-05-28 09:53:34 +00:00
|
|
|
if not 'S' in self.proto.mmtypes:
|
|
|
|
|
return skip(f'not supported by {self.proto.cls_name} protocol')
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_addrfile_chk(ftype='segwitaddr', pat=f'{self.nw_desc}.*Segwit')
|
2019-03-02 18:27:53 +00:00
|
|
|
|
|
|
|
|
def ref_bech32addrfile_chk(self):
|
2020-05-28 09:53:34 +00:00
|
|
|
if not 'B' in self.proto.mmtypes:
|
|
|
|
|
return skip(f'not supported by {self.proto.cls_name} protocol')
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_addrfile_chk(ftype='bech32addr', pat=f'{self.nw_desc}.*Bech32')
|
2019-03-02 18:27:53 +00:00
|
|
|
|
|
|
|
|
def ref_keyaddrfile_chk(self):
|
|
|
|
|
return self.ref_addrfile_chk(ftype='keyaddr')
|
|
|
|
|
|
2024-10-18 10:32:14 +00:00
|
|
|
def ref_passwdfile_chk(self, key, pat):
|
|
|
|
|
return self.ref_addrfile_chk(ftype='passwd', id_key=key, pat=pat)
|
2019-10-15 12:51:40 +00:00
|
|
|
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_b58_20(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='b58_20', pat=r'Base58.*len.* 20\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_b58_10(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='b58_10', pat=r'Base58.*len.* 10\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_b32_24(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='b32_24', pat=r'Base32.*len.* 24\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_b32_12(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='b32_12', pat=r'Base32.*len.* 12\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_hex_32(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='hex_32', pat=r'Hexadec.*len.* 32\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_hex_48(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='hex_48', pat=r'Hexadec.*len.* 48\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_hex_64(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='hex_64', pat=r'Hexadec.*len.* 64\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_bip39_12(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='bip39_12', pat=r'BIP39.*len.* 12\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_bip39_18(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='bip39_18', pat=r'BIP39.*len.* 18\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_bip39_24(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='bip39_24', pat=r'BIP39.*len.* 24\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_xmrseed_25(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='xmrseed_25', pat=r'Mon.*len.* 25\b')
|
2023-10-11 12:58:51 +00:00
|
|
|
def ref_passwdfile_chk_hex2bip39_12(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
return self.ref_passwdfile_chk(key='hex2bip39_12', pat=r'BIP39.*len.* 12\b')
|
2019-03-02 18:27:53 +00:00
|
|
|
|
|
|
|
|
def ref_tx_chk(self):
|
2024-09-29 11:59:56 +00:00
|
|
|
fn = self.sources['ref_tx_file'][self.coin][bool(self.tn_ext)]
|
2023-10-11 12:58:51 +00:00
|
|
|
if not fn:
|
|
|
|
|
return
|
2024-10-18 10:32:14 +00:00
|
|
|
tf = joinpath(ref_dir, self.ref_subdir, fn)
|
2019-03-02 18:27:53 +00:00
|
|
|
wf = dfl_words_file
|
2024-10-18 10:32:14 +00:00
|
|
|
self.write_to_tmpfile(pwfile, wpasswd)
|
|
|
|
|
return self.txsign(wf, tf, save=False, has_label=True, view='y')
|
2019-03-02 18:27:53 +00:00
|
|
|
|
|
|
|
|
def ref_brain_chk_spc3(self):
|
|
|
|
|
return self.ref_brain_chk(bw_file=ref_bw_file_spc)
|
|
|
|
|
|
2019-10-31 11:56:38 +00:00
|
|
|
def ref_dieroll_chk_seedtruncate(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
wf = joinpath(ref_dir, 'overflow128.b6d')
|
|
|
|
|
return self.walletchk(wf, sid='8EC6D4A2')
|
2019-10-30 09:20:47 +00:00
|
|
|
|
2019-03-02 18:27:53 +00:00
|
|
|
def ref_tool_decrypt(self):
|
2024-10-18 10:32:14 +00:00
|
|
|
f = joinpath(ref_dir, ref_enc_fn)
|
|
|
|
|
dec_file = joinpath(self.tmpdir, 'famous.txt')
|
2023-05-23 12:12:33 +00:00
|
|
|
t = self.spawn(
|
|
|
|
|
'mmgen-tool',
|
2024-10-18 10:32:14 +00:00
|
|
|
['-q', 'decrypt', f, 'outfile='+dec_file, 'hash_preset=1'],
|
2025-03-29 09:30:15 +00:00
|
|
|
env = cleanup_env(self.cfg))
|
2024-10-18 10:32:14 +00:00
|
|
|
t.passphrase('data', tool_enc_passwd)
|
2019-03-02 18:27:53 +00:00
|
|
|
t.written_to_file('Decrypted data')
|
|
|
|
|
dec_txt = read_from_file(dec_file)
|
|
|
|
|
imsg_r(dec_txt)
|
2024-10-18 10:32:14 +00:00
|
|
|
cmp_or_die(sample_text+'\n', dec_txt) # file adds a newline to sample_text
|
2019-03-02 18:27:53 +00:00
|
|
|
return t
|