1
0

Various fixes for command line. Make 'payto' command require network (fixes #1525)

This commit is contained in:
ThomasV
2015-10-29 11:06:09 +01:00
parent 079cb311ec
commit bb7b0884e3
8 changed files with 36 additions and 33 deletions

View File

@@ -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

View File

@@ -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 = {

View File

@@ -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):