Exemple #1
0
def pts_address(pubkey, compressed, ver, prefix):
    if compressed:
        pubkeybin = PublicKey(pubkey, **{"prefix": prefix}).__bytes__()
    else:
        pubkeybin = unhexlify(
            PublicKey(pubkey, **{
                "prefix": prefix
            }).unCompressed())

    #print(hexlify(pubkeybin),len(pubkeybin))
    bin = '%02x' % (ver) + hexlify(
        ripemd160(hexlify(hashlib.sha256(pubkeybin).digest()).decode(
            'ascii'))).decode("ascii")
    checksum = doublesha256(bin)

    #print('bin',bin)
    #print('csum1',checksum)
    hex = bin + hexlify(checksum[:4]).decode('ascii')
    #print('hex',hex)
    hash = hexlify(ripemd160(hex)).decode('ascii')
    #print('hash',hash)
    checksum2 = ripemd160(hash)
    #print('csum2',checksum2)
    b58 = prefix + base58encode(hash + hexlify(checksum2[:4]).decode('ascii'))
    #print('b58',b58)
    return b58
Exemple #2
0
 def test_htlc_create(self):
     preimage_hash = hexlify(ripemd160(hexlify(b"foobar"))).decode("ascii")
     self.op = operations.Htlc_create(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "from": "1.2.123",
             "to": "1.2.124",
             "amount": {
                 "amount": 1123456,
                 "asset_id": "1.3.0"
             },
             "preimage_hash": [0, preimage_hash],
             "preimage_size": 200,
             "claim_period_seconds": 120,
             "extensions": [],
         })
     self.cm = ("f68585abf4dce7c8045701310000000000000000007b7c8024"
                "1100000000000000a06e327ea7388c18e4740e350ed4e60f"
                "2e04fc41c800780000000000012071efeadf31703b98d155e1"
                "c196cf12bcda11c363518075be2aaca0443382648e2428d277"
                "e79b80bab4ff0b48fd00ed91e7e41d88974a00d50b832a198a"
                "00d62d")
     self.doit(False)
Exemple #3
0
 def derivesha512address(self):
     """ Derive address using ``RIPEMD160(SHA512(x))`` """
     pkbin         = unhexlify(repr(self._pubkey))
     addressbin    = ripemd160(hexlify(hashlib.sha512(pkbin).digest()))
     return Base58(hexlify(addressbin).decode('ascii'))