lbry-sdk/lbrynet/extras/wallet/server/tx.py
2018-11-04 10:50:15 -05:00

21 lines
662 B
Python

from torba.server.tx import Deserializer
from .opcodes import decode_claim_script
from .model import TxClaimOutput, LBRYTx
class LBRYDeserializer(Deserializer):
def _read_output(self):
value = self._read_le_int64()
script = self._read_varbytes() # pk_script
claim = decode_claim_script(script)
claim = claim[0] if claim else None
return TxClaimOutput(value, script, claim)
def read_tx(self):
return LBRYTx(
self._read_le_int32(), # version
self._read_inputs(), # inputs
self._read_outputs(), # outputs
self._read_le_uint32() # locktime
)