def test_trx_exchange_create(self, app): tx = app.packContract( tron.Transaction.Contract.ExchangeCreateContract, contract.ExchangeCreateContract( owner_address=bytes.fromhex(app.getAccount(0)['addressHex']), first_token_id="_".encode(), first_token_balance=10000000000, second_token_id="1000166".encode(), second_token_balance=10000000 ) ) data, status = app.sign(app.getAccount(0)['path'], tx) validSignature, txID = validateSignature.validate(tx,data[0:65],app.getAccount(0)['publicKey'][2:]) assert(validSignature == True)
def test_trx_exchange_create_with_token_name(self, app): tx = app.packContract( tron.Transaction.Contract.ExchangeCreateContract, contract.ExchangeCreateContract( owner_address=bytes.fromhex(app.getAccount(0)['addressHex']), first_token_id="_".encode(), first_token_balance=10000000000, second_token_id="1000166".encode(), second_token_balance=10000000 ) ) tokenSignature = ["0a0354525810061a463044022037c53ecb06abe1bfd708bd7afd047720b72e2bfc0a2e4b6ade9a33ae813565a802200a7d5086dc08c4a6f866aad803ac7438942c3c0a6371adcb6992db94487f66c7", "0a0b43727970746f436861696e10001a4730450221008417d04d1caeae31f591ae50f7d19e53e0dfb827bd51c18e66081941bf04639802203c73361a521c969e3fd7f62e62b46d61aad00e47d41e7da108546d954278a6b1"] data, status = app.sign(app.getAccount(0)['path'], tx, tokenSignature) validSignature, txID = validateSignature.validate(tx,data[0:65],app.getAccount(0)['publicKey'][2:]) assert(validSignature == True)
logger.debug('- Signature: {}'.format(binascii.hexlify(result[0:65]))) if (validSignature): logger.debug('- Valid: {}'.format(validSignature)) else: logger.error('- Valid: {}'.format(validSignature)) sys.exit(0) ######################### # VRC10 Exchange Create # ######################### logger.debug('\n\nExchange Create Contract:') tx = vision.Transaction() newContract = contract.ExchangeCreateContract( owner_address=bytes.fromhex(accounts[1]['addressHex']), first_token_id="_".encode(), first_token_balance=10000000000, second_token_id="1000166".encode(), second_token_balance=10000000) c = tx.raw_data.contract.add() c.type = vision.Transaction.Contract.ExchangeCreateContract param = Any() param.Pack(newContract) c.parameter.CopyFrom(param) raw_tx, result = ledgerSign(accounts[1]['path'], tx) validSignature, txID = validateSignature.validate(raw_tx, result[0:65], accounts[1]['publicKey'][2:]) logger.debug('- RAW: {}'.format(raw_tx)) logger.debug('- txID: {}'.format(txID)) logger.debug('- Signature: {}'.format(binascii.hexlify(result[0:65]))) if (validSignature):