Peer

@ObsoleteCoroutinesApi
class Peer(nodeParams: NodeParams, walletParams: WalletParams, watcher: ElectrumWatcher, db: Databases, socketBuilder: TcpSocket.Builder?, scope: CoroutineScope, initTlvStream: TlvStream<InitTlv>) : CoroutineScope

The peer we establish a connection to. This object contains the TCP socket, a flow of the channels with that peer, and watches the events on those channels and processes the relevant actions. The dialogue with the peer is done in coroutines.

Parameters

nodeParams

Low level, Lightning related parameters that our node will use in relation to this Peer.

walletParams

High level parameters for our node. It especially contains the Peer's NodeUri.

watcher

Watches events from the Electrum client and publishes transactions and events.

db

Wraps the various databases persisting the channels and payments data related to the Peer.

socketBuilder

Builds the TCP socket used to connect to the Peer.

initTlvStream

Optional stream of TLV for the Init message we send to this Peer after connection. Empty by default.

Constructors

Peer
Link copied to clipboard
common
fun Peer(nodeParams: NodeParams, walletParams: WalletParams, watcher: ElectrumWatcher, db: Databases, socketBuilder: TcpSocket.Builder?, scope: CoroutineScope, initTlvStream: TlvStream<InitTlv> = TlvStream.empty())

Types

Companion
Link copied to clipboard
common
object Companion

Functions

connect
Link copied to clipboard
common
fun connect()
disconnect
Link copied to clipboard
common
fun disconnect()
openListenerEventSubscription
Link copied to clipboard
common
fun openListenerEventSubscription(): ReceiveChannel<PeerListenerEvent>
registerFcmToken
Link copied to clipboard
common
fun registerFcmToken(token: String?)
send
Link copied to clipboard
common
suspend fun send(event: PeerEvent)
sendToPeer
Link copied to clipboard
common
suspend fun sendToPeer(msg: LightningMessage)

Properties

bootChannelsFlow
Link copied to clipboard
common
val bootChannelsFlow: StateFlow<Map<ByteVector32, ChannelState>?>
channels
Link copied to clipboard
common
val channels: Map<ByteVector32, ChannelState>
channelsFlow
Link copied to clipboard
common
val channelsFlow: StateFlow<Map<ByteVector32, ChannelState>>
connectionState
Link copied to clipboard
common
val connectionState: StateFlow<Connection>
coroutineContext
Link copied to clipboard
common
open override val coroutineContext: CoroutineContext
currentTipFlow
Link copied to clipboard
common
val currentTipFlow: MutableStateFlow<Pair<Int, BlockHeader>?>
db
Link copied to clipboard
common
val db: Databases
nodeParams
Link copied to clipboard
common
val nodeParams: NodeParams
onChainFeeratesFlow
Link copied to clipboard
common
val onChainFeeratesFlow: MutableStateFlow<OnChainFeerates?>
outputLightningMessages
Link copied to clipboard
common
val outputLightningMessages: ReceiveChannel<ByteArray>
remoteNodeId
Link copied to clipboard
common
val remoteNodeId: PublicKey
socketBuilder
Link copied to clipboard
common
var socketBuilder: TcpSocket.Builder?
walletParams
Link copied to clipboard
common
val walletParams: WalletParams
watcher
Link copied to clipboard
common
val watcher: ElectrumWatcher