Intermediate ยท 03 One payment from savings, taken apart
Fees and coins explained.
A Bitcoin wallet holds separate coins, not a balance, and a payment spends whole coins and sends the difference back to itself as change. The fee pays for the space the payment takes up in a block, so it depends on how many coins go in and out, not on how much is sent.
01 Coins
A Bitcoin wallet holds separate coins, and each coin is spent whole
A savings balance of 55,000 sats can be two coins underneath: one of 25,000 sats and one of 30,000 sats.
A coin is an amount locked to one of the wallet's addresses, sitting on the blockchain until it is spent. It cannot be split in place. To spend 10 sats of the 25,000 coin, the wallet spends all 25,000 and sends the rest back to itself.
If Alice pays Bob 40,000 sats, neither coin is big enough on its own, so the payment has to use both.
What you see: one number on the Savings tab, in sats unless you switch the keypad to BTC.
What it hides: the coins themselves. There is no screen that lists them and no way to pick which ones a payment spends. The app chooses for you.
Look underneath
Each coin is an unspent transaction output (UTXO): an output of an earlier transaction, identified by an outpoint txid:vout, holding an amount in sats and a scriptPubKey that says what is needed to spend it.
In OnlyBits savings every output is a Taproot key-path output (BIP341, derived per BIP86), so the script is OP_1 <32-byte x-only key> and spending it needs one Schnorr signature.
How the wallet knows its coins
The wallet is built on BDK (bdk_wallet). It asks an Esplora server which of its addresses have outputs and which of those are spent, and keeps an encrypted cache so later syncs only check addresses it already knows. The balance is the sum of unspent outputs it found.
What the app does not offer
No coin control: coins cannot be listed, frozen or chosen by hand. Coin selection is BDK's DefaultCoinSelectionAlgorithm (branch and bound, falling back to single random draw).
02 Inputs and outputs
A payment destroys the coins it spends and creates new ones
A Bitcoin transaction takes some coins in, called inputs, and makes new coins, called outputs. The inputs vanish. The outputs are the only thing left.
Alice's payment takes both coins in, 55,000 sats in total. It makes two outputs: 40,000 sats locked to Bob's address, and 13,304 sats locked to a new address of Alice's own. That second output is her change.
The outputs add up to 53,304, which is 1,696 sats less than the inputs. Nobody receives those 1,696 sats directly. The difference is the fee, and the miner who puts the payment in a block collects it.
Alice has two coins, 25,000 and 30,000 sats. Neither covers 40,000 on its own.
Both go into one transaction as inputs, 55,000 sats in total. Once it confirms, those two coins are spent and gone.
The first output is a new coin of 40,000 sats, locked to Bob's address.
The second output is 13,304 sats, locked to a new address of Alice's own. That is her change.
The outputs add up to 53,304. The missing 1,696 has no output: it is the fee, and the miner who includes the payment takes it.
What you see on review: the amount, the fee, "Change back to the wallet" and "Inputs spent", then a summary like "Pay 40,000 sats to Bob. Network fee 1,696 sats, total 41,696 sats."
What it hides: building the transaction, choosing the coins, and making sure the change output exists so nothing leaks to the miner by mistake.
Look underneath
A transaction is version, a list of inputs (prevout, scriptSig, nSequence, witness), a list of outputs (value, scriptPubKey) and nLockTime. The fee is implicit: sum(input values) - sum(output values).
# Alice's payment, illustrative vin[0] prevout a1b2..:0 25,000 sat witness: <schnorr sig> vin[1] prevout c3d4..:1 30,000 sat witness: <schnorr sig> vout[0] OP_1 <Bob key> 40,000 sat vout[1] OP_1 <Alice key> 13,304 sat # change, internal keychain fee 1,696 sat # 55,000 - 53,304
Each input carries its own signature. With Taproot key-path spends that is a 64-byte Schnorr signature per input under SIGHASH_DEFAULT, which commits to every input amount and every output.
BDK sets the output order randomly (BIP69 is not used), so the change is not always last.
03 Change
Change comes back to a fresh address and waits for a block before it can be spent
The change output is a new coin of Alice's, at an address she has never used. Until a miner puts the payment in a block, that coin exists only as a promise in a waiting transaction.
So for a while Alice owns 13,304 sats that she cannot spend yet. If she tried to spend them before the payment confirms, her new payment would depend on the first one, and both would wait together.
The wallet uses a separate set of addresses for change, so a change coin never lands on an address Alice handed to someone. That keeps her own leftovers apart from money other people sent her.
Before paying, Alice's balance is two confirmed coins, 55,000 sats, all of it spendable.
She sends. Both coins go into the payment, which waits in the mempool for a miner to put it in a block.
The payment makes 40,000 for Bob and 13,304 back to a fresh address on Alice's change list. That change coin is unconfirmed.
The balance counts the change straight away and shows 13,304. The send screen counts confirmed coins only, so it offers 0.
A block includes the payment. The change is confirmed, and the 13,304 can be spent.
What you see under the balance: "13,304 sats is change from your last payment. You can spend it once it confirms." The payment itself shows "Pending. It counts once a block includes it, usually within an hour."
What it hides: the change address, the separate change keychain, and the rule that the send pad's available amount counts confirmed coins only.
Look underneath
The savings wallet is two BIP86 descriptors under one account key:
tr([fp/86'/0'/0']xpub.../0/*) # receive (external) tr([fp/86'/0'/0']xpub.../1/*) # change (internal)
The coin type is 0' on mainnet and 1' on every test network. Change always goes to the next unused index on /1/*.
The balance fields
The Rust side reports confirmed_sats, change_sats (unconfirmed outputs of the wallet's own sends), incoming_sats (unconfirmed coins from others) and pending_sats. The headline is confirmed + change. Incoming unconfirmed coins show as an Arriving row instead, because someone else can still replace that payment.
Why not spend unconfirmed change
Spending it is allowed by the protocol (it creates a child of an unconfirmed parent), and a child confirms no sooner than its parent. The app tells you to wait and its amount pad counts confirmed coins only. BDK's coin selection is not told to exclude unconfirmed coins, though, so a payment of the whole balance can still pick up waiting change: here the screen is the rule, not the code.
04 Size
The fee pays for size in a block, and size depends on coins, not on the amount
Blocks have limited room, so a payment pays for how much room it takes. That room is measured in virtual bytes, or vbytes.
Each input adds about 58 vbytes, mostly the signature that proves Alice may spend it. Each output adds 43. There is a small fixed part on top. Alice's payment, two coins in and two out, comes to about 212 vbytes.
Sending 40,000 sats or 4,000,000 sats with the same coins and outputs costs exactly the same. Paying from one big coin would have been cheaper than paying from two small ones, because there would be one signature fewer.
What you see: the fee in sats, never in vbytes. It updates a moment after you type the amount, because the app builds the whole transaction to find out how big it is.
What it hides: the size itself and which coins were picked. The "Inputs spent" line on the review is the only trace of it.
Look underneath
Since SegWit (BIP141) blocks are limited to 4,000,000 weight units. Non-witness bytes weigh 4, witness bytes weigh 1, and vsize = ceil(weight / 4). Signatures sit in the witness, which is why they are discounted.
Sizes for Taproot key-path spends
- Fixed part: version, locktime, counts, SegWit marker and flag: 10.5 vB.
- Input: 36-byte outpoint, empty scriptSig, sequence (41 bytes, 164 WU) plus a 64-byte Schnorr signature with its length bytes (66 WU): 57.5 vB.
- P2TR output: 8-byte value, 1-byte length, 34-byte script: 43 vB.
2 in, 2 out: 10.5 + 2 x 57.5 + 2 x 43 = 211.5 -> 212 vB 1 in, 2 out: 10.5 + 57.5 + 2 x 43 = 154 vB 2 in, 1 out: 10.5 + 2 x 57.5 + 43 = 168.5 -> 169 vB
These assume Bob's address is also Taproot. A legacy P2PKH output is 34 vB, a P2WPKH output 31 vB, so paying other address types changes the total by a few vbytes.
05 The auction
Payments wait in the mempool and miners take the best-paying ones first
A fee rate is the fee divided by the size, in sats per vbyte (sat/vB). Alice's 1,696 sat fee on 212 vbytes is a rate of 8 sat/vB.
Signed payments that are not yet in a block wait in the mempool, a pool of pending transactions that every node keeps. A block comes roughly every ten minutes and holds about a million vbytes. Miners fill it with the highest fee rates they can find, because the fees are theirs.
So the fee is a bid in a running auction. If the payments waiting ahead of Alice's already fill the next few blocks, she waits. Nobody can promise a time, only estimate one from what the queue looks like now.
Signed payments wait in the mempool, each with a fee rate. Alice's is 1,696 sats over 212 vbytes: 8 sat/vB.
Miners keep the fees, so they rank the waiting payments by rate, highest first.
The next block holds about a million vbytes. Here the top three bids fill it.
Alice's 8 sat/vB and the 3 sat/vB payment wait for the next few blocks.
The 1 sat/vB payment may wait for days, and new higher bids keep arriving ahead of it.
What you see: no auction and no rate, only a speed and a price in sats.
What it hides: the app asks a block explorer server (mempool.space by default) for its current estimates and turns them into the three speeds in the next section. If no server gives estimates, it says "Fee estimates are not available. Enter a fee rate in sats per virtual byte."
Look underneath
Miners do not sort by single transactions alone. Bitcoin Core's block assembly selects by ancestor fee rate (a child with an unconfirmed parent is judged together with it), which is what makes child-pays-for-parent work for wallets that support it.
Each node's mempool is its own, limited by -maxmempool (300 MB by default). When it is full, the lowest fee rates are evicted and the node's minimum rate rises until it shrinks. Unconfirmed transactions also expire after -mempoolexpiry, two weeks by default.
Where the estimates come from
Esplora's GET /fee-estimates returns a map from confirmation target (in blocks) to a rate in sat/vB, for example {"1": 14.2, "2": 12.1, "3": 10.0, "6": 7.4, "144": 1.9, ...}. Estimates are the server's view, built from recent blocks and its own mempool. The app never asks for less than 1 sat/vB.
06 Speeds
Fast, Normal and Slow are bids aimed at 2, 6 and 144 blocks
Choosing a fee means choosing how long you are willing to wait. The app turns the server's estimates into three choices and picks Normal unless you change it.
Fast aims for a block within about 20 minutes, Normal within about an hour, Slow within about a day. On a quiet morning the numbers might be 12, 8 and 2 sat/vB, which for Alice's 212 vbytes means 2,544, 1,696 or 424 sats.
The fee does not shrink with the amount. A 400 sat payment of the same size would cost more than its own amount even on Slow.
What you see on the amount pad: a chip like "Normal fee 1,696 sats". Tapping it changes the speed, and the waits read "about 20 minutes", "about an hour" and "about a day".
What it hides: the sat/vB rate and the block targets. A custom rate can only be typed when no estimates are available.
Look underneath
FeeEstimates { fast, normal, slow } are read from the Esplora map at targets 2, 6 and 144. A server rarely lists every target, so the app takes the closest target at or below the one it wants, and if every listed target is slower it takes the fastest one listed.
fn fee_for_target(estimates, target) -> rate
closest key <= target, else the smallest key
rate.ceil().clamp(1, 1_000) # never below the server's suggestion
Rounding up means a 7.4 sat/vB estimate becomes 8. On regtest there is no fee market, so all three are fixed at 1 sat/vB.
The wait labels are rough conversions at ten minutes a block. Six blocks average an hour, but block times vary a lot: an hour can pass with no block at all.
07 Sending everything
Sending the whole balance leaves no change, and the fee comes out of the amount
A payment of the whole savings balance has nothing to give back, so it has one output and no change.
With no change to take the fee from, the fee comes out of what Bob receives. Two coins in and one out is about 169 vbytes, which at 8 sat/vB is 1,352 sats, so Bob would get 53,648.
The same rule catches a near miss. If the amount typed is so close to the balance that the amount and the fee do not both fit, the app sends everything and takes the fee from the amount, instead of refusing.
What you see: there is no separate "send all" button. Typing the whole balance does it, and the pad then says "They get 53,648 sats after the 1,352 sats fee".
What it hides: the switch from an ordinary payment to a drain, which happens whenever the amount is the balance or the amount plus fee does not fit.
Look underneath
Three Rust entry points sit behind the pad:
prepare_send(dest, amount, rate): pays exactlyamount, fails withInsufficientFundsif it plus the fee does not fit.prepare_send_up_to(dest, amount, rate): triesprepare_send, and onInsufficientFundsfalls back to a drain.prepare_send_all(dest, rate): BDKdrain_wallet()plusdrain_to(dest), so every coin goes in and the single output is whatever is left after the fee.
The pad calls the drain when the typed amount is at least the confirmed balance, and the up-to path otherwise. A payment request with a fixed amount (a bitcoin: link with amount=) is paid exactly or not at all.
Dust
When the change would be tiny, BDK drops it and adds it to the fee rather than creating an output worth less than it costs to spend later.
08 Addresses
Every payment gets a new address, and a restore stops looking after 20 unused ones
An address is cheap to make, so the wallet makes a new one for every payment it expects. Reusing one would let anyone link all the payments to it.
When Alice pays Bob, her phone asks his phone for an address, and his wallet hands over the next unused one. Her change goes to the next unused address on her own change list.
All these addresses come from Alice's recovery phrase in a fixed order, so a restore can rebuild them. It walks the list and stops after 20 unused addresses in a row, on the assumption that nothing further along was ever used. That rule is why the wallet is careful about handing out addresses nobody pays.
Alice's addresses come from her recovery phrase in a fixed order, in two lists. Five receive addresses have been used, and three change addresses; the third holds the 13,304 change.
A restore rebuilds the same lists and checks each address in order for payments.
Past the used ones it finds 20 unused addresses in a row, and stops. The same rule applies to the change list.
A payment to an address further along would still be on the chain, but the restored wallet never looks there.
So OnlyBits hands other phones fresh addresses only until 10 sit unused, then gives out the oldest unused one again. The run of unused addresses never reaches 20.
What you see when paying a contact: "Connecting to Bob's phone...", and in Contacts, "Their phone gives a fresh address for every payment." Receive always shows the next unused address.
What it hides: the gap rule. A phone hands other phones fresh addresses until 10 sit unused, then gives out the oldest unused one again, so a restore always finds every payment. Saved addresses for people without the app are reused on purpose: "Payments to a saved address go to that same address each time."
Look underneath
The gap limit of 20 comes from BIP44's account discovery rule. OnlyBits uses STOP_GAP = 20 for full scans, run with 16 parallel requests to the Esplora server. The first sync after a restore is a full scan of both keychains ("Syncing. The first sync scans the whole wallet."); later ones check known addresses from the encrypted cache.
const STOP_GAP: usize = 20;
const PEER_ADDRESS_GAP: usize = STOP_GAP / 2; # 10 unused handed to other phones, then reuse the oldest
Why half the gap
Addresses given to contacts are revealed over the network before anyone pays them. Capping the unused run at 10 leaves room inside the gap of 20 for the wallet's own receive screen, so a restore never misses a payment even if every contact asked and nobody paid.
The change keychain does not need the cap: the wallet only takes a change address when it builds a payment that uses it.
09 A stuck payment
A payment bid too low can sit unconfirmed for days, and the app has no button to raise the bid yet
Suppose Alice had picked Slow at 2 sat/vB, and an hour later a rush of other payments pushed the going rate to 30. Her payment is still valid. It is just never the best offer.
It stays pending, Bob sees it arriving but cannot count on it, and Alice's 13,304 sats of change are stuck with it, because change can only be spent once the payment confirms.
Bitcoin has two ways out. Alice can sign a replacement of the same payment with a higher fee, which is called replace-by-fee. Or the receiver can spend the waiting coin with a high fee, so a miner takes both to collect it, which is called child-pays-for-parent. OnlyBits can build the first but shows no button for it, and does not do the second.
What you see: the payment stays "Pending. It counts once a block includes it, usually within an hour.", longer than the hour it promises, and the change line under the balance stays too.
What it does not do yet: there is no speed-up button, no way to cancel, and no child-pays-for-parent. Picking Normal by default is the main protection, and the only remedy today is waiting for fees to fall.
Look underneath
Replace-by-fee
BDK signals replaceability by default through nSequence below 0xfffffffe (BIP125). Bitcoin Core 28 and later also relay replacements of non-signalling transactions (full RBF). A replacement must spend at least one of the same inputs and pay a higher absolute fee and a higher rate, plus enough extra to pay for its own relay (BIP125 rules 3 and 4).
The Rust has prepare_speed_up(txid, fee_rate), which calls BDK's build_fee_bump: the same recipient gets the same amount, and the extra fee comes out of change. No Android screen calls it as of October 2026.
Child-pays-for-parent
A child spending an unconfirmed output with a high fee raises the package's ancestor rate. OnlyBits has no screen for it: Alice cannot pick the coin to spend, and the fee the app sets pays for the new payment alone, not for the stuck parent. A receiver using another wallet that supports CPFP could do it from Bob's side.
If it never confirms
Nodes drop a transaction after -mempoolexpiry (two weeks) or when their mempool fills. A dropped payment can be rebroadcast by anyone who kept a copy, so it is not safely cancelled. Broadcast in the app treats coins as spent once any server may have accepted the payment, so resending is safe and nothing is spent twice.
10 A lying server
A server that lies about fees can make Alice overpay, and the app caps how far
The fee estimates come from a server the app trusts for nothing else of value. It cannot steal coins or redirect a payment, but it can lie about the going rate.
A broken or hostile server could answer that Fast costs 5,000 sat/vB. The app refuses any rate above 1,000 sat/vB, so the bid is cut to 1,000. For Alice's 212 vbytes that is still 212,000 sats, more than she owns, so the payment fails to build.
For someone with a bigger wallet it would build, and the chip would show a fee of 212,000 sats. The cap stops the absurd case. A quieter lie, say three times the real rate, gets through untouched, and the only guard against it is the fee in sats that is on screen before anything is signed.
A broken or hostile server answers that Fast costs 5,000 sat/vB.
The app accepts rates from 1 to 1,000 sat/vB only, so the bid is cut to 1,000.
For Alice's 212 vbytes that is a 212,000 sat fee, more than she owns. The payment fails to build.
In a bigger wallet it would build, and the chip would show the 212,000 sat fee before anything is signed.
A quieter lie, 24 sat/vB when the going rate is 8, passes the cap untouched. Only reading the fee in sats catches it.
What you see: the fee in sats on the chip and again in the confirm summary, "Network fee 1,696 sats, total 41,696 sats."
What it hides: the 1,000 sat/vB cap, the rounding, and which server answered. With the default list, the app races several public servers and uses whichever answers first; with your own server set in Advanced, it asks that one alone.
Look underneath
pub(crate) const MAX_FEE_RATE_SAT_VB: u64 = 1_000;
fn fee_rate(sat_per_vb) -> Result<FeeRate>
if !(1..=1_000).contains(&sat_per_vb) { Err(..) } # typed rates too
fee_for_target(..) -> rate.ceil().clamp(1, 1_000) # server rates
Server estimates are clamped; a rate typed by hand outside the range is refused. A server that answers with no estimates at all is skipped and the next one is asked, because guessing the minimum would leave payments stuck.
What a server cannot do
It never sees a private key, and the transaction is built and signed on the phone, so it cannot change the recipient or the amount. It can withhold or invent fee data, hide coins (making the balance look smaller), and learn which addresses belong together. That trust model is the subject of Servers explained.
Shared wallets check harder
In a shared wallet each co-signer refuses any payment above 1,000 sat/vB and flags one above twice its own fast estimate and above 20 sat/vB, using its own server, before approving.
11 The cost
Change gives away which coins are Alice's, and small payments can cost more in fees than they are worth
Anyone can read the payment on the blockchain. Most of what Alice hides from the app's screen, she does not hide from a stranger.
Both coins went into one transaction, so a stranger can assume both belonged to the same person. One output is a round 40,000 and the other is an odd 13,304, so the odd one is very likely the change, and the next payment from it is very likely Alice again. The app picks the coins, so there is no way to keep two coins apart.
Fees work against small amounts. A 1,000 sat payment from one coin is about 154 vbytes, so at 8 sat/vB its fee is 1,232 sats, more than the payment. On a busy day the cut-off for small payments rises further. Small, frequent payments belong in the spending account, which is the subject of the next page.
A stranger reading the chain sees two coins in, one transaction, two coins out. No names.
Both coins were spent together, so they probably belong to the same person.
40,000 is round, so it is probably the payment. The odd 13,304 is probably the change.
When the change is spent later, that next payment is very likely the same person again, so the trail continues.
What you see: the fee before every payment, and a separate Spending tab for small amounts.
What it does not offer: coin control, coin mixing of any kind, or a warning when a fee is a large share of the amount. The app is unaudited and in early development, so treat its fee choices as reasonable defaults rather than as tuned for privacy.
Look underneath
The heuristics
- Common input ownership: inputs to one transaction are assumed to share an owner. Collaborative transactions (CoinJoin, PayJoin, BIP78) break it; OnlyBits does neither.
- Round amount: payments tend to be round in sats or in a fiat currency, change tends not to be.
- Script type: change usually matches the input type. Here every output is Taproot, which helps, because Bob's output looks the same as Alice's change.
- Unnecessary input: if one input alone could have paid, the larger output is likely change.
Fees against amounts
1 in, 2 out = 154 vB at 2 sat/vB: 308 sat fee at 8 sat/vB: 1,232 sat fee at 30 sat/vB: 4,620 sat fee
What did not get traded away
Every coin stays locked to Alice's own keys from start to finish. No server, miner or wallet company can move it, and a payment that never confirms leaves the coins hers. The fee buys a place in a public, final record that nobody can reverse, and that is the thing the spending account gives up in exchange for speed.
One payment from savings, end to end
Two coins in, two coins out, one fee
- The coin
- An unspent output locked to one address, spent whole or not at all.
- The change
- A new output back to a fresh internal address, spendable once a block confirms the payment.
- The size
- About 58 vbytes per input and 43 per output, regardless of the amount.
- The rate
- Fee divided by size, bid in an auction for the next blocks.
- The speeds
- Fast, Normal and Slow aim at 2, 6 and 144 blocks, with Normal picked by default.
- The cap
- No rate above 1,000 sat/vB, whatever a server says.
- The cost
- Change links coins together, small payments lose a large share to fees, and a stuck payment can only wait.
The 25,000 and 30,000 sat coins, the 40,000 sat payment, and the 12, 8 and 2 sat/vB rates are illustrative; real rates move by the minute. The vbyte sizes are computed for Taproot key-path inputs and outputs and rounded up, so a real payment can differ by a vbyte or two. Behaviour was checked against the OnlyBits source (the Rust wallet and the Android screens) as of October 2026, and quoted screen text is copied from it; where the source and the README disagreed, the source won. The parts that will age first are the missing speed-up button (the Rust for replace-by-fee already exists), the exact screen wording, and the BDK version. Alice and Bob are labels for payer and payee; the example assumes Bob uses OnlyBits too, which is why his phone can hand Alice a fresh address. Read Bitcoin explained first if coins and addresses are new, and Lightning explained next for the account where small payments make sense.