本文整理汇总了Python中pycoin.key.Key._netcode方法的典型用法代码示例。如果您正苦于以下问题:Python Key._netcode方法的具体用法?Python Key._netcode怎么用?Python Key._netcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycoin.key.Key
的用法示例。
在下文中一共展示了Key._netcode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pycoin.key import Key [as 别名]
# 或者: from pycoin.key.Key import _netcode [as 别名]
def main():
networks = "MTLD"
parser = argparse.ArgumentParser(
description='Crypto coin utility ku ("key utility") to show'
' information about Bitcoin or other cryptocoin data structures.',
epilog='Known networks codes:\n ' \
+ ', '.join(['%s (%s)'%(i, full_network_name_for_netcode(i)) for i in NETWORK_NAMES])
)
parser.add_argument('-w', "--wallet", help='show just Bitcoin wallet key', action='store_true')
parser.add_argument('-W', "--wif", help='show just Bitcoin WIF', action='store_true')
parser.add_argument('-a', "--address", help='show just Bitcoin address', action='store_true')
parser.add_argument(
'-u', "--uncompressed", help='show output in uncompressed form',
action='store_true')
parser.add_argument(
'-P', "--public", help='only show public version of wallet keys',
action='store_true')
parser.add_argument('-j', "--json", help='output as JSON', action='store_true')
parser.add_argument('-s', "--subkey", help='subkey path (example: 0H/2/15-20)')
parser.add_argument('-n', "--network", help='specify network (default: BTC = Bitcoin)',
default='BTC', choices=NETWORK_NAMES)
parser.add_argument("--override-network", help='override detected network type',
default=None, choices=NETWORK_NAMES)
parser.add_argument(
'item', nargs="+", help='a BIP0032 wallet key string;'
' a WIF;'
' a bitcoin address;'
' an SEC (ie. a 66 hex chars starting with 02, 03 or a 130 hex chars starting with 04);'
' the literal string "create" to create a new wallet key using strong entropy sources;'
' P:wallet passphrase (NOT RECOMMENDED);'
' H:wallet passphrase in hex (NOT RECOMMENDED);'
' secret_exponent (in decimal or hex);'
' x,y where x,y form a public pair (y is a number or one of the strings "even" or "odd");'
' hash160 (as 40 hex characters)')
args = parser.parse_args()
if args.override_network:
# force network arg to match override, but also will override decoded data below.
args.network = args.override_network
def _create(_):
max_retries = 64
for _ in range(max_retries):
try:
return BIP32Node.from_master_secret(get_entropy(), netcode=args.network)
except ValueError as e:
continue
# Probably a bug if we get here
raise e
PREFIX_TRANSFORMS = (
("P:", lambda s:
BIP32Node.from_master_secret(s.encode("utf8"), netcode=args.network)),
("H:", lambda s:
BIP32Node.from_master_secret(h2b(s), netcode=args.network)),
("create", _create),
)
for item in args.item:
key = None
for k, f in PREFIX_TRANSFORMS:
if item.startswith(k):
try:
key = f(item[len(k):])
break
except Exception:
pass
else:
try:
key = Key.from_text(item)
except encoding.EncodingError:
pass
if key is None:
secret_exponent = parse_as_secret_exponent(item)
if secret_exponent:
key = Key(secret_exponent=secret_exponent, netcode=args.network)
if SEC_RE.match(item):
key = Key.from_sec(h2b(item))
if key is None:
public_pair = parse_as_public_pair(item)
if public_pair:
key = Key(public_pair=public_pair, netcode=args.network)
if HASH160_RE.match(item):
key = Key(hash160=h2b(item), netcode=args.network)
if key is None:
print("can't parse %s" % item, file=sys.stderr)
continue
if args.override_network:
# Override the network value, so we can take the same xpubkey and view what
# the values would be on each other network type.
# XXX public interface for this is needed...
#.........这里部分代码省略.........