Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
merged taker recovery into master
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-belcher committed Sep 23, 2015
2 parents b69c322 + f0724f8 commit 79caac7
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 57 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
##What is JoinMarket ?

The idea behind JoinMarket is that holders of bitcoin will allow their coins to be mixed with in return for a fee. The mixing will happen in coinjoin transactions. They form a kind of smart contract which means your private keys will never leave your computer so there is no risk of loss (barring malware or bug*)

Put simply, JoinMarket allows you to improve the privacy of your bitcoin transactions for low fees in a decentralized fashion Because of the fee paid, owners of bitcoin will be able to earn an income using JoinMarket.

As the risk is very low, the reward will also be low because of competition between fee-earners. It means that you will be eventually able to do a coinjoin very cheaply. We already see that holders of bitcoin are willing to earn very small amounts per day by lending on the bitfinex exchange, and that contains a substantial risk that bitfinex will go disappear.

##Installation

#####REQUIRED INSTALLATION DEPENDENCIES

+ You will need python 2.7

+ You will need libsodium installed

- You can get it here: http://doc.libsodium.org/ or through apt-get as `libsodium-dev`

- Use this line to check it was installed correctly: `python lib/enc_wrapper.py`

+ Matplotlib for displaying the graphs in orderbook-watcher (optional)

###DEBIAN / UBUNTU QUICK INSTALL:

1. `sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install python libsodium-dev -y`
2. `sudo apt-get install python-matplotlib -y` (optional)
3. `git clone https://github.com/chris-belcher/joinmarket.git`
4. Generating your first wallet will populate the configuration file: `joinmarket.cfg`.
Check if the default settings suit your needs.

###[WIKI PAGES FOR DETAILED ARTICLES/GUIDES](https://github.com/chris-belcher/joinmarket/wiki)

###[FOR WINDOWS](https://github.com/chris-belcher/joinmarket/wiki/Installing-JoinMarket-on-Windows-7-(temporary))

---

+ IRC: `#joinmarket` on irc.freenode.net https://webchat.freenode.net/?channels=%23joinmarket

+ Bitcointalk thread: https://bitcointalk.org/index.php?topic=919116.msg10096563

+ Subreddit: https://reddit.com/r/joinmarket

+ Twitter: https://twitter.com/joinmarket

+ Donation address: `1AZgQZWYRteh6UyF87hwuvyWj73NvWKpL`
41 changes: 0 additions & 41 deletions README.txt

This file was deleted.

2 changes: 1 addition & 1 deletion lib/blockchaininterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def add_watchonly_addresses(self, addr_list, wallet_name):
for addr in addr_list:
self.rpc('importaddress', [addr, wallet_name, False])
if common.config.get("BLOCKCHAIN", "blockchain_source") != 'regtest':
print 'now restart bitcoind with -rescan'
print 'now restart bitcoind with -rescan, unless you\'re sure the wallet is completely empty and unused'
sys.exit(0)

def sync_addresses(self, wallet):
Expand Down
3 changes: 1 addition & 2 deletions lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ def __init__(self):
elif config.get("POLICY", "merge_algorithm") != "default":
raise Exception("Unknown merge algorithm")
except NoSectionError:
debug("Please add the new [POLICY] section to your config")
debug("Set therein thine merge_algorithm as default or gradual")
pass

def get_key_from_addr(self, addr):
return None
Expand Down
2 changes: 1 addition & 1 deletion lib/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ def __handle_line(self, line):
self.send_raw('MODE ' + self.nick + ' +B') #marks as bots on unreal
self.send_raw('MODE ' + self.nick + ' -R') #allows unreg'd private messages
elif chunks[1] == '366': #end of names list
debug('Connected to IRC and joined channel')
if self.on_welcome:
self.on_welcome()
debug('Connected to IRC and joined channel')
elif chunks[1] == '332' or chunks[1] == 'TOPIC': #channel topic
topic = get_irc_text(line)
self.on_set_topic(topic)
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def queryHTTP (self, obj):
except JsonRpcConnectionError as exc:
raise exc
except Exception as exc:
raise JsonRpcConnectionError ("JSON-RPC connection failed")
raise JsonRpcConnectionError ("JSON-RPC connection failed. Err:" + repr(exc))

