Skip to content

Commit

Permalink
Merge branch 'wallet-v3.32'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thore3 committed Jun 6, 2017
2 parents fa20885 + 54f0b82 commit 20b4618
Show file tree
Hide file tree
Showing 12 changed files with 3,653 additions and 274 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ $ npm update -g blockchain-wallet-service

Requires:

* node >= 0.12.0
* npm >= 2.12.0, < 3.0.0
* node >= 6.0.0
* npm >= 3.0.0

If you have issues with the installation process, see the troubleshooting section below.

Expand All @@ -378,6 +378,8 @@ Installation errors:

* If you are getting `EACCESS` or permissions-related errors, it might be necessary to run the install as root, using the `sudo` command.

* If you are getting errors concerning node-gyp or python, install with `npm install --no-optional`

Startup errors:

* If startup fails with `/usr/bin/env: node: No such file or directory`, it's possible node is not installed, or was installed with a different name (Ubuntu, for example, installs node as nodejs). If node was installed with a different name, create a symlink to your node binary: `sudo ln -s /usr/bin/nodejs /usr/bin/node`, or install node through [Node Version Manager](https://github.com/creationix/nvm).
Expand Down Expand Up @@ -447,8 +449,8 @@ $ blockchain-wallet-service start --port 3000
## Development

1. Clone this repo
2. Run `npm install`
3. Run `npm start`
2. Run `yarn --ignore-engines`
3. Run `yarn start`
4. Dev server is now running on port 3000

If you are developing `blockchain-wallet-client` alongside this module, it is useful to create a symlink to `my-wallet-v3`:
Expand All @@ -460,7 +462,7 @@ $ ln -s ../path/to/my-wallet-v3 node_modules/blockchain-wallet-client
### Testing

```sh
$ npm test
$ yarn test
```

