electrum

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

commit 903e70566c7238a007e0e2e06843cea4a415d4d8
parent 6696e9643cab296f66f22781b8899155a16dd034
Author: thomasv <thomasv@gitorious>
Date:   Wed,  4 Sep 2013 10:33:14 +0200

wallet.make_unsigned_transaction()

Diffstat:
Mgui/gui_classic.py | 4++++
Mlib/wallet.py | 27++++++++++-----------------
2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/gui/gui_classic.py b/gui/gui_classic.py @@ -1013,6 +1013,10 @@ class ElectrumWindow(QMainWindow): except: QMessageBox.warning(self, _('Error'), _('Could not write transaction to file'), _('OK')) + # add recipient to addressbook + if to_address not in self.wallet.addressbook and not self.wallet.is_mine(to_address): + self.wallet.addressbook.append(to_address) + diff --git a/lib/wallet.py b/lib/wallet.py @@ -1110,46 +1110,39 @@ class Wallet: return default_label - def mktx(self, outputs, password, fee=None, change_addr=None, account=None ): - + def make_unsigned_transaction(self, outputs, fee=None, change_addr=None, account=None ): for address, x in outputs: assert is_valid(address) - amount = sum( map(lambda x:x[1], outputs) ) - inputs, total, fee = self.choose_tx_inputs( amount, fee, account ) if not inputs: raise ValueError("Not enough funds") - outputs = self.add_tx_change(inputs, outputs, amount, fee, total, change_addr, account) - tx = Transaction.from_io(inputs, outputs) + return Transaction.from_io(inputs, outputs) + + + def mktx(self, outputs, password, fee=None, change_addr=None, account=None ): + tx = self.make_unsigned_transaction(outputs, fee, change_addr, account) + self.sign_transaction(tx, password) + return tx + + def sign_transaction(self, tx, password): keypairs = {} for i, txin in enumerate(tx.inputs): address = txin['address'] - account, sequence = self.get_address_index(address) txin['KeyID'] = self.get_keyID(account, sequence) - redeemScript = self.accounts[account].redeem_script(sequence) if redeemScript: txin['redeemScript'] = redeemScript else: txin['redeemPubkey'] = self.accounts[account].get_pubkey(*sequence) - private_keys = self.get_private_key(address, password) - for sec in private_keys: pubkey = public_key_from_private_key(sec) keypairs[ pubkey ] = sec - tx.sign(keypairs) - for address, x in outputs: - if address not in self.addressbook and not self.is_mine(address): - self.addressbook.append(address) - - return tx - def sendtx(self, tx):