Skip to content

Commit

Permalink
psbt: Allow PSBTs to have both non_witness_utxo and witness_utxo
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Jun 6, 2020
1 parent 25e6d07 commit 65c6de6
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions hwilib/serializations.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def serialize(self):
tx = self.non_witness_utxo.serialize_with_witness()
r += ser_string(tx)

elif self.witness_utxo:
if self.witness_utxo:
r += ser_string(b"\x01")
tx = self.witness_utxo.serialize()
r += ser_string(tx)
Expand Down Expand Up @@ -623,19 +623,6 @@ def serialize(self):

return r

def is_sane(self):
# Cannot have both witness and non-witness utxos
if self.witness_utxo and self.non_witness_utxo:
return False

# if we have witness script or scriptwitness, must have witness utxo
if len(self.witness_script) != 0 and not self.witness_utxo:
return False
if not self.final_script_witness.is_null() and not self.witness_utxo:
return False

return True

class PartiallySignedOutput:
def __init__(self):
self.redeem_script = b""
Expand Down Expand Up @@ -795,9 +782,6 @@ def deserialize(self, psbt):
if len(self.outputs) != len(self.tx.vout):
raise PSBTSerializationError("Outputs provided does not match the number of outputs in transaction")

if not self.is_sane():
raise PSBTSerializationError("PSBT is not sane")

def serialize(self):
r = b""

Expand Down Expand Up @@ -831,12 +815,6 @@ def serialize(self):
# return hex string
return HexToBase64(binascii.hexlify(r)).decode()

def is_sane(self):
for input in self.inputs:
if not input.is_sane():
return False
return True

# An extended public key (xpub) or private key (xprv). Just a data container for now.
# Only handles deserialization of extended keys into component data to be handled by something else
class ExtendedKey(object):
Expand Down

0 comments on commit 65c6de6

Please sign in to comment.