import { execSync } from 'child_process'

// Returns one of: off, installed, enabled, running, synced, error
export function bitcoinStatus() {
  try {
    const stdout = execSync('source ~/Alchemy/ingredients/lead && source ~/Alchemy/ingredients/gold && bitcoin_is_synced')
    const isSynced = stdout.includes('Bitcoin is synced!')
    if(isSynced) return 'synced'
    else if(stdout.includes('error')) return 'error' 
  } catch(err) {
    return 'error'
  }
  return 'off'
}

export default {
  name: 'Bitcoin',
  description: 'payments',
  status: bitcoinStatus
}