Class Channel

class Channel ;

Constructors

NameDescription
this (flash_conf, conf, kp, priv_nonce, peer_nonce, peer, engine, taskman, txPublisher, paymentRouter, onChannelNotify, onPaymentComplete, onUpdateComplete, getFeeUTXOs, db) Constructor for new channels.
this (key, chan_id, flash_conf, engine, taskman, txPublisher, paymentRouter, onChannelNotify, onPaymentComplete, onUpdateComplete, getFeeUTXOs, makeFlashClient, db) Constructor for loading existing channels from the DB.

Fields

NameTypeDescription
peer FlashAPIThe peer of the other end of the channel
taskman ITaskManagerTask manager to spawn fibers with
txPublisher TransactionResult delegate(in ref Transaction) constUsed to publish funding / trigger / update / settlement txs to blockchain

Methods

NameDescription
applyChannelUpdate (update) Apply the given update to Channel if possible
beginCollaborativeClose (fee) Begin a collaborative close of the channel.
beginUnilateralClose () Begin a collaborative close of the channel.
buildUpdatedBalance (direction, old_balance, amount, payment_hash, lock_height, height) Add a new HTLC to the balance and fold any HTLCs for which the timeout has expired.
dump () Serialize and dump the channel metadata to the database.
foldHTLCs (old_balance, secrets, revert_htlcs, height) Fold HTLCs for which we've learned the secrets for or which have their lock time expired.
forwardPaymentError (error) Forwards the error information to previous node if this channel was a part of the route
getBalance (direction)
getChannelUpdate ()
getOurBalance ()
getState ()
isCollectingSignatures ()
isOpen ()
learnSecrets (secrets, revert_htlcs, height) Called to check if this channel has any payment hashes for which the provided secrets hash to. If they do, a new update will be requested with the counter-party.
loadChannels (flash_conf, db, makeFlashClient, engine, taskman, txPublisher, paymentRouter, onChannelNotify, onPaymentComplete, onUpdateComplete, getFeeUTXOs) Load all known channels from the database and return it in a map.
onBlockExternalized (block) Called when a new block has been externalized.
onProposedPayment (seq_id, payment_hash, amount, lock_height, packet, payload, peer_nonce, height, shared_secret) Called by a counter-party node when it wants to propose a new payment.
onProposedUpdate (seq_id, secrets, revert_htlcs, peer_nonce, height) Called by a counter-party when it wants to fold HTLCs by revealing secrets or when forced to spend HTLCs for which the time locks have expired.
onRequestSettleSig (seq_id) Called when the counter-party requests a settlement signature. If the sequence ID is unrecognized, it will return an error code.
onRequestUpdateSig (seq_id) Called when the counter-party requests an update signature. If the sequence ID is unrecognized, it will return an error code.
onUpdateTxExternalized (tx, utxo_idx, is_last) Called when the trigger / update transaction of this channel has been either detected in one of the nodes' transaction pools, or if it was externalized in the blockchain.
queueNewPayment (payment_hash, amount, lock_height, packet, height) Queue a payment to be routed through this channel. This could be for our own payment, or forwarded from another node.
requestCloseChannel (seq_id, peer_nonce, fee) Attempt to collaboratively close the channel.
requestCloseSig (seq_id) Requests the signature for the closing transaction from this node.
start () Start the setup stage of the channel. Should only be called once.
publishSettlementTx (update) Prepare the settlement TX and publish
publishUpdateTx (update) Prepare the update TX and publish