Table of Contents

Class MessageFactory

Namespace
NLightning.Application.Factories
Assembly
NLightning.Application.dll

Factory for creating messages.

public class MessageFactory : IMessageFactory
Inheritance
MessageFactory
Implements
Inherited Members

Constructors

MessageFactory(IOptions<NodeOptions>)

public MessageFactory(IOptions<NodeOptions> nodeOptions)

Parameters

nodeOptions IOptions<NodeOptions>

Methods

CreateAcceptChannel2Message(ChannelId, LightningMoney, PubKey, PubKey, PubKey, PubKey, PubKey, PubKey, Script?, byte[]?, bool)

Create a AcceptChannel2 message.

public AcceptChannel2Message CreateAcceptChannel2Message(ChannelId temporaryChannelId, LightningMoney fundingSatoshis, PubKey fundingPubKey, PubKey revocationBasepoint, PubKey paymentBasepoint, PubKey delayedPaymentBasepoint, PubKey htlcBasepoint, PubKey firstPerCommitmentPoint, Script? shutdownScriptPubkey = null, byte[]? channelType = null, bool requireConfirmedInputs = false)

Parameters

temporaryChannelId ChannelId

The temporary channel id.

fundingSatoshis LightningMoney

The amount of satoshis we're adding to the channel.

fundingPubKey PubKey

The funding pubkey of the channel.

revocationBasepoint PubKey

The revocation pubkey.

paymentBasepoint PubKey

The payment pubkey.

delayedPaymentBasepoint PubKey

The delayed payment pubkey.

htlcBasepoint PubKey

The htlc pubkey.

firstPerCommitmentPoint PubKey

The first per commitment pubkey.

shutdownScriptPubkey Script

The shutdown script to be used when closing the channel.

channelType byte[]

The type of the channel.

requireConfirmedInputs bool

If we want confirmed inputs to open the channel.

Returns

AcceptChannel2Message

The AcceptChannel2 message.

See Also
PubKey
Script

CreateChannelReadyMessage(ChannelId, PubKey, ShortChannelId?)

Create a ChannelReady message.

public ChannelReadyMessage CreateChannelReadyMessage(ChannelId channelId, PubKey secondPerCommitmentPoint, ShortChannelId? shortChannelId = null)

Parameters

channelId ChannelId

The channel id.

secondPerCommitmentPoint PubKey

The second per commitment point.

shortChannelId ShortChannelId?

The channel's shortChannelId.

Returns

ChannelReadyMessage

The ChannelReady message.

See Also
PubKey

CreateChannelReestablishMessage(ChannelId, ulong, ulong, ReadOnlyMemory<byte>, PubKey)

Create a ChannelReestablish message.

public ChannelReestablishMessage CreateChannelReestablishMessage(ChannelId channelId, ulong nextCommitmentNumber, ulong nextRevocationNumber, ReadOnlyMemory<byte> yourLastPerCommitmentSecret, PubKey myCurrentPerCommitmentPoint)

Parameters

channelId ChannelId

The channel id.

nextCommitmentNumber ulong

The next commitment number.

nextRevocationNumber ulong

The next revocation number.

yourLastPerCommitmentSecret ReadOnlyMemory<byte>

The peer last per commitment secret.

myCurrentPerCommitmentPoint PubKey

Our current per commitment point.

Returns

ChannelReestablishMessage

The ChannelReestablish message.

See Also

CreateClosingSignedMessage(ChannelId, ulong, ECDSASignature, ulong, ulong)

Create a ClosingSigned message.

public ClosingSignedMessage CreateClosingSignedMessage(ChannelId channelId, ulong feeSatoshis, ECDSASignature signature, ulong minFeeSatoshis, ulong maxFeeSatoshis)

Parameters

channelId ChannelId

The channel id.

feeSatoshis ulong

The fee we want them to pay for closing the channel.

signature ECDSASignature

The signature for closing the channel.

minFeeSatoshis ulong

The min fee we will accept them to pay to close the channel.

maxFeeSatoshis ulong

The max fee we will accept them to pay to close the channel.

Returns

ClosingSignedMessage

The ClosingSigned message.

See Also
ECDSASignature

CreateCommitmentSignedMessage(ChannelId, ECDSASignature, IEnumerable<ECDSASignature>)

