All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lnrpc.HTLCAttempt.scala Maven / Gradle / Ivy

The newest version!
// Generated by the Scala Plugin for the Protocol Buffer Compiler.
// Do not edit!
//
// Protofile syntax: PROTO3

package lnrpc
import org.bitcoins.lnd.rpc.LndUtils._

/** @param attemptId
  *   The unique ID that is used for this attempt.
  * @param status
  *   The status of the HTLC.
  * @param route
  *   The route taken by this HTLC.
  * @param attemptTimeNs
  *   The time in UNIX nanoseconds at which this HTLC was sent.
  * @param resolveTimeNs
  *  
  *  The time in UNIX nanoseconds at which this HTLC was settled or failed.
  *  This value will not be set if the HTLC is still IN_FLIGHT.
  * @param failure
  *   Detailed htlc failure info.
  * @param preimage
  *   The preimage that was used to settle the HTLC.
  */
@SerialVersionUID(0L)
final case class HTLCAttempt(
    attemptId: org.bitcoins.core.number.UInt64 = lnrpc.HTLCAttempt._typemapper_attemptId.toCustom(0L),
    status: lnrpc.HTLCAttempt.HTLCStatus = lnrpc.HTLCAttempt.HTLCStatus.IN_FLIGHT,
    route: _root_.scala.Option[lnrpc.Route] = _root_.scala.None,
    attemptTimeNs: _root_.scala.Long = 0L,
    resolveTimeNs: _root_.scala.Long = 0L,
    failure: _root_.scala.Option[lnrpc.Failure] = _root_.scala.None,
    preimage: _root_.com.google.protobuf.ByteString = _root_.com.google.protobuf.ByteString.EMPTY,
    unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty
    ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[HTLCAttempt] {
    @transient
    private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
    private[this] def __computeSerializedSize(): _root_.scala.Int = {
      var __size = 0
      
      {
        val __value = lnrpc.HTLCAttempt._typemapper_attemptId.toBase(attemptId)
        if (__value != 0L) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeUInt64Size(7, __value)
        }
      };
      
      {
        val __value = status.value
        if (__value != 0) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeEnumSize(1, __value)
        }
      };
      if (route.isDefined) {
        val __value = route.get
        __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize
      };
      
      {
        val __value = attemptTimeNs
        if (__value != 0L) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeInt64Size(3, __value)
        }
      };
      
      {
        val __value = resolveTimeNs
        if (__value != 0L) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeInt64Size(4, __value)
        }
      };
      if (failure.isDefined) {
        val __value = failure.get
        __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize
      };
      
      {
        val __value = preimage
        if (!__value.isEmpty) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeBytesSize(6, __value)
        }
      };
      __size += unknownFields.serializedSize
      __size
    }
    override def serializedSize: _root_.scala.Int = {
      var __size = __serializedSizeMemoized
      if (__size == 0) {
        __size = __computeSerializedSize() + 1
        __serializedSizeMemoized = __size
      }
      __size - 1
      
    }
    def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
      {
        val __v = status.value
        if (__v != 0) {
          _output__.writeEnum(1, __v)
        }
      };
      route.foreach { __v =>
        val __m = __v
        _output__.writeTag(2, 2)
        _output__.writeUInt32NoTag(__m.serializedSize)
        __m.writeTo(_output__)
      };
      {
        val __v = attemptTimeNs
        if (__v != 0L) {
          _output__.writeInt64(3, __v)
        }
      };
      {
        val __v = resolveTimeNs
        if (__v != 0L) {
          _output__.writeInt64(4, __v)
        }
      };
      failure.foreach { __v =>
        val __m = __v
        _output__.writeTag(5, 2)
        _output__.writeUInt32NoTag(__m.serializedSize)
        __m.writeTo(_output__)
      };
      {
        val __v = preimage
        if (!__v.isEmpty) {
          _output__.writeBytes(6, __v)
        }
      };
      {
        val __v = lnrpc.HTLCAttempt._typemapper_attemptId.toBase(attemptId)
        if (__v != 0L) {
          _output__.writeUInt64(7, __v)
        }
      };
      unknownFields.writeTo(_output__)
    }
    def withAttemptId(__v: org.bitcoins.core.number.UInt64): HTLCAttempt = copy(attemptId = __v)
    def withStatus(__v: lnrpc.HTLCAttempt.HTLCStatus): HTLCAttempt = copy(status = __v)
    def getRoute: lnrpc.Route = route.getOrElse(lnrpc.Route.defaultInstance)
    def clearRoute: HTLCAttempt = copy(route = _root_.scala.None)
    def withRoute(__v: lnrpc.Route): HTLCAttempt = copy(route = Option(__v))
    def withAttemptTimeNs(__v: _root_.scala.Long): HTLCAttempt = copy(attemptTimeNs = __v)
    def withResolveTimeNs(__v: _root_.scala.Long): HTLCAttempt = copy(resolveTimeNs = __v)
    def getFailure: lnrpc.Failure = failure.getOrElse(lnrpc.Failure.defaultInstance)
    def clearFailure: HTLCAttempt = copy(failure = _root_.scala.None)
    def withFailure(__v: lnrpc.Failure): HTLCAttempt = copy(failure = Option(__v))
    def withPreimage(__v: _root_.com.google.protobuf.ByteString): HTLCAttempt = copy(preimage = __v)
    def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
    def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
    def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
      (__fieldNumber: @_root_.scala.unchecked) match {
        case 7 => {
          val __t = lnrpc.HTLCAttempt._typemapper_attemptId.toBase(attemptId)
          if (__t != 0L) __t else null
        }
        case 1 => {
          val __t = status.javaValueDescriptor
          if (__t.getNumber() != 0) __t else null
        }
        case 2 => route.orNull
        case 3 => {
          val __t = attemptTimeNs
          if (__t != 0L) __t else null
        }
        case 4 => {
          val __t = resolveTimeNs
          if (__t != 0L) __t else null
        }
        case 5 => failure.orNull
        case 6 => {
          val __t = preimage
          if (__t != _root_.com.google.protobuf.ByteString.EMPTY) __t else null
        }
      }
    }
    def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
      _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor)
      (__field.number: @_root_.scala.unchecked) match {
        case 7 => _root_.scalapb.descriptors.PLong(lnrpc.HTLCAttempt._typemapper_attemptId.toBase(attemptId))
        case 1 => _root_.scalapb.descriptors.PEnum(status.scalaValueDescriptor)
        case 2 => route.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        case 3 => _root_.scalapb.descriptors.PLong(attemptTimeNs)
        case 4 => _root_.scalapb.descriptors.PLong(resolveTimeNs)
        case 5 => failure.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        case 6 => _root_.scalapb.descriptors.PByteString(preimage)
      }
    }
    def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
    def companion: lnrpc.HTLCAttempt.type = lnrpc.HTLCAttempt
    // @@protoc_insertion_point(GeneratedMessage[lnrpc.HTLCAttempt])
}

