proto/common.py -> proto/btc/common.py
This commit is contained in:
parent
70762c0f56
commit
d8965706d5
10 changed files with 13 additions and 13 deletions
|
|
@ -272,7 +272,7 @@ class AddrList(MMGenObject): # Address info for a single seed ID
|
|||
return out
|
||||
|
||||
def gen_wallet_passwd(self,privbytes):
|
||||
from .proto.common import hash256
|
||||
from .proto.btc.common import hash256
|
||||
return WalletPassword( hash256(privbytes)[:16].hex() )
|
||||
|
||||
def check_format(self,addr):
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ class CoinInfo(object):
|
|||
return '1'
|
||||
|
||||
def phash2addr(ver_num,pk_hash):
|
||||
from .proto.common import b58chk_encode
|
||||
from .proto.btc.common import b58chk_encode
|
||||
bl = ver_num.bit_length()
|
||||
ver_bytes = int.to_bytes(ver_num,bl//8 + bool(bl%8),'big')
|
||||
return b58chk_encode(ver_bytes + pk_hash)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.btc.addrgen: Bitcoin address generation classes for the MMGen suite
|
|||
|
||||
from ...addrgen import addr_generator,check_data
|
||||
from ...addr import CoinAddr
|
||||
from ..common import hash160
|
||||
from .common import hash160
|
||||
|
||||
class p2pkh(addr_generator.base):
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
# https://gitlab.com/mmgen/mmgen
|
||||
|
||||
"""
|
||||
proto.common: Functions and constants used by multiple protocols
|
||||
proto.btc.common: Shared Bitcoin functions and constants
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
|
|
@ -13,7 +13,7 @@ Bitcoin protocol
|
|||
"""
|
||||
|
||||
from ...protocol import CoinProtocol,decoded_wif,decoded_addr,_finfo,_nw
|
||||
from ..common import *
|
||||
from .common import b58chk_decode,b58chk_encode,hash160
|
||||
|
||||
class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proto.zec.addrgen: Zcash-Z address generation class for the MMGen suite
|
|||
|
||||
from ...addrgen import addr_generator,check_data
|
||||
from ...addr import CoinAddr
|
||||
from ..common import b58chk_encode
|
||||
from ..btc.common import b58chk_encode
|
||||
|
||||
class zcash_z(addr_generator.base):
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Zcash protocol
|
|||
"""
|
||||
|
||||
from ..btc.params import mainnet
|
||||
from ..common import b58chk_decode
|
||||
from ..btc.common import b58chk_decode
|
||||
from ...protocol import decoded_wif,decoded_addr
|
||||
from ...addr import CoinAddr
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class tool_cmd(tool_cmd_base):
|
|||
def pubhex2redeem_script(self,pubkeyhex:'sstr'): # new
|
||||
"convert a hexadecimal pubkey to a Segwit P2SH-P2WPKH redeem script"
|
||||
assert self.mmtype.name == 'segwit','This command is meaningful only for --type=segwit'
|
||||
from ..proto.common import hash160
|
||||
from ..proto.btc.common import hash160
|
||||
return self.proto.pubhash2redeem_script( hash160(bytes.fromhex(pubkeyhex)) ).hex()
|
||||
|
||||
def redeem_script2addr(self,redeem_script_hex:'sstr'): # new
|
||||
|
|
@ -155,7 +155,7 @@ class tool_cmd(tool_cmd_base):
|
|||
assert self.mmtype.name == 'segwit', 'This command is meaningful only for --type=segwit'
|
||||
assert redeem_script_hex[:4] == '0014', f'{redeem_script_hex!r}: invalid redeem script'
|
||||
assert len(redeem_script_hex) == 44, f'{len(redeem_script_hex)//2} bytes: invalid redeem script length'
|
||||
from ..proto.common import hash160
|
||||
from ..proto.btc.common import hash160
|
||||
return self.proto.pubhash2addr(
|
||||
hash160( bytes.fromhex(redeem_script_hex) ),
|
||||
p2sh = True )
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
def hash160(self,hexstr:'sstr'):
|
||||
"compute ripemd160(sha256(data)) (convert hex pubkey to hex addr)"
|
||||
from ..proto.common import hash160
|
||||
from ..proto.btc.common import hash160
|
||||
return hash160( bytes.fromhex(hexstr) ).hex()
|
||||
|
||||
# TODO: handle stdin
|
||||
|
|
@ -195,12 +195,12 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
def hextob58chk(self,hexstr:'sstr'):
|
||||
"convert a hexadecimal string to base58-check encoding"
|
||||
from ..proto.common import b58chk_encode
|
||||
from ..proto.btc.common import b58chk_encode
|
||||
return b58chk_encode( bytes.fromhex(hexstr) )
|
||||
|
||||
def b58chktohex(self,b58chk_str:'sstr'):
|
||||
"convert a base58-check encoded string to hexadecimal"
|
||||
from ..proto.common import b58chk_decode
|
||||
from ..proto.btc.common import b58chk_decode
|
||||
return b58chk_decode(b58chk_str).hex()
|
||||
|
||||
def hextob32(self,hexstr:'sstr',pad: 'pad output to this width' = 0):
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from .objmethods import Hilite,InitErrors
|
|||
from .obj import CoinTxID
|
||||
from .seed import SeedID
|
||||
from .protocol import init_proto
|
||||
from .proto.common import b58a
|
||||
from .proto.btc.common import b58a
|
||||
from .addr import CoinAddr,AddrIdx
|
||||
from .addrlist import KeyAddrList,AddrIdxList
|
||||
from .rpc import json_encoder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue