You're looking for witness encryption, where the decryption key is the solution to an arbitrary Turing complete problem. The problem here is a check of the bitcoin blockchain length.
Search for "How to build time-lock encryption" by J. Liu, T. Jager, S. A. Kakvi and B. Warinschi (2018), a paper that explain this very thing, using bitcoin as the time lock.
The only downside of this techniques is that witness encryption is still very new, and way too slow to be practical yet. But from a mathematical perspective, it seems to work, so I guess we can be rather hopeful.