ChannelState class

State for a payment channel aggregate

Represents the current state of a payment channel at a specific point in time. This state is rebuilt from events during aggregate recovery.

Immutable (bead libspiffy-mmb): every field is final and fundingAncestorTxids is an unmodifiable copy. Applying an event produces a new state with copyWith.

Constructors

ChannelState({required String channelId, String? walletId, ChannelStatus status = ChannelStatus.pending, ChannelRole? role, String? clientPeerId, String? serverPeerId, String? clientPubKeyHex, String? serverPubKeyHex, String? clientAddressB58, String? serverAddressB58, int? derivationIndex, BigInt? fundingAmountSats, String? fundingTxId, String? fundingTxHex, int? fundingOutputIndex, List<String>? fundingAncestorTxids, String? fundingBeefHex, int? fundingInputSats, int fundingBroadcastAttempts = 0, bool fundingBroadcastInFlight = false, String? fundingBroadcastError, bool fundingRecordedInWallet = false, bool fundingSent = false, bool fundingFailed = false, int? lockTimeUnix, String? refundTxHex, String? refundClientSigHex, String? refundServerSigHex, String? signedRefundTxHex, BigInt? clientBalanceSats, BigInt? serverBalanceSats, int latestSequenceNumber = 0, String? latestPaymentTxHex, String? latestPaymentTxId, String? latestClientSignatureHex, bool returnLegRecordedInWallet = false, String? context, String? counterpartyMarker, DateTime? createdAt, String? refundClaimedTxId, DateTime? closedAt, int version = 0, DateTime? lastModified})
ChannelState.empty(String channelId)
Create empty initial state
factory

Properties

channelId → String
final
clientAddressB58 → String?
final
clientBalanceSats → BigInt
final
clientPeerId → String?
final
clientPubKeyHex → String?
final
closedAt → DateTime?
final
context → String?
final
counterpartyMarker → String?
The app's opaque marker for the counterparty of this channel (bead libspiffy-bps1, spv-understanding.md "Core Data Management" requirement 5), journaled with the request or the acceptance.
final
createdAt → DateTime?
final
derivationIndex → int?
final
fundingAmountSats → BigInt
final
fundingAncestorTxids → List<String>
final
fundingBeefHex → String?
BEEF of the funding transaction journaled with the opening.
final
fundingBroadcastAttempts → int
Broadcasts of the funding transaction started so far (client).
final
fundingBroadcastError → String?
Error of the last failed funding broadcast, cleared by the next start.
final
fundingBroadcastInFlight → bool
A funding broadcast was started and has not failed (client): the channel may be opened for it.
final
fundingFailed → bool
The sent funding can never be mined (bead libspiffy-4kfq): the channel never opens, and nothing more is sent for it.
final
fundingInputSats → int?
Total input value of the funding transaction, when known.
final
fundingOutputIndex → int?
final
fundingRecordedInWallet → bool
The funding transaction is recorded in the client wallet.
final
fundingSent → bool
ARC took the client's funding broadcast (bead libspiffy-jark): the client sends channel_open and opens when the server says it has.
final
fundingTxHex → String?
final
fundingTxId → String?
final
hashCode → int
The hash code for this object.
no setterinherited
isClient → bool
no setter
isExpired → bool
no setter
isOpen → bool
no setter
isServer → bool
no setter
lastModified → DateTime
Timestamp when this state was last modified
final
latestClientSignatureHex → String?
The client's signature on latestPaymentTxHex, on the client's side: what a close sends with the latest payment, so the server is paid it even when its payment_update was lost.
final
latestPaymentTxHex → String?
final
latestPaymentTxId → String?
final
latestSequenceNumber → int
final
lockTimeUnix → int?
final
refundClaimedTxId → String?
The refund transaction this channel's refund was claimed with, once a claim has been journaled (bead libspiffy-07mx).
final
refundClientSigHex → String?
final
refundServerSigHex → String?
final
refundTxHex → String?
The refund template as built (unsigned), or on the server side the refund it signed.
final
remainingBalance → BigInt
no setter
returnLegRecordedInWallet → bool
Whether this side's wallet already holds the transaction that ended the channel and paid it back (bead libspiffy-lfrv). The counterpart of fundingRecordedInWallet; what lets a close or an expiry interrupted before its wallet write be resumed.
final
role → ChannelRole?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serverAddressB58 → String?
final
serverBalanceSats → BigInt
final
serverPeerId → String?
final
serverPubKeyHex → String?
final
signedRefundTxHex → String?
The fully signed refund the client holds, verified against the funding output (libspiffy-b83).
final
status → ChannelStatus
final
totalPaid → BigInt
no setter
typeName → String
Stable identity of this state type in storage.
no setterinherited
version → int
Version of this state Used for optimistic concurrency control
final
walletId → String?
final

Methods

copyWith({int? version, DateTime? lastModified, Object? walletId = _unset, ChannelStatus? status, Object? role = _unset, Object? clientPeerId = _unset, Object? serverPeerId = _unset, Object? clientPubKeyHex = _unset, Object? serverPubKeyHex = _unset, Object? clientAddressB58 = _unset, Object? serverAddressB58 = _unset, Object? derivationIndex = _unset, BigInt? fundingAmountSats, Object? fundingTxId = _unset, Object? fundingTxHex = _unset, Object? fundingOutputIndex = _unset, List<String>? fundingAncestorTxids, Object? fundingBeefHex = _unset, Object? fundingInputSats = _unset, int? fundingBroadcastAttempts, bool? fundingBroadcastInFlight, Object? fundingBroadcastError = _unset, bool? fundingRecordedInWallet, bool? fundingSent, bool? fundingFailed, Object? lockTimeUnix = _unset, Object? refundTxHex = _unset, Object? refundClientSigHex = _unset, Object? refundServerSigHex = _unset, Object? signedRefundTxHex = _unset, BigInt? clientBalanceSats, BigInt? serverBalanceSats, int? latestSequenceNumber, Object? latestPaymentTxHex = _unset, Object? latestPaymentTxId = _unset, Object? latestClientSignatureHex = _unset, bool? returnLegRecordedInWallet, Object? context = _unset, Object? counterpartyMarker = _unset, Object? createdAt = _unset, Object? refundClaimedTxId = _unset, Object? closedAt = _unset}) → ChannelState
A copy of this state with the given fields replaced. The nullable fields take an explicit null (e.g. fundingBroadcastError: null clears it); a field not given keeps its value.
getValidationErrors() → List<String>
Get validation errors Override in subclasses to provide specific error messages
inherited
isNewerThan(State other) → bool
Check if this state is newer than another state
inherited
isSameVersion(State other) → bool
Check if this state is the same version as another state
inherited
isValid() → bool
Validate the state Override in subclasses for custom validation
inherited
nextVersion([DateTime? timestamp]) → State
Create a new version of this state with incremented version
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() → Map<String, dynamic>
Convert state to a map for serialization.
inherited
toString() → String
A string representation of this object.

Operators

operator ==(Object other) → bool
The equality operator.
inherited