ttrezor/keepkey separation: tx output type - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 1359fac4c9b2166362c8b8498433e1168fec5ee1 DIR parent 65c15c5a03ecd9dbe706141bcfd55c4ab72182f2 HTML Author: SomberNight <somber.night@protonmail.com> Date: Mon, 4 Dec 2017 18:05:03 +0100 ttrezor/keepkey separation: tx output type Diffstat: M plugins/keepkey/plugin.py | 14 ++++++++++++-- M plugins/trezor/plugin.py | 17 ++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) --- DIR diff --git a/plugins/keepkey/plugin.py b/plugins/keepkey/plugin.py t@@ -4,7 +4,8 @@ from binascii import hexlify, unhexlify from electrum.util import bfh, bh2u from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey, - TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants) + TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants, + is_segwit_address) from electrum.i18n import _ from electrum.plugins import BasePlugin from electrum.transaction import deserialize t@@ -351,7 +352,16 @@ class TrezorCompatiblePlugin(HW_PluginBase): txoutputtype.script_type = self.types.PAYTOOPRETURN txoutputtype.op_return_data = address[2:] elif _type == TYPE_ADDRESS: - txoutputtype.script_type = self.types.PAYTOADDRESS + if is_segwit_address(address): + txoutputtype.script_type = self.types.PAYTOWITNESS + else: + addrtype, hash_160 = b58_address_to_hash160(address) + if addrtype == NetworkConstants.ADDRTYPE_P2PKH: + txoutputtype.script_type = self.types.PAYTOADDRESS + elif addrtype == NetworkConstants.ADDRTYPE_P2SH: + txoutputtype.script_type = self.types.PAYTOSCRIPTHASH + else: + raise BaseException('addrtype: ' + str(addrtype)) txoutputtype.address = address outputs.append(txoutputtype) DIR diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py t@@ -4,8 +4,7 @@ from binascii import hexlify, unhexlify from electrum.util import bfh, bh2u from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey, - TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants, - is_segwit_address) + TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants) from electrum.i18n import _ from electrum.plugins import BasePlugin from electrum.transaction import deserialize t@@ -352,19 +351,7 @@ class TrezorCompatiblePlugin(HW_PluginBase): txoutputtype.script_type = self.types.PAYTOOPRETURN txoutputtype.op_return_data = address[2:] elif _type == TYPE_ADDRESS: - # trezor would be fine with self.types.PAYTOADDRESS - # for any non-change output - # but we need to maintain keepkey compatibility in this cls - if is_segwit_address(address): - txoutputtype.script_type = self.types.PAYTOWITNESS - else: - addrtype, hash_160 = b58_address_to_hash160(address) - if addrtype == NetworkConstants.ADDRTYPE_P2PKH: - txoutputtype.script_type = self.types.PAYTOADDRESS - elif addrtype == NetworkConstants.ADDRTYPE_P2SH: - txoutputtype.script_type = self.types.PAYTOSCRIPTHASH - else: - raise BaseException('addrtype: ' + str(addrtype)) + txoutputtype.script_type = self.types.PAYTOADDRESS txoutputtype.address = address outputs.append(txoutputtype)