Skip to content

Commit

Permalink
fix from_json for segwit transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Bronzini committed May 1, 2020
1 parent 8e75c63 commit 66ec55c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions btcpy/structs/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ class SegWitTransaction(BaseTransaction, Immutable):
@classmethod
def from_json(cls, tx_json):
tx = super().from_json(tx_json)
if any(txin.witness is None for txin in tx.ins):
if all(txin.witness is None for txin in tx.ins):
raise TypeError('Trying to load segwit transaction from non-segwit transaction json')
return tx

Expand Down Expand Up @@ -1027,7 +1027,7 @@ def unhexlify(cls, string, mutable=False):

@classmethod
def from_json(cls, tx_json, mutable=False):
segwit = all('txinwitness' in txin for txin in tx_json['vin'])
segwit = any('txinwitness' in txin for txin in tx_json['vin'])
if segwit:
return cls._get_class(segwit=True, mutable=mutable).from_json(tx_json)
else:
Expand Down

0 comments on commit 66ec55c

Please sign in to comment.