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,
StoragePasswordError, VolatileStorage)
from .cryptoengine import BTCEngine, BTC_P2PKH, BTC_P2SH_P2WPKH, EngineError
from .configure import (load_program_config, get_p2pk_vbyte,
jm_single, get_network, validate_address, get_irc_mchannels,
get_blockchain_interface_instance, get_p2sh_vbyte, set_config)
from .configure import (
load_program_config, get_p2pk_vbyte, jm_single, get_network,
validate_address, get_irc_mchannels, get_blockchain_interface_instance,
get_p2sh_vbyte, set_config)
from .blockchaininterface import (BlockchainInterface, sync_wallet,
RegtestBitcoinCoreInterface, BitcoinCoreInterface)
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,
restart_wait, get_tumble_log, direct_send,
tumbler_filter_orders_callback)
from .wallet_utils import (wallet_tool_main, wallet_generate_recover_bip39,
wallet_display)
from .wallet_utils import (
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 .yieldgenerator import YieldGenerator, YieldGeneratorBasic, ygmain
# 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)
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.
@ -878,6 +879,7 @@ def open_wallet(path, ask_for_password=True, read_only=False, **kwargs):
path: str, full path to wallet file
ask_for_password: bool, if False password is assumed unset and user
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
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
break
else:
storage = Storage(path, read_only=read_only)
storage = Storage(path, password, read_only=read_only)
wallet_cls = get_wallet_cls(storage)
wallet = wallet_cls(storage, **kwargs)

2
jmclient/jmclient/yieldgenerator.py

@ -8,7 +8,7 @@ import abc
from twisted.python.log import startLogging
from optparse import OptionParser
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)
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.
"""
import binascii
import sys
import os
import json
@ -14,12 +13,12 @@ from pprint import pformat
from optparse import OptionParser
import jmclient.btc as btc
from jmbase import get_password
from jmclient import (load_program_config, jm_single, get_p2pk_vbyte, get_wallet_cls,
WalletError, sync_wallet, add_external_commitments,
generate_podle, update_commitments, PoDLE,
set_commitment_file, get_podle_commitments,
get_utxo_info, validate_utxo_data, quit)
from jmclient import (
load_program_config, jm_single, get_p2pk_vbyte, open_wallet, WalletError,
sync_wallet, add_external_commitments, generate_podle, update_commitments,
PoDLE, set_commitment_file, get_podle_commitments, get_utxo_info,
validate_utxo_data, quit, get_wallet_path)
def add_ext_commitments(utxo_datas):
"""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,
#csv file or json file.
if options.loadwallet:
while True:
pwd = get_password("Enter wallet decryption passphrase: ")
try:
wallet = get_wallet_cls()(options.loadwallet,
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
# TODO: new wallet has no unspent attribute
raise NotImplementedError("This is not yet implemented.")
wallet_path = get_wallet_path(options.loadwallet, None)
wallet = open_wallet(wallet_path, gap_limit=options.gaplimit)
sync_wallet(wallet, fast=options.fastsync)
unsp = {}
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.
"""
import binascii
import os
import sys
import random
from optparse import OptionParser
from pprint import pformat
import jmbitcoin as btc
from jmclient import (load_program_config, validate_address, jm_single,
WalletError, sync_wallet, RegtestBitcoinCoreInterface,
estimate_tx_fee, SegwitWallet, get_p2pk_vbyte,
get_p2sh_vbyte, get_wallet_cls)
from jmbase.support import get_password
from jmclient import (
load_program_config, validate_address, jm_single, WalletError, sync_wallet,
RegtestBitcoinCoreInterface, estimate_tx_fee, get_p2pk_vbyte,
get_p2sh_vbyte, open_test_wallet_maybe, get_wallet_path)
def get_parser():
parser = OptionParser(
@ -79,20 +76,10 @@ def is_utxo(utxo):
return True
def cli_get_wallet(wallet_name, sync=True):
if not os.path.exists(os.path.join('wallets', wallet_name)):
wallet = get_wallet_cls()(wallet_name, None, max_mix_depth=options.amtmixdepths)
else:
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
wallet_path = get_wallet_path(wallet_name, None)
wallet = open_test_wallet_maybe(
wallet_path, wallet_name, options.amtmixdepths, gap_limit=options.gaplimit)
if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server":
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
JM_GUI_VERSION = '7'
from jmclient import (load_program_config, get_network, SegwitWallet,
get_p2sh_vbyte, get_p2pk_vbyte, jm_single, validate_address,
get_log, weighted_order_choose, Taker,
JMClientProtocolFactory, WalletError,
start_reactor, get_schedule, get_tumble_schedule,
schedule_to_text, create_wallet_file,
get_blockchain_interface_instance, sync_wallet, direct_send,
RegtestBitcoinCoreInterface, tweak_tumble_schedule,
human_readable_schedule_entry, tumbler_taker_finished_update,
get_tumble_log, restart_wait, tumbler_filter_orders_callback,
wallet_generate_recover_bip39, wallet_display)
from jmclient import (
load_program_config, get_network, open_wallet, get_wallet_path,
get_p2sh_vbyte, get_p2pk_vbyte, jm_single, validate_address, get_log,
weighted_order_choose, Taker, JMClientProtocolFactory, WalletError,
start_reactor, get_schedule, get_tumble_schedule, schedule_to_text,
get_blockchain_interface_instance, sync_wallet,
direct_send, RegtestBitcoinCoreInterface, tweak_tumble_schedule,
human_readable_schedule_entry, tumbler_taker_finished_update,
get_tumble_log, restart_wait, tumbler_filter_orders_callback,
wallet_generate_recover_bip39, wallet_display)
from qtsupport import (ScheduleWizard, TumbleRestartWizard, warnings, config_tips,
config_types, TaskThread, QtHandler, XStream, Buttons,
@ -1373,16 +1372,14 @@ class JMMainWindow(QMainWindow):
def loadWalletFromBlockchain(self, firstarg=None, pwd=None, restart_cb=None):
if (firstarg and pwd) or (firstarg and get_network() == 'testnet'):
wallet_path = get_wallet_path(str(firstarg), None)
try:
self.wallet = SegwitWallet(
str(firstarg),
pwd,
max_mix_depth=jm_single().config.getint(
"GUI", "max_mix_depth"),
gaplimit=jm_single().config.getint("GUI", "gaplimit"))
except WalletError:
self.wallet = open_wallet(
wallet_path, ask_for_password=False, password=pwd,
gap_limit=jm_single().config.getint("GUI", "gaplimit"))
except Exception as e:
JMQtMessageBox(self,
"Wrong password",
str(e),
mbtype='warn',
title="Error")
return False

40
scripts/tumbler.py

@ -1,26 +1,19 @@
#! /usr/bin/env python
from __future__ import absolute_import, print_function
import random
import sys
import threading
from optparse import OptionParser
from twisted.internet import reactor
import time
import os
import pprint
import copy
import logging
from twisted.python.log import startLogging
from jmclient import (Taker, load_program_config, get_schedule,
weighted_order_choose, JMClientProtocolFactory,
start_reactor, validate_address, jm_single, WalletError,
get_wallet_cls, sync_wallet, get_tumble_schedule,
RegtestBitcoinCoreInterface, estimate_tx_fee,
tweak_tumble_schedule, human_readable_schedule_entry,
schedule_to_text, restart_waiter, get_tumble_log,
tumbler_taker_finished_update, tumbler_filter_orders_callback)
from jmclient import (
Taker, load_program_config, get_schedule, weighted_order_choose,
JMClientProtocolFactory, start_reactor, validate_address, jm_single,
get_wallet_path, open_test_wallet_maybe, WalletError, sync_wallet,
get_tumble_schedule, RegtestBitcoinCoreInterface, estimate_tx_fee,
tweak_tumble_schedule, human_readable_schedule_entry, schedule_to_text,
restart_waiter, get_tumble_log, tumbler_taker_finished_update,
tumbler_filter_orders_callback)
from jmbase.support import get_log, debug_dump_object, get_password
from cli_options import get_tumbler_parser
log = get_log()
@ -39,20 +32,9 @@ def main():
#Load the wallet
wallet_name = args[0]
max_mix_depth = options['mixdepthsrc'] + options['mixdepthcount']
if not os.path.exists(os.path.join('wallets', wallet_name)):
wallet = get_wallet_cls()(wallet_name, None, 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
wallet_path = get_wallet_path(wallet_name, None)
wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth)
if jm_single().config.get("BLOCKCHAIN",
"blockchain_source") == "electrum-server":
jm_single().bc_interface.synctype = "with-script"

Loading…
Cancel
Save