{"number":139,"title":"Wallet Metadata Export Format","authors":["Pyth"],"status":"Draft","type":"Specification","layer":"Applications","created":"2026-05-11","license":"BSD-2-Clause","requires":[],"replaces":[],"replacedBy":[],"discussion":["https://groups.google.com/g/bitcoindev/c/ylPeOnEIhO8"],"abstract":"This document specifies a format for exporting the metadata of a wallet: its accounts, descriptors, key information, signers, labels, transactions, coins, and partially signed Bitcoin transactions (PSBTs). The format gives these records a common structure and common field names, so that what one wallet application writes another can read. Each object structure defines a few mandatory fields; all other fields are optional. The base structure must include at least one account entry. The fields of the format are collected in a companion field registry , which acts as a central repository where a wallet implementer can register their usage of a field and share that usage through a test vector.","categories":["signatures"],"filename":"bip-0139.md","githubUrl":"https://github.com/bitcoin/bips/blob/master/bip-0139.md","format":"markdown","readingMinutes":7,"inbound":0,"revisions":3,"impact":6,"core":false,"references":[],"lastModified":"2026-10-24","html":"<h2 id=\"abstract\">Abstract</h2>\n<p>This document specifies a format for exporting the metadata of a wallet: its accounts,\ndescriptors, key information, signers, labels, transactions, coins, and partially signed\nBitcoin transactions (PSBTs).\nThe format gives these records a common structure and common field names, so that\nwhat one wallet application writes another can read.\nEach object structure defines a few mandatory fields; all other fields are optional.\nThe base structure must include at least one account entry.</p>\n<p>The fields of the format are collected in a companion\n<a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>, which acts as a central repository where\na wallet implementer can register their usage of a field and share that usage through a\ntest vector.</p>\n<h2 id=\"copyright\">Copyright</h2>\n<p>This BIP is licensed under the BSD 2-clause license.</p>\n<h2 id=\"motivation\">Motivation</h2>\n<p><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\">BIP-0032</a> and\n<a href=\"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki\">BIP-0039</a> let a\nuser carry keys from one application to another, and\n<a href=\"https://github.com/bitcoin/bips/blob/master/bip-0329.mediawiki\">BIP-0329</a> does the\nsame for the labels attached to a wallet&#39;s records.<br>There is no specification targeting the entire set of metadata a wallet can carry:</p>\n<ul>\n<li>list of accounts attached to this wallet and their descriptors.</li>\n<li>list of signers holding a key in the descriptor &amp; how to interact with these signers.</li>\n<li>when an account has been created &amp; what the last seen chain tip is.</li>\n<li>which outputs are owned by the account &amp; which of them have been frozen by the user.</li>\n<li>etc.</li>\n</ul>\n<p>A big part of this metadata cannot be recovered from the chain, so a user willing to\nmigrate from one wallet to another has to re-enter it by hand or do without it.\nA format that two applications can both write and read removes that cost, and the\nlock-in that follows from it.</p>\n<h2 id=\"rationale\">Rationale</h2>\n<p>Several wallet applications already export their whole state, each in a form only they\ncan read.\nBecause each format is specific to one application, moving between any two of them\nmeans writing a converter for that pair.<br>This proposal introduces a structured format, leveraging JSON to store wallet\nmetadata in a portable way.<br>The format is flexible and extensible, allowing wallet developers to include as much\nor as little information as they think necessary.  </p>\n<p>By keeping the mandatory set of metadata small and keeping every other field\noptional, this spec accommodates diverse use cases and preferences.<br>Wallet developers can include only the fields relevant to their software while\nmaintaining structural integrity.  </p>\n<h2 id=\"specification\">Specification</h2>\n<p>A wallet export is a UTF-8 encoded text file containing a single valid JSON object\nrepresenting the wallet.<br>This object includes wallet-level metadata, multiple accounts, and associated key\ndata.</p>\n<p>Every timestamp in this format and its registry is an integer representing a Unix\ntimestamp in seconds.<br>Block heights are integers and are never interchangeable with timestamps.  </p>\n<h3 id=\"field-registry\">Field Registry</h3>\n<p>The fields of every object structure are defined in the\n<a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a> rather than in this document, so new\nfields could be added without amending this BIP.\nThe registry records field and object definitions and marks mandatory fields, so each\nobject&#39;s structure can be read from its table.\nA registry pull request may add or change optional fields only. The mandatory fields\nare fixed by this BIP, and making a field mandatory is a change to this BIP.\nRegistration of a new field must state the field name, the object it belongs to,\nits type, and a short description, and should link a test vector or an implementation\nusing it when available.\nA field name must not conflict with an already registered field of the same object.</p>\n<h3 id=\"wallet-object-structure\">Wallet Object Structure</h3>\n<p>The top-level JSON object must contain the <code>version</code> and <code>network</code> fields and at\nleast one account in the <code>accounts</code> array.<br>Its fields are listed in the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>.  </p>\n<ul>\n<li><code>version</code>: Mandatory string identifying the version of the export format.\nMust be <code>BIP139-&lt;version&gt;</code>, where <code>&lt;version&gt;</code> is an integer.\nThe export format version is incremented only for changes that are not backward\ncompatible, such as adding a mandatory field.</li>\n<li><code>network</code>: Mandatory string naming the network the export covers.<br>Must be one of <code>bitcoin</code> (mainnet), <code>testnet3</code>, <code>testnet4</code>, <code>signet</code>, <code>mutinynet</code>\nor <code>regtest</code>.<br>An export covers a single network. A wallet holding accounts on more than one\nwrites one export per network.  </li>\n<li><code>accounts</code>: Mandatory array of account objects.<br>Must contain at least one account.<br>See <a href=\"#account-object-structure\">Account Object Structure</a>.</li>\n</ul>\n<p>The optional <code>signers</code> array holds information about devices that hold key material\npresent in at least one account&#39;s descriptor. See <a href=\"#signer-object-structure\">Signer Object Structure</a>.</p>\n<h3 id=\"account-object-structure\">Account Object Structure</h3>\n<p>Each account object in the <code>accounts</code> array represents a single account within the\nwallet and must contain the <code>type</code> and <code>descriptor</code> fields.\nIts fields are listed in the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>.</p>\n<ul>\n<li><code>type</code>: Mandatory string naming the account descriptor type.<br>Must be one of <code>bip380</code> (output descriptor), <code>multi_bip380</code> (a set of BIP-0380\noutput descriptors), <code>bip388</code> (wallet policies), or <code>bip392</code> (silent payments).  </li>\n<li><code>descriptor</code>: Mandatory value representing the account descriptor, with structure\ndefined by <code>type</code>.<br>The value is a string for every type except <code>multi_bip380</code>, which uses an array of\nstrings.</li>\n</ul>\n<p>A <code>multi_bip380</code> account groups several BIP380 descriptors without further restriction.\nThis can be needed for wallets such as Electrum.</p>\n<h3 id=\"signer-object-structure\">Signer Object Structure</h3>\n<p>Each entry in the <code>signers</code> array describes one holder of key material: a hardware\ndevice, a piece of software, or a remote service. A signer must contain the\n<code>fingerprints</code> field, and the field must not be empty.\nThe signer object&#39;s fields are listed in the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>.</p>\n<ul>\n<li><code>fingerprints</code>: Mandatory array of BIP32 fingerprints held by this signer, in\nhexadecimal form.</li>\n</ul>\n<p>The field is a list because one signer can hold several master keys, as with a device\nthat has more than one mnemonic loaded, or several keys generated using the BIP-0039\npassphrase mechanism.<br>The relation is many-to-many: a key restored onto two devices appears in the\n<code>fingerprints</code> of two signers.</p>\n<p>Signers are listed in the wallet object rather than inside each <code>accounts</code> object because\na signer can be related to several accounts and none of its metadata should change\nbetween accounts. A signer used by three accounts is written once, so the copies\ncannot drift.</p>\n<h3 id=\"key-object-structure\">Key Object Structure</h3>\n<p>Keys in the <code>keys</code> dictionary are indexed by their\n<a href=\"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\">BIP32 fingerprint</a>.\nEach key object records how <em>this account</em> uses the key and must contain the <code>key</code>\nfield. Its fields are listed in the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>.</p>\n<p>What the key <em>is</em>, independent of any account, belongs in the wallet-level <code>signers</code>\narray instead. The fingerprint is the shared key that reconciles the two.</p>\n<ul>\n<li><code>key</code>: Mandatory string representing the public key fingerprint in hexadecimal\nform.</li>\n</ul>\n<h3 id=\"transaction-object-structure\">Transaction Object Structure</h3>\n<p>Values of the wallet&#39;s <code>transactions</code> map are JSON objects, each describing a single\ntransaction. Each is keyed by its transaction id, so the object itself carries no\nidentifier. Its fields are listed in the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>.</p>\n<h3 id=\"coin-object-structure\">Coin Object Structure</h3>\n<p>Each entry in the <code>coins</code> array is a JSON object describing a single output owned by\nthe account and must contain the <code>outpoint</code> field.<br>The coin object&#39;s fields are listed in the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>.</p>\n<p>A coin object records wallet state: what the account owns and what the user has\ndecided about it. Silent payment outputs are coins too, and carry a <code>tweak</code> alongside\nthe rest.</p>\n<ul>\n<li><code>outpoint</code>: Mandatory string representing the outpoint in the form <code>&lt;txid&gt;:&lt;vout&gt;</code>.</li>\n</ul>\n<h3 id=\"importing\">Importing</h3>\n<p>When importing a file defined by this specification, software should follow these\nguidelines:</p>\n<ul>\n<li>Software should validate the structure, ensure at least one account is present, and\ncheck that every object carries its mandatory fields before attempting import.  </li>\n<li>Software, during import, should preserve all metadata it supports and discard\nunsupported fields.  </li>\n<li>Software should warn users if essential data cannot be restored.  </li>\n<li>Wallets may truncate labels or other string fields if necessary, but should warn\nusers when truncation occurs.</li>\n</ul>\n<h2 id=\"encryption\">Encryption</h2>\n<p>This format can be encrypted following <a href=\"https://github.com/bitcoin/bips/pull/1951\">BIP-138</a>.</p>\n<h2 id=\"security-considerations\">Security Considerations</h2>\n<ul>\n<li>The format MUST NOT include mainnet secret signing keys or mnemonics, since an\nexport kept as a backup may be stored online or in cloud storage.\nA BIP-0392 descriptor may include a private silent payment scan key, which is\nallowed on mainnet.</li>\n<li>Care should be taken to ensure that proprietary metadata does not contain sensitive\ninformation.</li>\n</ul>\n<h2 id=\"backwards-compatibility\">Backwards Compatibility</h2>\n<p>This format is extensible and allows future additions without breaking compatibility.<br>New fields are added through the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0139/field-registry.md\">field registry</a>, and\nwallets should gracefully handle unknown entries by ignoring them.  </p>\n<p>For all enum types, if the field is optional and the enum type is unknown, the field\nmust not be imported, but import of the file SHOULD NOT fail.</p>\n<h2 id=\"reference-implementation\">Reference Implementation</h2>\n<p>TBD</p>\n<h2 id=\"references\">References</h2>\n<ul>\n<li><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\">BIP-0032: Hierarchical Deterministic Wallets</a></li>\n<li><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki\">BIP-0039: Mnemonic code for generating deterministic keys</a></li>\n<li><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki\">BIP-0174: Partially Signed Bitcoin Transaction Format</a></li>\n<li><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0329.mediawiki\">BIP-0329: Wallet Labels Export Format</a></li>\n<li><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0380.mediawiki\">BIP-0380: Output Script Descriptors</a></li>\n<li><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki\">BIP-0085: Deterministic Entropy From BIP32 Keychains</a></li>\n</ul>\n","toc":[{"id":"abstract","title":"Abstract","level":2},{"id":"copyright","title":"Copyright","level":2},{"id":"motivation","title":"Motivation","level":2},{"id":"rationale","title":"Rationale","level":2},{"id":"specification","title":"Specification","level":2},{"id":"field-registry","title":"Field Registry","level":3},{"id":"wallet-object-structure","title":"Wallet Object Structure","level":3},{"id":"account-object-structure","title":"Account Object Structure","level":3},{"id":"signer-object-structure","title":"Signer Object Structure","level":3},{"id":"key-object-structure","title":"Key Object Structure","level":3},{"id":"transaction-object-structure","title":"Transaction Object Structure","level":3},{"id":"coin-object-structure","title":"Coin Object Structure","level":3},{"id":"importing","title":"Importing","level":3},{"id":"encryption","title":"Encryption","level":2},{"id":"security-considerations","title":"Security Considerations","level":2},{"id":"backwards-compatibility","title":"Backwards Compatibility","level":2},{"id":"reference-implementation","title":"Reference Implementation","level":2},{"id":"references","title":"References","level":2}],"history":{"totalCommits":3,"firstCommit":"2021-05-14T18:14:08-07:00","lastUpdated":"2026-10-24T17:11:13+02:00","events":[{"sha":"100ba872c808946155b1eeb8c4568058f2eea0a7","date":"2026-10-24T17:11:13+02:00","author":"pythcoiner","message":"Add BIP139: Wallet Metadata Backup Format (#2130)","url":"https://github.com/bitcoin/bips/commit/100ba872c808946155b1eeb8c4568058f2eea0a7","kind":"edit"},{"sha":"0e9aef5d9ed64db29f4fa74ef22e1974e1987496","date":"2021-05-14T18:37:07-07:00","author":"Hugo Nguyen","message":"Correct BIP number","url":"https://github.com/bitcoin/bips/commit/0e9aef5d9ed64db29f4fa74ef22e1974e1987496","kind":"edit"},{"sha":"b644e2933e98b1a30f442e711c3b2049f531a997","date":"2021-05-14T18:14:08-07:00","author":"Hugo Nguyen","message":"update BIP number and rename file","url":"https://github.com/bitcoin/bips/commit/b644e2933e98b1a30f442e711c3b2049f531a997","kind":"rename"}]}}