示例#1
0
def submit_operations(account_seed, operations, transaction_memo):
    """
    This method signs the given operations and submits them to the Stellar network
    :param str account_seed: Seed of the account submitting the operations. It is required to sign the transactions.
    :param Operation operations: Operations to be submitted.
    :param str transaction_memo: Text memo to be included in Stellar transaction. Maximum size of 28 bytes.
    :return: Returns a string containing the server response or None if the transaction could not be submitted.
    :rtype: str or None
    """
    try:
        builder = Builder(secret=account_seed)
    except Exception:
        # Too broad exception because no specific exception is being thrown by the stellar_base package.
        # TODO: This should be fixed in future versions
        print("An error occurred (Please check your Internet connection)")
        return None

    builder.add_text_memo(transaction_memo)
    for operation in operations:
        builder.append_op(operation)
    builder.sign()
    try:
        return builder.submit()
    except Exception:
        # Too broad exception because no specific exception is being thrown by the stellar_base package.
        # TODO: This should be fixed in future versions
        print("An error occurred (Please check your Internet connection)")
        return None
    def tx(self, account, asset):
        builder = Builder(address=account['account_id'])

        builder.append_op(ChangeTrust(opts={'asset': asset}))

        return builder.gen_te()