예제 #1
0
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
예제 #2
0
파일: intstream.py 프로젝트: wpr101/pycoin
 def from_bytes(bytes, byteorder="big", signed=False):
     if byteorder != "big":
         bytes = reversed(bytes)
     v = 0
     for c in iterbytes(bytes):
         v <<= 8
         v += c
     if signed and byte2int(bytes) & 0x80:
         v = v - (1 << (8 * len(bytes)))
     return v
        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
예제 #4
0
 def from_bytes(bytes, byteorder="big", signed=False):
     "See int.from_bytes in python 3"
     if byteorder != "big":
         bytes = reversed(bytes)
     v = 0
     for c in iterbytes(bytes):
         v <<= 8
         v += c
     if signed and byte2int(bytes) & 0x80:
         v = v - (1 << (8*len(bytes)))
     return v
예제 #5
0
 def from_bytes(bytes, byteorder="big", signed=False):
     """This is the same functionality as ``int.from_bytes`` in python 3"""
     if byteorder != "big":
         bytes = reversed(bytes)
     v = 0
     for c in iterbytes(bytes):
         v <<= 8
         v += c
     if signed and byte2int(bytes) & 0x80:
         v = v - (1 << (8*len(bytes)))
     return v
예제 #6
0
def ip_bin_to_ip4_addr(ip_bin):
    return "%d.%d.%d.%d" % tuple(iterbytes(ip_bin[-4:]))
예제 #7
0
 def do_test(as_int, prefix, as_rep, base):
     self.assertEqual((as_int, prefix), to_long(base, lambda v: v, iterbytes(as_rep)))
     self.assertEqual(as_rep, from_long(as_int, prefix, base, lambda v: v))
예제 #8
0
def ip_bin_to_ip4_addr(ip_bin):
    return "%d.%d.%d.%d" % tuple(iterbytes(ip_bin[-4:]))
예제 #9
0
 def for_p2sh_wit(self, hash256):
     assert len(hash256) == 32
     return segwit_addr.encode(bech32_hrp, 0, iterbytes(hash256))
예제 #10
0
 def do_test(as_int, prefix, as_rep, base):
     self.assertEqual((as_int, prefix),
                      to_long(base, lambda v: v, iterbytes(as_rep)))
     self.assertEqual(as_rep,
                      from_long(as_int, prefix, base, lambda v: v))
예제 #11
0
파일: uiclass.py 프로젝트: alanxu89/pycoin
 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 "???"
예제 #12
0
파일: uiclass.py 프로젝트: alanxu89/pycoin
 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 "???"
예제 #13
0
 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 "???"
예제 #14
0
 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 "???"
예제 #15
0
 def adaptor(nonce32_p, msg32_p, key32_p, algo16_p, data, attempt):
     nonce32_p.contents[:] = list(iterbytes(k_as_bytes))
     return 1
예제 #16
0
def b2a_base58(s):
    """Convert binary to base58 using BASE58_ALPHABET. Like Bitcoin addresses."""
    v, prefix = to_long(256, lambda x: x, iterbytes(s))
    s = from_long(v, prefix, BASE58_BASE, lambda v: BASE58_ALPHABET[v])
    return s.decode("utf8")
예제 #17
0
 def adaptor(nonce32_p, msg32_p, key32_p, algo16_p, data, attempt):
     nonce32_p.contents[:] = list(iterbytes(k_as_bytes))
     return 1
예제 #18
0
 def for_p2pkh_wit(self, h160):
     assert len(h160) == 20
     return segwit_addr.encode(bech32_hrp, 0, iterbytes(h160))
예제 #19
0
 def for_p2sh_wit(self, hash256):
     assert len(hash256) == 32
     return segwit_addr.encode(bech32_hrp, 0, iterbytes(hash256))
예제 #20
0
 def for_p2pkh_wit(self, h160):
     assert len(h160) == 20
     return segwit_addr.encode(bech32_hrp, 0, iterbytes(h160))