BIP: ?
Layer: Applications
Title: Finite Script Bundles for Watch-Only Wallets
Authors: Cristóbal Rosa <sato@cuvex.io>
Status: Draft
Type: Specification
Assigned: ?
License: BSD-2-Clause
Version: 0.1.0
Requires: 84, 141
Abstract
An offline Bitcoin signer can give an online watch-only wallet a finite inventory of receive and change scripts without exporting an extended public key, individual spending public keys or a reusable derivation descriptor. This proposal defines an authenticated binary bundle, its pairing and replenishment rules, and the behavior required before broadcasting a spend. The initial interoperable profile uses fresh native P2WPKH outputs. Bitcoin consensus, addresses, transactions and signatures are unchanged.
Motivation and limits
A descriptor containing an account xpub lets the recipient derive future child public keys. Losing the watch database may expose all of those keys. Here the same incident reveals the finite list of scripts and their associations. It does not disclose an account-wide derivation capability. Addresses, balances, queried scripts, transaction histories and traffic timing can still reveal identity and link payments. A hostile watcher can suppress transactions, show a substituted payment request or exfiltrate the inventory. Hardware address verification and a trusted source of chain data serve different purposes.
For a fresh P2WPKH output the receiving script carries a 20-byte hash of the spending key. Spending exposes the public key in the witness. The first connected component to receive that witness learns it even if no node admits the transaction. Previously disclosed account or child keys, address reuse and other outputs still payable to a revealed key retain their original exposure. There is no post-quantum spending guarantee. This proposal does not rely on HBR or a future soft fork.
Roles and scope
The issuer is an offline signer that manages a BIP84 account, derivation and a durable reservation journal. The watcher is a networked application that checks, stores and consumes a finite inventory. A bridge may carry bytes or display the binding on a second screen. It has no authority to allocate, sign or authorize. A broadcaster may be the watcher or a user-selected node.
The normative profile is version 1, fresh P2WPKH, one issuer and one issuing watcher per account. Mainnet, test networks and regtest are identified by their exact genesis block hash. Receiving and internal change are separate branches. Signing, transport framing and backing store are implementation choices subject to the safety rules below. A pure watch client can implement bundle interoperability without implementing signing. “MUST”, “SHOULD” and “MAY” use RFC 2119/8174 meanings.
Profile, keys and pairing
The issuer derives spending keys offline using m/84'/coin_type'/account'/branch/index (BIP84). branch is 0 for external and 1 for change; index is 0..2147483647. For Bitcoin mainnet coin_type is 0 and for Bitcoin test networks under this profile it is 1. The user selects an account on the signer. Each pairing has a uniformly random 16-byte account handle H and an independent Ed25519 authentication key pair. The authentication secret MUST be independent of all spending keys; the public verifier V is deliberately visible to that watcher. Never sign bundles using a Bitcoin spending key. Neither H nor V should be reused for an unrelated pairing. A signer MUST prevent two active allocators for the same underlying root/account even when their handles differ. It binds H, V and the private signing state to the exact seed/passphrase identity, derivation account, network and profile within authenticated offline storage.
An enrollment message contains literal ASCII FWB1, network G (32 bytes), handle H (16), profile byte 01 and raw Ed25519 verification key V (32). G is the genesis block hash in Bitcoin serialized byte order. The signer displays the full binding digest T("FWB/pair/v1", enrollment) in grouped hex or a QR which encodes those exact digest bytes. The watcher pins the tuple only after an operator compares both values over a trusted out-of-band path to the physical issuer; direct optical capture from a trusted device plus on-device verification is suitable. A QR delivered by the same untrusted bridge on both sides does not independently establish the pin. A client must offer full comparison even if it also offers an abbreviated display. No remote self-signed enrollment or automatic replacement of a pin is sufficient. Change of issuing watcher requires the recovery procedure below.
T(label,x) denotes SHA256(SHA256(ASCII(label)) || SHA256(ASCII(label)) || x). All integers below are unsigned, little-endian. All literal ASCII prefixes have no NUL terminator. All fixed-size arrays are raw bytes, not hex or UTF-8. A strict parser MUST reject unknown tags, noncanonical lengths, oversized data, arithmetic overflow and trailing data before durable mutation.
Normative bundle wire format
| Field in wire order |
Bytes |
Rule |
| Magic |
4 |
ASCII FWBP |
| Version |
1 |
01 |
| Genesis G |
32 |
Exactly the pinned network |
| Account handle H |
16 |
Exactly the paired handle |
| Profile |
1 |
01 for native P2WPKH |
| Sequence q |
8 |
Begins at 1 for the pairing, then increments by 1 across both branches |
| Predecessor |
32 |
All zeros for q=1; otherwise the prior bundle id |
| Branch |
1 |
00 receive or 01 change |
| First index i |
4 |
First index in that branch; no hardened child index |
| Count n |
2 |
1..128 |
| Payloads |
20n |
HASH160(compressed spending pubkey) in increasing index order |
| Authentication |
64 |
RFC 8032 pure Ed25519 over the 32-byte signing digest |
Let body be all bytes through the last payload. sig = Ed25519.Sign(auth_secret, T("FWB/sign/v1", body)). bundle = body || sig. id = T("FWB/id/v1", bundle). Total length is 165+20n bytes (185..2725). Genesis and pin select V; the verifier is deliberately absent from the batch. Verify the signature before persistence. Require canonical Ed25519 point encodings and S less than the group order, reject small-order public keys and R; require prime-order non-identity V and R and check the uncofactored verification equation. Use a reviewed implementation with documented handling for these cases. Derived receiving script is exactly 00 14 followed by the corresponding 20 bytes (hex notation); the address is rendered locally with the chosen network HRP and the BIP173 v0 checksum. Accept only the enrolled profile; no free-text address, descriptor, chain code, fingerprint, derivation path, xpub or Bitcoin public key is part of this package.
BIP32 defines exceptionally invalid child derivations. The version-1 contiguous encoding cannot express a skipped slot: if derivation fails or yields a duplicate script, do not sign a batch spanning that slot. Stop issuance on that branch, retain the old receiving history, and pair a fresh hardened account if further allocation is needed. No implementation may shift a child into an incorrect advertised index.
The first batch for each branch starts at zero. Later batches for that branch start at its prior exclusive end. The exclusive end is computed using a wider integer and may equal 2147483648. The next batch must not wrap or exceed it. An implementation MAY demand an independently authenticated birthday for scanning, or use a conservative earlier height. The wire format carries no birthday. Block height is never a substitute for proof of account ownership.
State transitions and persistence
- Enrollment. Store G,H,V,profile and a genesis journal before accepting batches. An exact repeated enrollment is idempotent. A change of any field requires deliberate new pairing. A watch-only replica may mirror receipts but MUST NOT allocate addresses or change unless it is the sole issuing watcher.
- Issuance. The offline issuer atomically records q, predecessor, branch, high-water mark, digest and recoverable exact bytes before offering a batch. It can re-export the same bytes after loss. It never issues overlapping branch/index slots or forks an existing sequence after a restore. An out-of-order presentation to the watcher is deferred without installing any part of it.
- Import. Verify total length, pin, signature, sequence, predecessor, branch range and duplicates (within and across all address roles). Commit the complete batch and both the sequence head and branch watermark in one transaction. A known identical id is a successful replay without new allocations. Same q with a different id, changed pin or a previously assigned script in a different slot raises a conflict; halt new issuance and retain the current state intact. Use database uniqueness constraints or equivalent serializable state.
- Receive. Atomically mark the next external script assigned to one invoice before display, QR, copy, chat, print or external share. A repeat lookup by invoice id returns the same address. Cancellation/expiry retires that address permanently from issuance; it continues to be watched. Other invoices never reuse it. Watch every authenticated script, including unassigned, retired and internal scripts, from an appropriate height.
- Change. Atomically reserve a fresh internal script for a specific intent. The offline signer rederives it and verifies its amount and position. Never substitute an external recipient or a receive script as change. Retire a change reservation once exposed in an exported intent; after ambiguous crashes err toward retirement. If a necessary branch is empty, explain how to replenish it. A genuine no-change spend may proceed with explicit fee verification.
- Recovery. Restore the issuer's authenticated state and the watcher's monotone assignment journal. Restore pending intents, checkpoints and both branch high-water marks. If freshness is uncertain, allow historical read-only scanning and offline recovery but suspend issuing new addresses. Replaying all batches cannot recover invoices that were shared but never paid. Recover the assignment journal or retire the entire uncertain range; after restoring a verified upper bound resume above it. Without a verified upper bound or with concurrent cloned issuers, create a new hardened account, retain monitoring for old funds and obtain a new pin. No fixed gap of twenty unused addresses establishes completeness. A seed/passphrase recovers keys; it cannot reconstruct labels, prior reservations or correspondence metadata.
- Multiple watchers. Two independently allocating installations must use independently authorized hardened accounts in this profile. A read-only replica or recovery workflow may inspect existing assignments. Do not initialize a second allocator at zero on the same account. Applications wanting partitioned ranges within a shared account need a separate negotiated extension.
Preparing, signing and releasing a payment
A draft can carry prevouts, amounts, scriptPubKeys, outputs, fees, network, opaque account handle and branch/index hints in a privately negotiated companion protocol. Recompute on the signer rather than trusting hints. For profile 1 the online component MUST NOT require PSBT global xpubs, per-key derivations, child spending keys or partially signed witnesses. BIP174 and BIP370 describe containers; their optional identifying fields can undermine the product's assurance. The signer authenticates prevout values/scripts against funding transaction data or an independently trusted coin view, derives each input and change script, checks network, spending policy, totals, fee, recipients and SIGHASH_ALL, and obtains on-device approval. A correct signature on the wrong intent is a failed payment flow.
The signer finalizes and holds the signed transaction offline. Before release the broadcaster may receive a human-reviewable intent id which is independent of undisclosed data. The user sees the exact intended node or first online receiver and authorizes release. The watcher verifies the intent against the final bytes at handoff and broadcasts identical bytes promptly. A user who chooses to export signed bytes for later broadcast must be told that key disclosure occurs at export. An incompatible signer requiring xpub or signed PSBT roundtrips must negotiate a different account mode explicitly. It cannot inherit this profile's disclosure claim.
Keep a journal which distinguishes “signed offline”, “release attempted”, “seen by a node”, “confirmed” and “reorganized”. Loss of acknowledgment leaves the release result uncertain and the key potentially exposed. Query by transaction id and retransmit identical bytes if authorized. Never advertise the key as hidden again after handing raw bytes to an online component. No wallet can require all downstream nodes to relay immediately. RPC preflight with the signed transaction is already disclosure to that RPC server.
Security, privacy and backward compatibility
A finite inventory still allows cluster analysis. Sending it in one Electrum or hosted-index request, reusing account handles across services, unprotected backups, automatic explorer links and crash reporting all leak metadata. Clients should offer own-node scanning, disclose hosted-query linkage, and restrict logs, backups and visual capture. An Ed25519 pairing key authenticates present inventory under conventional assumptions. It is not a Bitcoin spending key or a PQ authenticator. If authentication becomes unreliable the user can independently check addresses on the signer; future algorithms require a new version and authenticated negotiation.
Native P2WPKH is compatible with current Bitcoin nodes and payers. The watcher can always construct the script/address and monitor it. A current descriptor wallet may choose to import individual addr()/raw() watch entries while retaining the authenticated journal separately. A list of addr() descriptors does not convey branch, issuer, anti-replay or allocation semantics. BIP380/382, BIP84, BIP174/370, BIP129 device setup and BIP388 wallet policies address related but distinct tasks. No standard registry identifiers are claimed by the experimental file magic. Alternative script forms require independent rules. P2WSH can hide a script until spent, subject to private setup and safe signing between cosigners. P2TR exposes a curve point at funding irrespective of bundle transport. Wallets should label such modes accurately. Existing xpub-based accounts require no change; historical disclosure cannot be undone by changing their display name or database fields.
Test vectors, reference and adoption
The accompanying fwb-vectors.json includes public pins, two chained signed batches, branch assignments, exact messages, numeric bounds and expected results; all data is synthetic. verify-public-vectors.py is a small positive-fixture implementation of decoding, signature verification using a cryptographic library, bundle linkage and both hash-domain examples. It is not a wallet. Negative cases include truncation, network mismatch, signed-byte change, replay, fork at equal sequence, wrong predecessor, index overlap, exhausted branch and the upper index boundary. A reader must distinguish malformed data from a valid retransmission. Interoperability requires at least two independent implementations to exchange these bytes and reconcile allocation after a simulated crash. Hardware release and privacy tests remain separate.
Numeric example (hex)
For the public synthetic enrollment and first external batch in fwb-vectors.json:
pair digest = 015c3825806d56c510b5d32b4f1381ea8a86e167df7a4ba14ef385114e147717
first id = 6f5bde0827eb516e938fb4d193be0472cd7ab17cbb2ee145ebf1ce8563b54617
first scriptPubKey = 0014410cbe1fdf1ec0299c7f428c3816436d24388f0a
A receiving wallet that independently parses the signed data must obtain these values exactly. Re-importing that first batch after the second one leaves all allocations intact.
References
BIP 32, BIP 84, BIP 141, BIP 173, BIP 174, BIP 370, BIP 380, BIP 382, BIP 129, BIP 388, RFC 8032, BIP 3.
Copyright
Copyright 2026 Cristóbal Rosa. Proposed license for this draft and its accompanying example: BSD-2-Clause, as reproduced in LICENSE-FWB.txt.