electrum

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

commit 2e67ca43e84dd3a0cb6d10cd3851362acd4f7935
parent 3ddbbc1008685d80ad3b7ab1a5f83c769da946f9
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 29 May 2015 19:23:49 +0200

use csv instead of mkmanytx

Diffstat:
Mgui/qt/main_window.py | 30------------------------------
Mlib/commands.py | 23+++++++++++++++++++----
2 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -2186,36 +2186,6 @@ class ElectrumWindow(QMainWindow): else: self.show_message("unknown transaction") - def do_process_from_csvReader(self, csvReader): - outputs = [] - errors = [] - errtext = "" - try: - for position, row in enumerate(csvReader): - address = row[0] - if not bitcoin.is_address(address): - errors.append((position, address)) - continue - amount = Decimal(row[1]) - amount = int(100000000*amount) - outputs.append(('address', address, amount)) - except (ValueError, IOError, os.error), reason: - QMessageBox.critical(None, _("Unable to read file or no transaction found"), _("Electrum was unable to open your transaction file") + "\n" + str(reason)) - return - if errors != []: - for x in errors: - errtext += "CSV Row " + str(x[0]+1) + ": " + x[1] + "\n" - QMessageBox.critical(None, _("Invalid Addresses"), _("ABORTING! Invalid Addresses found:") + "\n\n" + errtext) - return - - try: - tx = self.wallet.make_unsigned_transaction(outputs, None, None) - except Exception as e: - self.show_message(str(e)) - return - - self.show_transaction(tx) - @protected def export_privkeys_dialog(self, password): diff --git a/lib/commands.py b/lib/commands.py @@ -80,6 +80,8 @@ register_command('listunspent', True, True, False, [], [], 'Returns t register_command('getaddressunspent', True, False, False, ['address'], [], 'Returns the list of unspent inputs for an address.') register_command('mktx', False, True, True, ['recipient', 'amount'], ['tx_fee', 'from_addr', 'change_addr'], 'Create a signed transaction') register_command('payto', True, True, True, ['recipient', 'amount'], ['tx_fee', 'from_addr', 'change_addr'], 'Create and broadcast a transaction.') +register_command('mktx_csv', False, True, True, ['csv_file'], ['tx_fee', 'from_addr', 'change_addr'], 'Create a signed transaction') +register_command('payto_csv', True, True, True, ['csv_file'], ['tx_fee', 'from_addr', 'change_addr'], 'Create and broadcast a transaction.') register_command('password', False, True, True, [], [], 'Change your password') register_command('restore', True, True, False, [], ['gap_limit', 'mpk', 'concealed'], 'Restore a wallet') register_command('searchcontacts', False, True, False, ['query'], [], 'Search through contacts, return matching entries') @@ -101,8 +103,6 @@ register_command('getutxoaddress', True, False, False, ['txid', 'pos'], [ register_command('sweep', True, False, False, ['privkey', 'destination_address'], ['tx_fee'], 'Sweep a private key.') register_command('make_seed', False, False, False, [], ['nbits', 'entropy', 'language'], 'Create a seed.') register_command('check_seed', False, False, False, ['seed'], ['entropy'], 'Check that a seed was generated with external entropy.') -#register_command('mksendmanytx', False, True, True, 'Create a signed transaction', mksendmany_syntax, payto_options) -#register_command('paytomany', True, True, True, 'Create and broadcast a transaction.', paytomany_syntax, payto_options) @@ -419,7 +419,21 @@ class Commands: tx = self._mktx([(to_address, amount)], fee, change_addr, domain) return tx - def mksendmanytx(self, outputs, fee = None, change_addr = None, domain = None): + def _read_csv(self, csvpath): + import csv + outputs = [] + with open(csvpath, 'rb') as csvfile: + csvReader = csv.reader(csvfile, delimiter=',') + for row in csvReader: + address, amount = row + assert bitcoin.is_address(address) + amount = Decimal(amount) + outputs.append((address, amount)) + return outputs + + def mktx_csv(self, path, fee = None, change_addr = None, domain = None): + outputs = self._read_csv(path) + print outputs tx = self._mktx(outputs, fee, change_addr, domain) return tx @@ -428,7 +442,8 @@ class Commands: r, h = self.wallet.sendtx( tx ) return h - def paytomany(self, outputs, fee = None, change_addr = None, domain = None): + def payto_csv(self, path, fee = None, change_addr = None, domain = None): + outputs = self._read_csv(path) tx = self._mktx(outputs, fee, change_addr, domain) r, h = self.wallet.sendtx( tx ) return h