electrum

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

commit 11e1e0e9239e18f2a8774869e455e2fdf705c2f0
parent ae56de316052f7a7dd321394501c022c5ccbabca
Author: ThomasV <thomasv@gitorious>
Date:   Tue, 19 Aug 2014 00:41:10 +0200

add support for p2sh addresses to trezor plugin

Diffstat:
Mplugins/trezor.py | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/plugins/trezor.py b/plugins/trezor.py @@ -9,7 +9,7 @@ from base64 import b64encode, b64decode from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog from electrum_gui.qt.util import ok_cancel_buttons from electrum.account import BIP32_Account -from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address +from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address, bc_address_to_hash_160 from electrum.i18n import _ from electrum.plugins import BasePlugin from electrum.transaction import deserialize @@ -255,23 +255,24 @@ class TrezorWallet(NewWallet): outputs = [] for type, address, amount in tx.outputs: + assert type == 'address' txoutputtype = types.TxOutputType() - if self.is_change(address): address_path = self.address_id(address) address_n = self.get_client().expand_path(address_path) txoutputtype.address_n.extend(address_n) else: txoutputtype.address = address - txoutputtype.amount = amount - - txoutputtype.script_type = types.PAYTOADDRESS - #TODO - #if output['is_p2sh']: - # txoutputtype.script_type = types.PAYTOSCRIPTHASH - + addrtype, hash_160 = bc_address_to_hash_160(address) + if addrtype == 0: + txoutputtype.script_type = types.PAYTOADDRESS + elif addrtype == 5: + txoutputtype.script_type = types.PAYTOSCRIPTHASH + else: + raise BaseException('addrtype') outputs.append(txoutputtype) + return outputs def electrum_tx_to_txtype(self, tx):