Advanced ยท 08 Bitcoin that even its owner cannot spend early
Locks explained.
A time lock is a rule written into a coin that the Bitcoin network will not let anyone break before a date. OnlyBits puts one of your keys and the date into a Taproot script with no other way out, and the coins cannot move until the network's own clock, the median time of recent blocks, has passed that date.
01 Time locks
A time lock keeps coins unspendable until a date, even by their owner
A time lock is a condition attached to coins that says they cannot be spent before a certain date. The example on this page locks 500,000 sats until 14 March 2027.
The condition is not a setting in an app that you could switch off. It is part of the coins' lock on the blockchain, and every computer running Bitcoin refuses a payment that breaks it, whoever signs it.
What you see: on the Savings tab, a panel headed "Locked": "Put bitcoin out of reach until a date you pick, so you cannot spend it before then." and a "Lock bitcoin" button.
What it hides: the script, the address, and how the network decides what time it is. You pick an amount and a date.
Look underneath
Bitcoin's time locks are consensus rules. A transaction that violates one is invalid, and a block containing it is invalid, so no node relays it and no miner can include it without having their block rejected. There is no operator who could make an exception.
What OnlyBits adds is the bookkeeping: a deterministic address for each date, a list of locks, a reminder when one opens and a one-tap way back to savings. The enforcement is entirely Bitcoin's.
02 A weak lock
A date on a payment does not stop its owner from signing another one
Every Bitcoin transaction has a field called nLockTime. Set it to a date and the transaction cannot be mined before that date.
It looks like a lock, but it is a lock on one particular payment, not on the coins. You can sign a payment dated 14 March that moves the 500,000 sats back to yourself, and keep it. The coins themselves are still yours to spend. Sign a new payment with no date and it is mined in the next block, and the dated one becomes worthless because the coins it spends are gone.
To bind the owner, the date has to be part of what the coins require, not part of one payment that spends them.
One coin of 500,000 sats, spendable with the owner's key. Nothing about the coin mentions a date.
The owner signs payment A, which spends the coin and carries nLockTime 14 Mar 2027. No block can include it before then, so it waits.
Later the owner signs payment B, spending the same coin with no date. The key signs whatever its holder asks it to.
B is valid now, so the next block includes it, and the coin is spent.
A spends a coin that no longer exists, so it can never be mined. The date bound one payment, not the coin.
What you see: nothing about this. The app never offers a dated payment as a lock.
What it hides: nLockTime still appears in the unlock payment, as the next sections show, because the stronger lock refers to it.
Look underneath
nLockTime is the last 4 bytes of a transaction. A value below 500,000,000 is a block height; a value at or above it is a Unix timestamp in seconds. The transaction is final, and can be mined, when the value is below the height of the block being built, or below that block's median time past for a timestamp. The field only applies if at least one input has an nSequence other than 0xffffffff.
Wallets use it routinely: setting nLockTime to the current height is a common anti-fee-sniping measure. The shared wallet in Shared wallets explained refuses proposals whose locktime is anything but a recent height.
03 Three locks
CLTV writes the date into the coin's lock, where every future payment has to meet it
Bitcoin has two instructions that put time into the script that locks a coin. CHECKLOCKTIMEVERIFY, CLTV for short, says "the payment that spends me must carry a date at least this late". CHECKSEQUENCEVERIFY, CSV, says "the payment that spends me must come at least this long after I was created".
CLTV is the one a lock needs. It is absolute: it names a fixed date, 14 March, and any payment trying to spend the coin must have its nLockTime set to that date or later, which in turn means it cannot be mined before then. The owner cannot sign around it, because the rule is part of the coin, and every payment from it is checked against the rule.
CSV is relative: "30 days after the coin was confirmed". It is what Lightning uses for its safety delays. OnlyBits does not use it for locks.
What you see: a fixed date and time, never a duration. Even the presets ("1 day", "1 week", "1 month", "1 year") are turned into a date before the lock is made.
What it hides: which opcode does the work. A relative lock would start counting only when the locking payment confirms, which is harder to show as one date.
Look underneath
OP_CHECKLOCKTIMEVERIFY (BIP65, opcode 0xb1, formerly OP_NOP2) fails the script unless all of these hold:
- the stack top is a number no larger than the spending transaction's
nLockTime, - both are the same kind (both heights or both timestamps, split at 500,000,000),
- the spending input's
nSequenceis not0xffffffff, sonLockTimeis actually enforced.
OP_CHECKSEQUENCEVERIFY (BIP112, 0xb2) does the same against the input's nSequence, which BIP68 gives a relative meaning in blocks or 512-second units. Both opcodes work in Taproot scripts (BIP342).
04 The output
The lock is a Taproot output with one way out: the owner's key, after the date
A Taproot output can be spent two ways: with a single key directly (the key path), or by revealing one of a set of scripts and meeting it (the script path). OnlyBits builds the lock so that only the script path works.
The key-path key is a special public key that nobody holds the private key for, because it was chosen in a way that makes finding it impossible. It is called a NUMS key, for "nothing up my sleeve". So the key path is closed for good.
The script path has exactly one script: the owner's key must sign, and the date must have passed. The key comes from the recovery words, as all the wallet's keys do. The date is 14 March 2027 at 9:00. There is no second script and no other key, which is what makes the lock unconditional.
What you see: "Nobody, you included, can move these coins before their date. Then you move them back to savings."
What it hides: the descriptor, the NUMS key and the leaf. Each lock has its own address, made from the date, and the app keeps a list of dates rather than a list of addresses.
Look underneath
The output descriptor, with mainnet coin type and the wallet's fingerprint shortened:
tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0, and_v(v:pk([fp/86'/0'/2']xpub.../0/30083580),after(1805014800)))
The leaf compiles to
<32-byte x-only key> OP_CHECKSIGVERIFY <10 57 96 6b> OP_CHECKLOCKTIMEVERIFY
1805014800 = 0x6b965710, pushed little-endian as 4 bytes
CLTV leaves the number on the stack, and a non-zero final stack item counts as success in tapscript, so the script ends there.
The NUMS key
50929b74... is the point BIP341 suggests: the x coordinate of a point derived by hashing the generator G, so its discrete log is unknown to everyone. BIP341 also suggests tweaking it with a random value so outsiders cannot tell the key path is dead. OnlyBits uses it as is, so when the lock is spent, anyone who recognises the key knows the output only ever had a script path.
05 The date
OnlyBits writes the date as a clock time in whole minutes, at most five years ahead
A lock date can be written two ways: as a block number ("not before block 990,000") or as a clock time ("not before 14 March 2027, 9:00"). The same field holds either, and Bitcoin tells them apart by size.
OnlyBits always uses clock time. People think in dates, and a block number only maps to a date approximately, since blocks come about every ten minutes on average but not on a schedule. The time is a whole minute, so the example lock opens at 9:00 exactly, never 9:00 and 17 seconds.
The date must be in the future, and no more than five years away. Five years is a guard against a slip of the thumb turning a one-year lock into a fifty-year one.
What you see: "Until when?" with the presets and a "Pick a date and time" button. Then "You cannot spend these 500,000 sats before this date, even if you change your mind."
What it hides: the conversion from your phone's local time to Unix seconds, the rounding down to the minute, and the five-year check. The picker will not offer a date further out than that.
Look underneath
- The unlock time must be a multiple of 60 seconds, or the wallet refuses it.
- Making a lock is refused when the time has passed or is more than
5 * 365days ahead. The date picker stops a day short of that. - The time is stored as Unix seconds. 14 March 2027 09:00 UTC is
1805014800; the phone's time zone only changes which Unix second "9:00" means. - Block-height locks are not supported, and nor are locks more than five years ahead.
The upper end of the timestamp range is 232 seconds, in the year 2106, so the five-year guard is the only practical limit.
06 Network time
The network judges the date by the median time of the last eleven blocks, so the coins open about an hour late
There is no official clock in Bitcoin. Each block carries a timestamp written by the miner who found it, and miners' clocks can be off by a little, or set wrong on purpose.
So for time locks the network uses the median time past: line up the timestamps of the last eleven blocks and take the middle one. One miner with a wrong clock cannot move the median much, and the median never goes backwards.
The middle of the last eleven blocks is about six blocks old, and at roughly ten minutes a block that is about an hour behind the real time. So the median passes 9:00 on 14 March at around 10:00, and only then can the unlock payment be mined.
The lock says 9:00 on 14 March. Bitcoin has no official clock to compare that with.
Blocks arrive roughly every ten minutes. Each carries a timestamp written by the miner who found it, and some clocks are off.
At about 10:00, take the timestamps of the last eleven blocks.
Line them up and take the middle one. It is about six blocks old, so it reads 9:11, about an hour behind real time.
9:11 is past 9:00, so the lock is open. Only now can the unlock payment be mined.
What you see: under the date, "The network's clock runs about an hour behind, so the coins open about an hour after this time." About an hour after the date, a notification: "A time lock opened", "Coins in it can be spent now."
What it hides: the median calculation. The lock card asks the server for the median time and shows the lock as opened only once it has passed the date.
Look underneath
BIP113 made median time past the clock for timestamp locktimes. A transaction with a timestamp nLockTime is final in a block only if nLockTime < MTP, where MTP is the median of the previous 11 block timestamps. Block timestamps must themselves exceed the MTP and be no more than two hours ahead of a node's network-adjusted time.
The app's lock status is unlocked = median_time > unlock_time, matching the consensus rule. The unlock button stays hidden, and the wallet refuses to build the payment, until that is true. The reminder is a scheduled background job set for the unlock time plus 3,600 seconds; it checks the lock is still in the list before notifying.
07 Locking
Locking is an ordinary payment from savings to the lock's own address
With a key and a date, the wallet can compute the lock's address. Locking the coins is then a normal payment: savings pays 500,000 sats to that address.
In the example, savings has a coin of 800,000 sats. The payment sends 500,000 to the lock, about 600 sats in network fee to the miner, and the rest back to savings as change. Once a block includes it, the 500,000 sats sit at an address whose only way out is the script from section 04.
Before sending, the app saves the date in its list of locks. Saving first means a lock that was paid is never missing from the list, even if the app is killed a moment later.
Savings has one coin of 800,000 sats.
The wallet builds an ordinary payment from savings, and the coin goes in as its input.
The first output pays 500,000 sats to the lock's address, computed from the owner's key and the date.
The rest goes back to savings as change, apart from about 600 sats of network fee for the miner.
Before sending, the app saves the date in its list of locks, so a lock that was paid is never missing from the list.
Then it broadcasts. Once mined, the 500,000 sats sit at an address whose only way out is the script from section 04, and nothing on the chain says so yet.
What you see: "Lock 500,000 sats", the date under "Until", "Plus a 616 sats network fee", then "There is no way to undo this. If you lose your phone, your recovery words and this date find the coins." The button reads "Lock until" and the date, and asks once more before sending.
What it hides: the address, the fee rate (the Normal one) and the coin selection. The amount can only come from savings, and the keypad counts only confirmed coins as available.
Look underneath
The size above assumes one Taproot key-path input and two Taproot outputs: about 154 vB, so 616 sats at 4 sat/vB. The app takes the rate from the server's Normal estimate.
The order of operations on confirm: save the new unlock time in the encrypted wallet data (and, if the Google backup is on, in the backed-up app state), then broadcast. A broadcast that fails leaves an empty lock in the list, which the card shows as Empty with a Remove button. A paid lock that was not in the list would be much worse, because the app would not know to look for it.
08 Spending early
Before the date nobody can move the coins, the owner included
Before the date, every way out of the lock fails.
The app will not help: the lock card has no button until the date has passed. A payment built by hand with the owner's key fails too. If it is dated today, the script's CLTV check fails, because the payment's date is earlier than 14 March, and every node rejects it as invalid. If it is dated 14 March, the script is satisfied, but the payment itself cannot go in a block until the network's clock reaches that date, so nodes refuse to pass it on and miners cannot include it.
The key path is no better. Its key belongs to nobody, so there is no signature anyone can make for it. All three routes are closed, and they are closed by the network, not by the app.
It is 15 December 2026. The lock needs the owner's key and a payment dated 14 March 2027 09:00 or later.
Attempt 1: a payment dated today. Its nLockTime is earlier than the script's date, so CLTV fails and every node rejects it as invalid.
Attempt 2: a payment dated 14 March. Now CLTV is satisfied, and the script passes.
But the payment itself cannot go in a block until the network's clock reaches its date. Nodes refuse to pass it on and miners cannot include it.
Attempt 3: the key path. Its key is the NUMS key, and nobody has a private key to sign with.
All three routes are closed by the network, not by the app.
What you see: the lock card says "Until" and the date, the balance, and no button to move it.
What it hides: the app also refuses to build the unlock payment while the median time is at or before the date. That is a courtesy, not the protection. The protection is the script.
Look underneath
- Attempt 1:
OP_CHECKLOCKTIMEVERIFYfails when the stack value1805014800is greater than the spending transaction'snLockTime. Script failure makes the transaction invalid under consensus rules. - Attempt 2: with
nLockTime = 1805014800and a non-finalnSequence, the script passes. ButIsFinalTxrequiresnLockTime < MTP; until then the transaction is non-final, mempools reject it and a block containing it is invalid. - Attempt 3: a key-path spend needs a signature for the tweaked output key, whose discrete log would require knowing the NUMS key's.
- Setting
nSequence = 0xffffffffto disablenLockTimemakes CLTV fail instead.
No miner can help either. A block with a non-final transaction is invalid and every node rejects it.
09 A thief
A thief with the phone also has to wait for the date, and then the lock no longer protects the owner
A thief who takes the phone is treated exactly like the owner: the coins cannot move before 14 March, whoever holds the key.
The thief also has to get past the app's phone lock, which asks for a fingerprint or the screen lock when the app opens and before money leaves. If they cannot, they have nothing. If they can, they still have to wait for the date, which gives the owner time to secure other funds. The owner cannot rescue the locked coins early either.
On the date, the coins belong to whoever has the key. A time lock delays everybody equally. A thief who has the unlocked phone, or the recovery words, can move the coins at 10:00 on 14 March just as the owner can. The lock protects savings from your own impulses, not from theft.
What you see: the phone lock, which is on by default and asks before money leaves.
What it hides: nothing about this trade. The app offers no way to move a lock's coins to a different key before the date, because doing so would also give the owner a way out.
Look underneath
The phone lock is enforced by the app and Android, not by Bitcoin. The wallet data on the phone is encrypted with a key held in Android Keystore. Someone who extracts the recovery words by other means bypasses the app entirely and needs only the date.
A lock that resisted theft after the date would need a second condition, such as a second key held elsewhere or a delay that a rescue key could beat. OnlyBits locks have one leaf and one key. Shared wallets explained covers the app's multi-key option, which does not combine with locks.
10 Unlocking
After the date, one tap moves every coin in the lock back to savings
At about 10:00 on 14 March the phone notifies that the lock has opened. One tap moves the coins to savings.
The app builds a payment that spends everything in the lock to a fresh savings address. It dates the payment 14 March 9:00, so CLTV is satisfied, and the network's clock has now passed that date, so the payment can be mined. It proves the script path: the owner's signature, the script itself, and a short proof that this script was the one committed to in the address.
Around 500 sats go to fees and about 499,480 sats arrive in savings.
The network's clock has passed 9:00 on 14 March. The lock holds 500,000 sats.
The app builds a payment that spends everything in the lock. It dates it 14 March 9:00, so CLTV is satisfied, and that date has passed, so it can be mined.
It takes the script path. The witness starts with the owner's signature.
Then the script itself, and the control block: a short proof that this script is the one the address committed to.
The single output sends 499,480 sats to a fresh savings address, and 520 sats go to fees.
What you see: the card changes from "Until" to "Opened" with the date, and offers "Move to savings". Then "Move 499,480 sats to savings. Fee: 520 sats." and a "Move" button. An emptied lock shows "Empty" and a "Remove" button.
What it hides: the script-path witness and the locktime fields. You cannot choose a partial amount or a different destination: the whole lock goes back to savings.
Look underneath
The wallet drains every coin at the lock address to a new savings receive address, at the Normal fee rate, with the spending condition timelock = 1805014800 so BDK sets nLockTime and a non-final nSequence. Sending to the lock's own address is refused.
witness: <64-byte Schnorr signature, SIGHASH_DEFAULT> <key> OP_CHECKSIGVERIFY <1805014800> OP_CHECKLOCKTIMEVERIFY 40 bytes c0|parity || 50929b74...3ac0 control block, 33 bytes
With one leaf, the control block holds only the leaf version, the output key's parity and the internal key; there is no Merkle path. The illustrative size is about 130 vB (94 bytes outside the witness, 143 witness bytes), so 520 sats at 4 sat/vB.
If more than one payment went into the same lock address, they all come out together.
11 Finding it
The recovery words and the exact date find the lock again
After a restore from the twelve words, savings come back by scanning addresses, but a lock has no place in that scan: its address depends on its date.
OnlyBits makes the lock's key from the words and the date together. The date, counted in minutes since 1970, is used as the number of the key, so each minute gives a different key and a different address. With the words and "14 March 2027, 9:00", the app rebuilds exactly the same address and finds the 500,000 sats waiting.
After a restore from the Google backup, the list of lock dates is in it and the locks reappear on their own. From the words alone, you enter the date yourself.
The twelve words give the lock account, m/86'/0'/2', the same way they give savings.
The date, 14 March 2027 9:00, counted in minutes since 1970, is minute 30,083,580.
That minute is used as the number of a child key under the lock account.
The key and the date together make the lock's script, and the script makes the address. The app looks it up and finds the 500,000 sats.
One minute off gives a different number, a different key and an unrelated address with nothing at it.
What you see: "Find a lock by its date" on the locks screen, which opens "Find a lock": "After recovering from your words, pick the exact unlock date and time of a lock to see it again." The picker reaches back to 2009, in case the date has already passed.
What it hides: the derivation. Each try checks one date; the app does not search a range.
Look underneath
The lock key is m/86'/coin'/2'/0/{unix_minute}, with coin 0 on mainnet and 1 on test networks. Account 0 is savings and account 1 the shared wallet. The minute index is unhardened: a u32 of seconds divided by 60 stays below 231.
Because the index is unhardened, the account xpub alone is enough to derive every lock's public key and address, without the private key. That makes a watch-only search possible in principle, but OnlyBits exposes no such tool.
The Google backup's app state includes the list of unlock times. The lock date shown in the app is in the phone's time zone, and the picker uses the phone's time zone too, so a restore in a different zone needs the same instant, not the same wall-clock reading.
12 The trade
A lock has no undo and no emergency exit, and a forgotten date turns recovery into a search
Everything that makes the lock useful against impulse spending also works against you in an emergency.
No undo. Once the locking payment confirms, there is no cancel, no grace period and no support line. A wrong date is a wrong date.
No emergency exit. If you need the money before the date, the lock does not know the difference between a medical bill and an impulse purchase. Nobody, including the makers of OnlyBits, can release it.
A forgotten date is a search. Without the Google backup, the words alone are not enough. If you remember the day but not the time, there are 1,440 minutes to try. If you remember only the month, about 43,000. The app checks one date per try. The app is also unaudited and in early development, so lock only what you can afford to lose.
What you see: the line the app shows before every lock, "There is no way to undo this. If you lose your phone, your recovery words and this date find the coins."
What it hides: nothing it could soften. The app has no early release, no partial unlock and no range search.
Look underneath
Costs, named:
- Irreversible: one leaf, one condition, no key path.
- No emergency path: no second leaf with another key or a shorter delay.
- Recovery needs the date: words plus the exact minute, or the Google backup's list.
- Privacy at unlock: the spend reveals the script, the date, and the unrandomised NUMS key.
- Open later than the date: by the median-time lag of about an hour, plus however long the unlock payment waits for a block.
- Limits: clock time only, whole minutes, at most five years ahead, funded from savings only.
What did not get traded away
No company, server or app update can release the coins early, freeze them, or take them. The lock is enforced by every Bitcoin node with rules that have been in force since 2015 (CLTV) and 2016 (BIP113). The words still control the coins, and after the date they are spendable again with no one's permission. For holding savings out of your own reach, that is the property you want, and the costs are the same property seen from the other side.
One lock, one date
A date in the script, a key no one holds, an hour of lag
- The weak lock
- nLockTime dates one transaction, and its owner can always sign another.
- The strong lock
- CLTV puts the date in the coin's script, so every spending transaction must carry it.
- The output
- A Taproot output with a NUMS internal key and one leaf: the owner's signature, after the date.
- The date
- A Unix timestamp on a whole minute, at most five years ahead.
- The clock
- Median time past of the last eleven blocks, about an hour behind, decides when the lock opens.
- The way back
- One payment moves every coin in the lock to savings once the clock has passed the date.
- The name
- The key is
86'/coin'/2'/0/{minute}, so the words and the exact date find the lock. - The bill
- No undo, no emergency exit, and a forgotten date is a search.
The example date is invented. It takes the phone's time zone as UTC, so 14 March 2027 09:00 is Unix time 1805014800 and minute 30083580; those two numbers are computed, not illustrative. The 800,000 sat savings coin, both fees (616 sats at about 154 vB and 520 sats at about 130 vB, each at 4 sat/vB), the 9:11 median and the addresses are illustrative. The search counts in the last section are plain arithmetic. The app's behaviour was checked against its source as of October 2026: the script, the five-year guard and the median-time check in timelock.rs, and the screens and reminder in Locks.kt and LockAlarm.kt. The parts most likely to age first are the UI wording, the presets, the use of the Normal fee rate and the unrandomised NUMS key; the derivation path cannot change without breaking existing locks, so it is the least likely to. Read Taproot explained first if script paths are new; Recovery phrase explained covers the words and the Google backup that bring a lock back; Servers explained is next and covers where the median time comes from.