Victor Gonzalez from CoinFabrik forked the Copay project and modified the code to facilitate the creation of online wallet services. Currently, the Copay project handles your wallet on your browser, desktop, and mobile devices but not on a Copay server. The new Bitcore Wallet Service does store your wallets on a server, but they are not live: a wallet and the balance it contains are only updated when you use the Bitcore Wallet Client.
Both Bitcore Wallet Service and Copay establish a connection to the Insight server to send and receive information to the blockchain each time a wallet is opened. The key limitation for running multiple wallets on a Copay server is the number of connections to the Insight server. We modified the Copay project code to receive blockchain updates for all the addresses in the different wallets through a single connection to the insight server. Currently, this only works for 1-1 wallets.
We are planning to include multi-signature wallets soon. We will modify the code so that copayers who use online bitcoin wallets also communicate with one another via a single connection shared amongst Insight mailboxes.
Code
The code is available at github.
Prerequisites
MongoDB: This code assumes that mongodb is on localhost. Change this line if you need to point to another host.
Installation
$ git clone https://github.com/CoinFabrik/copay.git
$ cd copay
$ git checkout tags/online-bitcoin-wallets-0.0.1
$ npm install
$ node example.js
Playing with Wallets
The program will prompt the user for an e-mail and password, used for encrypting wallets, and then it will create ten 1-1 wallets.
The program runs a REPL to allow the user to issue commands and query information. For example:
> var wallet = convenience.getAnyWallet()
> wallet.getAddresses()[0]
The above code will print one of the new wallet’s addresses. The user may send some bitcoins to this address.
To spend the bitcoins in the wallet, the user may enter the following command:
> convenience.spend(wallet, <destinationAddress>, <amountInSatoshis>)
To get the balance of the wallet:
> convenience.getBalance(wallet)
Notes
- MongoDB is used to store both the user’s identity and the wallet. The code can easily be modified to use another database. Additionally, add authentication and encryption to secure the connection between Copay and the database.
- It is important to note that the bitcoin community is divided on using online wallet services instead of a decentralized wallet since decentralization is at the heart of bitcoin, and online services pose greater security risks.
- As is the case with any software which will be used to handle other people’s money, a security professional should review any product you develop based on our code.
Resources
- Announcing the Bitcore Wallet Suite