# automatically generated by the FlatBuffers compiler, do not modify

# namespace: xbr

import flatbuffers

# /// XBR payment channel (from XBR consumer to XBR market maker) and XBR paying channels (from XBR market maker to XBR provider).
class PaymentChannel(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAsPaymentChannel(cls, buf, offset):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = PaymentChannel()
        x.Init(buf, n + offset)
        return x

    # PaymentChannel
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

# /// Channel type: payment channel (from XBR consumer to XBR market maker) or paying channel (from XBR market maker to XBR provider).
    # PaymentChannel
    def Type(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0

# /// ID of the payment channel.
    # PaymentChannel
    def Channel(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def ChannelAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def ChannelLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// ID of the market this payment channel is associated with.
    # PaymentChannel
    def Market(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def MarketAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def MarketLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Ethereum address of the sender (either XBR Consumer or XBR Market).
    # PaymentChannel
    def Sender(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def SenderAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def SenderLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Ethereum address of the sender delegate (either XBR Consumer delegate or XBR Market delegate == market maker)
    # PaymentChannel
    def Delegate(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def DelegateAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def DelegateLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Ethereum address of the recipient (either XBR Market or XBR Provider)
    # PaymentChannel
    def Recipient(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def RecipientAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def RecipientLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Amount of XBR tokens initially deposited into the payment channel.
    # PaymentChannel
    def Amount(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def AmountAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def AmountLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Payment channel (non-cooperative) closed timeout in blocks (on the blockchain).
    # PaymentChannel
    def Timeout(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
        return 0

# /// Current state of payment channel.
    # PaymentChannel
    def State(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0

# /// Block number (on the blockchain) when the payment channel was opened.
    # PaymentChannel
    def OpenAt(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def OpenAtAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def OpenAtLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Block number (on the blockchain) when the payment channel will close (at the latest).
    # PaymentChannel
    def ClosingAt(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def ClosingAtAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def ClosingAtLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Block number (on the blockchain) when the payment channel was finally closed.
    # PaymentChannel
    def ClosedAt(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def ClosedAtAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def ClosedAtLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Closing signature by market maker.
    # PaymentChannel
    def CloseMmSig(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def CloseMmSigAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def CloseMmSigLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Closing signature by (seller or buyer) delegate.
    # PaymentChannel
    def CloseDelSig(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def CloseDelSigAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def CloseDelSigLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Last off-chain, closing transaction: channel transaction sequence number.
    # PaymentChannel
    def CloseChannelSeq(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
        return 0

# /// Remaining (closing) channel balance (XBR).
    # PaymentChannel
    def CloseBalance(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def CloseBalanceAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def CloseBalanceLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(34))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

# /// Flag indication if close is final (happens immediately without a channel timeout).
    # PaymentChannel
    def CloseIsFinal(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(36))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

# /// When channel was finally closed on-chain, the Ethereum transaction ID.
    # PaymentChannel
    def ClosedTx(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(38))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # PaymentChannel
    def ClosedTxAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(38))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # PaymentChannel
    def ClosedTxLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(38))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

def PaymentChannelStart(builder): builder.StartObject(18)
def PaymentChannelAddType(builder, type): builder.PrependUint8Slot(0, type, 0)
def PaymentChannelAddChannel(builder, channel): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(channel), 0)
def PaymentChannelStartChannelVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddMarket(builder, market): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(market), 0)
def PaymentChannelStartMarketVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddSender(builder, sender): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(sender), 0)
def PaymentChannelStartSenderVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddDelegate(builder, delegate): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(delegate), 0)
def PaymentChannelStartDelegateVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddRecipient(builder, recipient): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(recipient), 0)
def PaymentChannelStartRecipientVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddAmount(builder, amount): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(amount), 0)
def PaymentChannelStartAmountVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddTimeout(builder, timeout): builder.PrependUint32Slot(7, timeout, 0)
def PaymentChannelAddState(builder, state): builder.PrependUint8Slot(8, state, 0)
def PaymentChannelAddOpenAt(builder, openAt): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(openAt), 0)
def PaymentChannelStartOpenAtVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddClosingAt(builder, closingAt): builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(closingAt), 0)
def PaymentChannelStartClosingAtVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddClosedAt(builder, closedAt): builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(closedAt), 0)
def PaymentChannelStartClosedAtVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddCloseMmSig(builder, closeMmSig): builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(closeMmSig), 0)
def PaymentChannelStartCloseMmSigVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddCloseDelSig(builder, closeDelSig): builder.PrependUOffsetTRelativeSlot(13, flatbuffers.number_types.UOffsetTFlags.py_type(closeDelSig), 0)
def PaymentChannelStartCloseDelSigVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddCloseChannelSeq(builder, closeChannelSeq): builder.PrependUint32Slot(14, closeChannelSeq, 0)
def PaymentChannelAddCloseBalance(builder, closeBalance): builder.PrependUOffsetTRelativeSlot(15, flatbuffers.number_types.UOffsetTFlags.py_type(closeBalance), 0)
def PaymentChannelStartCloseBalanceVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelAddCloseIsFinal(builder, closeIsFinal): builder.PrependBoolSlot(16, closeIsFinal, 0)
def PaymentChannelAddClosedTx(builder, closedTx): builder.PrependUOffsetTRelativeSlot(17, flatbuffers.number_types.UOffsetTFlags.py_type(closedTx), 0)
def PaymentChannelStartClosedTxVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def PaymentChannelEnd(builder): return builder.EndObject()
