Browse Source

remove references to old wallet classes

master
undeath 8 years ago
parent
commit
3cf99266b5
  1. 13
      jmclient/jmclient/__init__.py
  2. 6
      jmclient/jmclient/wallet_utils.py
  3. 2
      jmclient/jmclient/yieldgenerator.py
  4. 31
      scripts/add-utxo.py
  5. 31
      scripts/jmtainter.py
  6. 35
      scripts/joinmarket-qt.py
  7. 40
      scripts/tumbler.py

13
jmclient/jmclient/__init__.py

@ -23,9 +23,10 @@ from .wallet import (estimate_tx_fee, WalletError, BaseWallet, ImportWalletMixin
from .storage import (Argon2Hash, Storage, StorageError, from .storage import (Argon2Hash, Storage, StorageError,
StoragePasswordError, VolatileStorage) StoragePasswordError, VolatileStorage)
from .cryptoengine import BTCEngine, BTC_P2PKH, BTC_P2SH_P2WPKH, EngineError from .cryptoengine import BTCEngine, BTC_P2PKH, BTC_P2SH_P2WPKH, EngineError
from .configure import (load_program_config, get_p2pk_vbyte, from .configure import (
jm_single, get_network, validate_address, get_irc_mchannels, load_program_config, get_p2pk_vbyte, jm_single, get_network,
get_blockchain_interface_instance, get_p2sh_vbyte, set_config) validate_address, get_irc_mchannels, get_blockchain_interface_instance,
get_p2sh_vbyte, set_config)
from .blockchaininterface import (BlockchainInterface, sync_wallet, from .blockchaininterface import (BlockchainInterface, sync_wallet,
RegtestBitcoinCoreInterface, BitcoinCoreInterface) RegtestBitcoinCoreInterface, BitcoinCoreInterface)
from .electruminterface import ElectrumInterface from .electruminterface import ElectrumInterface
@ -42,8 +43,10 @@ from .commitment_utils import get_utxo_info, validate_utxo_data, quit
from .taker_utils import (tumbler_taker_finished_update, restart_waiter, from .taker_utils import (tumbler_taker_finished_update, restart_waiter,
restart_wait, get_tumble_log, direct_send, restart_wait, get_tumble_log, direct_send,
tumbler_filter_orders_callback) tumbler_filter_orders_callback)
from .wallet_utils import (wallet_tool_main, wallet_generate_recover_bip39, from .wallet_utils import (
wallet_display) wallet_tool_main, wallet_generate_recover_bip39, open_wallet,
open_test_wallet_maybe, create_wallet, get_wallet_cls, get_wallet_path,
wallet_display)
from .maker import Maker from .maker import Maker
from .yieldgenerator import YieldGenerator, YieldGeneratorBasic, ygmain from .yieldgenerator import YieldGenerator, YieldGeneratorBasic, ygmain
# Set default logging handler to avoid "No handler found" warnings. # Set default logging handler to avoid "No handler found" warnings.

6
jmclient/jmclient/wallet_utils.py

@ -870,7 +870,8 @@ def open_test_wallet_maybe(path, seed, max_mixdepth, **kwargs):
return open_wallet(path, **kwargs) return open_wallet(path, **kwargs)
def open_wallet(path, ask_for_password=True, read_only=False, **kwargs): def open_wallet(path, ask_for_password=True, password=None, read_only=False,
**kwargs):
""" """
Open the wallet file at path and return the corresponding wallet object. Open the wallet file at path and return the corresponding wallet object.
@ -878,6 +879,7 @@ def open_wallet(path, ask_for_password=True, read_only=False, **kwargs):
path: str, full path to wallet file path: str, full path to wallet file
ask_for_password: bool, if False password is assumed unset and user ask_for_password: bool, if False password is assumed unset and user
will not be asked to type it will not be asked to type it
password: password for storage, ignored if ask_for_password is True
read_only: bool, if True, open wallet in read-only mode read_only: bool, if True, open wallet in read-only mode
kwargs: additional options to pass to wallet's init method kwargs: additional options to pass to wallet's init method
@ -898,7 +900,7 @@ def open_wallet(path, ask_for_password=True, read_only=False, **kwargs):
raise e raise e
break break
else: else:
storage = Storage(path, read_only=read_only) storage = Storage(path, password, read_only=read_only)
wallet_cls = get_wallet_cls(storage) wallet_cls = get_wallet_cls(storage)
wallet = wallet_cls(storage, **kwargs) wallet = wallet_cls(storage, **kwargs)

2
jmclient/jmclient/yieldgenerator.py

@ -8,7 +8,7 @@ import abc
from twisted.python.log import startLogging from twisted.python.log import startLogging
from optparse import OptionParser from optparse import OptionParser
from jmclient import (Maker, jm_single, get_network, load_program_config, get_log, from jmclient import (Maker, jm_single, get_network, load_program_config, get_log,
get_wallet_cls, sync_wallet, JMClientProtocolFactory, sync_wallet, JMClientProtocolFactory,
start_reactor, calc_cj_fee, WalletError) start_reactor, calc_cj_fee, WalletError)
from .wallet_utils import open_test_wallet_maybe, get_wallet_path from .wallet_utils import open_test_wallet_maybe, get_wallet_path

31
scripts/add-utxo.py

@ -6,7 +6,6 @@ users to retry transactions more often without getting banned by
the anti-snooping feature employed by makers. the anti-snooping feature employed by makers.
""" """
import binascii
import sys import sys
import os import os
import json import json
@ -14,12 +13,12 @@ from pprint import pformat
from optparse import OptionParser from optparse import OptionParser
import jmclient.btc as btc import jmclient.btc as btc
from jmbase import get_password from jmclient import (
from jmclient import (load_program_config, jm_single, get_p2pk_vbyte, get_wallet_cls, load_program_config, jm_single, get_p2pk_vbyte, open_wallet, WalletError,
WalletError, sync_wallet, add_external_commitments, sync_wallet, add_external_commitments, generate_podle, update_commitments,
generate_podle, update_commitments, PoDLE, PoDLE, set_commitment_file, get_podle_commitments, get_utxo_info,
set_commitment_file, get_podle_commitments, validate_utxo_data, quit, get_wallet_path)
get_utxo_info, validate_utxo_data, quit)
def add_ext_commitments(utxo_datas): def add_ext_commitments(utxo_datas):
"""Persist the PoDLE commitments for this utxo """Persist the PoDLE commitments for this utxo
@ -174,20 +173,10 @@ def main():
#Three options (-w, -r, -R) for loading utxo and privkey pairs from a wallet, #Three options (-w, -r, -R) for loading utxo and privkey pairs from a wallet,
#csv file or json file. #csv file or json file.
if options.loadwallet: if options.loadwallet:
while True: # TODO: new wallet has no unspent attribute
pwd = get_password("Enter wallet decryption passphrase: ") raise NotImplementedError("This is not yet implemented.")
try: wallet_path = get_wallet_path(options.loadwallet, None)
wallet = get_wallet_cls()(options.loadwallet, wallet = open_wallet(wallet_path, gap_limit=options.gaplimit)
pwd,
options.maxmixdepth,
options.gaplimit)
except WalletError:
print("Wrong password, try again.")
continue
except Exception as e:
print("Failed to load wallet, error message: " + repr(e))
sys.exit(0)
break
sync_wallet(wallet, fast=options.fastsync) sync_wallet(wallet, fast=options.fastsync)
unsp = {} unsp = {}
for u, av in wallet.unspent.iteritems(): for u, av in wallet.unspent.iteritems():

31
scripts/jmtainter.py

@ -9,17 +9,14 @@ can spread to other outputs included.
This is a tool for Joinmarket wallets specifically. This is a tool for Joinmarket wallets specifically.
""" """
import binascii import binascii
import os
import sys
import random
from optparse import OptionParser from optparse import OptionParser
from pprint import pformat from pprint import pformat
import jmbitcoin as btc import jmbitcoin as btc
from jmclient import (load_program_config, validate_address, jm_single, from jmclient import (
WalletError, sync_wallet, RegtestBitcoinCoreInterface, load_program_config, validate_address, jm_single, WalletError, sync_wallet,
estimate_tx_fee, SegwitWallet, get_p2pk_vbyte, RegtestBitcoinCoreInterface, estimate_tx_fee, get_p2pk_vbyte,
get_p2sh_vbyte, get_wallet_cls) get_p2sh_vbyte, open_test_wallet_maybe, get_wallet_path)
from jmbase.support import get_password
def get_parser(): def get_parser():
parser = OptionParser( parser = OptionParser(
@ -79,20 +76,10 @@ def is_utxo(utxo):
return True return True
def cli_get_wallet(wallet_name, sync=True): def cli_get_wallet(wallet_name, sync=True):
if not os.path.exists(os.path.join('wallets', wallet_name)): wallet_path = get_wallet_path(wallet_name, None)
wallet = get_wallet_cls()(wallet_name, None, max_mix_depth=options.amtmixdepths) wallet = open_test_wallet_maybe(
else: wallet_path, wallet_name, options.amtmixdepths, gap_limit=options.gaplimit)
while True:
try:
pwd = get_password("Enter wallet decryption passphrase: ")
wallet = get_wallet_cls()(wallet_name, pwd, max_mix_depth=options.amtmixdepths)
except WalletError:
print("Wrong password, try again.")
continue
except Exception as e:
print("Failed to load wallet, error message: " + repr(e))
sys.exit(0)
break
if jm_single().config.get("BLOCKCHAIN", if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server": "blockchain_source") == "electrum-server":
jm_single().bc_interface.synctype = "with-script" jm_single().bc_interface.synctype = "with-script"

35
scripts/joinmarket-qt.py

@ -52,17 +52,16 @@ JM_CORE_VERSION = '0.3.5'
#Version of this Qt script specifically #Version of this Qt script specifically
JM_GUI_VERSION = '7' JM_GUI_VERSION = '7'
from jmclient import (load_program_config, get_network, SegwitWallet, from jmclient import (
get_p2sh_vbyte, get_p2pk_vbyte, jm_single, validate_address, load_program_config, get_network, open_wallet, get_wallet_path,
get_log, weighted_order_choose, Taker, get_p2sh_vbyte, get_p2pk_vbyte, jm_single, validate_address, get_log,
JMClientProtocolFactory, WalletError, weighted_order_choose, Taker, JMClientProtocolFactory, WalletError,
start_reactor, get_schedule, get_tumble_schedule, start_reactor, get_schedule, get_tumble_schedule, schedule_to_text,
schedule_to_text, create_wallet_file, get_blockchain_interface_instance, sync_wallet,
get_blockchain_interface_instance, sync_wallet, direct_send, direct_send, RegtestBitcoinCoreInterface, tweak_tumble_schedule,
RegtestBitcoinCoreInterface, tweak_tumble_schedule, human_readable_schedule_entry, tumbler_taker_finished_update,
human_readable_schedule_entry, tumbler_taker_finished_update, get_tumble_log, restart_wait, tumbler_filter_orders_callback,
get_tumble_log, restart_wait, tumbler_filter_orders_callback, wallet_generate_recover_bip39, wallet_display)
wallet_generate_recover_bip39, wallet_display)
from qtsupport import (ScheduleWizard, TumbleRestartWizard, warnings, config_tips, from qtsupport import (ScheduleWizard, TumbleRestartWizard, warnings, config_tips,
config_types, TaskThread, QtHandler, XStream, Buttons, config_types, TaskThread, QtHandler, XStream, Buttons,
@ -1373,16 +1372,14 @@ class JMMainWindow(QMainWindow):
def loadWalletFromBlockchain(self, firstarg=None, pwd=None, restart_cb=None): def loadWalletFromBlockchain(self, firstarg=None, pwd=None, restart_cb=None):
if (firstarg and pwd) or (firstarg and get_network() == 'testnet'): if (firstarg and pwd) or (firstarg and get_network() == 'testnet'):
wallet_path = get_wallet_path(str(firstarg), None)
try: try:
self.wallet = SegwitWallet( self.wallet = open_wallet(
str(firstarg), wallet_path, ask_for_password=False, password=pwd,
pwd, gap_limit=jm_single().config.getint("GUI", "gaplimit"))
max_mix_depth=jm_single().config.getint( except Exception as e:
"GUI", "max_mix_depth"),
gaplimit=jm_single().config.getint("GUI", "gaplimit"))
except WalletError:
JMQtMessageBox(self, JMQtMessageBox(self,
"Wrong password", str(e),
mbtype='warn', mbtype='warn',
title="Error") title="Error")
return False return False

40
scripts/tumbler.py

@ -1,26 +1,19 @@
#! /usr/bin/env python #! /usr/bin/env python
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function
import random
import sys import sys
import threading
from optparse import OptionParser
from twisted.internet import reactor from twisted.internet import reactor
import time
import os import os
import pprint import pprint
import copy
import logging
from twisted.python.log import startLogging from twisted.python.log import startLogging
from jmclient import (Taker, load_program_config, get_schedule, from jmclient import (
weighted_order_choose, JMClientProtocolFactory, Taker, load_program_config, get_schedule, weighted_order_choose,
start_reactor, validate_address, jm_single, WalletError, JMClientProtocolFactory, start_reactor, validate_address, jm_single,
get_wallet_cls, sync_wallet, get_tumble_schedule, get_wallet_path, open_test_wallet_maybe, WalletError, sync_wallet,
RegtestBitcoinCoreInterface, estimate_tx_fee, get_tumble_schedule, RegtestBitcoinCoreInterface, estimate_tx_fee,
tweak_tumble_schedule, human_readable_schedule_entry, tweak_tumble_schedule, human_readable_schedule_entry, schedule_to_text,
schedule_to_text, restart_waiter, get_tumble_log, restart_waiter, get_tumble_log, tumbler_taker_finished_update,
tumbler_taker_finished_update, tumbler_filter_orders_callback) tumbler_filter_orders_callback)
from jmbase.support import get_log, debug_dump_object, get_password from jmbase.support import get_log, debug_dump_object, get_password
from cli_options import get_tumbler_parser from cli_options import get_tumbler_parser
log = get_log() log = get_log()
@ -39,20 +32,9 @@ def main():
#Load the wallet #Load the wallet
wallet_name = args[0] wallet_name = args[0]
max_mix_depth = options['mixdepthsrc'] + options['mixdepthcount'] max_mix_depth = options['mixdepthsrc'] + options['mixdepthcount']
if not os.path.exists(os.path.join('wallets', wallet_name)): wallet_path = get_wallet_path(wallet_name, None)
wallet = get_wallet_cls()(wallet_name, None, max_mix_depth) wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth)
else:
while True:
try:
pwd = get_password("Enter wallet decryption passphrase: ")
wallet = get_wallet_cls()(wallet_name, pwd, max_mix_depth)
except WalletError:
print("Wrong password, try again.")
continue
except Exception as e:
print("Failed to load wallet, error message: " + repr(e))
sys.exit(0)
break
if jm_single().config.get("BLOCKCHAIN", if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server": "blockchain_source") == "electrum-server":
jm_single().bc_interface.synctype = "with-script" jm_single().bc_interface.synctype = "with-script"

Loading…
Cancel
Save