  Bitcoin is currently subject to a significant pay-for-speed trade-off. This
is caused by lengthy and highly variable transaction confirmation times,
especially during times of congestion. Users can reduce their transaction
confirmation times by increasing their transaction fee. In this paper, based on
the inner workings of Bitcoin, we propose a model-based approach (based on the
Cram\'er-Lundberg model) that can be used to determine the optimal fee, via,
for example, the mean or quantiles, and models accurately the confirmation time
distribution for a given fee. The proposed model is highly suitable as it
arises as the limiting model for the mempool process (that tracks the
unconfirmed transactions), which we rigorously show via a fluid limit and we
extend this to the diffusion limit (an approximation of the Cram\'er-Lundberg
model for fast computations in highly congested instances). We also propose
methods (incorporating the real-time data) to estimate the model parameters,
thereby combining model and data-driven approaches. The model-based approach is
validated on real-world data and the resulting transaction fees outperform, in
most instances, the data-driven ones.