Create a CommitmentSigned message.

public CommitmentSignedMessage CreateCommitmentSignedMessage(ChannelId channelId, ECDSASignature signature, IEnumerable<ECDSASignature> htlcSignatures)

Parameters

channelId ChannelId

The channel id.

signature ECDSASignature

The signature for the commitment transaction.

htlcSignatures IEnumerable<ECDSASignature>

The signatures for each open htlc.

Returns

CommitmentSignedMessage

The CommitmentSigned message.

See Also
ECDSASignature

CreateErrorMessage(byte[], ChannelId?)

Create an Error message.

public ErrorMessage CreateErrorMessage(byte[] data, ChannelId? channelId)

Parameters

data byte[]

The data to be sent.

channelId ChannelId?

The channel id, if any.

Returns

ErrorMessage

The Error message.

See Also

CreateErrorMessage(string, ChannelId?)

Create an Error message.

public ErrorMessage CreateErrorMessage(string message, ChannelId? channelId)

Parameters

message string

The message to be sent.

channelId ChannelId?

The channel id, if any.

Returns

ErrorMessage

The Error message.

See Also

CreateInitMessage()

Create an Init message.

public InitMessage CreateInitMessage()

Returns

InitMessage

The Init message.

See Also

CreateOpenChannel2Message(ChannelId, uint, uint, ulong, PubKey, PubKey, PubKey, PubKey, PubKey, PubKey, PubKey, ChannelFlags, Script?, byte[]?, bool)

Create a OpenChannel2 message.

public OpenChannel2Message CreateOpenChannel2Message(ChannelId temporaryChannelId, uint fundingFeeRatePerKw, uint commitmentFeeRatePerKw, ulong fundingSatoshis, PubKey fundingPubKey, PubKey revocationBasepoint, PubKey paymentBasepoint, PubKey delayedPaymentBasepoint, PubKey htlcBasepoint, PubKey firstPerCommitmentPoint, PubKey secondPerCommitmentPoint, ChannelFlags channelFlags, Script? shutdownScriptPubkey = null, byte[]? channelType = null, bool requireConfirmedInputs = false)

Parameters

temporaryChannelId ChannelId

The temporary channel id.

fundingFeeRatePerKw uint

The funding fee rate to open the channel.

commitmentFeeRatePerKw uint

The commitment fee rate.

fundingSatoshis ulong

The amount of satoshis we're adding to the channel.

fundingPubKey PubKey

The funding pubkey of the channel.

revocationBasepoint PubKey

The revocation pubkey.

paymentBasepoint PubKey

The payment pubkey.

delayedPaymentBasepoint PubKey

The delayed payment pubkey.

htlcBasepoint PubKey

The htlc pubkey.

firstPerCommitmentPoint PubKey

The first per commitment pubkey.

secondPerCommitmentPoint PubKey

The second per commitment pubkey.

channelFlags ChannelFlags

The flags for the channel.

shutdownScriptPubkey Script

The shutdown script to be used when closing the channel.

channelType byte[]

The type of the channel.

requireConfirmedInputs bool

If we want confirmed inputs to open the channel.

Returns

OpenChannel2Message

The OpenChannel2 message.

See Also
PubKey
Script

CreatePingMessage()

Create a Ping message.

public PingMessage CreatePingMessage()

Returns

PingMessage

The Ping message.

See Also

CreatePongMessage(IMessage)

Create a Pong message.

public PongMessage CreatePongMessage(IMessage pingMessage)

Parameters

pingMessage IMessage

The ping message we're responding to

Returns

PongMessage

The Pong message.

See Also

CreateRevokeAndAckMessage(ChannelId, ReadOnlyMemory<byte>, PubKey)

Create a RevokeAndAck message.

public RevokeAndAckMessage CreateRevokeAndAckMessage(ChannelId channelId, ReadOnlyMemory<byte> perCommitmentSecret, PubKey nextPerCommitmentPoint)

Parameters

channelId ChannelId

The channel id.

perCommitmentSecret ReadOnlyMemory<byte>

The secret for the commitment transaction.

nextPerCommitmentPoint PubKey

The next per commitment point.

Returns

RevokeAndAckMessage

