Skip to content

Commit

Permalink
Merge pull request #1 from BCH-Consolidating-CoinJoin/unstable
Browse files Browse the repository at this point in the history
Removing CoinJoin code
  • Loading branch information
christroutner committed Nov 26, 2018
2 parents 611c073 + 403f277 commit cfd3973
Show file tree
Hide file tree
Showing 14 changed files with 2 additions and 1,185 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Consolidating CoinJoin Mirror
This is a [koa api server](https://github.com/christroutner/babel-free-koa2-api-boilerplate), similar to [Consolidating CoinJoin Server](https://github.com/BCH-Consolidating-CoinJoin/ccoinjoin-server), but much more slimmed down. Unlike the server, this app does not engage in any CoinJoin activities. Instead, it mirrors the peer-to-peer database. It's purpose is to help support the network by rebroadcasting the list of network servers. Unlike the server, there should be no legal repercussions to running it.
This is a [koa api server](https://github.com/christroutner/babel-free-koa2-api-boilerplate), similar to [Consolidating CoinJoin Server](https://github.com/BCH-Consolidating-CoinJoin/ccoinjoin-server), but much more slimmed down. Unlike the server, this app does not engage in any CoinJoin activities. Instead, it only mirrors the peer-to-peer database. It's purpose is to help support the network by rebroadcasting the list of network servers. Unlike the server, there should be no (potential) legal repercussions to running it.


[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
Expand All @@ -18,7 +18,7 @@ This is a [koa api server](https://github.com/christroutner/babel-free-koa2-api-
* npm __^5.7.1__

## Installation
Installation is different depending on if you want to create a *development* server for developing the code, or a *production* server for setting up your own Consolidating CoinJoin service.
Installation is different depending on if you want to create a *development* server for developing the code, or a *production* server running as a Docker container.

### Development
- `npm install` to install npm dependencies.
Expand Down
77 changes: 0 additions & 77 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,14 @@ const passport = require('koa-passport')
const mount = require('koa-mount')
const serve = require('koa-static')
const cors = require('kcors')
const cCoinJoinUtils = require('../src/utils/ccoinjoin-utils')

// Winston logger
const wlogger = require('../src/utils/logging')

// Wallet functionality
const CreateWallet = require('ccoinjoin-wallet/src/commands/create-wallet')
const UpdateBalance = require('ccoinjoin-wallet/src/commands/update-balances')

const config = require('../config')
const errorMiddleware = require('../src/middleware')

let torUtil, p2pdb
if (config.env !== 'test') {
torUtil = require('../src/utils/tor')
p2pdb = require('../src/utils/orbitdb')
}

// SERVER CONFIGURATION
const CHECK_BALANCE_PERIOD = 1000 * 60 * 2 // 2 minutes
process.env.FILENAME = `${__dirname}/../wallets/wallet.json`
process.env.ACTIVE_WALLET = `${__dirname}/../wallets/active-wallet.json`
process.env.THRESHOLD = 0.1 // for triggering a CoinJoin round.

// Determine the network. Testnet by default.
if (!process.env.NETWORK) process.env.NETWORK = `testnet`
const NETWORK = process.env.NETWORK

// Instantiate BITBOX
const BB = require('bitbox-sdk/lib/bitbox-sdk').default
let BITBOX
if (NETWORK === 'testnet') {
BITBOX = new BB({ restURL: 'https://trest.bitcoin.com/v1/' })
} else BITBOX = new BB({ restURL: 'https://rest.bitcoin.com/v1/' })

// Set the standarized BCH output of the CoinJoin
process.env.COINJOINOUT = 0.01

// Set the CoinJoin round.
if (!process.env.ROUND) process.env.ROUND = 0

let torInterval
const TOR_PERIOD = 1000 * 60 // 1 minute

async function startServer () {
// Create a new wallet.
const createWallet = new CreateWallet()
const filename = `${__dirname}/../wallets/wallet.json`
let walletInfo
if (NETWORK === `testnet`) {
walletInfo = await createWallet.createWallet(filename, BITBOX, true)
} else {
walletInfo = await createWallet.createWallet(filename, BITBOX, false)
}

// Create a Koa instance.
const app = new Koa()
app.keys = [config.session]
Expand Down Expand Up @@ -113,17 +66,6 @@ async function startServer () {
console.log(`Server started on ${config.port}`)
wlogger.info(`Server started on ${config.port}`)

// Periodically check the balance of server's wallet
setInterval(function () {
const updateBalance = new UpdateBalance()
cCoinJoinUtils.checkBalance(BITBOX, updateBalance)
}, CHECK_BALANCE_PERIOD)

// Periodically attempt to retrieve the tor .onion hostname.
torInterval = setInterval(function () {
getTorHostname()
}, TOR_PERIOD)

return app
}
// startServer()
Expand All @@ -133,22 +75,3 @@ async function startServer () {
module.exports = {
startServer
}

// Called periodically to attempt to get the tor hostname.
async function getTorHostname () {
let hostname = false

const env = process.env.COINJOIN_ENV || 'development'

if (env !== 'production') {
hostname = `test${Math.floor(Math.random() * 1000).toString()}.onion`
} else hostname = await torUtil.getHostname()

if (hostname) {
console.log(`Tor hostname: ${hostname}`)

clearInterval(torInterval)

p2pdb.broadcastHostname(hostname)
}
}
31 changes: 0 additions & 31 deletions test/integration/ccoinjoin1/ccoinjoin1.test.js

This file was deleted.

35 changes: 0 additions & 35 deletions test/integration/ccoinjoin1/wallet.json

This file was deleted.

99 changes: 0 additions & 99 deletions test/integration/ccoinjoin2/ccoinjoin2.test.js

This file was deleted.

41 changes: 0 additions & 41 deletions test/integration/ccoinjoin2/wallet.json

This file was deleted.

Loading

0 comments on commit cfd3973

Please sign in to comment.