Various fixes for command line. Make 'payto' command require network (fixes #1525)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from version import ELECTRUM_VERSION
|
||||
from util import format_satoshis, print_msg, print_json, print_error, set_verbosity
|
||||
from util import format_satoshis, print_msg, print_error, set_verbosity
|
||||
from wallet import Synchronizer, WalletStorage
|
||||
from wallet import Wallet, Imported_Wallet
|
||||
from network import Network, DEFAULT_SERVERS, DEFAULT_PORTS, pick_random_server
|
||||
|
||||
@@ -418,14 +418,14 @@ class Commands:
|
||||
self.wallet.sign_transaction(tx, self.password)
|
||||
return tx
|
||||
|
||||
@command('wp')
|
||||
@command('wpn')
|
||||
def payto(self, destination, amount, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False):
|
||||
"""Create a transaction. """
|
||||
domain = [from_addr] if from_addr else None
|
||||
tx = self._mktx([(destination, amount)], tx_fee, change_addr, domain, nocheck, unsigned)
|
||||
return tx.deserialize() if deserialized else tx
|
||||
|
||||
@command('wp')
|
||||
@command('wpn')
|
||||
def paytomany(self, outputs, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False):
|
||||
"""Create a multi-output transaction. """
|
||||
domain = [from_addr] if from_addr else None
|
||||
@@ -657,8 +657,8 @@ arg_types = {
|
||||
'pubkeys': json.loads,
|
||||
'inputs': json.loads,
|
||||
'outputs': json.loads,
|
||||
'tx_fee': lambda x: Decimal(x) if x is not None else None,
|
||||
'amount': lambda x: Decimal(x) if x!='!' else '!',
|
||||
'tx_fee': lambda x: float(x) if x is not None else None,
|
||||
'amount': lambda x: float(x) if x!='!' else '!',
|
||||
}
|
||||
|
||||
config_variables = {
|
||||
|
||||
10
lib/util.py
10
lib/util.py
@@ -112,14 +112,18 @@ def print_msg(*args):
|
||||
sys.stdout.write(" ".join(args) + "\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
def print_json(obj):
|
||||
def json_encode(obj):
|
||||
try:
|
||||
s = json.dumps(obj, sort_keys = True, indent = 4, cls=MyEncoder)
|
||||
except TypeError:
|
||||
s = repr(obj)
|
||||
sys.stdout.write(s + "\n")
|
||||
sys.stdout.flush()
|
||||
return s
|
||||
|
||||
def json_decode(x):
|
||||
try:
|
||||
return json.loads(x)
|
||||
except:
|
||||
return x
|
||||
|
||||
# decorator that prints execution time
|
||||
def profiler(func):
|
||||
|
||||
Reference in New Issue
Block a user