Inheritance script: Alice's heirs get access after block 950,000
9. Timelock Script Patterns for Inheritance
The Problem: Bitcoin and Death
Bitcoin presents a unique challenge for inheritance: private keys don't automatically transfer to heirs, and traditional legal mechanisms (probate, wills) don't interface with blockchain consensus. If the holder of a private key dies without sharing access, the funds are lost forever. Too early a share, and the intended recipient might spend the funds prematurely. Timelocks offer cryptographic solutions to this dilemma.
Pattern 1: Dead Man's Switch with CLTV
The simplest inheritance script: funds go to an heir after a fixed date, but the original owner can "reset" the lock by sweeping and re-locking.
# Inheritance script: Alice's heirs get access after block 950,000
# (approximately 2 years from now)
# Alice can also spend any time with her key (for "keep-alive" sweeps)
redeemScript:
OP_IF
# Heir's path: time-locked
950000 OP_CHECKLOCKTIMEVERIFY OP_DROP
OP_DUP OP_HASH160 <HeirPubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
OP_ELSE
# Alice's keep-alive path: always available
OP_DUP OP_HASH160 <AlicePubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
OP_ENDIF
# Alice's "keep-alive" procedure:
# Every year, Alice sweeps all funds to a new CLTV script with
# an updated expiry (e.g., current_block + 52560).
# If Alice dies, she stops refreshing, and heirs can claim after expiry.
Pattern 2: Multisig Inheritance with Timeout
A more secure pattern using multisig. The estate requires both the lawyer and the heir to agree, but after a timeout, the heir alone can act.
# Option A: Lawyer + Heir cooperate (2-of-2 multisig)
# Option B: Heir alone after 2-year timeout (CLTV)
redeemScript:
OP_IF
# Heir + Lawyer cooperative spend (no time restriction)
2 <LawyerPubKey> <HeirPubKey> 2 OP_CHECKMULTISIG
OP_ELSE
# Heir alone after locktime
<InheritanceBlock> OP_CHECKLOCKTIMEVERIFY OP_DROP
OP_DUP OP_HASH160 <HeirPubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
OP_ENDIF
# Unlocking before timeout (cooperative):
scriptSig: 0 <LawyerSig> <HeirSig> 1 <redeemScript>
# Unlocking after timeout (heir alone):
scriptSig: <HeirSig> <HeirPubKey> 0 <redeemScript>
Pattern 3: Tiered Inheritance (Multiple Heirs, Staggered Access)
Distribute access across multiple heirs at different times, replicating traditional trust fund behavior:
# Alice's estate: split among three children
# Child 1 (eldest): access at block 870,000 (~1 year)
# Child 2: access at block 922,500 (~2 years)
# Child 3: access at block 975,000 (~3 years)
# Executor + any child: cooperative close anytime
def make_inheritance_script(child_pubkey_hash, unlock_block, executor_pubkey, child_pubkey):
script = f"""
OP_IF
{unlock_block} OP_CHECKLOCKTIMEVERIFY OP_DROP
OP_DUP OP_HASH160 {child_pubkey_hash} OP_EQUALVERIFY OP_CHECKSIG
OP_ELSE
2 {executor_pubkey} {child_pubkey} 2 OP_CHECKMULTISIG
OP_ENDIF
"""
return script
# Create three separate UTXOs (one per child's share)
child1_script = make_inheritance_script(child1_hash, 870000, executor_pub, child1_pub)
child2_script = make_inheritance_script(child2_hash, 922500, executor_pub, child2_pub)
child3_script = make_inheritance_script(child3_hash, 975000, executor_pub, child3_pub)
Pattern 4: Social Recovery with Timelock
Combines secret-sharing with timelocks for a multi-guardian approach:
# Normal spend: Alice's key alone
# Recovery: 2-of-3 guardians cooperate after CSV timeout (in case Alice is incapacitated)
# Inheritance: heir + 1 guardian after CLTV (Alice assumed dead)
witnessScript:
OP_IF
# Normal Alice spend
<AlicePubKey> OP_CHECKSIG
OP_ELSE
OP_IF
# Social recovery: 2 of 3 guardians after 26 weeks
1008 OP_CHECKSEQUENCEVERIFY OP_DROP
2 <Guardian1PubKey> <Guardian2PubKey> <Guardian3PubKey> 3 OP_CHECKMULTISIG
OP_ELSE
# Inheritance: heir + 1 guardian after absolute lock
<InheritanceBlock> OP_CHECKLOCKTIMEVERIFY OP_DROP
2 <HeirPubKey> <Guardian1PubKey> <Guardian2PubKey> 3 OP_CHECKMULTISIG
OP_ENDIF
OP_ENDIF
Operational Considerations
Inheritance scripts require ongoing maintenance from the original owner:
-
Keep-alive sweeps: The owner must periodically spend and re-lock funds to reset the timelock, proving they are still alive and in control.
-
Key management: Heirs need to know the redeemScript/witnessScript, not just the address. Store the script securely alongside the will.
-
UTXO management: Avoid creating too many small UTXOs (dust), as fees may erode the inheritance value.
-
Exchange rate risk: All heirs should understand that the USD value at inheritance time may differ dramatically from the locking time.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: