Scripts for Batch Signing Multisig Transactions - For Vendors

We developed some scripts for our vendors to help sign multisig transactions via a CLI. It won't be worth it for small vendors who only have a handful of orders to sign, but for those who do some serious selling, it could be a huge time saver. Because Coinb.in seems to be well regarded and trusted, we leverage Coinb.in to do the actual signing. We wrote some shell scripts to prepare some input and wrote a separate index2.html page that calls the "sign" function on Coinb.in. While it is more tightly integrated with Sourcery because we generate the properly formatted input file, these scripts could easily be tweaked to accomodate how you get your transactions. What this does is save teh vendor time because they no longer have to cut and paste between Coinb.in, get the signed result, and broadcast it. We wanted to share with the community to promote Multisig and enable vendors to use it efficiently. From the vendors we spoke with, the extra time it takes is a bummer, compared to central escrow. We want to make multisig as easy as it can be and minimize the burden to vendors.

There is a one time setup that needs to be completed. We have complete steps at http://sourcel3zg2kzu4k.onion/open-source.php.

The short steps to set up:

  1. Download Coinb.in locally

  2. There is one part that needs to be altered that seems to break, it deals with entropy - so do NOT use this installation of Coinb.in to generate keys!!! Only use it for this. The code fragment needed to be removed is on the market.

  3. Download the shell script for preparing the input to Coinb.in for batch signing

  4. For ease of use, we use jq. All this does is basically an easy "grep" for getting the private key from the output of Electrum. The script could be updated easily to use awk/grep to pull this. On linux flavors, apt-get install jq.

The short steps to batch sign transactions

  1. On Sourcery, we have an option that gives vendors a plain text output of all of their finalized contracts (we'll be supporting pre-signing soon as well). Vendor clicks on "View as File" and then copies and pastes the output from the browser into a new file locally. The file format is quite simple - one line is the Bitcoin address used in the multisig transaction (the vendor's). The next line is the signed transaction withdrawing coin from the multisig. This repeats for however many finalized contracts you have. Someone outside of Sourcery wanting to use these scripts can either put in this format or alter the prepare-input.sh script to accomodate whatever format they want to use.

  2. This script from Step 1 basically takes the address in the file, queries electrum

  3. run prepare-input.sh. It takes a few parameters described on the market. This script basically takes the file from step 1 and generates a new file - its a JavaScript file that contains two arrays - one array are your private keys and the other array is the signed transaction from the market.

  4. Now, go to your browser (enable JS, just like Coinb.in requires). Go to where you installed Coinb.in locally for this, and open index2.html.

  5. index2.html will output, one per line, all of your signed transactions.

  6. On Sourcery, vendors can past all of these transactions and we'll broadcast for you. Alternatively, you can broadcast these via the usual method you use. Another script could be further built to go through each tx and call electrum broadcast -.

We'd love to hear feedback. I know the setup is a bit clunky. We didn't want to use new libraries that vendors weren't comfortable with. Vendors seem to be comfortable with running Coinb.in and hence, we decided to write a wrapper around it to use a batch signing library. Please feel free to use and we hope you find this helpful!

Check out http://sourcel3zg2kzu4k.onion/open-source.php for details instructions and the actual script.

NOTE: One PITA aspect is the password for electrum. If the wallet doesn't have a password, then it does go through quickly, but if your wallet has a password, then you'll need to paste it in when prompted - which will be for every transaction. We will work further on pushing the password through to Electrum and letting it be a CLI arg. But this version doesn't have that. We'll try to update this as we can to better it.


Comments


[4 Points] DooshNozzzle:

Sometimes I feel like everyone here has studied CS except me lol. Just confirming my belief that dnm users are all druggie nerds. I love it!


[1 Points] None:

[deleted]


[1 Points] throwaways_9001:

You can already do batch sign/withdrawal on Hansa, how does this save time, especially with the electrum issue?

Like copy/paste, press button, copy/paste, press button. Done.

Not trying to cut it down because its awesome that you are releasing things like this into the world.


[1 Points] DooshNozzzle:

Curious why you didn't post the .onion address for coinb?

http://4zpinp6gdkjfplhk.onion/#sign