示例#1
0
 def SystemShare():
     amount = Fixed8.FromDecimal(sum(Blockchain.GENERATION_AMOUNT) * Blockchain.DECREMENT_INTERVAL)
     owner = ECDSA.secp256r1().Curve.Infinity
     admin = Crypto.ToScriptHash(PUSHT)
     return RegisterTransaction([], [], AssetType.GoverningToken,
                                "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]",
                                amount, 0, owner, admin)
示例#2
0
    def SystemCoin():
        amount = Fixed8.FromDecimal(sum(Blockchain.GENERATION_AMOUNT) * Blockchain.DECREMENT_INTERVAL)

        owner = ECDSA.secp256r1().Curve.Infinity

        precision = 8
        admin = Crypto.ToScriptHash(PUSHF)

        return RegisterTransaction([], [], AssetType.UtilityToken,
                                   "[{\"lang\":\"zh-CN\",\"name\":\"小蚁币\"},{\"lang\":\"en\",\"name\":\"AntCoin\"}]",
                                   amount, precision, owner, admin)
示例#3
0
    def __init__(self, priv_key):

        self.setup_curve()

        length = len(priv_key)

        if length != 32 and length != 96 and length != 104:
            raise Exception("Invalid private key")

        self.PrivateKey = bytearray(priv_key[-32:])

        pubkey_encoded_not_compressed = None

        if length == 32:

            pubkey_encoded_not_compressed = bitcoin.privkey_to_pubkey(priv_key)

        elif length == 64 or length == 72:
            skip = length - 64
            pubkey_encoded_not_compressed = bytearray(
                b'04').hex() + priv_key[skip:]

        elif length == 96 or length == 104:
            skip = length - 96
            pubkey_encoded_not_compressed = bytearray(b'\x04') + bytearray(
                priv_key[skip:skip + 64])

        if pubkey_encoded_not_compressed:
            pubkey_points = bitcoin.decode_pubkey(
                pubkey_encoded_not_compressed, 'bin')

            pubx = pubkey_points[0]
            puby = pubkey_points[1]
            edcsa = ECDSA.secp256r1()
            self.PublicKey = edcsa.Curve.point(pubx, puby)

        else:
            raise Exception("Could not determine public key")

        self.PublicKeyHash = Crypto.ToScriptHash(
            self.PublicKey.encode_point(True), unhex=True)