object HTLCAttempt extends scalapb.GeneratedMessageCompanion[lnrpc.HTLCAttempt] {
  implicit def messageCompanion: scalapb.GeneratedMessageCompanion[lnrpc.HTLCAttempt] = this
  def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): lnrpc.HTLCAttempt = {
    var __attemptId: _root_.scala.Long = 0L
    var __status: lnrpc.HTLCAttempt.HTLCStatus = lnrpc.HTLCAttempt.HTLCStatus.IN_FLIGHT
    var __route: _root_.scala.Option[lnrpc.Route] = _root_.scala.None
    var __attemptTimeNs: _root_.scala.Long = 0L
    var __resolveTimeNs: _root_.scala.Long = 0L
    var __failure: _root_.scala.Option[lnrpc.Failure] = _root_.scala.None
    var __preimage: _root_.com.google.protobuf.ByteString = _root_.com.google.protobuf.ByteString.EMPTY
    var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null
    var _done__ = false
    while (!_done__) {
      val _tag__ = _input__.readTag()
      _tag__ match {
        case 0 => _done__ = true
        case 56 =>
          __attemptId = _input__.readUInt64()
        case 8 =>
          __status = lnrpc.HTLCAttempt.HTLCStatus.fromValue(_input__.readEnum())
        case 18 =>
          __route = Option(__route.fold(_root_.scalapb.LiteParser.readMessage[lnrpc.Route](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _)))
        case 24 =>
          __attemptTimeNs = _input__.readInt64()
        case 32 =>
          __resolveTimeNs = _input__.readInt64()
        case 42 =>
          __failure = Option(__failure.fold(_root_.scalapb.LiteParser.readMessage[lnrpc.Failure](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _)))
        case 50 =>
          __preimage = _input__.readBytes()
        case tag =>
          if (_unknownFields__ == null) {
            _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
          }
          _unknownFields__.parseField(tag, _input__)
      }
    }
    lnrpc.HTLCAttempt(
        attemptId = lnrpc.HTLCAttempt._typemapper_attemptId.toCustom(__attemptId),
        status = __status,
        route = __route,
        attemptTimeNs = __attemptTimeNs,
        resolveTimeNs = __resolveTimeNs,
        failure = __failure,
        preimage = __preimage,
        unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result()
    )
  }
  implicit def messageReads: _root_.scalapb.descriptors.Reads[lnrpc.HTLCAttempt] = _root_.scalapb.descriptors.Reads{
    case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
      _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.")
      lnrpc.HTLCAttempt(
        attemptId = lnrpc.HTLCAttempt._typemapper_attemptId.toCustom(__fieldsMap.get(scalaDescriptor.findFieldByNumber(7).get).map(_.as[_root_.scala.Long]).getOrElse(0L)),
        status = lnrpc.HTLCAttempt.HTLCStatus.fromValue(__fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scalapb.descriptors.EnumValueDescriptor]).getOrElse(lnrpc.HTLCAttempt.HTLCStatus.IN_FLIGHT.scalaValueDescriptor).number),
        route = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).flatMap(_.as[_root_.scala.Option[lnrpc.Route]]),
        attemptTimeNs = __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.scala.Long]).getOrElse(0L),
        resolveTimeNs = __fieldsMap.get(scalaDescriptor.findFieldByNumber(4).get).map(_.as[_root_.scala.Long]).getOrElse(0L),
        failure = __fieldsMap.get(scalaDescriptor.findFieldByNumber(5).get).flatMap(_.as[_root_.scala.Option[lnrpc.Failure]]),
        preimage = __fieldsMap.get(scalaDescriptor.findFieldByNumber(6).get).map(_.as[_root_.com.google.protobuf.ByteString]).getOrElse(_root_.com.google.protobuf.ByteString.EMPTY)
      )
    case _ => throw new RuntimeException("Expected PMessage")
  }
  def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = LightningProto.javaDescriptor.getMessageTypes().get(137)
  def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = LightningProto.scalaDescriptor.messages(137)
  def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = {
    var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null
    (__number: @_root_.scala.unchecked) match {
      case 2 => __out = lnrpc.Route
      case 5 => __out = lnrpc.Failure
    }
    __out
  }
  lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty
  def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = {
    (__fieldNumber: @_root_.scala.unchecked) match {
      case 1 => lnrpc.HTLCAttempt.HTLCStatus
    }
  }
  lazy val defaultInstance = lnrpc.HTLCAttempt(
    attemptId = lnrpc.HTLCAttempt._typemapper_attemptId.toCustom(0L),
    status = lnrpc.HTLCAttempt.HTLCStatus.IN_FLIGHT,
    route = _root_.scala.None,
    attemptTimeNs = 0L,
    resolveTimeNs = 0L,
    failure = _root_.scala.None,
    preimage = _root_.com.google.protobuf.ByteString.EMPTY
  )
  sealed abstract class HTLCStatus(val value: _root_.scala.Int) extends _root_.scalapb.GeneratedEnum {
    type EnumType = HTLCStatus
    def isInFlight: _root_.scala.Boolean = false
    def isSucceeded: _root_.scala.Boolean = false
    def isFailed: _root_.scala.Boolean = false
    def companion: _root_.scalapb.GeneratedEnumCompanion[HTLCStatus] = lnrpc.HTLCAttempt.HTLCStatus
    final def asRecognized: _root_.scala.Option[lnrpc.HTLCAttempt.HTLCStatus.Recognized] = if (isUnrecognized) _root_.scala.None else _root_.scala.Some(this.asInstanceOf[lnrpc.HTLCAttempt.HTLCStatus.Recognized])
  }
  
  object HTLCStatus extends _root_.scalapb.GeneratedEnumCompanion[HTLCStatus] {
    sealed trait Recognized extends HTLCStatus
    implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[HTLCStatus] = this
    
    @SerialVersionUID(0L)
    case object IN_FLIGHT extends HTLCStatus(0) with HTLCStatus.Recognized {
      val index = 0
      val name = "IN_FLIGHT"
      override def isInFlight: _root_.scala.Boolean = true
    }
    
    @SerialVersionUID(0L)
    case object SUCCEEDED extends HTLCStatus(1) with HTLCStatus.Recognized {
      val index = 1
      val name = "SUCCEEDED"
      override def isSucceeded: _root_.scala.Boolean = true
    }
    
    @SerialVersionUID(0L)
    case object FAILED extends HTLCStatus(2) with HTLCStatus.Recognized {
      val index = 2
      val name = "FAILED"
      override def isFailed: _root_.scala.Boolean = true
    }
    
    @SerialVersionUID(0L)
    final case class Unrecognized(unrecognizedValue: _root_.scala.Int) extends HTLCStatus(unrecognizedValue) with _root_.scalapb.UnrecognizedEnum
    lazy val values = scala.collection.immutable.Seq(IN_FLIGHT, SUCCEEDED, FAILED)
    def fromValue(__value: _root_.scala.Int): HTLCStatus = __value match {
      case 0 => IN_FLIGHT
      case 1 => SUCCEEDED
      case 2 => FAILED
      case __other => Unrecognized(__other)
    }
    def javaDescriptor: _root_.com.google.protobuf.Descriptors.EnumDescriptor = lnrpc.HTLCAttempt.javaDescriptor.getEnumTypes().get(0)
    def scalaDescriptor: _root_.scalapb.descriptors.EnumDescriptor = lnrpc.HTLCAttempt.scalaDescriptor.enums(0)
  }
  implicit class HTLCAttemptLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, lnrpc.HTLCAttempt]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, lnrpc.HTLCAttempt](_l) {
    def attemptId: _root_.scalapb.lenses.Lens[UpperPB, org.bitcoins.core.number.UInt64] = field(_.attemptId)((c_, f_) => c_.copy(attemptId = f_))
    def status: _root_.scalapb.lenses.Lens[UpperPB, lnrpc.HTLCAttempt.HTLCStatus] = field(_.status)((c_, f_) => c_.copy(status = f_))
    def route: _root_.scalapb.lenses.Lens[UpperPB, lnrpc.Route] = field(_.getRoute)((c_, f_) => c_.copy(route = Option(f_)))
    def optionalRoute: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[lnrpc.Route]] = field(_.route)((c_, f_) => c_.copy(route = f_))
    def attemptTimeNs: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Long] = field(_.attemptTimeNs)((c_, f_) => c_.copy(attemptTimeNs = f_))
    def resolveTimeNs: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Long] = field(_.resolveTimeNs)((c_, f_) => c_.copy(resolveTimeNs = f_))
    def failure: _root_.scalapb.lenses.Lens[UpperPB, lnrpc.Failure] = field(_.getFailure)((c_, f_) => c_.copy(failure = Option(f_)))
    def optionalFailure: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[lnrpc.Failure]] = field(_.failure)((c_, f_) => c_.copy(failure = f_))
    def preimage: _root_.scalapb.lenses.Lens[UpperPB, _root_.com.google.protobuf.ByteString] = field(_.preimage)((c_, f_) => c_.copy(preimage = f_))
  }
  final val ATTEMPT_ID_FIELD_NUMBER = 7
  final val STATUS_FIELD_NUMBER = 1
  final val ROUTE_FIELD_NUMBER = 2
  final val ATTEMPT_TIME_NS_FIELD_NUMBER = 3
  final val RESOLVE_TIME_NS_FIELD_NUMBER = 4
  final val FAILURE_FIELD_NUMBER = 5
  final val PREIMAGE_FIELD_NUMBER = 6
  @transient
  private[lnrpc] val _typemapper_attemptId: _root_.scalapb.TypeMapper[_root_.scala.Long, org.bitcoins.core.number.UInt64] = implicitly[_root_.scalapb.TypeMapper[_root_.scala.Long, org.bitcoins.core.number.UInt64]]
  def of(
    attemptId: org.bitcoins.core.number.UInt64,
    status: lnrpc.HTLCAttempt.HTLCStatus,
    route: _root_.scala.Option[lnrpc.Route],
    attemptTimeNs: _root_.scala.Long,
    resolveTimeNs: _root_.scala.Long,
    failure: _root_.scala.Option[lnrpc.Failure],
    preimage: _root_.com.google.protobuf.ByteString
  ): _root_.lnrpc.HTLCAttempt = _root_.lnrpc.HTLCAttempt(
    attemptId,
    status,
    route,
    attemptTimeNs,
    resolveTimeNs,
    failure,
    preimage
  )
  // @@protoc_insertion_point(GeneratedMessageCompanion[lnrpc.HTLCAttempt])
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy