electrum

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

commit 0df24d9321eb1c9ecc38685bdb70c0aa1d3fc9cb
parent 6656154b780a5d2c8adc2a7695e9912fad16db68
Author: ThomasV <thomasv@electrum.org>
Date:   Wed, 11 Oct 2017 12:23:10 +0200

trezor plugin: add paytowitness (not supported yet)

Diffstat:
Mplugins/trezor/plugin.py | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py @@ -6,7 +6,7 @@ from binascii import hexlify, unhexlify from functools import partial from electrum.util import bfh, bh2u -from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey, +from electrum.bitcoin import (is_segwit_address, b58_address_to_hash160, xpub_from_pubkey, public_key_to_p2pkh, EncodeBase58Check, TYPE_ADDRESS, TYPE_SCRIPT, TESTNET, ADDRTYPE_P2PKH, ADDRTYPE_P2SH) @@ -365,13 +365,16 @@ class TrezorCompatiblePlugin(HW_PluginBase): txoutputtype.script_type = self.types.PAYTOOPRETURN txoutputtype.op_return_data = address[2:] elif _type == TYPE_ADDRESS: - addrtype, hash_160 = b58_address_to_hash160(address) - if addrtype == ADDRTYPE_P2PKH: - txoutputtype.script_type = self.types.PAYTOADDRESS - elif addrtype == ADDRTYPE_P2SH: - txoutputtype.script_type = self.types.PAYTOSCRIPTHASH + if is_segwit_address(address): + txoutputtype.script_type = self.types.PAYTOWITNESS else: - raise BaseException('addrtype') + addrtype, hash_160 = b58_address_to_hash160(address) + if addrtype == ADDRTYPE_P2PKH: + txoutputtype.script_type = self.types.PAYTOADDRESS + elif addrtype == ADDRTYPE_P2SH: + txoutputtype.script_type = self.types.PAYTOSCRIPTHASH + else: + raise BaseException('addrtype') txoutputtype.address = address outputs.append(txoutputtype)