def get_p2wpkh_segwit(self, witness_version: int): if self.segwit_p2wpkh is None: compressed = self.get_compressed_hash160_address() prefix = "bc" self.segwit_p2wpkh = segwit_addr.encode( prefix, witness_version, binascii.unhexlify(compressed)) return self.segwit_p2wpkh
def address_for_pay_to_script_wit(script, netcode=None): if netcode is None: netcode = get_current_netcode() bech32_hrp = bech32_hrp_for_netcode(netcode) address = segwit_addr.encode(bech32_hrp, 0, iterbytes(hashlib.sha256(script).digest())) return address
def address_f(netcode=netcode): from pycoin.networks import bech32_hrp_for_netcode from pycoin.networks.default import get_current_netcode if netcode is None: netcode = get_current_netcode() bech32_hrp = bech32_hrp_for_netcode(netcode) address = segwit_addr.encode(bech32_hrp, self.version, self.hash256) return address
def address_f(netcode=netcode): from pycoin.networks import bech32_hrp_for_netcode from pycoin.networks.default import get_current_netcode if netcode is None: netcode = get_current_netcode() bech32_hrp = bech32_hrp_for_netcode(netcode) if bech32_hrp: return segwit_addr.encode(bech32_hrp, self.version, iterbytes(self.hash160)) return None
def for_p2sh_wit(self, hash256): assert len(hash256) == 32 return segwit_addr.encode(bech32_hrp, 0, iterbytes(hash256))
def for_p2pkh_wit(self, h160): assert len(h160) == 20 return segwit_addr.encode(bech32_hrp, 0, iterbytes(h160))
def address_for_p2sh_wit(self, hash256): if self._bech32_hrp and len(hash256) == 32: return segwit_addr.encode(self._bech32_hrp, 0, iterbytes(hash256)) return "???"
def address_for_p2pkh_wit(self, h160): if self._bech32_hrp and len(h160) == 20: return segwit_addr.encode(self._bech32_hrp, 0, iterbytes(h160)) return "???"
def bech32_p2wpkh_address(self) -> str: hrp = bech32_hrp_for_netcode(self.netcode()) witprog_version = 1 p2aw_script = self.p2wpkh_script() return segwit_addr.encode(hrp, witprog_version, p2aw_script)