electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit fbb65416d3072520f71ccce12a9f0acc7f29d391
parent 691fc54370a2c56acd4d28e7e98a605a56922918
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 20 Oct 2015 13:08:32 +0200

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

Diffstat:
Mlib/commands.py | 17++++-------------
Mlib/transaction.py | 9++++++++-
2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/lib/commands.py b/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"), diff --git a/lib/transaction.py b/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):