Browse Source

Merge #806: Correct formatting of sendtomany help message.

9d7f332 Correct formatting of sendtomany help message. (Adam Gibson)
master
Adam Gibson 5 years ago
parent
commit
d485904681
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 3
      jmbase/jmbase/__init__.py
  2. 8
      jmbase/jmbase/support.py
  3. 11
      jmclient/jmclient/wallet_utils.py
  4. 42
      scripts/sendtomany.py

3
jmbase/jmbase/__init__.py

@ -6,7 +6,8 @@ from .support import (get_log, chunks, debug_silence, jmprint,
hextobin, lehextobin, utxostr_to_utxo, hextobin, lehextobin, utxostr_to_utxo,
utxo_to_utxostr, EXIT_ARGERROR, EXIT_FAILURE, utxo_to_utxostr, EXIT_ARGERROR, EXIT_FAILURE,
EXIT_SUCCESS, hexbin, dictchanger, listchanger, 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 .twisted_utils import stop_reactor
from .bytesprod import BytesProducer from .bytesprod import BytesProducer
from .commands import * from .commands import *

8
jmbase/jmbase/support.py

@ -4,6 +4,8 @@ import binascii
from getpass import getpass from getpass import getpass
from os import path, environ from os import path, environ
from functools import wraps from functools import wraps
from optparse import IndentedHelpFormatter
# JoinMarket version # JoinMarket version
JM_CORE_VERSION = '0.8.2dev' JM_CORE_VERSION = '0.8.2dev'
@ -16,6 +18,12 @@ EXIT_SUCCESS = 0
EXIT_FAILURE = 1 EXIT_FAILURE = 1
EXIT_ARGERROR = 2 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 ( from chromalog.log import (
ColorizingStreamHandler, ColorizingStreamHandler,
ColorizingFormatter, ColorizingFormatter,

11
jmclient/jmclient/wallet_utils.py

@ -6,7 +6,7 @@ import sqlite3
import sys import sys
from datetime import datetime from datetime import datetime
from calendar import timegm from calendar import timegm
from optparse import OptionParser, IndentedHelpFormatter from optparse import OptionParser
from numbers import Integral from numbers import Integral
from collections import Counter from collections import Counter
from itertools import islice 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) is_native_segwit_mode, load_program_config, add_base_options, check_regtest)
from jmclient.wallet_service import WalletService from jmclient.wallet_service import WalletService
from jmbase.support import (get_password, jmprint, EXIT_FAILURE, 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, \ from .cryptoengine import TYPE_P2PKH, TYPE_P2SH_P2WPKH, TYPE_P2WPKH, \
TYPE_SEGWIT_LEGACY_WALLET_FIDELITY_BONDS TYPE_SEGWIT_LEGACY_WALLET_FIDELITY_BONDS
@ -31,12 +32,6 @@ DEFAULT_MIXDEPTH = 4
def get_wallettool_parser(): 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. description ="""Use this script to monitor and manage your Joinmarket wallet.
The method is one of the following: The method is one of the following:
(display) Shows addresses and balances. (display) Shows addresses and balances.

42
scripts/sendtomany.py

@ -8,7 +8,8 @@ for other reasons).
from pprint import pformat from pprint import pformat
from optparse import OptionParser from optparse import OptionParser
import jmbitcoin as btc 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,\ from jmclient import load_program_config, estimate_tx_fee, jm_single,\
validate_address, get_utxo_info, add_base_options,\ validate_address, get_utxo_info, add_base_options,\
validate_utxo_data, quit, BTCEngine, compute_tx_locktime 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) success, msg = btc.sign(tx, 0, rawpriv, amount=amtforsign, native=native)
assert success, msg assert success, msg
return tx 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(): def main():
parser = OptionParser( parser = OptionParser(
usage= usage=
'usage: %prog [options] utxo destaddr1 destaddr2 ..', 'usage: %prog [options] utxo destaddr1 destaddr2 ..',
description="For creating multiple utxos from one (for commitments in JM)." description=description, formatter=IndentedHelpFormatterWithNL())
"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."
)
parser.add_option( parser.add_option(
'-t', '-t',
'--utxo-address-type', '--utxo-address-type',

Loading…
Cancel
Save