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 multi-sig, 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 multi-sig 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 workflow for using custom Script.

Let’s take a quick look at the steps required to use a non-standard Script in the context of a legally binding contract:

  1. Write a script template to achieve your desired goals,
  2. Coordinate with the parties involved to gather their pubKeys or other needed information,
  3. Build the final hex for the script template, compute the hash160 and the P2SH address from the redeem script pre-image,
  4. Store the redeem script somewhere safe (if the script details are forgotten the funds will be lost),
  5. Obtain agreement from the parties involved that they agree with the P2SH address (assuming they double check your work somehow),
  6. Communicate the final redeem script and address with the involved parties,
  7. Have some funds sent to the final address
  8. Spend the funds sometime in the future using the redeem script

If you followed me through that list please give yourself a pat on the back; that’s a lot of steps.  Typically, no one does these things manually.  Instead, some custom software is built to handle the specific custom script at hand.  This process is extremely inefficient.

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.

Let’s review the basic components of P2SH.cash.

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):

P2SH Calculator

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. (https://gist.github.com/jcramer/6453fa012fa6ddba2ed9035b5b3f4062).

The P2SH Spend Assistant

The “Spend P2SH” tab provides an assistant to make it as easy as possible to spend the balance located at an address.   The process for spending from a P2SH address involves following a series of steps to build an unlocking script that will satisfy the constraints of the locking script.

Summary

In this post, we provided an introduction to P2SH.cash system.  The system provides the following key components:

  • JSON schema for a Bitcoin Script Template (BST) bst.schema.json,
  • GUI for calculating P2SH addresses,
  • GUI for spending balances at P2SH addresses,
  • GUI for a for writing and validating new BST documents

The License

The system is open source. This includes the BST 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.