def call (self, method, params):
"""
Expand Down
2 changes: 2 additions & 0 deletions test/regtest_joinmarket.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#NOTE: This configuration file is for testing with regtest only
#For mainnet usage, running a JoinMarket script will create the default file
[BLOCKCHAIN]
blockchain_source = regtest
network = testnet
Expand Down
28 changes: 17 additions & 11 deletions tumbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ def generate_tumbler_tx(destaddrs, options):
'srcmixdepth': m + options.mixdepthsrc, 'makercount': makercount, 'destination': 'internal'}
tx_list.append(tx)

total_dest_addr = len(destaddrs) + options.addrask
external_dest_addrs = ['addrask']*options.addrask + destaddrs
if total_dest_addr > options.mixdepthcount:
print 'not enough mixing depths to pay to all destination addresses'
return None
for mix_offset in range(total_dest_addr):
addrask = options.addrcount - len(destaddrs)
external_dest_addrs = ['addrask']*addrask + destaddrs
for mix_offset in range(options.addrcount):
srcmix = options.mixdepthsrc + options.mixdepthcount - mix_offset - 1
for tx in reversed(tx_list):
if tx['srcmixdepth'] == srcmix:
Expand Down Expand Up @@ -193,6 +190,9 @@ def run(self):
sqlorders = self.taker.db.execute('SELECT cjfee, ordertype FROM orderbook;').fetchall()
orders = [o['cjfee'] for o in sqlorders if o['ordertype'] == 'relorder']
orders = sorted(orders)
if len(orders) == 0:
debug('There are no orders at all in the orderbook! Is the bot connecting to the right server?')
return
relorder_fee = float(orders[0])
debug('relorder fee = ' + str(relorder_fee))
maker_count = sum([tx['makercount'] for tx in self.taker.tx_list])
Expand Down Expand Up @@ -259,9 +259,9 @@ def main():
default=(0.01, 10000), help='maximum coinjoin fee and bitcoin value the tumbler is '
'willing to pay to a single market maker. Both values need to be exceeded, so if '
'the fee is 30% but only 500satoshi is paid the tx will go ahead. default=0.01, 10000 (1%, 10000satoshi)')
parser.add_option('-a', '--addrask', type='int', dest='addrask',
default=2, help='How many more addresses to ask for in the terminal. Should '
'be similar to --txcountparams. default=2')
parser.add_option('-a', '--addrcount', type='int', dest='addrcount',
default=3, help='How many destination addresses in total should be used. If not enough are given'
' as command line arguments, the script will ask for more, default=3')
parser.add_option('-N', '--makercountrange', type='float', nargs=2, action='store',
dest='makercountrange',
help='Input the mean and spread of number of makers to use. e.g. 3 1.5 will be a normal distribution '
Expand Down Expand Up @@ -297,8 +297,13 @@ def main():
if not addr_valid:
print 'ERROR: Address ' + addr + ' invalid. ' + errormsg
return

if len(destaddrs) + options.addrask <= 1:

if len(destaddrs) > options.addrcount:
options.addrcount = len(destaddrs)
if options.addrcount+1 > options.mixdepthcount:
print 'not enough mixing depths to pay to all destination addresses, increasing mixdepthcount'
options.mixdepthcount = options.addrcount+1
if options.addrcount <= 1:
print '='*50
print 'WARNING: You are only using one destination address'
print 'this is very bad for privacy'
Expand All @@ -324,6 +329,7 @@ def main():
pprint(dbg_tx_list)

total_wait = sum([tx['wait'] for tx in tx_list])
print 'creates ' + str(len(tx_list)) + ' transactions in total'
print 'waits in total for ' + str(len(tx_list)) + ' blocks and ' + str(total_wait) + ' minutes'
total_block_and_wait = len(tx_list)*10 + total_wait
print('estimated time taken ' + str(total_block_and_wait) +
Expand Down

0 comments on commit 79caac7

Please sign in to comment.