def create_from_secret(ctx, to, amount, symbol, type, secret, expiration,
                       length, account):
    """Create an HTLC contract from a secret preimage

    If you are the party choosing the preimage, this version of
    htlc_create will compute the hash for you from the supplied
    preimage, and create the HTLC with the resulting hash.
    """
    if length != 0 and length != len(secret):
        raise ValueError("Length must be zero or agree with actual preimage length")

    ctx.blockchain.blocking = True
    tx = ctx.blockchain.htlc_create(
        Amount(amount, symbol),
        to,
        preimage=secret,
        preimage_length=length,
        hash_type=type,
        expiration=expiration,
        account=account,
    )
    tx.pop("trx", None)
    print_tx(tx)
    results = tx.get("operation_results", {})
    if results:
        htlc_id = results[0][1]
        print("Your htlc_id is: {}".format(htlc_id))