diff --git a/bitcoin/__init__.py b/bitcoin/__init__.py deleted file mode 100644 index 829b48a..0000000 --- a/bitcoin/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -import secp256k1 -from bitcoin.secp256k1_main import * -from bitcoin.secp256k1_transaction import * -from bitcoin.secp256k1_deterministic import * -from bitcoin.bci import * - diff --git a/base/__init__.py b/jmbase/__init__.py similarity index 100% rename from base/__init__.py rename to jmbase/__init__.py diff --git a/base/commands.py b/jmbase/commands.py similarity index 100% rename from base/commands.py rename to jmbase/commands.py diff --git a/base/support.py b/jmbase/support.py similarity index 100% rename from base/support.py rename to jmbase/support.py diff --git a/jmbitcoin/__init__.py b/jmbitcoin/__init__.py new file mode 100644 index 0000000..d8a423f --- /dev/null +++ b/jmbitcoin/__init__.py @@ -0,0 +1,6 @@ +import secp256k1 +from jmbitcoin.secp256k1_main import * +from jmbitcoin.secp256k1_transaction import * +from jmbitcoin.secp256k1_deterministic import * +from jmbitcoin.bci import * + diff --git a/bitcoin/bci.py b/jmbitcoin/bci.py similarity index 98% rename from bitcoin/bci.py rename to jmbitcoin/bci.py index c09a19b..9b894cc 100644 --- a/bitcoin/bci.py +++ b/jmbitcoin/bci.py @@ -4,7 +4,7 @@ import random import sys import time import platform -from base.support import get_log +from jmbase.support import get_log if platform.system() == "Windows": import ssl import urllib2 diff --git a/bitcoin/secp256k1_deterministic.py b/jmbitcoin/secp256k1_deterministic.py similarity index 98% rename from bitcoin/secp256k1_deterministic.py rename to jmbitcoin/secp256k1_deterministic.py index b323973..6957dd3 100644 --- a/bitcoin/secp256k1_deterministic.py +++ b/jmbitcoin/secp256k1_deterministic.py @@ -1,4 +1,4 @@ -from bitcoin.secp256k1_main import * +from jmbitcoin.secp256k1_main import * import hmac import hashlib from binascii import hexlify diff --git a/bitcoin/secp256k1_main.py b/jmbitcoin/secp256k1_main.py similarity index 100% rename from bitcoin/secp256k1_main.py rename to jmbitcoin/secp256k1_main.py diff --git a/bitcoin/secp256k1_transaction.py b/jmbitcoin/secp256k1_transaction.py similarity index 99% rename from bitcoin/secp256k1_transaction.py rename to jmbitcoin/secp256k1_transaction.py index df8416f..f5a54e6 100644 --- a/bitcoin/secp256k1_transaction.py +++ b/jmbitcoin/secp256k1_transaction.py @@ -1,6 +1,6 @@ #!/usr/bin/python import binascii, re, json, copy, sys -from bitcoin.secp256k1_main import * +from jmbitcoin.secp256k1_main import * from _functools import reduce import os diff --git a/client/__init__.py b/jmclient/__init__.py similarity index 100% rename from client/__init__.py rename to jmclient/__init__.py diff --git a/client/blockchaininterface.py b/jmclient/blockchaininterface.py similarity index 99% rename from client/blockchaininterface.py rename to jmclient/blockchaininterface.py index a40a7d3..8caf164 100644 --- a/client/blockchaininterface.py +++ b/jmclient/blockchaininterface.py @@ -21,9 +21,9 @@ import btc # This can be removed once CliJsonRpc is gone. import subprocess -from client.jsonrpc import JsonRpcConnectionError, JsonRpcError -from client.configure import get_p2pk_vbyte, jm_single -from base.support import get_log, chunks +from jmclient.jsonrpc import JsonRpcConnectionError, JsonRpcError +from jmclient.configure import get_p2pk_vbyte, jm_single +from jmbase.support import get_log, chunks log = get_log() @@ -682,7 +682,7 @@ class BitcoinCoreInterface(BlockchainInterface): sys.exit(0) def sync_addresses(self, wallet): - from client.wallet import BitcoinCoreWallet + from jmclient.wallet import BitcoinCoreWallet if isinstance(wallet, BitcoinCoreWallet): return @@ -812,7 +812,7 @@ class BitcoinCoreInterface(BlockchainInterface): self.wallet_synced = True def sync_unspent(self, wallet): - from client.wallet import BitcoinCoreWallet + from jmclient.wallet import BitcoinCoreWallet if isinstance(wallet, BitcoinCoreWallet): return diff --git a/client/btc.py b/jmclient/btc.py similarity index 99% rename from client/btc.py rename to jmclient/btc.py index 4aceb1b..657d105 100644 --- a/client/btc.py +++ b/jmclient/btc.py @@ -6,7 +6,7 @@ BTC_P2PK_VBYTE = {"mainnet": 0x00, "testnet": 0x6f} BTC_P2SH_VBYTE = {"mainnet": 0x05, "testnet": 0xc4} PODLE_COMMIT_FILE = None -from base.support import get_log +from jmbase.support import get_log import binascii, sys, re, hashlib, base64 from pprint import pformat log = get_log() @@ -17,7 +17,7 @@ N = 1157920892373161954235709850086879078528375642790749043826051631415181614943 interface = "joinmarket-joinmarket" try: - from bitcoin import * + from jmbitcoin import * bjm = True except ImportError: #TODO figure out the right flexibility structure diff --git a/client/client_protocol.py b/jmclient/client_protocol.py similarity index 99% rename from client/client_protocol.py rename to jmclient/client_protocol.py index 0cd4e3e..de48109 100644 --- a/client/client_protocol.py +++ b/jmclient/client_protocol.py @@ -14,7 +14,7 @@ import string import time import hashlib import os -from client import (Taker, Wallet, jm_single, get_irc_mchannels, +from jmclient import (Taker, Wallet, jm_single, get_irc_mchannels, load_program_config, get_log) import btc diff --git a/client/commands.py b/jmclient/commands.py similarity index 100% rename from client/commands.py rename to jmclient/commands.py diff --git a/client/configure.py b/jmclient/configure.py similarity index 98% rename from client/configure.py rename to jmclient/configure.py index e928fba..c673e96 100644 --- a/client/configure.py +++ b/jmclient/configure.py @@ -10,9 +10,9 @@ import sys from ConfigParser import SafeConfigParser, NoOptionError import btc -from client.jsonrpc import JsonRpc -from base.support import get_log, joinmarket_alert, core_alert, debug_silence -from client.podle import set_commitment_file +from jmclient.jsonrpc import JsonRpc +from jmbase.support import get_log, joinmarket_alert, core_alert, debug_silence +from jmclient.podle import set_commitment_file log = get_log() @@ -341,9 +341,9 @@ def load_program_config(config_path=None, bs=None): def get_blockchain_interface_instance(_config): # todo: refactor joinmarket module to get rid of loops # importing here is necessary to avoid import loops - from client.blockchaininterface import BitcoinCoreInterface, \ + from jmclient.blockchaininterface import BitcoinCoreInterface, \ RegtestBitcoinCoreInterface, BlockrInterface, ElectrumWalletInterface - from client.blockchaininterface import CliJsonRpc + from jmclient.blockchaininterface import CliJsonRpc source = _config.get("BLOCKCHAIN", "blockchain_source") network = get_network() diff --git a/client/jsonrpc.py b/jmclient/jsonrpc.py similarity index 100% rename from client/jsonrpc.py rename to jmclient/jsonrpc.py diff --git a/client/old_mnemonic.py b/jmclient/old_mnemonic.py similarity index 100% rename from client/old_mnemonic.py rename to jmclient/old_mnemonic.py diff --git a/client/podle.py b/jmclient/podle.py similarity index 100% rename from client/podle.py rename to jmclient/podle.py diff --git a/client/slowaes.py b/jmclient/slowaes.py similarity index 100% rename from client/slowaes.py rename to jmclient/slowaes.py diff --git a/client/socks.py b/jmclient/socks.py similarity index 100% rename from client/socks.py rename to jmclient/socks.py diff --git a/client/support.py b/jmclient/support.py similarity index 99% rename from client/support.py rename to jmclient/support.py index b2cffb8..4fa88b2 100644 --- a/client/support.py +++ b/jmclient/support.py @@ -5,7 +5,7 @@ import sys import logging import pprint import random -from base.support import get_log +from jmbase.support import get_log from decimal import Decimal from math import exp diff --git a/client/taker.py b/jmclient/taker.py similarity index 98% rename from client/taker.py rename to jmclient/taker.py index ba5f9a4..207cfaa 100644 --- a/client/taker.py +++ b/jmclient/taker.py @@ -9,11 +9,11 @@ import time import copy import btc -from client.configure import jm_single, get_p2pk_vbyte, donation_address -from base.support import get_log -from client.support import calc_cj_fee, weighted_order_choose, choose_orders -from client.wallet import estimate_tx_fee -from client.podle import (generate_podle, get_podle_commitments, +from jmclient.configure import jm_single, get_p2pk_vbyte, donation_address +from jmbase.support import get_log +from jmclient.support import calc_cj_fee, weighted_order_choose, choose_orders +from jmclient.wallet import estimate_tx_fee +from jmclient.podle import (generate_podle, get_podle_commitments, PoDLE, PoDLEError) jlog = get_log() diff --git a/client/wallet.py b/jmclient/wallet.py similarity index 98% rename from client/wallet.py rename to jmclient/wallet.py index d887c10..b6c0094 100644 --- a/client/wallet.py +++ b/jmclient/wallet.py @@ -9,11 +9,11 @@ from ConfigParser import NoSectionError from getpass import getpass import btc -from client.slowaes import decryptData -from client.blockchaininterface import BitcoinCoreInterface, RegtestBitcoinCoreInterface -from client.configure import jm_single, get_network, get_p2pk_vbyte -from base.support import get_log -from client.support import select_gradual, select_greedy,select_greediest, select +from jmclient.slowaes import decryptData +from jmclient.blockchaininterface import BitcoinCoreInterface, RegtestBitcoinCoreInterface +from jmclient.configure import jm_single, get_network, get_p2pk_vbyte +from jmbase.support import get_log +from jmclient.support import select_gradual, select_greedy,select_greediest, select log = get_log() diff --git a/daemon/__init__.py b/jmdaemon/__init__.py similarity index 91% rename from daemon/__init__.py rename to jmdaemon/__init__.py index edb90e7..ecb2f51 100644 --- a/daemon/__init__.py +++ b/jmdaemon/__init__.py @@ -5,10 +5,10 @@ from protocol import * from .enc_wrapper import as_init_encryption, decode_decrypt, \ encrypt_encode, init_keypair, init_pubkey, get_pubkey, NaclError from .irc import IRCMessageChannel, B_PER_SEC -from base.support import get_log +from jmbase.support import get_log from .message_channel import MessageChannel, MessageChannelCollection from .orderbookwatch import OrderbookWatch -from base import commands +from jmbase import commands # Set default logging handler to avoid "No handler found" warnings. try: diff --git a/daemon/enc_wrapper.py b/jmdaemon/enc_wrapper.py similarity index 100% rename from daemon/enc_wrapper.py rename to jmdaemon/enc_wrapper.py diff --git a/daemon/irc.py b/jmdaemon/irc.py similarity index 99% rename from daemon/irc.py rename to jmdaemon/irc.py index e192cda..e1f008d 100644 --- a/daemon/irc.py +++ b/jmdaemon/irc.py @@ -10,7 +10,7 @@ import Queue from daemon.message_channel import MessageChannel -from base.support import get_log, chunks +from jmbase.support import get_log, chunks from daemon.socks import socksocket, setdefaultproxy, PROXY_TYPE_SOCKS5 from daemon.protocol import * MAX_PRIVMSG_LEN = 450 diff --git a/daemon/message_channel.py b/jmdaemon/message_channel.py similarity index 99% rename from daemon/message_channel.py rename to jmdaemon/message_channel.py index 32c7ebc..6e8d172 100644 --- a/daemon/message_channel.py +++ b/jmdaemon/message_channel.py @@ -6,7 +6,7 @@ from daemon import ( NICK_HASH_LENGTH, NICK_MAX_ENCODED, JM_VERSION, JOINMARKET_NICK_HEADER, nickname, plaintext_commands, encrypted_commands, commitment_broadcast_list, offername_list, public_commands, private_commands) -from base.support import get_log +from jmbase.support import get_log from functools import wraps log = get_log() diff --git a/daemon/orderbookwatch.py b/jmdaemon/orderbookwatch.py similarity index 98% rename from daemon/orderbookwatch.py rename to jmdaemon/orderbookwatch.py index ce5fe10..e5bad22 100644 --- a/daemon/orderbookwatch.py +++ b/jmdaemon/orderbookwatch.py @@ -12,7 +12,7 @@ import json from decimal import InvalidOperation, Decimal from daemon.protocol import JM_VERSION -from base.support import get_log, joinmarket_alert, DUST_THRESHOLD +from jmbase.support import get_log, joinmarket_alert, DUST_THRESHOLD from daemon.irc import B_PER_SEC log = get_log() diff --git a/daemon/protocol.py b/jmdaemon/protocol.py similarity index 100% rename from daemon/protocol.py rename to jmdaemon/protocol.py diff --git a/daemon/socks.py b/jmdaemon/socks.py similarity index 100% rename from daemon/socks.py rename to jmdaemon/socks.py diff --git a/sendpayment.py b/sendpayment.py index 9d27346..8b19567 100644 --- a/sendpayment.py +++ b/sendpayment.py @@ -25,7 +25,7 @@ from optparse import OptionParser import time -from client import (Taker, load_program_config, +from jmclient import (Taker, load_program_config, JMTakerClientProtocolFactory, start_reactor, validate_address, jm_single, choose_orders, choose_sweep_orders, pick_order, @@ -33,7 +33,7 @@ from client import (Taker, load_program_config, Wallet, BitcoinCoreWallet, estimate_tx_fee) -from base.support import get_log, debug_dump_object +from jmbase.support import get_log, debug_dump_object log = get_log() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f6d7137 --- /dev/null +++ b/setup.py @@ -0,0 +1,40 @@ +from setuptools import setup +import sys +if '--client-only' in sys.argv: + sys.argv.remove('--client-only') + setup(name='joinmarketclient', + version='0.1', + description='Joinmarket client library for Bitcoin coinjoins', + url='http://github.com/Joinmarket-Org/joinmarket-client', + author='Adam Gibson', + author_email='ekaggata@gmail.com', + license='GPL', + packages=['jmbase', 'jmclient'], + install_requires=['twisted',], + zip_safe=False) +elif '--client-bitcoin' in sys.argv: + sys.argv.remove('--client-bitcoin') + setup(name='joinmarketclient', + version='0.1', + description='Joinmarket client library for Bitcoin coinjoins', + url='http://github.com/Joinmarket-Org/joinmarket-client', + author='Adam Gibson', + author_email='ekaggata@gmail.com', + license='GPL', + packages=['jmbase', 'jmbitcoin', 'jmclient'], + install_requires=['twisted', 'secp256k1'], + zip_safe=False) + +elif '--backend' in sys.argv: + sys.argv.remove('--backend') + setup(name='joinmarketdaemon', + version='0.1', + description='Joinmarket daemon for Bitcoin coinjoins', + author='Adam Gibson', + author_email='ekaggata@gmail.com', + license='GPL', + packages=['jmbase','jmdaemon'], + install_requires=['libnacl', 'twisted'], + zip_safe=False) +else: + raise Exception("Invalid arguments")