Monero
Loading...
Searching...
No Matches
cointool Namespace Reference

Functions

 crayon (color, string, bold=False, dim=False)
 print_log (level, *args, **kwargs)
 c_str_filter (b)
 black_repr_filter (val)
 ascii_filter (s)
 make_support_filter (support_info)
 render_file (src, dst, coins, support_info)
 mark_unsupported (support_info, coins)
 highlight_key (coin, color)
 find_collisions (coins, field)
 check_eth (coins)
 check_btc (coins)
 check_dups (buckets, print_at_level=logging.WARNING)
 check_backends (coins)
 check_icons (coins)
 check_key_uniformity (coins)
 check_segwit (coins)
 check_fido (apps)
 convert_icon (icon)
 coindef_from_dict (coin)
 serialize_coindef (proto, icon)
 sign (data)
 cli (colors)
 check (backend, icons, show_duplicates)
 dump (outfile, support, pretty, flat_list, include, exclude, include_type, exclude_type, filter, filter_exclude, exclude_tokens, device)
 coindefs (outfile)
 render (paths, outfile, verbose, bitcoin_only)

Variables

 termcolor = None
bool CAN_RENDER = True
 requests = None
bool CAN_BUILD_DEFS = True
bool USE_COLORS = False
dict MAKO_FILTERS
 IGNORE_NONUNIFORM_KEYS = frozenset(("unsupported", "duplicate"))
 FIDO_KNOWN_KEYS

Function Documentation

◆ ascii_filter()

cointool.ascii_filter ( s)

◆ black_repr_filter()

cointool.black_repr_filter ( val)

◆ c_str_filter()

cointool.c_str_filter ( b)

◆ check()

cointool.check ( backend,
icons,
show_duplicates )
Validate coin definitions.

Checks that every btc-like coin is properly filled out, reports duplicate symbols,
missing or invalid icons, backend responses, and uniform key information --
i.e., that all coins of the same type have the same fields in their JSON data.

Uniformity check ignores NEM mosaics and ERC20 tokens, where non-uniformity is
expected.

The `--show-duplicates` option can be set to:

- all: all shortcut collisions are shown, including colliding ERC20 tokens

- nontoken: only collisions that affect non-ERC20 coins are shown

- errors: only collisions between non-ERC20 tokens are shown. This is the default,
as a collision between two or more non-ERC20 tokens is an error.

In the output, duplicate ERC tokens will be shown in cyan; duplicate non-tokens
in red. An asterisk (*) next to symbol name means that even though it was detected
as duplicate, it is still included in results.

The collision detection checks that SLIP44 numbers don't collide between different
mainnets (testnet collisions are allowed), that `address_prefix` doesn't collide
with Bitcoin (other collisions are reported as warnings). `address_prefix_p2sh`
is also checked but we have a bunch of collisions there and can't do much
about them, so it's not an error.

In the collision checks, Bitcoin is shown in red, other mainnets in blue,
testnets in green and unsupported networks in gray, marked with `(X)` for
non-colored output.

◆ check_backends()

cointool.check_backends ( coins)

◆ check_btc()

cointool.check_btc ( coins)

◆ check_dups()

cointool.check_dups ( buckets,
print_at_level = logging.WARNING )
Analyze and pretty-print results of `coin_info.mark_duplicate_shortcuts`.

`print_at_level` can be one of logging levels.

The results are buckets of colliding symbols.
If the collision is only between ERC20 tokens, it's DEBUG.
If the collision includes one non-token, it's INFO.
If the collision includes more than one non-token, it's ERROR and printed always.

◆ check_eth()

cointool.check_eth ( coins)

◆ check_fido()

cointool.check_fido ( apps)

◆ check_icons()

cointool.check_icons ( coins)

◆ check_key_uniformity()

cointool.check_key_uniformity ( coins)

◆ check_segwit()

cointool.check_segwit ( coins)

◆ cli()

cointool.cli ( colors)

