Browse Source

remove --broadcast option for payto, and parse transactions from json 'hex' field

283
ThomasV 9 years ago
parent
commit
fbb65416d3
  1. 17
      lib/commands.py
  2. 9
      lib/transaction.py

17
lib/commands.py

@ -412,26 +412,18 @@ class Commands:
return tx
@command('wp')
def payto(self, destination, amount, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False, broadcast=False):
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)
if broadcast:
r, h = self.wallet.sendtx(tx)
return h
else:
return tx.deserialize() if deserialized else tx
return tx.deserialize() if deserialized else tx
@command('wp')
def paytomany(self, outputs, tx_fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, deserialized=False, broadcast=False):
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
tx = self._mktx(outputs, tx_fee, change_addr, domain, nocheck, unsigned)
if broadcast:
r, h = self.wallet.sendtx(tx)
return h
else:
return tx.deserialize() if deserialized else tx
return tx.deserialize() if deserialized else tx
@command('wn')
def history(self):
@ -620,7 +612,6 @@ param_descriptions = {
}
command_options = {
'broadcast': (None, "--broadcast", "Broadcast the transaction to the Bitcoin network"),
'password': ("-W", "--password", "Password"),
'concealed': ("-C", "--concealed", "Don't echo seed to console when restoring"),
'receiving': (None, "--receiving", "Show only receiving addresses"),

9
lib/transaction.py

@ -470,7 +470,14 @@ class Transaction:
return self.raw
def __init__(self, raw):
self.raw = raw.strip() if raw else None
if raw is None:
self.raw = None
elif type(raw) in [str, unicode]:
self.raw = raw.strip() if raw else None
elif type(raw) is dict:
self.raw = raw['hex']
else:
raise BaseException("cannot initialize transaction", raw)
self.inputs = None
def update(self, raw):

Loading…
Cancel
Save