Exemplo n.º 1
0
def create_offer_hash(neo_address, offer_asset_hash, offer_asset_amt, want_asset_hash, want_asset_amt, txn_uuid):
    reverse_user_hash = reverse_hex(neo_get_scripthash_from_address(neo_address))
    reverse_offer_asset_hash = reverse_hex(offer_asset_hash)
    reverse_offer_amount = num2hexstring(number=offer_asset_amt, size=8, little_endian=True)
    reverse_want_asset_hash = reverse_hex(want_asset_hash)
    reverse_want_amount = num2hexstring(number=want_asset_amt, size=8, little_endian=True)
    nonce_hex = txn_uuid.encode('utf-8').hex()
    offer_key_bytes = reverse_user_hash + reverse_offer_asset_hash + reverse_want_asset_hash + reverse_offer_amount +\
                      reverse_want_amount + nonce_hex
    offer_hash = reverse_hex(Crypto.Hash256(binascii.a2b_hex(offer_key_bytes)).hex())
    return offer_hash
Exemplo n.º 2
0
def neo_get_address_from_scripthash(scripthash):
    """
    Core methods for manipulating keys
    NEP2 <=> WIF <=> Private => Public => ScriptHash <=> Address
    Keys are arranged in order of derivation.
    Arrows determine the direction.
    """
    scripthash_bytes = binascii.unhexlify(reverse_hex(scripthash))
    return scripthash_to_address(scripthash_bytes)
Exemplo n.º 3
0
def neo_get_scripthash_from_address(address):
    """
    Convert a Public Address String to a ScriptHash (Address) String.

    :param address: The Public address to convert.
    :type address: str
    :return: String containing the converted ScriptHash.
    """
    hash_bytes = binascii.hexlify(base58.b58decode_check(address))
    return reverse_hex(hash_bytes[2:].decode('utf-8'))
Exemplo n.º 4
0
 def test_reverse_hex(self):
     self.assertEqual(reverse_hex('ABCD'), 'CDAB')
     self.assertEqual(reverse_hex('0000000005f5e100'), '00e1f50500000000')
Exemplo n.º 5
0
 def toReverseHex(self):
     return reverse_hex(self.toHex())
Exemplo n.º 6
0
def serialize_transaction_output(txn_output):
    value = SwitcheoFixed8(float(txn_output['value'])).toReverseHex()
    return reverse_hex(txn_output['assetId']) + value + reverse_hex(txn_output['scriptHash'])
Exemplo n.º 7
0
def serialize_transaction_input(txn_input):
    return reverse_hex(txn_input['prevHash']) + reverse_hex(num2hexstring(txn_input['prevIndex'], 2))