### Configuration
Expand Down
27 changes: 19 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.25.2",
"description": "Blockchain.info wallet api service",
"main": "index.js",
"preferGlobal": true,
"repository": {
"type": "git",
"url": "git://github.com/blockchain/service-my-wallet-v3.git"
Expand All @@ -14,8 +15,8 @@
"blockchain-wallet-service": "./bin/cli.js"
},
"engines": {
"node": ">= 0.12.0",
"npm": ">= 2.11.0"
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"scripts": {
"start": "node_modules/nodemon/bin/nodemon.js scripts/start.js",
Expand All @@ -25,11 +26,21 @@
"lint": "node_modules/.bin/standard src/*.js"
},
"author": "Justin Tormey <[email protected]>",
"standard": {
"global": [
"describe",
"it",
"before",
"beforeEach",
"after",
"afterEach"
]
},
"dependencies": {
"basic-auth": "~1.0.3",
"bip39": "~2.3.1",
"bitcoinjs-lib": "~2.2.0",
"blockchain-wallet-client-prebuilt": "3.22.*",
"blockchain-wallet-client": "3.32.4",
"blockchain.info": "~2.2.2",
"body-parser": "~1.14.1",
"colors": "~1.1.2",
Expand All @@ -39,19 +50,19 @@
"q": "~1.4.1",
"ramda": "~0.23.0",
"registry-url": "~3.1.0",
"request-promise": "^2.0.1",
"request-promise": "~2.0.1",
"semver": "~5.3.0",
"unicode-length": "~2.0.0",
"winston": "^2.2.0"
"winston": "~2.2.0"
},
"devDependencies": {
"chai": "~3.4.1",
"chai-as-promised": "^5.2.0",
"chai-as-promised": "~5.2.0",
"mocha": "~2.3.4",
"node-env-file": "~0.1.8",
"nodemon": "~1.8.1",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"sinon": "~1.17.3",
"sinon-chai": "~2.8.0",
"standard": "~8.6.0"
}
}
9 changes: 1 addition & 8 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ MerchantAPI.prototype.makePayment = function (guid, options) {
var warning
if (!isNaN(options.fee_per_byte)) {
if (options.fee_per_byte < 50) warning = warnings.LOW_FEE_PER_BYTE
payment.then(function (paymentObject) {
paymentObject.feePerKb = feePerByteToFeePerKb(options.fee_per_byte)
return paymentObject
}).prebuild()
payment.updateFeePerKb(options.fee_per_byte)
} else if (!isNaN(options.fee)) {
warning = warnings.STATIC_FEE_AMOUNT
payment.fee(options.fee)
Expand Down Expand Up @@ -310,7 +307,3 @@ function add (total, next) {
function satoshiToBTC (satoshi) {
return parseFloat((satoshi / SATOSHI_PER_BTC).toFixed(8))
}

function feePerByteToFeePerKb (feePerByte) {
return Math.floor(feePerByte * 1000)
}
9 changes: 5 additions & 4 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ var warnings = require('./warnings')

overrides.clearModuleRequireCache()

var Blockchain = require('blockchain-wallet-client-prebuilt')
var Address = require('blockchain-wallet-client-prebuilt/src/address')
var WalletNetwork = require('blockchain-wallet-client-prebuilt/src/wallet-network')
var HDWallet = require('blockchain-wallet-client-prebuilt/src/hd-wallet')
var Blockchain = require('blockchain-wallet-client')
var Address = Blockchain.Address
var WalletNetwork = Blockchain.WalletNetwork
var HDWallet = require('blockchain-wallet-client/lib/hd-wallet')

overrides.configureApiUrls(Blockchain.API)
overrides.substituteWithCryptoRNG(Blockchain.RNG)
overrides.disableSyncWallet(Blockchain.MyWallet)

Expand Down
11 changes: 8 additions & 3 deletions src/overrides.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var WS_URL = 'wss://ws.blockchain.info/inv'

var path = require('path')
var winston = require('winston')
var crypto = require('crypto')

Expand All @@ -27,9 +28,13 @@ exports.disableSyncWallet = function (instance) {
}

exports.clearModuleRequireCache = function () {
var walletModule = 'blockchain-wallet-client-prebuilt'
var walletModuleR = new RegExp(walletModule + '.(index|src)')
var walletModule = 'blockchain-wallet-client' + path.sep + 'lib'
Object.keys(require.cache)
.filter(function (m) { return walletModuleR.test(m) })
.filter(function (m) { return m.indexOf(walletModule) > -1 })
.forEach(function (m) { delete require.cache[m] })
}

exports.configureApiUrls = function (api) {
api.ROOT_URL = process.env.ROOT_URL || 'https://blockchain.info/'
api.API_ROOT_URL = process.env.API_ROOT_URL || 'https://api.blockchain.info/'
}
4 changes: 2 additions & 2 deletions src/rpc-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var metrics = require('./metrics')
var request = require('request-promise')
var bitcoin = require('bitcoinjs-lib')
var winston = require('winston')
var helpers = require('blockchain-wallet-client-prebuilt/src/helpers')
var wcrypto = require('blockchain-wallet-client-prebuilt/src/wallet-crypto')
var helpers = require('blockchain-wallet-client/lib/helpers')
var wcrypto = require('blockchain-wallet-client/lib/wallet-crypto')

var apiCode = ''
var secondPasswordStore = new TimedStore()
Expand Down
4 changes: 2 additions & 2 deletions src/wallet-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ WalletCache.prototype.login = function (guid, options) {

instance.API.API_CODE = options.api_code
instance.WalletStore.isLogoutDisabled = function () { return true }
overrides.configureApiUrls(instance.API)
overrides.handleSocketErrors(instance.MyWallet.ws)
overrides.substituteWithCryptoRNG(instance.RNG)

Expand Down Expand Up @@ -120,14 +121,13 @@ module.exports = WalletCache

function generateInstance () {
overrides.clearModuleRequireCache()
return require('blockchain-wallet-client-prebuilt')
return require('blockchain-wallet-client')
}

function walletFromInstance (maybePw, instance) {
if (!(this instanceof WalletCache)) throw 'ERR_UNEXPECT'
var w = instance.MyWallet.wallet
if (!validatePassword(this.pwHashStore[w.guid], maybePw)) throw 'ERR_PASSWORD'
w.createPayment = function (p) { return new instance.Payment(p) }

w.waitForSync = function (value) {
winston.debug('Waiting for wallet sync')
Expand Down
Loading

0 comments on commit 20b4618

Please sign in to comment.