The RevokeAndAck message.

See Also
ECDSASignature

CreateShutdownMessage(ChannelId, Script)

Create a Shutdown message.

public ShutdownMessage CreateShutdownMessage(ChannelId channelId, Script scriptPubkey)

Parameters

channelId ChannelId

The channel id.

scriptPubkey Script

The ScriptPubKey to send closing funds to.

Returns

ShutdownMessage

The Shutdown message.

See Also
Script

CreateStfuMessage(ChannelId, bool)

Create a Stfu message.

public StfuMessage CreateStfuMessage(ChannelId channelId, bool initiator)

Parameters

channelId ChannelId

The channel id, if any.

initiator bool

If we are the sender of the message.

Returns

StfuMessage

The Stfu message.

See Also

CreateTxAbortMessage(ChannelId, byte[])

Create a TxAbort message.

public TxAbortMessage CreateTxAbortMessage(ChannelId channelId, byte[] data)

Parameters

channelId ChannelId

The channel id.

data byte[]

The data.

Returns

TxAbortMessage

The TxAbort message.

See Also

CreateTxAckRbfMessage(ChannelId, long, bool)

Create a TxAckRbf message.

public TxAckRbfMessage CreateTxAckRbfMessage(ChannelId channelId, long fundingOutputContrubution, bool requireConfirmedInputs)

Parameters

channelId ChannelId

The channel id.

fundingOutputContrubution long

The output contribution.

requireConfirmedInputs bool

How many confirmed inputs we need.

Returns

TxAckRbfMessage

The TxAckRbf message.

See Also

CreateTxAddInputMessage(ChannelId, ulong, byte[], uint, uint)

Create a TxAddInput message.

public TxAddInputMessage CreateTxAddInputMessage(ChannelId channelId, ulong serialId, byte[] prevTx, uint prevTxVout, uint sequence)

Parameters

channelId ChannelId

The channel id.

serialId ulong

The serial id.

prevTx byte[]

The previous transaction.

prevTxVout uint

The previous transaction vout.

sequence uint

The sequence number.

Returns

TxAddInputMessage

The TxAddInput message.

See Also

CreateTxAddOutputMessage(ChannelId, ulong, LightningMoney, Script)

Create a TxAddOutput message.

public TxAddOutputMessage CreateTxAddOutputMessage(ChannelId channelId, ulong serialId, LightningMoney amount, Script script)

Parameters

channelId ChannelId

The channel id.

serialId ulong

The serial id.

amount LightningMoney

The number of satoshis.

script Script

The script.

Returns

TxAddOutputMessage

The TxAddOutput message.

See Also

CreateTxCompleteMessage(ChannelId)

Create a TxComplete message.

public TxCompleteMessage CreateTxCompleteMessage(ChannelId channelId)

Parameters

channelId ChannelId

The channel id.

Returns

TxCompleteMessage

The TxComplete message.

See Also

CreateTxInitRbfMessage(ChannelId, uint, uint, long, bool)

Create a TxInitRbf message.

public TxInitRbfMessage CreateTxInitRbfMessage(ChannelId channelId, uint locktime, uint feerate, long fundingOutputContrubution, bool requireConfirmedInputs)

Parameters

channelId ChannelId

The channel id.

locktime uint

The locktime.

feerate uint

The feerate

fundingOutputContrubution long

The output contribution.

requireConfirmedInputs bool

How many confirmed inputs we need.

Returns

TxInitRbfMessage

The TxInitRbf message.

See Also

CreateTxRemoveInputMessage(ChannelId, ulong)

Create a TxRemoveInput message.

public TxRemoveInputMessage CreateTxRemoveInputMessage(ChannelId channelId, ulong serialId)

Parameters

channelId ChannelId

The channel id.

serialId ulong

The serial id.

Returns

TxRemoveInputMessage

The TxRemoveInput message.

See Also

CreateTxRemoveOutputMessage(ChannelId, ulong)

Create a TxRemoveOutput message.

public TxRemoveOutputMessage CreateTxRemoveOutputMessage(ChannelId channelId, ulong serialId)

Parameters

channelId ChannelId

The channel id.

serialId ulong

The serial id.

Returns

TxRemoveOutputMessage

The TxRemoveOutput message.

