-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'packages/bitcore-wallet-client/' from commit '1b2223febd442e1908…
…596bf220b6b3e9d7c77068' git-subtree-dir: packages/bitcore-wallet-client git-subtree-mainline: 0c3a17f git-subtree-split: 1b2223f
- Loading branch information
Showing
34 changed files
with
17,887 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
repo_token: JrJM1SMeS0mtVEmRlgijo9LiovuFjVlLX | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
; .editorconfig | ||
|
||
root = true | ||
|
||
[**.js] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[**.css] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[**.html] | ||
indent_style = space | ||
indent_size = 2 | ||
max_char = 78 | ||
brace_style = expand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Logs | ||
logs | ||
*.log | ||
*.sw* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Commenting this out is preferred by some people, see | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- | ||
node_modules | ||
|
||
# Users Environment Variables | ||
.lock-wscript | ||
|
||
*.swp | ||
out/ | ||
db/* | ||
|
||
docs | ||
|
||
# VIM ignore | ||
[._]*.s[a-w][a-z] | ||
[._]s[a-w][a-z] | ||
*.un~ | ||
Session.vim | ||
.netrwhist | ||
*~ | ||
|
||
# OSX | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- '8' | ||
install: | ||
- npm install | ||
after_success: | ||
- npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = function(grunt) { | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json') | ||
}); | ||
|
||
// Default task(s). | ||
grunt.registerTask('default', []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2015 BitPay | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: cover | ||
|
||
BIN_PATH:=node_modules/.bin/ | ||
|
||
all: bitcore-wallet-client.min.js | ||
|
||
clean: | ||
rm bitcore-wallet-client.js | ||
rm bitcore-wallet-client.min.js | ||
|
||
bitcore-wallet-client.js: index.js lib/*.js | ||
${BIN_PATH}browserify $< > $@ | ||
|
||
bitcore-wallet-client.min.js: bitcore-wallet-client.js | ||
uglify -s $< -o $@ | ||
|
||
cover: | ||
./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# bitcore-wallet-client | ||
|
||
[![NPM Package](https://img.shields.io/npm/v/bitcore-wallet-client.svg?style=flat-square)](https://www.npmjs.org/package/bitcore-wallet-client) | ||
[![Build Status](https://img.shields.io/travis/bitpay/bitcore-wallet-client.svg?branch=master&style=flat-square)](https://travis-ci.org/bitpay/bitcore-wallet-client) | ||
[![Coverage Status](https://coveralls.io/repos/bitpay/bitcore-wallet-client/badge.svg)](https://coveralls.io/r/bitpay/bitcore-wallet-client) | ||
|
||
The *official* client library for [bitcore-wallet-service] (https://github.com/bitpay/bitcore-wallet-service). | ||
|
||
## Description | ||
|
||
This package communicates with BWS [Bitcore wallet service](https://github.com/bitpay/bitcore-wallet-service) using the REST API. All REST endpoints are wrapped as simple async methods. All relevant responses from BWS are checked independently by the peers, thus the importance of using this library when talking to a third party BWS instance. | ||
|
||
See [Bitcore-wallet] (https://github.com/bitpay/bitcore-wallet) for a simple CLI wallet implementation that relays on BWS and uses bitcore-wallet-client. | ||
|
||
## Get Started | ||
|
||
You can start using bitcore-wallet-client in any of these two ways: | ||
|
||
* via [Bower](http://bower.io/): by running `bower install bitcore-wallet-client` from your console | ||
* or via [NPM](https://www.npmjs.com/package/bitcore-wallet-client): by running `npm install bitcore-wallet-client` from your console. | ||
|
||
## Example | ||
|
||
Start your own local [Bitcore wallet service](https://github.com/bitpay/bitcore-wallet-service) instance. In this example we assume you have `bitcore-wallet-service` running on your `localhost:3232`. | ||
|
||
Then create two files `irene.js` and `tomas.js` with the content below: | ||
|
||
**irene.js** | ||
|
||
``` javascript | ||
var Client = require('bitcore-wallet-client'); | ||
|
||
|
||
var fs = require('fs'); | ||
var BWS_INSTANCE_URL = 'https://bws.bitpay.com/bws/api' | ||
|
||
var client = new Client({ | ||
baseUrl: BWS_INSTANCE_URL, | ||
verbose: false, | ||
}); | ||
|
||
client.createWallet("My Wallet", "Irene", 2, 2, {network: 'testnet'}, function(err, secret) { | ||
if (err) { | ||
console.log('error: ',err); | ||
return | ||
}; | ||
// Handle err | ||
console.log('Wallet Created. Share this secret with your copayers: ' + secret); | ||
fs.writeFileSync('irene.dat', client.export()); | ||
}); | ||
``` | ||
|
||
**tomas.js** | ||
|
||
``` javascript | ||
|
||
var Client = require('bitcore-wallet-client'); | ||
|
||
|
||
var fs = require('fs'); | ||
var BWS_INSTANCE_URL = 'https://bws.bitpay.com/bws/api' | ||
|
||
var secret = process.argv[2]; | ||
if (!secret) { | ||
console.log('./tomas.js <Secret>') | ||
|
||
process.exit(0); | ||
} | ||
|
||
var client = new Client({ | ||
baseUrl: BWS_INSTANCE_URL, | ||
verbose: false, | ||
}); | ||
|
||
client.joinWallet(secret, "Tomas", {}, function(err, wallet) { | ||
if (err) { | ||
console.log('error: ', err); | ||
return | ||
}; | ||
|
||
console.log('Joined ' + wallet.name + '!'); | ||
fs.writeFileSync('tomas.dat', client.export()); | ||
|
||
|
||
client.openWallet(function(err, ret) { | ||
if (err) { | ||
console.log('error: ', err); | ||
return | ||
}; | ||
console.log('\n\n** Wallet Info', ret); //TODO | ||
|
||
console.log('\n\nCreating first address:', ret); //TODO | ||
if (ret.wallet.status == 'complete') { | ||
client.createAddress({}, function(err,addr){ | ||
if (err) { | ||
console.log('error: ', err); | ||
return; | ||
}; | ||
|
||
console.log('\nReturn:', addr) | ||
}); | ||
} | ||
}); | ||
}); | ||
``` | ||
|
||
Install `bitcore-wallet-client` before start: | ||
|
||
``` | ||
npm i bitcore-wallet-client | ||
``` | ||
|
||
Create a new wallet with the first script: | ||
|
||
``` | ||
$ node irene.js | ||
info Generating new keys | ||
Wallet Created. Share this secret with your copayers: JbTDjtUkvWS4c3mgAtJf4zKyRGzdQzZacfx2S7gRqPLcbeAWaSDEnazFJF6mKbzBvY1ZRwZCbvT | ||
``` | ||
|
||
Join to this wallet with generated secret: | ||
|
||
``` | ||
$ node tomas.js JbTDjtUkvWS4c3mgAtJf4zKyRGzdQzZacfx2S7gRqPLcbeAWaSDEnazFJF6mKbzBvY1ZRwZCbvT | ||
Joined My Wallet! | ||
Wallet Info: [...] | ||
Creating first address: | ||
Return: [...] | ||
``` | ||
|
||
Note that the scripts created two files named `irene.dat` and `tomas.dat`. With these files you can get status, generate addresses, create proposals, sign transactions, etc. | ||
|
||
|
Oops, something went wrong.