예제 #1
0
def main():
    h = ByteArray(
        "4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20446f6e65632061742066617563696275732073617069656e2c2076656c20666163696c6973697320617263752e20536564207574206d61737361206e6962682e205574206d6f6c6c69732070756c76696e6172206d617373612e20557420756c6c616d636f7270657220646f6c6f7220656e696d2c20696e206d6f6c657374696520656e696d20636f6e64696d656e74756d2061632e20416c697175616d206572617420766f6c75747061742e204e756c6c6120736f64616c657320617420647569206e656320"
    )
    print(h)
    print(blake_hash(h.bytes()).hex())
    print(crypto.hash160(h.bytes()).hex())
예제 #2
0
def main():
    script = ByteArray(
        "512103af3c24d005ca8b755e7167617f3a5b4c60a65f8318a7fcd1b0cacb1abd2a97fc21027b81bc16954e28adb832248140eb58bedb6078ae5f4dabf21fde5a8ab7135cb652ae"
    )
    print(crypto.hash160(script.bytes()).hex())

    _, addrs, _ = txscript.extractPkScriptAddrs(0, script, nets.testnet)
    for addr in addrs:
        print("addr", addr.string())
예제 #3
0
def encodeAddress(k, netID):
    """
    Base-58 encode the number, with the netID prepended byte-wise.

    Args:
        k (ByteArray): The pubkey or pubkey-hash or script-hash.
        netID (byte-like): The addresses network encoding ID.

    Returns:
        string: Base-58 encoded address.
    """
    b = ByteArray(netID)
    b += k
    b += checksum(b.b)
    return b58encode(b.bytes()).decode()
예제 #4
0
    def string(self):
        """
        A base-58 encoding of the pubkey.

        Returns:
            str: The encoded address.
        """
        encoded = ByteArray(self.pubkeyID)
        buf = ByteArray(STEcdsaSecp256k1, length=1)
        compressed = self.pubkey.serializeCompressed()
        # set the y-bit if needed
        if compressed[0] == 0x03:
            buf[0] |= 1 << 7
        buf += compressed[1:]
        encoded += buf
        encoded += checksum(encoded.b)
        return b58encode(encoded.bytes()).decode()