Skip to content

Commit

Permalink
Deprecate "netcode" for "symbol".
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkiss committed Aug 19, 2018
1 parent b77f122 commit a682ffb
Show file tree
Hide file tree
Showing 35 changed files with 104 additions and 106 deletions.
12 changes: 6 additions & 6 deletions pycoin/cmds/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def trace_script(opcode, data, pc, vmc):
def dump_inputs(output, tx, network, verbose_signature, traceback_f, disassembly_level):
for idx, tx_in in enumerate(tx.txs_in):
if tx.is_coinbase():
output.append("%4d: COINBASE %12.5f m%s" % (idx, satoshi_to_mbtc(tx.total_in()), network.code))
output.append("%4d: COINBASE %12.5f m%s" % (idx, satoshi_to_mbtc(tx.total_in()), network.symbol))
continue
suffix = ""
if tx.missing_unspent(idx):
Expand All @@ -60,7 +60,7 @@ def dump_inputs(output, tx, network, verbose_signature, traceback_f, disassembly
else:
tx_out = tx.unspents[idx]
sig_result = " sig ok" if tx.is_solution_ok(idx, traceback_f=traceback_f) else " BAD SIG"
suffix = " %12.5f m%s %s" % (satoshi_to_mbtc(tx_out.coin_value), network.code, sig_result)
suffix = " %12.5f m%s %s" % (satoshi_to_mbtc(tx_out.coin_value), network.symbol, sig_result)
address = network.ui.address_for_script(tx_out.puzzle_script())
t = "%4d: %34s from %s:%-4d%s" % (idx, address, b2h_rev(tx_in.previous_hash),
tx_in.previous_index, suffix)
Expand Down Expand Up @@ -104,11 +104,11 @@ def dump_signatures(output, tx, tx_in, tx_out, idx, network, traceback_f):

def dump_footer(network, output, tx, missing_unspents):
if not missing_unspents:
output.append("Total input %12.5f m%s" % (satoshi_to_mbtc(tx.total_in()), network.code))
output.append("Total input %12.5f m%s" % (satoshi_to_mbtc(tx.total_in()), network.symbol))
if 1:
output.append("Total output %12.5f m%s" % (satoshi_to_mbtc(tx.total_out()), network.code))
output.append("Total output %12.5f m%s" % (satoshi_to_mbtc(tx.total_out()), network.symbol))
if not missing_unspents:
output.append("Total fees %12.5f m%s" % (satoshi_to_mbtc(tx.fee()), network.code))
output.append("Total fees %12.5f m%s" % (satoshi_to_mbtc(tx.fee()), network.symbol))


def dump_tx(output, tx, network, verbose_signature, disassembly_level, do_trace, use_pdb):
Expand All @@ -123,7 +123,7 @@ def dump_tx(output, tx, network, verbose_signature, disassembly_level, do_trace,
for idx, tx_out in enumerate(tx.tx_outs_as_spendable()):
amount_mbtc = satoshi_to_mbtc(tx_out.coin_value)
address = network.ui.address_for_script(tx_out.puzzle_script()) or "(unknown)"
output.append("%4d: %34s receives %12.5f m%s" % (idx, address, amount_mbtc, network.code))
output.append("%4d: %34s receives %12.5f m%s" % (idx, address, amount_mbtc, network.symbol))
if disassembly_level > 0:
for (pre_annotations, pc, opcode, instruction, post_annotations) in \
network.extras.annotate.annotate_spendable(tx.__class__, tx_out):
Expand Down
2 changes: 1 addition & 1 deletion pycoin/cmds/ku.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def add_output(json_key, value=None, human_readable_key=None):
full_network_name = "%s %s" % (network.network_name, network.subnet_name)
add_output("input", item)
add_output("network", full_network_name)
add_output("netcode", network.code)
add_output("symbol", network.symbol)

if hasattr(key, "hwif"):
if subkey_path:
Expand Down
4 changes: 2 additions & 2 deletions pycoin/cmds/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def parse_scripts(args, keychain):


def create_tx_db(network):
tx_db = get_tx_db(network.code)
tx_db = get_tx_db(network.symbol)
tx_db.warning_tx_cache = message_about_tx_cache_env()
tx_db.warning_tx_for_tx_hash = message_about_tx_for_tx_hash_env(network.code)
tx_db.warning_tx_for_tx_hash = message_about_tx_for_tx_hash_env(network.symbol)
return tx_db


Expand Down
10 changes: 4 additions & 6 deletions pycoin/networks/bitcoinish.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ def f(public_pair):

address = ui_context.address_for_p2pkh(hash160 or hash160_c)
yield ("address", address, "%s address" % network_name)
yield ("%s_address" % network.code, address, "legacy")
yield ("%s_address" % network.symbol, address, "legacy")

if hash160_c and hash160_u:
address = key.address(use_uncompressed=True)
yield ("address_uncompressed", address, "%s address uncompressed" % network_name)
yield ("%s_address_uncompressed" % network.code, address, "legacy")
yield ("%s_address_uncompressed" % network.symbol, address, "legacy")

# don't print segwit addresses unless we're sure we have a compressed key
if hash160_c and hasattr(network, "ui") and getattr(network.ui, "_bech32_hrp"):
address_segwit = network.ui.address_for_p2pkh_wit(hash160_c)
if address_segwit:
# this network seems to support segwit
yield ("address_segwit", address_segwit, "%s segwit address" % network_name)
yield ("%s_address_segwit" % network.code, address_segwit, "legacy")
yield ("%s_address_segwit" % network.symbol, address_segwit, "legacy")

p2sh_script = network.ui._script_info.script_for_p2pkh_wit(hash160_c)
p2s_address = network.ui.address_for_p2s(p2sh_script)
Expand All @@ -138,7 +138,7 @@ def f(hash160):

address = network.ui.address_for_p2pkh(hash160)
yield ("address", address, "%s address" % network.network_name)
yield ("%s_address" % network.code, address, "legacy")
yield ("%s_address" % network.symbol, address, "legacy")
return f


Expand Down Expand Up @@ -175,7 +175,6 @@ def create_bitcoinish_network(symbol, network_name, subnet_name, **kwargs):
NETWORK_KEYS = ("network_name subnet_name tx block ui extras "
"dns_bootstrap default_port magic_header").split()
network_kwargs = {k: kwargs.get(k) for k in NETWORK_KEYS if k in kwargs}
network_kwargs["code"] = symbol # BRAIN DAMAGE

for k, v in network_kwargs.items():
setattr(network, k, v)
Expand All @@ -185,7 +184,6 @@ def create_bitcoinish_network(symbol, network_name, subnet_name, **kwargs):
streamer, standard_messages(), standard_message_post_unpacks(streamer))

network.script_info = _script_info
network.code = network.symbol
network.script_tools = scriptTools
network.output_for_hwif = make_output_for_hwif(network)
network.output_for_secret_exponent = make_output_for_secret_exponent(network.extras.Key)
Expand Down
4 changes: 2 additions & 2 deletions pycoin/networks/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def network_for_netcode(symbol):
for prefix in search_prefixes():
try:
module = importlib.import_module("%s.%s" % (prefix, netcode))
if module.network.code.upper() == symbol:
if module.network.symbol.upper() == symbol:
module.symbol = symbol
return module.network
except (AttributeError, ImportError):
Expand All @@ -35,7 +35,7 @@ def iterate_symbols():
for importer, modname, ispkg in pkgutil.walk_packages(path=package.__path__, onerror=lambda x: None):
network = network_for_netcode(modname)
if network:
yield network.code.upper()
yield network.symbol.upper()


def network_codes():
Expand Down
4 changes: 2 additions & 2 deletions pycoin/ui/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def is_address_valid(address, allowable_types=None, allowable_netcodes=None):
k = network.ui.parse_to_info(metadata, types=["address"])
if k:
if allowable_types is None or k.get("address_type") in allowable_types:
return network.code
return network.symbol
return None


Expand All @@ -33,7 +33,7 @@ def _is_key_valid(text, allowable_netcodes, info_filter_f, types=["key"]):
k = network.ui.parse_to_info(metadata, types=types)
if k:
if info_filter_f(k):
return network.code
return network.symbol
return None


Expand Down
2 changes: 1 addition & 1 deletion tests/cmds/test_cases/ku/bip32_keyphrase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ku P:foo

input : P:foo
network : Bitcoin mainnet
netcode : BTC
symbol : BTC
wallet key : xprv9s21ZrQH143K31AgNK5pyVvW23gHnkBq2wh5aEk6g1s496M8ZMjxncCKZKgb5j\
ZoY5eSJMJ2Vbyvi2hbmQnCuHBujZ2WXGTux1X2k9Krdtq
public version : xpub661MyMwAqRbcFVF9ULcqLdsEa5WnCCugQAcgNd9iEMQ31tgH6u4DLQWoQayvtS\
Expand Down
12 changes: 6 additions & 6 deletions tests/cmds/test_cases/ku/bip32_subpaths_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ku -j P:foo -s 5-10
"input": "P:foo",
"key_pair_as_sec": "0378a0d972953591dcf8f6220a0e1e5a2291b0a503604095d64a1e046ec8c0bfa8",
"key_pair_as_sec_uncompressed": "0478a0d972953591dcf8f6220a0e1e5a2291b0a503604095d64a1e046ec8c0bfa81e81dde9b0926b2b0587286684670938d0f995a00b11bd1cf78320c38f7da863",
"netcode": "BTC",
"network": "Bitcoin mainnet",
"p2sh_segwit": "3ELJbuAHwifoBaCWExbJcy5t9Za1PLjEzB",
"p2sh_segwit_script": "0014639c2e98539808eb087fa64543efc4dd7aaa5e4e",
Expand All @@ -27,6 +26,7 @@ ku -j P:foo -s 5-10
"public_version": "xpub68aEVREZHhr72mZLNzBxQ1k3FY3uj3o6s85T2i9Bvi6FMK31SDpyEKWnggnTwV4C9arVkTf3mmseHPhRX1CinoxPnTurziTAZzNBmVRE8VH",
"secret_exponent": "40918369503193358591655779847354936042373884792933527980707662629744645039409",
"secret_exponent_hex": "5a76f9f65f9ab0896dfbcab181a64cdc7d5511cb57b2a68be30267936fd8e531",
"symbol": "BTC",
"tree_depth": "1",
"wallet_key": "xprv9uat5uhfTLHopHUsGxex2soJhWDRKb5FVu9rEKjaNNZGUWhrtgWigXCJqPafqKYAosYpgzw9L64C1HJvu2t54UJ9DYZWBsVcfHzUKUGhopL",
"wif": "KzFZadNu81enWFLRLXt4ACqsGriW4gQ4ou5ZfVUZutrRF8uoTyrA",
Expand All @@ -48,7 +48,6 @@ ku -j P:foo -s 5-10
"input": "P:foo",
"key_pair_as_sec": "0342009b6607d46faa21abd7e71ecc8fa83b5f9add661aba2af65e997fb7f107e0",
"key_pair_as_sec_uncompressed": "0442009b6607d46faa21abd7e71ecc8fa83b5f9add661aba2af65e997fb7f107e02735caaecc69ac891afbe2cc61a2f163c5f437bbdf8674c1dbbe34e9e3c67b7f",
"netcode": "BTC",
"network": "Bitcoin mainnet",
"p2sh_segwit": "3MGZvnJLZfAzEo1kiS45W6EpcHWhzzFSM8",
"p2sh_segwit_script": "0014f39a290b7a6ff88c8c61cecc9a8e7b742a23ef6e",
Expand All @@ -61,6 +60,7 @@ ku -j P:foo -s 5-10
"public_version": "xpub68aEVREZHhr74Yttv3btt36dsViBXyoCcY358VDs8DkqHb9J5Y7vwavtr56k71hEVRf7ZAM1S9UtGarUkLjqEDmYE2vH6bMa2iWsNDgvbWS",
"secret_exponent": "75103382993292550813022707013026401143473390552852219021491906081137013555534",
"secret_exponent_hex": "a60b02255c8dc2c4ae81843d41a5be129b53f1af377b33ae664e1e2e804c014e",
"symbol": "BTC",
"tree_depth": "1",
"wallet_key": "xprv9uat5uhfTLHor4pRp24tWu9uKTsh8X5MFK7UL6pFZtDrQnp9XzogPncQzntHtZ23tMKPiUyPedgXb55Z7rYrngBNuzwCbyNUXGUraeicShc",
"wif": "L2nUc8tUPHHSRHe2wkWv2wwoszv3p9X1hASzfyf9bYi81w1R2AVx",
Expand All @@ -82,7 +82,6 @@ ku -j P:foo -s 5-10
"input": "P:foo",
"key_pair_as_sec": "032a881c9182821c7153663572cb657cdaa69128f555bec8982d443f427c717f39",
"key_pair_as_sec_uncompressed": "042a881c9182821c7153663572cb657cdaa69128f555bec8982d443f427c717f396a45e73f0b46c4d431b054b99cda747608950a1dbbc17d2c59439f558a822d71",
"netcode": "BTC",
"network": "Bitcoin mainnet",
"p2sh_segwit": "3BEmuNdXqK5XdG4g5Ypz8XUTJc2hSRbE9N",
"p2sh_segwit_script": "00149c6b340312237006369bba466eb846ff3b5c62f5",
Expand All @@ -95,6 +94,7 @@ ku -j P:foo -s 5-10
"public_version": "xpub68aEVREZHhr76nAdFAe6K2H39y2KrJxGWtX2Sv3EVXRCFJdfZsq8TZst4KmRCvT5QEYMTko7pKrkqXwtPVKuN2X7xjnhrmpTN5cL9pVpADG",
"secret_exponent": "78954076812467044262705749545456798798317520337466927399368208082095870538940",
"secret_exponent_hex": "ae8e6c8158b424e65a1bdb85693d44fa8e249fa6143b39a92821aa0d7a9b74bc",
"symbol": "BTC",
"tree_depth": "1",
"wallet_key": "xprv9uat5uhfTLHotJ6A9975wtLJbwBqSrER9fbReXdcwBtDNWJX2LWsumZQD3o3ypufv6JxH2k5FdJC4XFR65m3UQEeievrMivEWMyKA2RJswm",
"wif": "L352SNyuqHvNH8PpQYiVzUiifaPMfEG1fJ52MRCrrJDwUcKGYt5F",
Expand All @@ -116,7 +116,6 @@ ku -j P:foo -s 5-10
"input": "P:foo",
"key_pair_as_sec": "02288828380f4a40619ab1c54f7490f52306835e7bd5e8c540f884f9f4e3157171",
"key_pair_as_sec_uncompressed": "04288828380f4a40619ab1c54f7490f52306835e7bd5e8c540f884f9f4e3157171e1b22857caa0aeff5067a0f20acdc3d2d5aca73db7f0a7b2049faaa439677ba0",
"netcode": "BTC",
"network": "Bitcoin mainnet",
"p2sh_segwit": "3KRpSzFGdEr1me3ApDurGUKbSXtF7NP728",
"p2sh_segwit_script": "00141e71ebce1b3f50ecd78b44598dab4351ae426a20",
Expand All @@ -129,6 +128,7 @@ ku -j P:foo -s 5-10
"public_version": "xpub68aEVREZHhr78VQQTUk7FEuCYBm29gZFbtAMzG3fYPeHaqxi6K5GtxPQDXJPzyVRyDVWtQmzNR7SCwSWUwbaidNimNb4wJyuVYqd5vPYKLr",
"secret_exponent": "107462026720556236616484426653791453571709178385594686554100345484864641650754",
"secret_exponent_hex": "ed955a08c5b1025ac28b812094a1b931f693b99e175a5c3ea723ec2e8f8d5042",
"symbol": "BTC",
"tree_depth": "1",
"wallet_key": "xprv9uat5uhfTLHov1KwMTD6t6xTz9vXkDqQEfEmBse3z47Ji3dZYmm2MA4vNHmQyXkN9JKetTW6PCXHVGc5mXSFmZqGrdk1vEGsNG6cLv5NXT8",
"wif": "L5BYPTRGyiLJGfucqsai7t5jskmLbRhGRJ4AEKaJzQWDTJBfCP7g",
Expand All @@ -150,7 +150,6 @@ ku -j P:foo -s 5-10
"input": "P:foo",
"key_pair_as_sec": "02bc7c9c4b6a3944d3c8f9b1dc8fe362172a7dbe724aad6363c3f82910e41e1428",
"key_pair_as_sec_uncompressed": "04bc7c9c4b6a3944d3c8f9b1dc8fe362172a7dbe724aad6363c3f82910e41e14287ea63b21525757e89a6b7ef3ec2b9714bdaafc46b1cabf8fe46e9ae2c841a754",
"netcode": "BTC",
"network": "Bitcoin mainnet",
"p2sh_segwit": "32LXf368At98ibdWwLrW6pJt5PBXq9QTVo",
"p2sh_segwit_script": "0014ef264fe68474d1955d41d2e0645f2df88f569739",
Expand All @@ -163,6 +162,7 @@ ku -j P:foo -s 5-10
"public_version": "xpub68aEVREZHhr7CkmrbKPWETyT3zuPvzPB1ShsnyKsZLC1b9aL2SUAzo5f6kaisyv48wFUQe7ovuem8TGcfPqFCRyAQNaZmcdE29a3BkB6LAz",
"secret_exponent": "40325196013906318172997347138488077663161531717996424433674181404381159275615",
"secret_exponent_hex": "5927408ad317270eafed9eed841853d95927e1eb51d1700334d792eb9d9abc5f",
"symbol": "BTC",
"tree_depth": "1",
"wallet_key": "xprv9uat5uhfTLHozGhPVHrVsL2iVy4uXXfKeDnGzavFzzf2iMFBUu9vSzmBFUoD6frq5o1sYLPocoaWo2xnqeeAHmVXBJ9gf8LypAEftHTc3Bh",
"wif": "KzD1j134pMHZ35U8tgkwe9oCCnYGiDNPQAg4imLqPdqWeYJQ2rKB",
Expand All @@ -184,7 +184,6 @@ ku -j P:foo -s 5-10
"input": "P:foo",
"key_pair_as_sec": "026f2ac6865005d4e6c1e6605d4fb3d67df4ceabd582aa84d98e668c2cbbeac6cc",
"key_pair_as_sec_uncompressed": "046f2ac6865005d4e6c1e6605d4fb3d67df4ceabd582aa84d98e668c2cbbeac6cc062011ce1d912338c1c3ed6ed64f7b566bebd22eb6c1865a7e34f7628171beea",
"netcode": "BTC",
"network": "Bitcoin mainnet",
"p2sh_segwit": "33xCsFEYVijkrQkynb9gfsJEkLZRudGnUr",
"p2sh_segwit_script": "00147d423c8fb2af77053c30219f6257dbfa0737ba0d",
Expand All @@ -197,6 +196,7 @@ ku -j P:foo -s 5-10
"public_version": "xpub68aEVREZHhr7FVcVGP3o16mrTX7VRS8PW1a7wpqdiLskrYqKmHpwfAJWDBX1gXLXJoXbF5iay6fvXnKiKCGAHKxE6zPrj35GBSdPJt98dda",
"secret_exponent": "61244055186273633076491690690983351171079007835517960602599216301867941360994",
"secret_exponent_hex": "8766e825e65022f510851c923e0b5fccd93b3ecec2cabade644c66f25a21f562",
"symbol": "BTC",
"tree_depth": "1",
"wallet_key": "xprv9uat5uhfTLHp31Y2AMWndxq7uVH11yQY8neX9SS2A1LmykWBDkWh7Mz2MvfvHeiVR5u99yXuyqhEZKvgKgTpSQCiJmMN6vWy44TAiYnqHMa",
"wif": "L1kv16ChRQ2aYYYFUSSyRUa1B2EtUHCKAZkw1aP8Z4KgfHMNK37N",
Expand Down
Loading

0 comments on commit a682ffb

Please sign in to comment.