◆ coindef_from_dict()

cointool.coindef_from_dict ( coin)

◆ coindefs()

cointool.coindefs ( outfile)
Generate signed coin definitions for python-trezor and others

This is currently unused but should enable us to add new coins without having to
update firmware.

◆ convert_icon()

cointool.convert_icon ( icon)
Convert PIL icon to TOIF format

◆ crayon()

cointool.crayon ( color,
string,
bold = False,
dim = False )

◆ dump()

cointool.dump ( outfile,
support,
pretty,
flat_list,
include,
exclude,
include_type,
exclude_type,
filter,
filter_exclude,
exclude_tokens,
device )
Dump coin data in JSON format.

This file is structured the same as the internal data. That is, top-level object
is a dict with keys: 'bitcoin', 'eth', 'erc20', 'nem' and 'misc'. Value for each
key is a list of dicts, each describing a known coin.

If '--list' is specified, the top-level object is instead a flat list of coins.

\b
Fields are category-specific, except for four common ones:
- 'name' - human-readable name
- 'shortcut' - currency symbol
- 'key' - unique identifier, e.g., 'bitcoin:BTC'
- 'support' - a dict with entries per known device

To control the size and properties of the resulting file, you can specify whether
or not you want pretty-printing and whether or not to include support data with
each coin.

You can specify which categories and which fields will be included or excluded.
You cannot specify both include and exclude at the same time. Include is "stronger"
than exclude, in that _only_ the specified fields are included.

You can also specify filters, in the form '-f field=value' (or '-F' for inverse
filter). Filter values are case-insensitive and support shell-style wildcards,
so '-f name=bit*' finds all coins whose names start with "bit" or "Bit".

◆ find_collisions()

cointool.find_collisions ( coins,
field )
Detects collisions in a given field. Returns buckets of colliding coins.

◆ highlight_key()

cointool.highlight_key ( coin,
color )
Return a colorful string where the SYMBOL part is bold.

◆ make_support_filter()

cointool.make_support_filter ( support_info)

◆ mark_unsupported()

cointool.mark_unsupported ( support_info,
coins )

◆ print_log()

cointool.print_log ( level,
* args,
** kwargs )

◆ render()

cointool.render ( paths,
outfile,
verbose,
bitcoin_only )
Generate source code from Mako templates.

For every "foo.bar.mako" filename passed, runs the template and
saves the result as "foo.bar". For every directory name passed,
processes all ".mako" files found in that directory.

If `-o` is specified, renders a single file into the specified outfile.

If no arguments are given, processes the current directory.

◆ render_file()

cointool.render_file ( src,
dst,
coins,
support_info )
Renders `src` template into `dst`.

`src` is a filename, `dst` is an open file object.

◆ serialize_coindef()

cointool.serialize_coindef ( proto,
icon )

◆ sign()

cointool.sign ( data)

Variable Documentation

◆ CAN_BUILD_DEFS

bool cointool.CAN_BUILD_DEFS = True

◆ CAN_RENDER

bool cointool.CAN_RENDER = True

◆ FIDO_KNOWN_KEYS

cointool.FIDO_KNOWN_KEYS
Initial value:
1= frozenset(
2 (
3 "key",
4 "u2f",
5 "webauthn",
6 "label",
7 "use_sign_count",
8 "use_self_attestation",
9 "no_icon",
10 "icon",
11 )
12)

◆ IGNORE_NONUNIFORM_KEYS

cointool.IGNORE_NONUNIFORM_KEYS = frozenset(("unsupported", "duplicate"))

◆ MAKO_FILTERS

dict cointool.MAKO_FILTERS
Initial value:
1= {
2 "c_str": c_str_filter,
3 "ascii": ascii_filter,
4 "black_repr": black_repr_filter,
5}

◆ requests

cointool.requests = None

◆ termcolor

cointool.termcolor = None

◆ USE_COLORS

bool cointool.USE_COLORS = False