Strike bugfix (#122)

This commit is contained in:
Fabio Cigliano 2018-06-13 01:11:53 +12:00 committed by Josh Harvey
parent bce177c63c
commit 25030fab2a
4 changed files with 33 additions and 8 deletions

View file

@ -160,7 +160,13 @@ cat <<EOF > $CONFIG_DIR/lamassu.json
"lamassuServerPath": "$NODE_MODULES/lamassu-server",
"migrateStatePath": "$MIGRATE_STATE_PATH",
"blockchainDir": "$BLOCKCHAIN_DIR",
"ofacDataDir": "$OFAC_DATA_DIR"
"ofacDataDir": "$OFAC_DATA_DIR",
"strike": {
"baseUrl": "https://api.strike.acinq.co/api/"
},
"coinAtmRadar": {
"url": "https://coinatmradar.info/api/lamassu/"
}
}
EOF

View file

@ -9,7 +9,10 @@ module.exports = {
cryptoNetwork
}
axios.defaults.baseURL = options.strike.baseUrl
axios.defaults.baseURL = _.get('strike.baseUrl', options)
if (_.isEmpty(axios.defaults.baseURL)) {
throw new Error('Missing Strike baseUrl!')
}
function cryptoNetwork (account, cryptoCode) {
return Promise.resolve('test')
@ -34,11 +37,18 @@ function createCharge (account, info) {
currency: 'btc',
description: 'Lamassu cryptomat cash-out'
}
const token = _.get('token', account)
if (_.isEmpty(token)) {
return Promise.reject(new Error('Missing Strike account token!'))
}
return axios({
method: 'post',
url: 'v1/charges',
auth: {username: account.token, password: ''},
auth: {
username: token,
password: ''
},
data
}).then(_.get('data'))
}
@ -46,7 +56,6 @@ function createCharge (account, info) {
function newAddress (account, info) {
return checkCryptoCode(info.cryptoCode)
.then(() => createCharge(account, info))
.then(_.tap(console.log))
.then(r => `strike:${r.id}:${r.payment_hash}:${r.payment_request}`)
}

16
package-lock.json generated
View file

@ -1186,6 +1186,11 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE="
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
}
}
},
@ -1219,6 +1224,11 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE="
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
}
}
},
@ -5705,9 +5715,9 @@
}
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
"version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
},
"lodash.clonedeep": {
"version": "4.5.0",

View file

@ -31,7 +31,7 @@
"inquirer": "^5.2.0",
"kraken-api": "github:DeX3/npm-kraken-api",
"lnd-async": "^1.2.0",
"lodash": "^4.17.2",
"lodash": "^4.17.10",
"longjohn": "^0.2.12",
"make-dir": "^1.0.0",
"mem": "^1.1.0",