67e8e179d34e3b162a3882f8acf314a43c1c597fc0ed5f4175fedde46a175e9c
{
  "bitpost": "article",
  "data": "For a while now, I’ve been trying to enable consumer BSV wallets to broadcast data and non-standard transactions by daisy chaining transactions together. My first stab at this was [Proxypay](https://github.com/libitx/proxypay) but I’ve since turned my efforts to [Paypresto](https://www.paypresto.co) - a service built on peer-to-peer transaction protocols.\n\nIn doing this I’ve had to dive deep in to the various P2P protocols the BSV wallet ecosystem supports. And it turns out the landscape is a somewhat confusing one, so I thought I’d share a few of the things I’ve discovered.\n\n## The standard(s)\n\n![How standards proliferate](https://data.bitpost.app/file/10a08a05f971c2d2b6ff960f40f002d6ca9c1f67c7a26ddd2acc238f9c0cc8e5)\n\nThere are currently three distinct protocols different wallets are using for sending transactions peer to peer. On top of this, between the wallets’ own implementations there are some quirks and discrepancies that can make it tricky to support all wallets, even those following the same protocol.\n\nIn short, it’s quite a minefield for any app or service that wants to accept P2P transactions. So it’s a good job I built Paypresto so you don’t have to worry about it. But in case you do have masochistic tendencies, maybe the following will help you enjoy the process as much as I did.\n\n## Simplified Payment Protocol (BIP270)\n\nAny look into the BSV’s P2P transaction protocols naturally starts with the [Simplified Payment Protocol](https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki), otherwise known as BIP270 (or more accurately, BIP270 through to BIP274).\n\nThe Simplified Payment Protocol spec came our of a wallet workshop event at the start of 2019. It is itself based on the older [BIP70](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) spec with a few simplifications made for developers’ sanity.\n\nThe concept is a pretty simple one to grasp:\n\n1. When an app wants a user to pay for something, it creates a “payment request” and presents a URL to the user which they enter in to their wallet - usually via a QR code.\n2. The wallet loads the payment request from the URL and presents the details to the user for confirmation.\n3. Once confirmed, the wallet sends a “payment” object, complete with raw transaction directly back to the host application.\n4. The app responds to confirm it received the transaction. Both parties are then free to broadcast the transaction as soon as they want.\n\n![BIP270 Protocol Sequence](https://data.bitpost.app/file/26cac0890e6e185e50a937cee2b101768942b1d516191d6dc4db1842fb7471ad)\n\nThe specification is a reasonable one. It’s easy enough to read, although does have the slight whiff of “design by standards committee” to it. But because all BSV’s P2P protocols follow this same basic flow, once you’ve grokked BIP270 you are well on your way to mastering P2P transactions. Kind of.\n\n### Handcash’s P2P implementation\n\nOne of the first wallets to announce support of BIP270 was Handcash. They’ve written some [great dev docs which you can read here](https://handcash.github.io/handcash-merchant-integration/). In implementing the spec, it’s fair to say they’ve gone “off piste” slightly.\n\nThings they’ve changed:\n\n* Uses JSON content types instead of the unfamiliar `bitcoin/*` content types that are introduced in BIP271. This is a relatively non-problematic change to be honest - but one to be aware of in case your service is strict about content types.\n* Repurposes the `merchantData` attribute as a means to give the wallet the name and logo of the merchant, instead of a way of passing any arbitrary data between merchant and wallet. It’s nice for the wallet to show a logo of the merchant, but this will be a problem if you actually intended to use the `merchantData` attribute for its intended purpose.\n* Introduces a new URL format that is different from the BIP272 URL format. I don’t really understand why they’ve done this. If the aim of a standard is to create a single experience that users can benefit from no-matter what wallet they use, then to introduce a different URL that requires a different QR code seems backwards. Thankfully other BIP270-supporting wallets seem to be following Handcash’s lead, so if you want maximum compatibility with a single QR code, the Handcash URL format is the way to go.\n\n## Paymail P2P capabilities\n\nPaymail has its own P2P BRFC specifications. There are two relevant specs to read through:\n\n* [P2P Payment Desination](https://docs.moneybutton.com/docs/paymail-07-p2p-payment-destination.html)\n* [P2P Transactions](https://docs.moneybutton.com/docs/paymail-06-p2p-transactions.html)\n\nBecause Paymail involves resolving email-like addresses to Bitcoin addresses and depends on DNS, it’s a fundamentally different approach so it’s understandable that we need a different spec.\n\nI like the Paymail P2P specs. They are well written, easy to work with, and are flexible enough to allow most of the same core functionality that can be delivered through BIP270. In my testing, the Paymail wallets that have implemented the P2P specs have all done so consistently and so it works well and reliably across the board.\n\n## Open Payment Protocol\n\nThe [Open Payment Protocol](https://v.maxthon.com/doc/#/opp) was created by the folks building the Maxthon browser and is used by their built-in wallet, VBox. It has also been implemented by both [Volt](https://volt.id/) and [DotWallet](https://www.dotwallet.com/) which makes this a protocol well worth paying attention to.\n\nThe OPP specs describe it as an “extension to BIP270”. In addition to BIP270’s features, it allows apps to specify which UTXOs should be spent in a transaction, and also provides a way to let wallets sign arbitrary bits of data. Both pretty interesting and useful features.\n\nHowever, whilst OPP follows the same basic flow of BIP270, it’s actually very different. The JSON objects that are sent as messages are entirely different and the way of encoding a URL in a QR code is different.\n\nAs an English speaker, I found the spec a little tricky to follow. There’s a few ambiguities that have crept in through translation. I also found some discrepancies between the VBox and Volt implementations that required some hacky server-side jiggery-pokery to ensure OPP “just works” across both wallets. I unfortunately haven’t been able to get it to work in DotWallet at all yet.\n\n## Conclusions\n\nSo there we have it - three P2P specs each claiming to be the [greatest and most flexible](https://twitter.com/apagut/status/1321891870226743296) standards. And we might as well call it four as we effectively have vanilla BIP270 vs Handcash flavoured BIP270.\n\nI’m not sure the user wins in this situation, but for now I’m glad we at least have competing standards. It’s probably true that the people trying new things and innovating the most are not necessarily those sat in technical standards committees, so to that end I’m sympathetic to Handcash making a few changes and Maxthon doing their own thing entirely.\n\nMaxthon’s OPP brings some novel and potentially very useful concepts to the table but I wish it could have been built on top of the standard BIP270 JSON objects and URLs, instead of rewriting everything.\n\nIf studying the Web tells us anything, it’s that users will demand standards and so it will be in wallet ecosystem’s interest to naturally revolve around one solid standard. My money is on BIP270, but it will take time to get there and we’re early enough in all of this to allow a bit of enthusiastic experimentation along the way.",
  "opts": {
    "enc": "0",
    "pub": "1",
    "tip": "1"
  },
  "signatures": {
    "child": {
      "hash": "c27ff64262409dc082581f9c37ee68cbcfba2feebf76c0029ba8bc9f5af2cc89",
      "pubkey": "1Ay13PogvqiYWfdpGomeszNvB4kwSsi64i",
      "signature": "IHZZlHgrNvyU/mC2Fa97PxrtCyySoY5Jvy4QZ27Yzfmscw6soJHOpLjy3EsQEB5ODPh6DFM5mEW5ko/2086nijk=",
      "timestamp": 1604419496,
      "verified": true
    },
    "parent": {
      "hash": "9468df17e0612ca0e3daeb2d9fe385975e0883d467794fdea8c60e16d7b90920",
      "pubkey": "17L6WChSmwEtfHGxnSKDTE5Htzm9tq8isF",
      "signature": "H4eDc8dLXc7eQN3OqTZdKfmYeNKRQIS0soH8/qR7xAw3QG0tPOHgu1PSa8zIyax6OX3h7QPjOP20Rd5j9n96E68=",
      "timestamp": 1604419496,
      "verified": true
    }
  },
  "title": "Demystifying BSV’s peer-to-peer transaction protocols",
  "type": "text/markdown"
}