<oembed><type>rich</type><version>1.0</version><author_name>npub1qvg3k0w2c3ggh4wumg3pkzetfeqe9y4wgq7x5aaxz4ypjvap9vksr9t9zs</author_name><author_url>https://nostr.ae/npub1qvg3k0w2c3ggh4wumg3pkzetfeqe9y4wgq7x5aaxz4ypjvap9vksr9t9zs</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2022-08-25&#xA;📝 Original message:Thanks for your thoughts Ryan.&#xA;&#xA;Without reference to the quality feedback on this proposal, I was aware&#xA;when submitting it for review that it provides an excellent opportunity for&#xA;bike shedding. As developers, we have all experienced frustration with data&#xA;formats. One thing that I did not perhaps make clear enough is that this&#xA;format is not solely intended for developers, but general users who are&#xA;probably not well represented on this list.&#xA;&#xA;While doing research for this proposal I spoke to several professional&#xA;users of Sparrow Wallet (who are not developers). They all expressed a&#xA;desire for the format to integrate with their business processes, which are&#xA;driven by business tools such as Excel. Labelling provides an important&#xA;function in UTXO and address management in these scenarios, and needs to be&#xA;accessible and manageable outside of wallet software.&#xA;&#xA;If this is to be achieved, it immediately rules out JSON as a data format.&#xA;Not only is JSON limited to editing only through specific software or text&#xA;editors, but (in the latter case) it is fragile enough that a single&#xA;missing character can cause an entire file to fail parsing. CSV is more&#xA;forgiving in this regard. With respect to your comments on escaping, my&#xA;expectation would be that developers will be using a mature CSV library&#xA;rather than handling character escaping themselves. I would rather propose&#xA;a format that is generally usable, even if occasionally a label is escaped&#xA;incorrectly.&#xA;&#xA;Finally, I&#39;ll note that CSV files are already common and uncontroversial in&#xA;Bitcoin wallet software. Bitcoin Core, Electrum, Sparrow (and no doubt many&#xA;others) already export addresses and/or transactions with their labels as&#xA;CSV files. This proposal simply attempts to create a standard for importing&#xA;and exporting all the labels in a wallet.&#xA;&#xA;Craig&#xA;&#xA;On Wed, Aug 24, 2022 at 9:01 PM &lt;rhavar at protonmail.com&gt; wrote:&#xA;&#xA;&gt; I&#39;d strongly suggest not using CSV. Especially for a standard. I&#39;ve worked&#xA;&gt; with it as an interchange format many a times, and it&#39;s always been a&#xA;&gt; clusterfuck.&#xA;&gt;&#xA;&gt; Right off the bat, you have stuff like &#34;The fields may be quoted, but this&#xA;&gt; is unnecessary as the first comma in the line will always be the delimiter&#34;&#xA;&gt; which invariably leads to some implementations doing it, some&#xA;&gt; implementations not doing it, and others that are intolerant of the other&#xA;&gt; way.&#xA;&gt;&#xA;&gt; And you have also made the classic mistake of not strictly defining escape&#xA;&gt; rules. So everyone will pick their own (e.g. some will \, escape commas,&#xA;&gt; others will not cause it&#39;s quoted and escape quotes, and others will assume&#xA;&gt; no escaping is required since its the last column in a csv).&#xA;&gt;&#xA;&gt; Over time it morphs into its own mini-monster that introduces so much pain.&#xA;&gt;&#xA;&gt; On a similar note, allowing alternatives (like: txid&gt;index vs txid:index)&#xA;&gt; provides no benefit, but creates additional work for implementations (who&#xA;&gt; quite likely only test formats they produce) and future incompatibilities.&#xA;&gt;&#xA;&gt; I know everyone loves to hate on it, but really (line-separated?) json is&#xA;&gt; the way to go.&#xA;&gt;&#xA;&gt; { &#34;tx&#34;: &#34;c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b‎&#34;,&#xA;&gt; &#34;label&#34;: &#34;wow, such label&#34; }&#xA;&gt; { &#34;tx: &#34;c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b&#34;,&#xA;&gt; &#34;txout&#34;: 4, &#34;label&#34;: &#34;omg this is so easy to parse&#34; }&#xA;&gt; { &#34;tx: &#34;c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b&#34;,&#xA;&gt; &#34;txin&#34;: 0, &#34;label&#34;: &#34;wow this is going to be extensible as well&#34; }&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt; -Ryan&#xA;&gt;&#xA;&gt; ------- Original Message -------&#xA;&gt; On Wednesday, August 24th, 2022 at 2:18 AM, Craig Raw via bitcoin-dev &lt;&#xA;&gt; bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&gt;&#xA;&gt; Hi all,&#xA;&gt;&#xA;&gt; I would like to propose a BIP that specifies a format for the export and&#xA;&gt; import of labels from a wallet. While transferring access to funds across&#xA;&gt; wallet applications has been made simple through standards such as BIP39,&#xA;&gt; wallet labels remain siloed and difficult to extract despite their value,&#xA;&gt; particularly in a privacy context.&#xA;&gt;&#xA;&gt; The proposed format is a simple two column CSV file, with the reference to&#xA;&gt; a transaction, address, input or output in the first column, and the label&#xA;&gt; in the second column. CSV was chosen for its wide accessibility, especially&#xA;&gt; to users without specific technical expertise. Similarly, the CSV file may&#xA;&gt; be compressed using the ZIP format, and optionally encrypted using AES.&#xA;&gt;&#xA;&gt; The full text of the BIP can be found at&#xA;&gt; https://github.com/craigraw/bips/blob/master/bip-wallet-labels.mediawiki&#xA;&gt; and also copied below.&#xA;&gt;&#xA;&gt; Feedback is appreciated.&#xA;&gt;&#xA;&gt; Thanks,&#xA;&gt; Craig Raw&#xA;&gt;&#xA;&gt; ---&#xA;&gt;&#xA;&gt; &lt;pre&gt;&#xA;&gt; BIP: wallet-labels&#xA;&gt; Layer: Applications&#xA;&gt; Title: Wallet Labels Export Format&#xA;&gt; Author: Craig Raw &lt;craig at sparrowwallet.com&gt;&#xA;&gt; Comments-Summary: No comments yet.&#xA;&gt; Comments-URI:&#xA;&gt; https://github.com/bitcoin/bips/wiki/Comments:BIP-wallet-labels&#xA;&gt; Status: Draft&#xA;&gt; Type: Informational&#xA;&gt; Created: 2022-08-23&#xA;&gt; License: BSD-2-Clause&#xA;&gt; &lt;/pre&gt;&#xA;&gt;&#xA;&gt; ==Abstract==&#xA;&gt;&#xA;&gt; This document specifies a format for the export of labels that may be&#xA;&gt; attached to the transactions, addresses, input and outputs in a wallet.&#xA;&gt;&#xA;&gt; ==Copyright==&#xA;&gt;&#xA;&gt; This BIP is licensed under the BSD 2-clause license.&#xA;&gt;&#xA;&gt; ==Motivation==&#xA;&gt;&#xA;&gt; The export and import of funds across different Bitcoin wallet&#xA;&gt; applications is well defined through standards such as BIP39, BIP32, BIP44&#xA;&gt; etc.&#xA;&gt; These standards are well supported and allow users to move easily between&#xA;&gt; different wallets.&#xA;&gt; There is, however, no defined standard to transfer any labels the user may&#xA;&gt; have applied to the transactions, addresses, inputs or outputs in their&#xA;&gt; wallet.&#xA;&gt; The UTXO model that Bitcoin uses makes these labels particularly valuable&#xA;&gt; as they may indicate the source of funds, whether received externally or as&#xA;&gt; a result of change from a prior transaction.&#xA;&gt; In both cases, care must be taken when spending to avoid undesirable leaks&#xA;&gt; of private information.&#xA;&gt; Labels provide valuable guidance in this regard, and have even become&#xA;&gt; mandatory when spending in several Bitcoin wallets.&#xA;&gt; Allowing users to export their labels in a standardized way ensures that&#xA;&gt; they do not experience lock-in to a particular wallet application.&#xA;&gt; In addition, by using common formats, this BIP seeks to make manual or&#xA;&gt; bulk management of labels accessible to users without specific technical&#xA;&gt; expertise.&#xA;&gt;&#xA;&gt; ==Specification==&#xA;&gt;&#xA;&gt; In order to make the import and export of labels as widely accessible as&#xA;&gt; possible, this BIP uses the comma separated values (CSV) format, which is&#xA;&gt; widely supported by consumer, business, and scientific applications.&#xA;&gt; Although the technical specification of CSV in RFC4180 is not always&#xA;&gt; followed, the application of the format in this BIP is simple enough that&#xA;&gt; compatibility should not present a problem.&#xA;&gt; Moreover, the simplicity and forgiving nature of CSV (over for example&#xA;&gt; JSON) lends itself well to bulk label editing using spreadsheet and text&#xA;&gt; editing tools.&#xA;&gt;&#xA;&gt; A CSV export of labels from a wallet must be a UTF-8 encoded text file,&#xA;&gt; containing one record per line, with records containing two fields&#xA;&gt; delimited by a comma.&#xA;&gt; The fields may be quoted, but this is unnecessary, as the first comma in&#xA;&gt; the line will always be the delimiter.&#xA;&gt; The first line in the file is a header, and should be ignored on import.&#xA;&gt; Thereafter, each line represents a record that refers to a label applied&#xA;&gt; in the wallet.&#xA;&gt; The order in which these records appear is not defined.&#xA;&gt;&#xA;&gt; The first field in the record contains a reference to the transaction,&#xA;&gt; address, input or output in the wallet.&#xA;&gt; This is specified as one of the following:&#xA;&gt; * Transaction ID (&lt;tt&gt;txid&lt;/tt&gt;)&#xA;&gt; * Address&#xA;&gt; * Input (rendered as &lt;tt&gt;txid&lt;index&lt;/tt&gt;)&#xA;&gt; * Output (rendered as &lt;tt&gt;txid&gt;index&lt;/tt&gt; or &lt;tt&gt;txid:index&lt;/tt&gt;)&#xA;&gt;&#xA;&gt; The second field contains the label applied to the reference.&#xA;&gt; Exporting applications may omit records with no labels or labels of zero&#xA;&gt; length.&#xA;&gt; Files exported should use the &lt;tt&gt;.csv&lt;/tt&gt; file extension.&#xA;&gt;&#xA;&gt; In order to reduce file size while retaining wide accessibility, the CSV&#xA;&gt; file may be compressed using the ZIP file format, using the &lt;tt&gt;.zip&lt;/tt&gt;&#xA;&gt; file extension.&#xA;&gt; This &lt;tt&gt;.zip&lt;/tt&gt; file may optionally be encrypted using either AES-128&#xA;&gt; or AES-256 encryption, which is supported by numerous applications&#xA;&gt; including Winzip and 7-zip.&#xA;&gt; In order to ensure that weak encryption does not proliferate, importers&#xA;&gt; following this standard must refuse to import &lt;tt&gt;.zip&lt;/tt&gt; files encrypted&#xA;&gt; with the weaker Zip 2.0 standard.&#xA;&gt; The textual representation of the wallet&#39;s extended public key (as defined&#xA;&gt; by BIP32, with an &lt;tt&gt;xpub&lt;/tt&gt; header) should be used as the password.&#xA;&gt;&#xA;&gt; ==Importing==&#xA;&gt;&#xA;&gt; When importing, a naive algorithm may simply match against any reference,&#xA;&gt; but it is possible to disambiguate between transactions, addresses, inputs&#xA;&gt; and outputs.&#xA;&gt; For example in the following pseudocode:&#xA;&gt; &lt;pre&gt;&#xA;&gt; if reference length &lt; 64&#xA;&gt; Set address label&#xA;&gt; else if reference length == 64&#xA;&gt; Set transaction label&#xA;&gt; else if reference contains &#39;&lt;&#39;&#xA;&gt; Set input label&#xA;&gt; else&#xA;&gt; Set output label&#xA;&gt; &lt;/pre&gt;&#xA;&gt;&#xA;&gt; Importing applications may truncate labels if necessary.&#xA;&gt;&#xA;&gt; ==Test Vectors==&#xA;&gt;&#xA;&gt; The following fragment represents a wallet label export:&#xA;&gt; &lt;pre&gt;&#xA;&gt; Reference,Label&#xA;&gt;&#xA;&gt; c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b‎,Transaction&#xA;&gt; 1A69TXnEM2ms9fMaY9UuiJ7415X7xZaUSg,Address&#xA;&gt; c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b‎&lt;0,Input&#xA;&gt; c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b‎&gt;0,Output&#xA;&gt; c3bdad6e7dcd7997e16a5b7b7cf4d8f6079820ff2eedd5fcbb2ad088f767b37b‎:0,Output&#xA;&gt; (alternative)&#xA;&gt; &lt;/pre&gt;&#xA;&gt;&#xA;&gt; ==Reference Implementation==&#xA;&gt;&#xA;&gt; TBD&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20220825/0b1b7bed/attachment-0001.html&gt;</html></oembed>