See Also

CreateTxSignaturesMessage(ChannelId, byte[], List<Witness>)

Create a TxSignatures message.

public TxSignaturesMessage CreateTxSignaturesMessage(ChannelId channelId, byte[] txId, List<Witness> witnesses)

Parameters

channelId ChannelId

The channel id.

txId byte[]

The transaction id.

witnesses List<Witness>

The witnesses.

Returns

TxSignaturesMessage

The TxSignatures message.

See Also

CreateUpdateAddHtlcMessage(ChannelId, ulong, ulong, ReadOnlyMemory<byte>, uint, ReadOnlyMemory<byte>?)

Create a UpdateAddHtlc message.

public UpdateAddHtlcMessage CreateUpdateAddHtlcMessage(ChannelId channelId, ulong id, ulong amountMsat, ReadOnlyMemory<byte> paymentHash, uint cltvExpiry, ReadOnlyMemory<byte>? onionRoutingPacket = null)

Parameters

channelId ChannelId

The channel id.

id ulong

The htlc id.

amountMsat ulong

The amount for this htlc.

paymentHash ReadOnlyMemory<byte>

The htlc payment hash.

cltvExpiry uint

The cltv expiry.

onionRoutingPacket ReadOnlyMemory<byte>?

The onion routing packet.

Returns

UpdateAddHtlcMessage

The UpdateAddHtlc message.

See Also

CreateUpdateFailHtlcMessage(ChannelId, ulong, ReadOnlyMemory<byte>)

Create a UpdateFailHtlc message.

public UpdateFailHtlcMessage CreateUpdateFailHtlcMessage(ChannelId channelId, ulong id, ReadOnlyMemory<byte> reason)

Parameters

channelId ChannelId

The channel id.

id ulong

The htlc id.

reason ReadOnlyMemory<byte>

The reason for failure.

Returns

UpdateFailHtlcMessage

The UpdateFailHtlc message.

See Also

CreateUpdateFailMalformedHtlcMessage(ChannelId, ulong, ReadOnlyMemory<byte>, ushort)

Create a UpdateFailMalformedHtlc message.

public UpdateFailMalformedHtlcMessage CreateUpdateFailMalformedHtlcMessage(ChannelId channelId, ulong id, ReadOnlyMemory<byte> sha256OfOnion, ushort failureCode)

Parameters

channelId ChannelId

The channel id.

id ulong

The htlc id.

sha256OfOnion ReadOnlyMemory<byte>

The sha256OfOnion for this htlc.

failureCode ushort

The failureCode.

Returns

UpdateFailMalformedHtlcMessage

The UpdateFailMalformedHtlc message.

See Also

CreateUpdateFeeMessage(ChannelId, uint)

Create a UpdateFee message.

public UpdateFeeMessage CreateUpdateFeeMessage(ChannelId channelId, uint feeratePerKw)

Parameters

channelId ChannelId

The channel id.

feeratePerKw uint

The fee rate for the commitment transaction.

Returns

UpdateFeeMessage

The UpdateFee message.

See Also

CreateUpdateFulfillHtlcMessage(ChannelId, ulong, ReadOnlyMemory<byte>)

Create a UpdateFulfillHtlc message.

public UpdateFulfillHtlcMessage CreateUpdateFulfillHtlcMessage(ChannelId channelId, ulong id, ReadOnlyMemory<byte> preimage)

Parameters

channelId ChannelId

The channel id.

id ulong

The htlc id.

preimage ReadOnlyMemory<byte>

The preimage for this htlc.

Returns

UpdateFulfillHtlcMessage

The UpdateFulfillHtlc message.

See Also

CreateWarningMessage(byte[], ChannelId?)

Create a Warning message.

public WarningMessage CreateWarningMessage(byte[] data, ChannelId? channelId)

Parameters

data byte[]

The data to be sent.

channelId ChannelId?

The channel id, if any.

Returns

WarningMessage

The Warning message.

See Also

CreateWarningMessage(string, ChannelId?)

Create a Warning message.

public WarningMessage CreateWarningMessage(string message, ChannelId? channelId)

Parameters

message string

The message to be sent.

channelId ChannelId?

The channel id, if any.

Returns

WarningMessage

The Warning message.

See Also