UNPKG

ilp-plugin-xrp-paychan

Version:

Uses payment channels on ripple to do fast ILP transactions between you and a peer. Current in-flight payments are at risk (your peer can choose not to give you claims for them), but are secured against the ledger as soon as you get a claim.

45 lines (38 loc) 1.07 kB
'use strict' const _ = require('lodash') const fs = require('fs') const path = require('path') function getUserHomePath () { return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE } function loadWallet () { const secretPath = path.join(getUserHomePath(), '.ripple_wallet') try { const walletRaw = fs.readFileSync(secretPath, {encoding: 'utf8'}).trim() return JSON.parse(walletRaw) } catch (e) { return null } } const WALLET = loadWallet() function getTestKey (key) { if (process.env.TEST_ADDRESS && process.env.TEST_SECRET) { if (key === 'address') { return process.env.TEST_ADDRESS } if (key === 'secret') { return process.env.TEST_SECRET } } if (WALLET === null) { throw new Error('Could not find .ripple_wallet file in home directory') } if (WALLET.test === undefined) { throw new Error('Wallet does not contain a "test" account') } return WALLET.test[key] } module.exports = { getAddress: _.partial(getTestKey, 'address'), getSecret: _.partial(getTestKey, 'secret') }