Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/embit/liquid/pset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ def blinded_vin(self):
witness=TxInWitness(self.issue_rangeproof, self.token_rangeproof),
)

def read_value(self, stream, k):
def read_value(self, stream, k, version=None):
# standard bitcoin stuff
if (b"\xfc\x08elements" not in k) and (b"\xfc\x04pset" not in k):
super().read_value(stream, k)
super().read_value(stream, k, version=version)
elif k == b"\xfc\x04pset\x0e":
# range proof is very large,
# so we don't load it if compress flag is set.
Expand Down Expand Up @@ -386,9 +386,9 @@ def reblind(self, nonce, blinding_pubkey=None, extra_message=b""):
secp256k1.generator_parse(self.asset_commitment),
)

def read_value(self, stream, k):
def read_value(self, stream, k, version=None):
if (b"\xfc\x08elements" not in k) and (b"\xfc\x04pset" not in k):
super().read_value(stream, k)
super().read_value(stream, k, version=version)
# range proof and surjection proof are very large,
# so we don't load them if compress flag is set.
elif k in [b"\xfc\x08elements\x04", b"\xfc\x04pset\x04"]:
Expand Down Expand Up @@ -503,6 +503,18 @@ class PSET(PSBT):
PSBTOUT_CLS = LOutputScope
TX_CLS = LTransaction

@classmethod
def _validate_v2_output(cls, out, i):
"""PSET allows value_commitment as an alternative to value (blinded outputs)."""
if out.value is None and not getattr(out, "value_commitment", None):
raise PSBTError(
"PSBTv2 output %d missing required PSBT_OUT_AMOUNT (0x03)" % i
)
if out.script_pubkey is None:
raise PSBTError(
"PSBTv2 output %d missing required PSBT_OUT_SCRIPT (0x04)" % i
)

def unblind(self, blinding_key):
for inp in self.inputs:
inp.unblind(blinding_key)
Expand Down
Loading
Loading