P2SH.cash: A Brief Introduction and Sneak Preview
Over the last few weeks our team has been working hard on a new serverless web app called P2SH.cash. The original intention of this app was to provide a simple tool for calculating P2SH addresses of commonly used script templates (e.g., p2sh multisig, etc.).
In Bitcoin, the only way to use a custom, non-standard, Script is to utilize a P2SH address, so having a calculator tool can greatly help get everyone in agreement of the proper P2SH address to use.
If you are scratching your head, please consider this: Would you enter into an agreement involving a P2SH multisig address without first being confident that the P2SH address presented was correct? Most likely you would not. This project aims to address the issues of confidence and usability surrounding P2SH type addresses.
After we started building the product we quickly realized the project could accomplish more ambitious goals. By combining the power of Bitcoin Files Protocol (BFP) and Simple Ledger Protocol (SLP) Tokens we are able to build a system that can simplify the entire P2SH workflow.
Before we take a look at the goodies, lets take a quick look at the steps required to use a non-standard Script in the context of a legally binding contract:
- Research previously used scripts for achieving your goals,
- Coordinate with all parties involved to gather their pubKeys and other needed info,
- Build the hex for a locking script (i.e., the pre-image),
- Compute the hash160 and P2SH address from the pre-image,
- Store the pre-image and address somewhere safe (if pre-image info or script template is lost funds will be lost),
- Obtain agreement from all parties involved that they agree with the computed P2SH address,
- Communicate the final pre-image and address with the involved parties,
- Write a traditional paper contract that includes terms around the final address,
- Have some funds sent to the final address,
- Track any funds received at the final address,
- Build the hex for an unlocking script,
- Spend the P2SH output
If you followed me through that list please give yourself a pat on the back. That's a lot of steps.
And this is why we are building P2SH.cash. We are going to introduce features, released in phases over the next couple of months, which can assist in almost all of the steps listed above.
For now, I am going to get back to the basics.
The P2SH Calculator
In the next week or two the P2SH.cash website will go live, here's what the step-by-step workflow will look like (with all sections unhidden):
The screenshot shows our current user interface design for calculating P2SH addresses. You simply choose a script template from a drop down (which may be stored using BFP or loaded locally), select template options, and fill in the blanks required to compute the P2SH address.
The Bitcoin Script Template (BST)
To accomplish the calculator above, we defined a specific JSON schema, called bst.schema.json. Anyone can use this schema to define their own script template.
We also provided a Schema validator and BFP upload tool to assist in this process:
The P2SH Spend Assistant
The P2SH calculator tool works with the locking script section of the bst.schema.json. The spend assistant uses the unlocking scripts which may also be defined in the schema.
The P2SH.cash SLP Token Document and Token Generator
At the bottom of the calculator tool you will notice that we provide a way to send funds to the calculated P2SH address from MoneyButton or other wallets. During this process a checkbox for creating new SLP tokens can be selected. The purpose of these SLP tokens is for sharing the details of the calculated P2SH address with interested parties' wallets.
The SLP token document of these tokens will include references to (1) the BST template URI, and (2) the actual user inputs used to calculate the subject P2SH. The token document can contain multiple P2SH references, so holding a single token may provide you with information about how to spend multiple P2SH addresses.
The purpose of the SLP token is to make the web apps and wallets aware of the P2SH outputs that the user is interested in tracking. This will allow the app or any SLP aware wallet to know all of the data necessary to reconstruct the specific P2SH pre-image, and provide unlocking script options so that the P2SH can be spent by the web app or wallet.
We have defined a JSON schema to be used for the SLP token document which houses both the script template URI reference and the user template inputs for an array of P2SH addresses, it is called p2sh.token.schema.json. The token can then be sent to all involved parties so they have all the information about the P2SH.
Additional details about this system will be explained in a future post once the feature is released.
Summary of the P2SH.cash System
In summary, the P2SH.cash system provides the following key components:
- JSON schema for a Bitcoin Script Template (BST) bst.schema.json,
- GUI for calculating the proper P2SH address from a BST,
- GUI for spending an existing P2SH balance using a BST,
- GUI for a for writing and validating new BST documents,
- GUI and SLP token document JSON schema for communicating the requirements for reconstructing a P2SH pre-image
The system is open source. This includes the BST schema, the SLP token document schema, and everything about the P2SH.cash system. The web app's source code will be closed source, but feel free to reverse engineer the uglified React app script.
Copyright 2018 Simple Ledger, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 of 3 reviewers say it's worth paying for
0 of 3 reviewers say it's not worth paying for