Skip to content

Documentation

akscanb edited this page Jul 3, 2017 · 8 revisions

Running bitcoind

First download the binaries that correspond to your system https://bitcoin.org/en/download Download the tar.gz and unpackage it. Next navigate to the unpackaged folder from the terminal and cd in to the bin folder located inside. Inside we will have the binaries necessary to run the server which is done by running ./bitcoind in the bin folder.

For testing I suggest not using mainnet and instead use regtest or testnet, so you don't download the entire blockchain to just run the rpc server, so if you run bitcoind once a data file be generated to see where your data directory is located check here https://en.bitcoin.it/wiki/Data_directory . Then you can delete all the contents and add a bitcoin.conf file with the following configurations
regtest=1
rpcuser=user
rpcpassword=pass
rpcport=8332
Then you can simply run bitcoind, and all the configurations will be set correctly by default. Then run bitcoin-cli getnewaddress in another terminal to get a bitcoin address.

Trying the Demo

A demonstration of signing is inside the src/Shared folder in the repo under bitcoin.js. You can comment and uncomment the blocks of code to test it, but to do so make sure you have bitcoind running with at least one public address which you can generate using bitcoin-cli. Then make sure to copy over the address in to the address section and run $node bitcoin.js in the terminal. It should modify the payload.json file by adding the signatures associated with each payload, or the code will spit out a signed version of a pdf file depending on what part of the code is commented. Overall, what it should do is generate buffers for each payload or pdf and turn that in to a sha256 hash which is then signed. So, for verification what should happen is that the person responsible should hash the payload verify that the hashes match then check to see if the signature is correct based on the public address associated with the signature.

Setting up the Client software

To set up the client software first pull the repository, and run npm install. All the associated libraries should be already included in the package.json, but if it is not simply run npm install on the missing packages. Then next we need to set up nginx. Which will proxy the hosting of the web client and bitcoind rpc server through one port, so we do not get a CORS issue. It should be easy as installing nginx and running it with the configurations that is in nginx.conf. You can nginx with homebrew on osX or the standard package manager in linux. Then look up where the configuration folder is for nginx on your respective systems and copy over the contents from nginx.conf, and restart nginx.

Now we are ready to run the app with npm start. However, the port it will be on 3000, but because in the nginx configuration we proxied everything in to port 8080 you should open up localhost:8080 on your browser instead. Realize running it on port 3000 will not work. Furthermore, make sure that you change the configurations for the bitcoin client connection in both claim.js and document.js. So, be sure to change the public address to the public address that exists on your machine, and also the rpc user and pass in accordance with what you have pre-configured in the bitcoin.conf. If all the things are in order you should be able to navigate to a document and click sign and eventually have an alert window pop up that gives you the address you used to sign with, a hashed payload, and a signature. If the signature is undefined or if it is blank then there is something wrong with the setup. Also, be aware if you have something running on port 8080 that conflicts with what you have configured in nginx you can change the configuration in nginx to a different unused port.

Clone this wiki locally