1
0

[TREZOR] Added Segwit support.

Following changes were necessary outside the TREZOR plugin.
- transaction.py: update_transaction handles segwit transactions.
- keystore.py: added a segwit parameter to bip44_derivation,
  use m/49' instead of m/44' for segwit.
This commit is contained in:
Jochen Hoenicke
2017-08-16 15:45:38 +02:00
parent fbe27fce04
commit ec0de566a8
4 changed files with 30 additions and 18 deletions

View File

@@ -227,7 +227,7 @@ class BaseWizard(object):
self.derivation_dialog(f)
def derivation_dialog(self, f):
default = bip44_derivation(0)
default = bip44_derivation(0, self.config.get('segwit'))
message = '\n'.join([
_('Enter your wallet derivation here.'),
_('If you are not sure what this is, leave this field unchanged.')

View File

@@ -684,11 +684,10 @@ is_private_key = lambda x: is_xprv(x) or is_private_key_list(x)
is_bip32_key = lambda x: is_xprv(x) or is_xpub(x)
def bip44_derivation(account_id):
if bitcoin.TESTNET:
return "m/44'/1'/%d'"% int(account_id)
else:
return "m/44'/0'/%d'"% int(account_id)
def bip44_derivation(account_id, segwit=False):
bip = 49 if segwit else 44
coin = 1 if bitcoin.TESTNET else 0
return "m/%d'/%d'/%d'" % (bip, coin, int(account_id))
def from_seed(seed, passphrase):
t = seed_type(seed)

View File

@@ -421,8 +421,7 @@ def parse_input(vds):
def parse_witness(vds):
n = vds.read_compact_size()
for i in range(n):
x = vds.read_bytes(vds.read_compact_size())
return list(vds.read_bytes(vds.read_compact_size()).encode('hex') for i in xrange(n))
def parse_output(vds, i):
d = {}
@@ -548,7 +547,12 @@ class Transaction:
for i, txin in enumerate(self.inputs()):
pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin)
sigs1 = txin.get('signatures')
sigs2 = d['inputs'][i].get('signatures')
if d.get('witness') is None:
sigs2 = d['inputs'][i].get('signatures')
else:
# signatures are in the witnesses. But the last item is
# the pubkey or the multisig script, so skip that.
sigs2 = d['witness'][i][:-1]
for sig in sigs2:
if sig in sigs1:
continue