47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const path = require('path')
|
|
|
|
const { utils: coinUtils } = require('lamassu-coins')
|
|
|
|
const common = require('./common')
|
|
|
|
module.exports = { setup, updateCore }
|
|
|
|
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
|
|
|
function setup (dataDir) {
|
|
common.firewall([coinRec.defaultPort])
|
|
const config = buildConfig()
|
|
common.writeFile(path.resolve(dataDir, coinRec.configFile), config)
|
|
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
|
common.writeSupervisorConfig(coinRec, cmd)
|
|
}
|
|
|
|
function updateCore (coinRec) {
|
|
common.logger.info('Updating Bitcoin Core. This may take a minute.')
|
|
common.es(`supervisorctl stop bitcoin`)
|
|
common.es(`curl -#o /tmp/bitcoin.tar.gz ${coinRec.url}`)
|
|
common.es(`tar -xzf /tmp/bitcoin.tar.gz -C /tmp/`)
|
|
|
|
common.logger.info('Updating wallet...')
|
|
common.es(`cp /tmp/${coinRec.dir}/* /usr/local/bin/`)
|
|
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
|
|
common.es(`rm /tmp/bitcoin.tar.gz`)
|
|
|
|
common.logger.info('Starting wallet...')
|
|
common.es(`supervisorctl start bitcoin`)
|
|
|
|
common.logger.info('Bitcoin Core is updated!')
|
|
}
|
|
|
|
function buildConfig () {
|
|
return `rpcuser=lamassuserver
|
|
rpcpassword=${common.randomPass()}
|
|
dbcache=500
|
|
server=1
|
|
connections=40
|
|
keypool=10000
|
|
prune=4000
|
|
daemon=0
|
|
addresstype=p2sh-segwit
|
|
walletrbf=1`
|
|
}
|