Class MessageFactory
- Namespace
- NLightning.Application.Protocol.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
CreateAcceptChannel1Message(LightningMoney, ChannelTypeTlv?, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, ushort, LightningMoney, uint, CompactPubKey, CompactPubKey, ChannelId, ushort, UpfrontShutdownScriptTlv?)
Creates an AcceptChannel1 message.
public AcceptChannel1Message CreateAcceptChannel1Message(LightningMoney channelReserveAmount, ChannelTypeTlv? channelTypeTlv, CompactPubKey delayedPaymentBasepoint, CompactPubKey firstPerCommitmentPoint, CompactPubKey fundingPubKey, CompactPubKey htlcBasepoint, ushort maxAcceptedHtlcs, LightningMoney maxHtlcValueInFlight, uint minimumDepth, CompactPubKey paymentBasepoint, CompactPubKey revocationBasepoint, ChannelId temporaryChannelId, ushort toSelfDelay, UpfrontShutdownScriptTlv? upfrontShutdownScriptTlv)
Parameters
channelReserveAmount
LightningMoneyThe reserve amount for the channel.
channelTypeTlv
ChannelTypeTlvOptional parameter specifying the channel type.
delayedPaymentBasepoint
CompactPubKeyThe basepoint for the delayed payment key.
firstPerCommitmentPoint
CompactPubKeyThe first per-commitment point for the channel.
fundingPubKey
CompactPubKeyPublic key associated with the channel funding.
htlcBasepoint
CompactPubKeyThe basepoint for the HTLC key.
maxAcceptedHtlcs
ushortThe maximum number of HTLCs to be accepted for this channel.
maxHtlcValueInFlight
LightningMoneyThe maximum HTLC value that can be in flight.
minimumDepth
uintThe minimum confirmation depth required for the channel opening transaction.
paymentBasepoint
CompactPubKeyThe basepoint for the payment key.
revocationBasepoint
CompactPubKeyThe basepoint for the revocation key.
temporaryChannelId
ChannelIdThe temporary identifier for the channel negotiation.
toSelfDelay
ushortThe delay in blocks before self outputs can be claimed.
upfrontShutdownScriptTlv
UpfrontShutdownScriptTlvOptional parameter specifying the upfront shutdown script TLV.
Returns
- AcceptChannel1Message
The created AcceptChannel1 message.
- See Also
CreateAcceptChannel2Message(ChannelId, LightningMoney, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, LightningMoney, BitcoinScript?, byte[]?, bool)
Create an AcceptChannel2 message.
public AcceptChannel2Message CreateAcceptChannel2Message(ChannelId temporaryChannelId, LightningMoney fundingSatoshis, CompactPubKey fundingPubKey, CompactPubKey revocationBasepoint, CompactPubKey paymentBasepoint, CompactPubKey delayedPaymentBasepoint, CompactPubKey htlcBasepoint, CompactPubKey firstPerCommitmentPoint, LightningMoney maxHtlcValueInFlight, BitcoinScript? shutdownScriptPubkey = null, byte[]? channelType = null, bool requireConfirmedInputs = false)
Parameters
temporaryChannelId
ChannelIdThe temporary channel id.
fundingSatoshis
LightningMoneyThe amount of satoshis we're adding to the channel.
fundingPubKey
CompactPubKeyThe funding pubkey of the channel.
revocationBasepoint
CompactPubKeyThe revocation pubkey.
paymentBasepoint
CompactPubKeyThe payment pubkey.
delayedPaymentBasepoint
CompactPubKeyThe delayed payment pubkey.
htlcBasepoint
CompactPubKeyThe htlc pubkey.
firstPerCommitmentPoint
CompactPubKeyThe first per-commitment pubkey.
maxHtlcValueInFlight
LightningMoneyMaximum HTLC value that can be in flight.
shutdownScriptPubkey
BitcoinScript?The shutdown script to be used when closing the channel.
channelType
byte[]The type of the channel.
requireConfirmedInputs
boolIf we want confirmed inputs to open the channel.
Returns
- AcceptChannel2Message
The AcceptChannel2 message.
- See Also
CreateChannelReadyMessage(ChannelId, CompactPubKey, ShortChannelId?)
Create a ChannelReady message.
public ChannelReadyMessage CreateChannelReadyMessage(ChannelId channelId, CompactPubKey secondPerCommitmentPoint, ShortChannelId? shortChannelId = null)
Parameters
channelId
ChannelIdThe channel id.
secondPerCommitmentPoint
CompactPubKeyThe second per commitment point.
shortChannelId
ShortChannelId?The channel's shortChannelId.
Returns
- ChannelReadyMessage
The ChannelReady message.
- See Also
CreateChannelReestablishMessage(ChannelId, ulong, ulong, ReadOnlyMemory<byte>, CompactPubKey)
Create a ChannelReestablish message.
public ChannelReestablishMessage CreateChannelReestablishMessage(ChannelId channelId, ulong nextCommitmentNumber, ulong nextRevocationNumber, ReadOnlyMemory<byte> yourLastPerCommitmentSecret, CompactPubKey myCurrentPerCommitmentPoint)
Parameters
channelId
ChannelIdThe channel id.
nextCommitmentNumber
ulongThe next commitment number.
nextRevocationNumber
ulongThe next revocation number.
yourLastPerCommitmentSecret
ReadOnlyMemory<byte>The peer's last per-commitment secret.
myCurrentPerCommitmentPoint
CompactPubKeyOur current per commitment point.
Returns
- ChannelReestablishMessage
The ChannelReestablish message.
- See Also
CreateClosingSignedMessage(ChannelId, ulong, CompactSignature, ulong, ulong)
Create a ClosingSigned message.
public ClosingSignedMessage CreateClosingSignedMessage(ChannelId channelId, ulong feeSatoshis, CompactSignature signature, ulong minFeeSatoshis, ulong maxFeeSatoshis)
Parameters
channelId
ChannelIdThe channel id.
feeSatoshis
ulongThe fee we want them to pay for closing the channel.
signature
CompactSignatureThe signature for closing the channel.
minFeeSatoshis
ulongThe min fee we will accept them to pay to close the channel.
maxFeeSatoshis
ulongThe max fee we will accept them to pay to close the channel.
Returns
- ClosingSignedMessage
The ClosingSigned message.
- See Also
CreateCommitmentSignedMessage(ChannelId, CompactSignature, IEnumerable<CompactSignature>)
Create a CommitmentSigned message.
public CommitmentSignedMessage CreateCommitmentSignedMessage(ChannelId channelId, CompactSignature signature, IEnumerable<CompactSignature> htlcSignatures)
Parameters
channelId
ChannelIdThe channel id.
signature
CompactSignatureThe signature for the commitment transaction.
htlcSignatures
IEnumerable<CompactSignature>The signatures for each open htlc.
Returns
- CommitmentSignedMessage
The CommitmentSigned message.
- See Also
CreateErrorMessage(byte[], ChannelId?)
Create an Error message.
public ErrorMessage CreateErrorMessage(byte[] data, ChannelId? channelId)
Parameters
Returns
- ErrorMessage
The Error message.
- See Also
CreateErrorMessage(string, ChannelId?)
Create an Error message.
public ErrorMessage CreateErrorMessage(string message, ChannelId? channelId)
Parameters
Returns
- ErrorMessage
The Error message.
- See Also
CreateInitMessage()
Create an Init message.
public InitMessage CreateInitMessage()
Returns
- InitMessage
The Init message.
- See Also
CreateOpenChannel1Message(ChannelId, LightningMoney, CompactPubKey, LightningMoney, LightningMoney, LightningMoney, ushort, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, ChannelFlags, UpfrontShutdownScriptTlv?, ChannelTypeTlv?)
Create an OpenChannel1 message.
public OpenChannel1Message CreateOpenChannel1Message(ChannelId temporaryChannelId, LightningMoney fundingAmount, CompactPubKey fundingPubKey, LightningMoney pushAmount, LightningMoney channelReserveAmount, LightningMoney feeRatePerKw, ushort maxAcceptedHtlcs, CompactPubKey revocationBasepoint, CompactPubKey paymentBasepoint, CompactPubKey delayedPaymentBasepoint, CompactPubKey htlcBasepoint, CompactPubKey firstPerCommitmentPoint, ChannelFlags channelFlags, UpfrontShutdownScriptTlv? upfrontShutdownScriptTlv, ChannelTypeTlv? channelTypeTlv)
Parameters
temporaryChannelId
ChannelIdThe temporary channel id.
fundingAmount
LightningMoneyThe amount of satoshis we're adding to the channel.
fundingPubKey
CompactPubKeyThe funding pubkey of the channel.
pushAmount
LightningMoneyThe amount of satoshis we're pushing to the other side.
channelReserveAmount
LightningMoneyThe channel reserve amount.
feeRatePerKw
LightningMoneyThe fee rate per kw.
maxAcceptedHtlcs
ushortThe max accepted htlcs.
revocationBasepoint
CompactPubKeyThe revocation pubkey.
paymentBasepoint
CompactPubKeyThe payment pubkey.
delayedPaymentBasepoint
CompactPubKeyThe delayed payment pubkey.
htlcBasepoint
CompactPubKeyThe htlc pubkey.
firstPerCommitmentPoint
CompactPubKeyThe first per-commitment pubkey.
channelFlags
ChannelFlagsThe flags for the channel.
upfrontShutdownScriptTlv
UpfrontShutdownScriptTlvThe upfront shutdown script tlv.
channelTypeTlv
ChannelTypeTlvThe channel type tlv.
Returns
- OpenChannel1Message
The OpenChannel1 message.
- See Also
CreateOpenChannel2Message(ChannelId, uint, uint, ulong, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, CompactPubKey, ChannelFlags, BitcoinScript?, byte[]?, bool)
Create an OpenChannel2 message.
public OpenChannel2Message CreateOpenChannel2Message(ChannelId temporaryChannelId, uint fundingFeeRatePerKw, uint commitmentFeeRatePerKw, ulong fundingSatoshis, CompactPubKey fundingPubKey, CompactPubKey revocationBasepoint, CompactPubKey paymentBasepoint, CompactPubKey delayedPaymentBasepoint, CompactPubKey htlcBasepoint, CompactPubKey firstPerCommitmentPoint, CompactPubKey secondPerCommitmentPoint, ChannelFlags channelFlags, BitcoinScript? shutdownScriptPubkey = null, byte[]? channelType = null, bool requireConfirmedInputs = false)
Parameters
temporaryChannelId
ChannelIdThe temporary channel id.
fundingFeeRatePerKw
uintThe funding fee rate to open the channel.
commitmentFeeRatePerKw
uintThe commitment fee rate.
fundingSatoshis
ulongThe amount of satoshis we're adding to the channel.
fundingPubKey
CompactPubKeyThe funding pubkey of the channel.
revocationBasepoint
CompactPubKeyThe revocation pubkey.
paymentBasepoint
CompactPubKeyThe payment pubkey.
delayedPaymentBasepoint
CompactPubKeyThe delayed payment pubkey.
htlcBasepoint
CompactPubKeyThe htlc pubkey.
firstPerCommitmentPoint
CompactPubKeyThe first per-commitment pubkey.
secondPerCommitmentPoint
CompactPubKeyThe second per-commitment pubkey.
channelFlags
ChannelFlagsThe flags for the channel.
shutdownScriptPubkey
BitcoinScript?The shutdown script to be used when closing the channel.
channelType
byte[]The type of the channel.
requireConfirmedInputs
boolIf we want confirmed inputs to open the channel.
Returns
- OpenChannel2Message
The OpenChannel2 message.
- See Also
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
IMessageThe ping message we're responding to
Returns
- PongMessage
The Pong message.
- See Also
CreateRevokeAndAckMessage(ChannelId, ReadOnlyMemory<byte>, CompactPubKey)
Create a RevokeAndAck message.
public RevokeAndAckMessage CreateRevokeAndAckMessage(ChannelId channelId, ReadOnlyMemory<byte> perCommitmentSecret, CompactPubKey nextPerCommitmentPoint)
Parameters
channelId
ChannelIdThe channel id.
perCommitmentSecret
ReadOnlyMemory<byte>The secret for the commitment transaction.
nextPerCommitmentPoint
CompactPubKeyThe next per commitment point.
Returns
- RevokeAndAckMessage
The RevokeAndAck message.
- See Also
CreateShutdownMessage(ChannelId, BitcoinScript)
Create a Shutdown message.
public ShutdownMessage CreateShutdownMessage(ChannelId channelId, BitcoinScript scriptPubkey)
Parameters
channelId
ChannelIdThe channel id.
scriptPubkey
BitcoinScriptThe ScriptPubKey to send closing funds to.
Returns
- ShutdownMessage
The Shutdown message.
- See Also
CreateStfuMessage(ChannelId, bool)
Create a Stfu message.
public StfuMessage CreateStfuMessage(ChannelId channelId, bool initiator)
Parameters
Returns
- StfuMessage
The Stfu message.
- See Also
CreateTxAbortMessage(ChannelId, byte[])
Create a TxAbort message.
public TxAbortMessage CreateTxAbortMessage(ChannelId channelId, byte[] data)
Parameters
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
ChannelIdThe channel id.
fundingOutputContrubution
longThe output contribution.
requireConfirmedInputs
boolHow 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
ChannelIdThe channel id.
serialId
ulongThe serial id.
prevTx
byte[]The previous transaction.
prevTxVout
uintThe previous transaction vout.
sequence
uintThe sequence number.
Returns
- TxAddInputMessage
The TxAddInput message.
- See Also
CreateTxAddOutputMessage(ChannelId, ulong, LightningMoney, BitcoinScript)
Create a TxAddOutput message.
public TxAddOutputMessage CreateTxAddOutputMessage(ChannelId channelId, ulong serialId, LightningMoney amount, BitcoinScript script)
Parameters
channelId
ChannelIdThe channel id.
serialId
ulongThe serial id.
amount
LightningMoneyThe number of satoshis.
script
BitcoinScriptThe script.
Returns
- TxAddOutputMessage
The TxAddOutput message.
- See Also
CreateTxCompleteMessage(ChannelId)
Create a TxComplete message.
public TxCompleteMessage CreateTxCompleteMessage(ChannelId channelId)
Parameters
channelId
ChannelIdThe 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
ChannelIdThe channel id.
locktime
uintThe locktime.
feerate
uintThe feerate
fundingOutputContrubution
longThe output contribution.
requireConfirmedInputs
boolHow 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
Returns
- TxRemoveInputMessage
The TxRemoveInput message.
- See Also
CreateTxRemoveOutputMessage(ChannelId, ulong)
Create a TxRemoveOutput message.
public TxRemoveOutputMessage CreateTxRemoveOutputMessage(ChannelId channelId, ulong serialId)
Parameters
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
ChannelIdThe 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 an UpdateAddHtlc message.
public UpdateAddHtlcMessage CreateUpdateAddHtlcMessage(ChannelId channelId, ulong id, ulong amountMsat, ReadOnlyMemory<byte> paymentHash, uint cltvExpiry, ReadOnlyMemory<byte>? onionRoutingPacket = null)
Parameters
channelId
ChannelIdThe channel id.
id
ulongThe htlc id.
amountMsat
ulongThe amount for this htlc.
paymentHash
ReadOnlyMemory<byte>The htlc payment hash.
cltvExpiry
uintThe cltv expiry.
onionRoutingPacket
ReadOnlyMemory<byte>?The onion routing packet.
Returns
- UpdateAddHtlcMessage
The UpdateAddHtlc message.
- See Also
CreateUpdateFailHtlcMessage(ChannelId, ulong, ReadOnlyMemory<byte>)
Create an UpdateFailHtlc message.
public UpdateFailHtlcMessage CreateUpdateFailHtlcMessage(ChannelId channelId, ulong id, ReadOnlyMemory<byte> reason)
Parameters
channelId
ChannelIdThe channel id.
id
ulongThe htlc id.
reason
ReadOnlyMemory<byte>The reason for failure.
Returns
- UpdateFailHtlcMessage
The UpdateFailHtlc message.
- See Also
CreateUpdateFailMalformedHtlcMessage(ChannelId, ulong, ReadOnlyMemory<byte>, ushort)
Create an UpdateFailMalformedHtlc message.
public UpdateFailMalformedHtlcMessage CreateUpdateFailMalformedHtlcMessage(ChannelId channelId, ulong id, ReadOnlyMemory<byte> sha256OfOnion, ushort failureCode)
Parameters
channelId
ChannelIdThe channel id.
id
ulongThe htlc id.
sha256OfOnion
ReadOnlyMemory<byte>The sha256OfOnion for this htlc.
failureCode
ushortThe failureCode.
Returns
- UpdateFailMalformedHtlcMessage
The UpdateFailMalformedHtlc message.
- See Also
CreateUpdateFeeMessage(ChannelId, uint)
Create a UpdateFee message.
public UpdateFeeMessage CreateUpdateFeeMessage(ChannelId channelId, uint feeratePerKw)
Parameters
Returns
- UpdateFeeMessage
The UpdateFee message.
- See Also
CreateUpdateFulfillHtlcMessage(ChannelId, ulong, ReadOnlyMemory<byte>)
Create an UpdateFulfillHtlc message.
public UpdateFulfillHtlcMessage CreateUpdateFulfillHtlcMessage(ChannelId channelId, ulong id, ReadOnlyMemory<byte> preimage)
Parameters
channelId
ChannelIdThe channel id.
id
ulongThe 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
Returns
- WarningMessage
The Warning message.
- See Also
CreateWarningMessage(string, ChannelId?)
Create a Warning message.
public WarningMessage CreateWarningMessage(string message, ChannelId? channelId)
Parameters
Returns
- WarningMessage
The Warning message.
- See Also
CreatedFundingCreatedMessage(ChannelId, TxId, ushort, CompactSignature)
Create a FundingCreated message.
public FundingCreatedMessage CreatedFundingCreatedMessage(ChannelId temporaryChannelId, TxId fundingTxId, ushort fundingOutputIndex, CompactSignature signature)
Parameters
temporaryChannelId
ChannelIdThe temporary channel id.
fundingTxId
TxIdThe funding transaction id.
fundingOutputIndex
ushortThe funding output index.
signature
CompactSignatureThe signature for the funding transaction.
Returns
- FundingCreatedMessage
The FundingCreated message.
- See Also
CreatedFundingSignedMessage(ChannelId, CompactSignature)
Create a FundingSigned message.
public FundingSignedMessage CreatedFundingSignedMessage(ChannelId channelId, CompactSignature signature)
Parameters
channelId
ChannelIdThe channel id.
signature
CompactSignature
Returns
- FundingSignedMessage
The FundingSigned message.
- See Also