Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
@diracdeltas was right
Browse files Browse the repository at this point in the history
  • Loading branch information
mrose17 committed Aug 27, 2016
1 parent 602c84e commit 4c53932
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const session = electron.session

const acorn = require('acorn')
const ledgerBalance = require('ledger-balance')
const ledgerClient = require('ledger-client')
const ledgerPublisher = require('ledger-publisher')
const qr = require('qr-image')
const random = require('random-lib')
Expand Down Expand Up @@ -115,6 +116,9 @@ const doAction = (action) => {
*/
var init = () => {
try {
ledgerInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_INFO_DEBUG)
publisherInfo._internal.debugP = ledgerClient.prototype.boolion(process.env.LEDGER_PUBLISHER_DEBUG)

appDispatcher.register(doAction)
initialize(getSetting(settings.PAYMENTS_ENABLED))
} catch (ex) { console.log('initialization failed: ' + ex.toString() + '\n' + ex.stack) }
Expand All @@ -136,7 +140,7 @@ var boot = () => {
ledgerInfo.creating = true
appActions.updateLedgerInfo({ creating: true })
try {
client = (require('ledger-client'))(null, underscore.extend({ roundtrip: roundtrip }, clientOptions), null)
client = ledgerClient(null, underscore.extend({ roundtrip: roundtrip }, clientOptions), null)
} catch (ex) {
appActions.updateLedgerInfo({})

Expand Down Expand Up @@ -351,7 +355,7 @@ var initialize = (onoff) => {

getStateInfo(state)
try {
client = (require('ledger-client'))(state.personaId,
client = ledgerClient(state.personaId,
underscore.extend(state.options, { roundtrip: roundtrip }, clientOptions), state)
} catch (ex) {
return console.log('ledger client creation error: ' + ex.toString() + '\n' + ex.stack)
Expand Down Expand Up @@ -466,7 +470,7 @@ var updatePublisherInfo = () => {
syncWriter(synopsisPath, synopsis, () => {})
publisherInfo.synopsis = synopsisNormalizer()

if (clientOptions.debugP) {
if (publisherInfo._internal.debugP) {
console.log('\nupdatePublisherInfo: ' + JSON.stringify(underscore.omit(publisherInfo, [ '_internal' ])))
}

Expand Down Expand Up @@ -732,16 +736,14 @@ var updateLedgerInfo = () => {
var info = ledgerInfo._internal.paymentInfo
var now = underscore.now()

if (!client) return

if (info) {
underscore.extend(ledgerInfo,
underscore.pick(info, [ 'address', 'balance', 'unconfirmed', 'satoshis', 'btc', 'amount', 'currency' ]))
if ((!info.buyURLExpires) || (info.buyURLExpires > now)) ledgerInfo.buyURL = info.buyURL
underscore.extend(ledgerInfo, ledgerInfo._internal.cache || {})
}

if (clientOptions.debugP) {
if (ledgerInfo._internal.debugP) {
console.log('\nupdateLedgerInfo: ' + JSON.stringify(underscore.omit(ledgerInfo, [ '_internal' ]), null, 2))
}

Expand Down

0 comments on commit 4c53932

Please sign in to comment.