proto.decoded_addr: add ver_bytes field
This commit is contained in:
parent
8035688fb7
commit
a48b43c838
4 changed files with 5 additions and 4 deletions
|
|
@ -148,6 +148,7 @@ class CoinAddr(str,Hilite,InitErrors,MMGenObject):
|
|||
assert ap, f'coin address {addr!r} could not be parsed'
|
||||
me.addr_fmt = ap.fmt
|
||||
me.hex = ap.bytes.hex()
|
||||
me.ver_bytes = ap.ver_bytes
|
||||
me.proto = proto
|
||||
return me
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
|
|||
msg(f'{ret[0]}: Invalid witness version number')
|
||||
return False
|
||||
|
||||
return decoded_addr( bytes(ret[1]), 'bech32' ) if ret[1] else False
|
||||
return decoded_addr( bytes(ret[1]), None, 'bech32' ) if ret[1] else False
|
||||
|
||||
return self.decode_addr_bytes(b58chk_decode(addr))
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1):
|
|||
|
||||
def decode_addr(self,addr):
|
||||
if is_hex_str_lc(addr) and len(addr) == self.addr_len * 2:
|
||||
return decoded_addr( bytes.fromhex(addr), 'ethereum' )
|
||||
return decoded_addr( bytes.fromhex(addr), None, 'ethereum' )
|
||||
if g.debug:
|
||||
Msg(f'Invalid address: {addr}')
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from .devtools import *
|
|||
from .globalvars import g
|
||||
|
||||
parsed_wif = namedtuple('parsed_wif',['sec','pubkey_type','compressed'])
|
||||
decoded_addr = namedtuple('decoded_addr',['bytes','fmt'])
|
||||
decoded_addr = namedtuple('decoded_addr',['bytes','ver_bytes','fmt'])
|
||||
|
||||
_finfo = namedtuple('fork_info',['height','hash','name','replayable'])
|
||||
_nw = namedtuple('coin_networks',['mainnet','testnet','regtest'])
|
||||
|
|
@ -143,7 +143,7 @@ class CoinProtocol(MMGenObject):
|
|||
vlen = len(ver_bytes)
|
||||
if addr_bytes[:vlen] == ver_bytes:
|
||||
if len(addr_bytes[vlen:]) == self.get_addr_len(addr_fmt):
|
||||
return decoded_addr( addr_bytes[vlen:], addr_fmt )
|
||||
return decoded_addr( addr_bytes[vlen:], ver_bytes, addr_fmt )
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue