diff --git a/jmbase/jmbase/__init__.py b/jmbase/jmbase/__init__.py index e071f11..961a0a4 100644 --- a/jmbase/jmbase/__init__.py +++ b/jmbase/jmbase/__init__.py @@ -6,7 +6,8 @@ from .support import (get_log, chunks, debug_silence, jmprint, hextobin, lehextobin, utxostr_to_utxo, utxo_to_utxostr, EXIT_ARGERROR, EXIT_FAILURE, EXIT_SUCCESS, hexbin, dictchanger, listchanger, - JM_WALLET_NAME_PREFIX, JM_APP_NAME) + JM_WALLET_NAME_PREFIX, JM_APP_NAME, + IndentedHelpFormatterWithNL) from .twisted_utils import stop_reactor from .bytesprod import BytesProducer from .commands import * diff --git a/jmbase/jmbase/support.py b/jmbase/jmbase/support.py index a656b27..98e2e44 100644 --- a/jmbase/jmbase/support.py +++ b/jmbase/jmbase/support.py @@ -4,6 +4,8 @@ import binascii from getpass import getpass from os import path, environ from functools import wraps +from optparse import IndentedHelpFormatter + # JoinMarket version JM_CORE_VERSION = '0.8.2dev' @@ -16,6 +18,12 @@ EXIT_SUCCESS = 0 EXIT_FAILURE = 1 EXIT_ARGERROR = 2 +# optparse munges description paragraphs. We sometimes +# don't want that. +class IndentedHelpFormatterWithNL(IndentedHelpFormatter): + def format_description(self, description): + return description + from chromalog.log import ( ColorizingStreamHandler, ColorizingFormatter, diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index 3081318..815db24 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -6,7 +6,7 @@ import sqlite3 import sys from datetime import datetime from calendar import timegm -from optparse import OptionParser, IndentedHelpFormatter +from optparse import OptionParser from numbers import Integral from collections import Counter from itertools import islice @@ -17,7 +17,8 @@ from jmclient import (get_network, WALLET_IMPLEMENTATIONS, Storage, podle, is_native_segwit_mode, load_program_config, add_base_options, check_regtest) from jmclient.wallet_service import WalletService from jmbase.support import (get_password, jmprint, EXIT_FAILURE, - EXIT_ARGERROR, utxo_to_utxostr, hextobin, bintohex) + EXIT_ARGERROR, utxo_to_utxostr, hextobin, bintohex, + IndentedHelpFormatterWithNL) from .cryptoengine import TYPE_P2PKH, TYPE_P2SH_P2WPKH, TYPE_P2WPKH, \ TYPE_SEGWIT_LEGACY_WALLET_FIDELITY_BONDS @@ -31,12 +32,6 @@ DEFAULT_MIXDEPTH = 4 def get_wallettool_parser(): - # optparse munges description paragraphs. Here we - # have a big, complex paragraph which we need to control: - class IndentedHelpFormatterWithNL(IndentedHelpFormatter): - def format_description(self, description): - return description - description ="""Use this script to monitor and manage your Joinmarket wallet. The method is one of the following: (display) Shows addresses and balances. diff --git a/scripts/sendtomany.py b/scripts/sendtomany.py index 6d36d25..44b8652 100755 --- a/scripts/sendtomany.py +++ b/scripts/sendtomany.py @@ -8,7 +8,8 @@ for other reasons). from pprint import pformat from optparse import OptionParser import jmbitcoin as btc -from jmbase import get_log, jmprint, bintohex, utxostr_to_utxo +from jmbase import (get_log, jmprint, bintohex, utxostr_to_utxo, + IndentedHelpFormatterWithNL) from jmclient import load_program_config, estimate_tx_fee, jm_single,\ validate_address, get_utxo_info, add_base_options,\ validate_utxo_data, quit, BTCEngine, compute_tx_locktime @@ -46,30 +47,29 @@ def sign(utxo, priv, destaddrs, utxo_address_type): success, msg = btc.sign(tx, 0, rawpriv, amount=amtforsign, native=native) assert success, msg return tx - + +description="""For creating multiple utxos from one (for commitments in JM). +Provide a utxo in form txid:N that has some unspent coins; +Specify a list of destination addresses and the coins will +be split equally between them (after bitcoin fees). +You'll be prompted to enter the private key for the utxo +during the run; it must be in WIF compressed format. +After the transaction is completed, the utxo strings for +the new outputs will be shown. +Note that these utxos will not be ready for use as external +commitments in Joinmarket until 5 confirmations have passed. +BE CAREFUL about handling private keys! +Don't do this in insecure environments. +Works only with p2pkh ('1'), p2sh-p2wpkh (segwit '3') or +p2wpkh ('bc1') addresses. +utxos - set segwit=False in the POLICY section of +joinmarket.cfg for the former.""" + def main(): parser = OptionParser( usage= 'usage: %prog [options] utxo destaddr1 destaddr2 ..', - description="For creating multiple utxos from one (for commitments in JM)." - "Provide a utxo in form txid:N that has some unspent coins;" - "Specify a list of destination addresses and the coins will" - "be split equally between them (after bitcoin fees)." - - "You'll be prompted to enter the private key for the utxo" - "during the run; it must be in WIF compressed format." - "After the transaction is completed, the utxo strings for" - - "the new outputs will be shown." - "Note that these utxos will not be ready for use as external" - - "commitments in Joinmarket until 5 confirmations have passed." - " BE CAREFUL about handling private keys!" - " Don't do this in insecure environments." - " Works only with p2pkh ('1') or p2sh-p2wpkh (segwit '3')" - " utxos - set segwit=False in the POLICY section of" - " joinmarket.cfg for the former." - ) + description=description, formatter=IndentedHelpFormatterWithNL()) parser.add_option( '-t', '--utxo-address-type',