def main(filename, cost, skip, txsize, refresh, api_key, verbose): """ Updates maxfee_kb in JSON coin definitions. The new value is calculated from the --cost argument which specifies maximum transaction fee in fiat denomination. The fee is converted to coin value using current price data. Then per-kilobyte fee is computed using given transaction size. If no filenames are provided, all definitions except Bitcoin and testnets are updated. """ setup_logging(verbose) marketcap.init(api_key, refresh=refresh) if len(filename) > 0: coin_files = filename else: coin_files = glob.glob( os.path.join(coin_info.DEFS_DIR, "bitcoin", "*.json")) if len(skip) == 0: skip = DEFAULT_SKIP_RE for filename in sorted(coin_files): coin = coin_info.load_json(filename) short = coin["coin_shortcut"] if any(re.search(s, coin["coin_name"]) is not None for s in skip): logging.warning(f"{short}:\tskipping because --skip matches") continue price = marketcap.fiat_price(short) if price is None: logging.error(f"{short}:\tno price data, skipping") continue old_maxfee_kb = coin["maxfee_kb"] new_maxfee_kb = round_sats(compute_maxfee(cost, price, txsize)) if old_maxfee_kb != new_maxfee_kb: coin["maxfee_kb"] = new_maxfee_kb with open(filename, "w") as fh: json.dump(coin, fh, indent=2) fh.write("\n") logging.info( f"{short}:\tupdated {old_maxfee_kb} -> {new_maxfee_kb}") delta = delta_percent(old_maxfee_kb, new_maxfee_kb) if delta > MAX_DELTA_PERCENT: logging.warning(f"{short}:\tprice has changed by {delta} %") else: logging.info(f"{short}:\tno change")
import logging import os import sys import time import click import coin_info import marketcap LOG = logging.getLogger(__name__) OPTIONAL_KEYS = ("links", "notes", "wallet") ALLOWED_SUPPORT_STATUS = ("yes", "no", "planned", "soon") WALLETS = coin_info.load_json("wallets.json") OVERRIDES = coin_info.load_json("coins_details.override.json") VERSIONS = coin_info.latest_releases() # automatic wallet entries WALLET_SUITE = {"Trezor Suite": "https://suite.trezor.io"} WALLET_NEM = { "Nano Wallet": "https://nem.io/downloads/", "Magnum": "https://magnumwallet.co", } WALLETS_ETH_3RDPARTY = { "MyEtherWallet": "https://www.myetherwallet.com", "MyCrypto": "https://mycrypto.com", } TREZOR_KNOWN_URLS = (
import os import time import json import logging import requests import sys import coin_info import click LOG = logging.getLogger(__name__) OPTIONAL_KEYS = ("links", "notes", "wallet") ALLOWED_SUPPORT_STATUS = ("yes", "no", "planned", "soon") OVERRIDES = coin_info.load_json("coins_details.override.json") VERSIONS = coin_info.latest_releases() COINMAKETCAP_CACHE = os.path.join(os.path.dirname(__file__), "coinmarketcap.json") COINMARKETCAP_API_BASE = "https://pro-api.coinmarketcap.com/v1/" MARKET_CAPS = {} def coinmarketcap_call(endpoint, api_key, params=None): url = COINMARKETCAP_API_BASE + endpoint r = requests.get(url, params=params, headers={"X-CMC_PRO_API_KEY": api_key}) r.raise_for_status() return r.json()
import os import time import json import logging import requests import sys import coin_info import click LOG = logging.getLogger(__name__) OPTIONAL_KEYS = ("links", "notes", "wallet") ALLOWED_SUPPORT_STATUS = ("yes", "no", "planned", "soon") WALLETS = coin_info.load_json("wallets.json") OVERRIDES = coin_info.load_json("coins_details.override.json") VERSIONS = coin_info.latest_releases() COINMAKETCAP_CACHE = os.path.join(os.path.dirname(__file__), "coinmarketcap.json") COINMARKETCAP_API_BASE = "https://pro-api.coinmarketcap.com/v1/" MARKET_CAPS = {} # automatic wallet entries WALLET_TREZOR = {"Trezor": "https://wallet.trezor.io"} WALLET_TREZOR_NEXT = {"Trezor Beta": "https://beta-wallet.trezor.io/next/"} WALLET_NEM = {"Nano Wallet": "https://nem.io/downloads/"} WALLETS_ETH_3RDPARTY = { "MyEtherWallet": "https://www.myetherwallet.com",