Wallet Version Strings with Capability Flags
Wallets needed a way to tell apps "I support this optional feature" or "I don't" without a long back and forth, but earlier attempts to add that information to the version string made it too long, so apps using older code saw a wallet as unavailable even though it was working fine. This fixes that by squeezing the yes/no answers into a few extra characters that always fit inside the original size limit.
About Wallet calls, the set of calls an app makes to a wallet.
Reference for an AI
Everything an assistant needs to answer questions about BRC-263 accurately, including what it depends on.
Summary
- Why
- Capability attributes added to a wallet's version string pushed it past the 30 byte limit that existing validators enforce, causing working wallets to be rejected as unavailable.
- What
- BRC-263 is a format for BRC-100's getVersion string that packs up to 48 boolean wallet capability flags into a tilde-suffixed base64url segment that never exceeds the existing 30 byte limit.
- How
- A wallet appends a tilde and one or more base64url digits to its vendor-version string, each digit's bits mapping to six registry flag indexes in order, and a reader parses the string, keeps only recognized flags in the 0 to 47 range, and treats anything that does not match the grammar as a legacy string with no flags.
What this lets you do
- Pack up to 48 boolean capability advertisements into a wallet's getVersion string
- Keep that string within BRC-100's 7 to 30 byte limit so old validators accept it unchanged
- Encode and decode flags with base64url digits, six flags per character
- Claim a registry index for a new boolean capability instead of inventing an attribute
- Treat non-matching version strings safely as legacy with no flags assumed
Written by claude-sonnet-5 from the specification text. Where the two differ, the original is correct.
The specification
Abstract
This proposal defines one format for the BRC-100 getVersion result: [vendor]-[major].[minor].[patch]~[flags]. The optional flags part is a bit mask of boolean wallet capabilities, written in the base64url digit alphabet, six flags per character. The complete string stays within BRC-100's 7–30 characters, so validators that check only the length accept it without change.
The proposal gives each part of the 30 bytes a fixed budget. A vendor of up to 12 bytes and a version of up to 8 bytes leave room for 8 flag characters, so every conforming wallet can advertise any of 48 registered flags. The proposal also holds the flag registry. A BRC that needs a yes/no capability advertisement claims the next free index in that registry.
This proposal replaces the brc212 attribute of BRC-212 and keeps its flag indexes. It does not use BRC-205 attributes.
Motivation
BRC-100 gives getVersion a VersionString7To30Characters result: a [vendor]-[major].[minor].[patch] string of 7–30 characters. SDKs and wallets in the field enforce that bound in result validation and in the binary wire transceiver.
BRC-205 added ; key=value; attributes and raised the complete-string limit to 2048 bytes. Capability attributes such as brc207-color=4 and brc177-nosend=2 followed. BRC-212 then packed boolean capabilities into one attribute to save bytes. Both approaches have the same problem: a string longer than 30 bytes fails every validator that enforces BRC-100's bound. One capability attribute is enough to cross it. For example, wallet-brc100-1.0.0; brc177-nosend=2; is 37 bytes, and applications that use an older SDK report that no wallet is available.
A boolean capability needs one bit. If the bits are part of the version format itself, with no other content after them, the string never needs more than 30 bytes. No validator needs to change, and no wallet needs a workaround.
The 30 bytes are not enough for every possible vendor name, version and flag set together. So this proposal gives each part an explicit budget, and limits the registry to the number of flags that the budget guarantees.
Scope
The uppercase terms MUST, MUST NOT, SHOULD, SHOULD NOT and MAY have the meanings in RFC 2119 and RFC 8174. The Specification section is normative. Examples and rationale are informative.
This proposal defines the format of the version string that getVersion({}) returns, a flag encoding, and a registry of flag indexes. It does not change the getVersion({}) call, its { version: string } result shape, its call code, any transport, or BRC-100's 7–30-byte bound.
Only boolean capability advertisements are in scope. This proposal defines no way to carry values such as labels, icons or revision numbers in the version string. A capability revision that applications must tell apart gets its own flag.
Specification
1. Format
A conforming version string matches this grammar (RFC 5234 ABNF, case-sensitive):
version = vendor "-" semver [ "~" flags ]
vendor = 1*12( %x61-7A / DIGIT ) ; lowercase a-z and 0-9
semver = number "." number "." number ; 5 to 8 bytes in total
number = "0" / ( %x31-39 *DIGIT ) ; no leading zeros
flags = 1*( ALPHA / DIGIT / "-" / "_" ) ; base64url digits
The complete string MUST be 7–30 characters, as BRC-100 requires. All characters are ASCII, so this proposal counts bytes and characters as equal.
The vendor part names the wallet implementation. It is not an identity, and it proves nothing about the wallet.
The semver part is the wallet implementation's version. Its length limit allows versions such as 1.0.0, 2.15.0, 10.20.30 and 1.10.100.
2. Budget
The 30 bytes divide into fixed budgets:
| Part | Budget |
|---|---|
vendor | 1–12 bytes |
- | 1 byte |
semver | 5–8 bytes |
~ | 1 byte |
flags | at least 8 characters, which is 48 flags |
A wallet with the longest vendor and the longest version has 8 flag characters left. A wallet that uses less of its vendor or version budget has more characters left, up to 22 characters for a 1-byte vendor and a 5-byte version. Only the first 8 characters can carry registered flags (section 5).
| Vendor bytes | Version bytes | Base bytes | Flag characters available | Flags available |
|---|---|---|---|---|
| 12 | 8 | 21 | 8 | 48 |
| 12 | 5 | 18 | 11 | 66 |
| 7 | 5 | 13 | 16 | 96 |
| 1 | 5 | 7 | 22 | 132 |
3. Flag encoding
Each character of flags is one digit from the base64url alphabet of RFC 4648 section 5:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
A is 0 and _ is 63. Flag index i is set if and only if bit i mod 6 of the digit at character position floor(i / 6) is 1, where bit 0 is the least significant bit and position 0 is the first character after ~. So the first character holds flags 0–5, the second holds flags 6–11, and so on.
This is not base64 of a byte string. There is no padding, and any length is valid within the budget.
4. Rules for wallets
A wallet that implements this proposal:
- MUST return a string that matches section 1, and MUST NOT return a string longer than 30 bytes.
- MUST NOT append anything after the flags. In particular, it MUST NOT append BRC-205 attributes or any
;. - MUST set exactly the flags for the capabilities it advertises, and MUST NOT set an unregistered flag.
- MUST omit
~andflagswhen no flag is set. - SHOULD omit trailing
Adigits. - MAY clear flags for privacy (section 7) or while it is locked.
A wallet that does not implement this proposal can keep any BRC-100 string. Readers treat it as a legacy string (section 6).
5. Flag registry
Registered flag indexes MUST be in the range 0–47. That range fits in the 8 characters that section 2 guarantees, so every conforming wallet can set any registered flag. A future BRC can extend the range only if it also revises the budget.
| Flag | Defining BRC | Capability | Replaces |
|---|---|---|---|
| 0 | BRC-207 | 1Color wallet module, capability revision 4 | brc207-color=4 |
| 1 | BRC-207 | Default attested admission profile, all four trust modes, revision 1 | brc207-color-attested=1 |
| 2 | BRC-175 | Offline bundle acceptance, revision 2 | brc175-offline=2 |
| 3 | BRC-177 | noSend expiry, batches and never, revision 2 | brc177-nosend=2 |
| 4–47 | Unassigned |
Flags 0–3 have the same meaning as the same indexes in BRC-212. Earlier revisions of these capabilities have no flag, because their defining BRCs state that those values do not establish support for the current revision.
Allocation rules:
- A BRC that defines a new boolean capability advertisement after this proposal MUST claim a flag in this table, and MUST NOT define a version-string attribute for it. The attributes that BRC-175, BRC-177 and BRC-207 already define are not changed by this rule (see Compatibility).
- A new entry MUST use the lowest unassigned index. Before assigning, the author MUST check this table on the current
masterbranch and the flags claimed by open pull requests, and MUST recheck immediately before merging. - A flag, once merged, is permanent. It is never reassigned, even if its capability is withdrawn. A withdrawn flag stays in the table, marked withdrawn.
- A new revision of a capability gets a new flag only if applications must tell the revisions apart. A compatible revision keeps the existing flag.
- Each entry's defining BRC MUST state what the flag asserts, at what revision, and its privacy implications.
6. Rules for readers
A reader that implements this proposal:
- MUST apply BRC-100's 7–30-byte bound first. This proposal does not change how a reader handles a string outside that bound.
- MUST treat a string that does not match section 1 as a legacy string. A legacy string is a valid BRC-100 version with no flags. The reader MUST NOT reject the wallet because the string is legacy.
- MUST NOT try to repair a legacy string, or to read flags from part of it. For example,
example-1.2.3-betaandexample-1.2.3; brc212=P;are legacy strings with no flags. - MUST treat flag positions beyond the end of
flagsas clear, and MUST accept trailingAdigits. - MUST ignore set flags that are unregistered, including any flag of index 48 or higher.
7. Meaning of a flag
A set flag makes the same assertion, with the same semantics, as the capability advertisement that its defining BRC describes. Every rule of the defining BRC still applies. In addition:
- A flag is optional descriptive metadata. It is not BRC-100 method negotiation, an authentication result, a permission grant or spending authority. All 28 BRC-100 methods remain mandatory.
- A clear flag, or a legacy string, MUST NOT be treated as proof of non-support.
- A set flag MUST NOT be treated as proof that a call will be authorized or succeed. Every call still checks actual support and permissions.
- A flag MUST NOT encode user-specific state such as balances, holdings, grants or history.
8. Privacy
A capability set can help to fingerprint a wallet. Wallets SHOULD set only the flags that a requesting application plausibly needs, and MAY return different flag sets to different originators. Consumers MUST NOT send the version string or the decoded flag set to analytics, unrelated servers or logs by default, and MUST NOT use them for cross-application correlation.
Consumers SHOULD read the flags again on the selected connection before a workflow that depends on them, and MUST discard stored flags on provider change, account change or disconnection.
9. Reference implementation (informative)
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
const REGISTERED = 48
const VERSION = /^([a-z0-9]{1,12})-((?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*))(?:~([A-Za-z0-9_-]+))?$/
function encodeFlags (indexes) {
const digits = []
for (const i of indexes) {
if (!Number.isInteger(i) || i < 0 || i >= REGISTERED) throw new RangeError(`flag ${i}`)
const pos = Math.floor(i / 6)
while (digits.length <= pos) digits.push(0)
digits[pos] |= 1 << (i % 6)
}
while (digits.length > 0 && digits[digits.length - 1] === 0) digits.pop()
return digits.map(d => ALPHABET[d]).join('')
}
function formatVersion (vendor, semver, flagIndexes = []) {
const flags = encodeFlags(flagIndexes)
const version = flags === '' ? `${vendor}-${semver}` : `${vendor}-${semver}~${flags}`
const parsed = parseVersion(version)
if (parsed === null || parsed.flags === null) throw new RangeError(`not a BRC-263 string: ${version}`)
return version
}
// null: outside BRC-100's 7-30 bytes. { flags: null }: a legacy string.
function parseVersion (version) {
const bytes = new TextEncoder().encode(version).length
if (bytes < 7 || bytes > 30) return null
const m = VERSION.exec(version)
if (m === null || m[2].length > 8) return { flags: null }
const flags = new Set()
const digits = m[3] ?? ''
for (let pos = 0; pos < digits.length; pos++) {
const d = ALPHABET.indexOf(digits[pos])
for (let bit = 0; bit < 6; bit++) {
if ((d >> bit) & 1) flags.add(pos * 6 + bit)
}
}
return { vendor: m[1], semver: m[2], flags }
}
A reader keeps only the registered flags from the returned set.
Examples and conformance cases
The inputs are complete version values, without JSON quoting.
| Input | Bytes | Required result |
|---|---|---|
example-1.2.3 | 13 | Conforming. No flags set. |
example-1.2.3~B | 15 | Flag 0. |
example-1.2.3~I | 15 | Flag 3. |
example-1.2.3~F | 15 | Flags 0 and 2. |
example-1.2.3~P | 15 | Flags 0–3. |
example-1.2.3~PAA | 17 | Flags 0–3. Trailing A digits are accepted. |
example-1.2.3~AB | 16 | Flag 6, unregistered: ignored. No registered flags set. |
example-1.2.3~7B | 16 | Flags 0, 1, 3, 4, 5 and 6. Registered flags 0, 1 and 3; flags 4–6 ignored. |
abcdefghijkl-10.20.30~________ | 30 | Longest vendor and version. Flags 0–47 all set. |
x-1.0.0~AAAAAAAAB | 17 | Flag 48: ignored, because it is outside the registry range. |
wallet-brc100-1.0.0 | 19 | Legacy: the vendor contains -. No flags. The wallet is not rejected. |
abcdefghijklm-1.0.0~P | 21 | Legacy: the vendor is 13 bytes. |
Example-1.2.3~P | 15 | Legacy: the vendor has an uppercase letter. |
example-01.2.3~P | 16 | Legacy: leading zero. |
example-100.200.300~P | 21 | Legacy: the version is 11 bytes. |
example-1.2.3-beta | 18 | Legacy: a pre-release tag is not flags. |
example-1.2.3~ | 14 | Legacy: empty flags. |
example-1.2.3~e. | 16 | Legacy: . is outside the alphabet. |
example-1.2.3~P~B | 17 | Legacy: a second ~. |
example-1.2.3+P | 15 | Legacy: + is not the separator. |
example-1.2.3; brc212=P; | 24 | Legacy: BRC-205 attributes are not part of this format. |
1.0.0.0 | 7 | Legacy: no vendor. |
abcdefghijkl-10.20.30~_________ | 31 | Outside BRC-100's bound. A wallet MUST NOT return it. |
Rationale
Why flags only. BRC-205 lets a version string carry any number of attributes, up to 2048 bytes. Every attribute takes a string over BRC-100's 30-byte bound, so every deployed validator rejects it. Flags give boolean capabilities a place inside the bound, and the format allows nothing else, so the string can never grow past it.
Why ~. The separator must not occur in existing version strings, and must not be in the flag alphabet. Semver uses - for pre-release tags such as 1.2.3-beta, and beta is valid base64url, so - gives false flags. Semver uses + for build metadata, and a value such as +20261123 is also valid base64url. ~ is in neither semver nor the alphabet, so a reader can split the string at ~ without doubt. ~ is also an unreserved URI character and needs no escaping in JSON.
Why a 12-byte vendor. A vendor needs enough room for a readable name. A budget of 12 bytes for the vendor and 8 bytes for the version still leaves 8 flag characters, which is 48 flags, in the worst case. A larger vendor budget reduces the guaranteed flag count by 6 for each byte.
Why lowercase letters and digits only in the vendor. A vendor without - lets a reader find the vendor at the first -. Lowercase only gives each vendor one spelling.
Why a hard registry limit. If the registry assigned an index beyond the guaranteed 8 characters, a wallet with a long vendor or version could not set that flag within 30 bytes. Limiting the registry to 48 indexes means every registered flag fits in every conforming string.
Compatibility
BRC-100. A conforming string is a valid BRC-100 version string of 7–30 bytes. Validators that check only the length accept it without change. A validator that checks a strict [vendor]-[major].[minor].[patch] pattern rejects a string with flags, and needs to allow the optional ~ suffix.
BRC-205. This proposal does not use BRC-205 attributes. A conforming wallet does not append them, so its string stays within 30 bytes. A conforming string with no flags, such as example-1.2.3, is also a valid BRC-205 base with no attributes. A conforming string with flags, such as example-1.2.3~P, does not match BRC-205's core-version, so a BRC-205 reader gets no metadata from it. BRC-205 section 3 says that this failure alone does not cause the wallet to be rejected.
Value attributes. Attributes that carry a value, such as account-label from BRC-205 and brc185-icon from BRC-185, have no place in this format. A wallet that adopts this proposal does not send them in the version string.
BRC-212. This proposal replaces the brc212 attribute. The flag encoding and flags 0–3 are the same, so a BRC-212 decoder can read the flags part without change. A wallet that sends brc212= sends a legacy string under this proposal, and readers see no flags in it.
Existing wallets. A wallet that returns a legacy string, such as wallet-brc100-1.0.0, keeps working. Readers see no flags in it. A wallet that adopts this proposal can need a new vendor name, because its current name can be longer than 12 bytes or contain -.
Capability BRCs. BRC-207, BRC-175 and BRC-177 each define a capability attribute. Under this proposal, a wallet advertises those capabilities with flags 0–3 in place of the attributes. Those BRCs still describe the attributes, and separate amendments can point them to the flags.
References
- BRC-100: Wallet-to-Application Interface
- BRC-175: 1Color Offline Peer-to-Peer Payments
- BRC-177: Wallet-Enforced Expiry for noSend Actions
- BRC-185: Wallet Substrate Discovery, Selection, and Encrypted Mobile Connections
- BRC-205: Extensible Wallet Version Strings and Account Labels
- BRC-207: 1Color Wallet Module
- BRC-212: Compact Wallet Feature Flags in
getVersion - RFC 2119: Key words for use in RFCs to Indicate Requirement Levels
- RFC 4648: The Base16, Base32, and Base64 Data Encodings
- RFC 5234: Augmented BNF for Syntax Specifications
- RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words