tapchannelmsg

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxNumOutputs is the maximum number of asset outputs that are allowed
	// in a single record. This mainly affects the maximum number of asset
	// UTXOs that can reside within a single commitment. This number should
	// in practice be very small (probably close to 1), as all outputs must
	// be from the same asset group but from different tranches to be
	// encoded as an individual record.
	MaxNumOutputs = 2048

	// MaxNumHTLCs is the maximum number of HTLCs that are allowed in a
	// single record.
	MaxNumHTLCs = input.MaxHTLCNumber

	// OutputMaxSize is the maximum size of an asset output record. This is
	// the sum of the maximum sizes of the fields in the record.
	OutputMaxSize = 32 + 8 + proof.FileMaxProofSizeBytes
)
View Source
const (
	// TapMessageTypeBaseOffset is the Taproot Assets specific message type
	// identifier base offset. All Taproot Asset Protocol messages will have
	// a type identifier that is greater than or equal to this value.
	//
	// The range for custom message types starts at 32768 according to
	// BOLT-1. This offset was chosen as the concatenation of the
	// alphabetical index positions of the letters "t" (20), "a" (1), and
	// "p" (16).
	TapMessageTypeBaseOffset = 20116 + lnwire.CustomTypeStart

	// TapChannelMessageTypeOffset is the offset that is added to the type
	// of each message type related to Taproot Asset channel funding.
	TapChannelMessageTypeOffset = TapMessageTypeBaseOffset + 256

	// TxAssetInputProofType is the message type of the TxAssetInput
	// message.
	TxAssetInputProofType = TapChannelMessageTypeOffset + 0

	// TxAssetOutputProofType is the message type of the TxAssetOutput
	// message.
	TxAssetOutputProofType = TapChannelMessageTypeOffset + 1

	// AssetFundingCreatedType is the message type of the
	// AssetFundingCreated message.
	AssetFundingCreatedType = TapChannelMessageTypeOffset + 2

	// AssetFundingAckType is the message type of the AssetFundingAck
	// message.
	AssetFundingAckType = TapChannelMessageTypeOffset + 3
)

Variables

View Source
var (
	// ErrListInvalid is the error that's returned when a list of encoded
	// entries is invalid.
	ErrListInvalid = errors.New("encoded list is invalid")
)

Functions

func OutputSum

func OutputSum(outputs []*AssetOutput) uint64

OutputSum returns the sum of the amounts of all the asset outputs in the list.

func ParseCustomChannelData

func ParseCustomChannelData(msg proto.Message) error

ParseCustomChannelData parses the custom channel data in the given lnd RPC message and converts it to JSON, replacing it inline.

Types

type AssetFundingAck

type AssetFundingAck struct {
	// PendingChanID is the pending channel ID that was assigned to the
	// channel.
	PendingChanID tlv.RecordT[tlv.TlvType0, funding.PendingChanID]

	// Accept is a boolean that indicates if the responder is able to fully
	// validate the proofs sent in the prior step.
	Accept tlv.RecordT[tlv.TlvType1, bool]
}

AssetFundingAck is sent by the responder of the funding flow after they've received the funding input and output proofs. If the responder is able to fully validate the proposed funding parameters, then they'll send this method with accept=true. Otherwise, they'll send with accept set to false.

func NewAssetFundingAck

func NewAssetFundingAck(pid funding.PendingChanID,
	accept bool) *AssetFundingAck

NewAssetFundingAck creates a new AssetFundingAck message.

func (*AssetFundingAck) Amt

func (t *AssetFundingAck) Amt() fn.Option[uint64]

Amt returns the amount of the asset that this output represents.

func (*AssetFundingAck) Decode

func (t *AssetFundingAck) Decode(r io.Reader, _ uint32) error

Decode reads the bytes stream and converts it to the object.

func (*AssetFundingAck) Encode

func (t *AssetFundingAck) Encode(w *bytes.Buffer, _ uint32) error

Encode converts object to the bytes stream and write it into the write buffer.

func (*AssetFundingAck) MsgType

func (t *AssetFundingAck) MsgType() lnwire.MessageType

MsgType returns the type of the message.

func (*AssetFundingAck) PID

PID returns the pending channel ID that was assigned to the channel.

type AssetFundingCreated

type AssetFundingCreated struct {
	// PendingChanID is the pending channel ID that was assigned to the
	// channel.
	PendingChanID tlv.RecordT[tlv.TlvType0, funding.PendingChanID]

	// FundingOutputs are the completed set of funding output proofs. The
	// remote party will use the transition (suffix) proofs encoded in the
	// funding output to be able to create the aux funding+commitment
	// blobs.
	FundingOutputs tlv.RecordT[tlv.TlvType1, AssetOutputListRecord]
}

AssetFundingCreated is sent by the initiator of the funding flow after they've able to fully finalize the funding transaction. This message will be sent before the normal funding_created message.

func NewAssetFundingCreated

func NewAssetFundingCreated(pid funding.PendingChanID,
	outputs []*AssetOutput) *AssetFundingCreated

NewAssetFundingCreated creates a new AssetFundingCreated message.

func (*AssetFundingCreated) Amt

func (t *AssetFundingCreated) Amt() fn.Option[uint64]

Amt returns the amount of the asset that this output represents.

func (*AssetFundingCreated) Decode

func (t *AssetFundingCreated) Decode(r io.Reader, _ uint32) error

Decode reads the bytes stream and converts it to the object.

func (*AssetFundingCreated) Encode

func (t *AssetFundingCreated) Encode(w *bytes.Buffer, _ uint32) error

Encode converts object to the bytes stream and write it into the write buffer.

func (*AssetFundingCreated) MsgType

func (t *AssetFundingCreated) MsgType() lnwire.MessageType

MsgType returns the type of the message.

func (*AssetFundingCreated) PID

PID returns the pending channel ID that was assigned to the channel.

type AssetFundingMsg

type AssetFundingMsg interface {
	lnwire.Message

	// PID returns the pending channel ID that was assigned to the channel.
	PID() funding.PendingChanID

	// Amt returns the amount of the asset that is committed to the channel.
	Amt() fn.Option[uint64]
}

AssetFundingMsg is an interface that represents a message that is sent during the asset funding process.

type AssetKeyShutdownType

type AssetKeyShutdownType = tlv.TlvType65540

AssetKeyShutdownType is the type alias for the TLV type that is used to encode the asset internal key of the shutdown record on the wire.

type AssetOutput

type AssetOutput struct {
	// AssetBalance is the asset ID and amount of the output.
	rfqmsg.AssetBalance

	// Proof is the last transition proof that proves this output was
	// committed to in the Bitcoin transaction that anchors this asset
	// output.
	Proof tlv.RecordT[tlv.TlvType2, proof.Proof]
}

AssetOutput is a record that represents a single asset UTXO.

func DecodeAssetOutput

func DecodeAssetOutput(blob tlv.Blob) (*AssetOutput, error)

DecodeAssetOutput deserializes a AssetOutput from the given blob.

func NewAssetOutput

func NewAssetOutput(assetID asset.ID, amount uint64,
	p proof.Proof) *AssetOutput

NewAssetOutput creates a new AssetOutput record with the given asset ID, amount, and proof.

func (*AssetOutput) Bytes

func (o *AssetOutput) Bytes() []byte

Bytes returns the serialized AssetOutput record.

func (*AssetOutput) Decode

func (o *AssetOutput) Decode(r io.Reader) error

Decode deserializes the AssetOutput from the given io.Reader.

func (*AssetOutput) Encode

func (o *AssetOutput) Encode(w io.Writer) error

Encode serializes the AssetOutput to the given io.Writer.

type AssetOutputListRecord

type AssetOutputListRecord struct {
	Outputs []*AssetOutput
}

AssetOutputListRecord is a record that represents a list of asset outputs.

func (*AssetOutputListRecord) Decode

func (l *AssetOutputListRecord) Decode(r io.Reader) error

Decode deserializes the AssetOutputListRecord from the given io.Reader.

func (*AssetOutputListRecord) Encode

func (l *AssetOutputListRecord) Encode(w io.Writer) error

Encode serializes the AssetOutputListRecord to the given io.Writer.

func (*AssetOutputListRecord) Record

func (l *AssetOutputListRecord) Record() tlv.Record

Record creates a Record out of a AssetOutputListRecord using the passed eAssetOutputList and dAssetOutputList functions.

NOTE: This is part of the tlv.RecordProducer interface.

func (*AssetOutputListRecord) Sum

func (l *AssetOutputListRecord) Sum() uint64

Sum returns the sum of the amounts of all the asset outputs in the list.

type AssetSig

type AssetSig struct {
	// AssetID is the asset ID that the signature is for.
	AssetID tlv.RecordT[tlv.TlvType0, asset.ID]

	// Sig is the signature for the asset spend.
	Sig tlv.RecordT[tlv.TlvType1, lnwire.Sig]

	// SigHashType is the sigHash type that was used to create the
	// signature.
	SigHashType tlv.RecordT[tlv.TlvType2, uint32]
}

AssetSig is a record that represents the signature for spending an asset output.

func DecodeAssetSig

func DecodeAssetSig(blob tlv.Blob) (*AssetSig, error)

DecodeAssetSig deserializes a AssetSig from the given blob.

func NewAssetSig

func NewAssetSig(assetID asset.ID, sig lnwire.Sig,
	sigHashType txscript.SigHashType) *AssetSig

NewAssetSig creates a new AssetSig record with the given asset ID and partial sig.

func (*AssetSig) Bytes

func (a *AssetSig) Bytes() []byte

Bytes returns the serialized AssetSig record.

func (*AssetSig) Decode

func (a *AssetSig) Decode(r io.Reader) error

Decode deserializes the AssetSig from the given io.Reader.

func (*AssetSig) Encode

func (a *AssetSig) Encode(w io.Writer) error

Encode serializes the AssetOutput to the given io.Writer.

type AssetSigListRecord

type AssetSigListRecord struct {
	Sigs []*AssetSig
}

AssetSigListRecord is a record that represents a list of asset signatures.

func DecodeAssetSigListRecord

func DecodeAssetSigListRecord(rec []byte) (*AssetSigListRecord, error)

DecodeAssetSigListRecord deserializes a AssetSigListRecord from the given blob.

func (*AssetSigListRecord) Bytes

func (l *AssetSigListRecord) Bytes() []byte

Bytes returns the serialized AssetSigListRecord record.

func (*AssetSigListRecord) Decode

func (l *AssetSigListRecord) Decode(r io.Reader) error

Decode deserializes the AssetSigListRecord from the given io.Reader.

func (*AssetSigListRecord) Encode

func (l *AssetSigListRecord) Encode(w io.Writer) error

Encode serializes the AssetSigListRecord to the given io.Writer.

func (*AssetSigListRecord) Record

func (l *AssetSigListRecord) Record() tlv.Record

Record creates a Record out of a AssetSigListRecord using the passed eAssetSigListRecord and dAssetSigListRecord functions.

NOTE: This is part of the tlv.RecordProducer interface.

type AuxLeaves

type AuxLeaves struct {
	// LocalAuxLeaf is the auxiliary leaf that corresponds to the local
	// commitment.
	LocalAuxLeaf tlv.OptionalRecordT[tlv.TlvType0, TapLeafRecord]

	// RemoteAuxLeaf is the auxiliary leaf that corresponds to the remote
	// commitment.
	RemoteAuxLeaf tlv.OptionalRecordT[tlv.TlvType1, TapLeafRecord]

	// OutgoingHtlcLeaves is a map of HTLC indices to auxiliary leaves that
	// correspond to the outgoing HTLCs.
	OutgoingHtlcLeaves tlv.RecordT[tlv.TlvType2, HtlcAuxLeafMapRecord]

	// IncomingHtlcLeaves is a map of HTLC indices to auxiliary leaves that
	// correspond to the incoming HTLCs.
	IncomingHtlcLeaves tlv.RecordT[tlv.TlvType3, HtlcAuxLeafMapRecord]
}

AuxLeaves is a record that represents the auxiliary leaves that correspond to a commitment.

func DecodeAuxLeaves

func DecodeAuxLeaves(blob tlv.Blob) (*AuxLeaves, error)

DecodeAuxLeaves deserializes an OpenChannel from the given blob.

func NewAuxLeaves

func NewAuxLeaves(local, remote input.AuxTapLeaf, outgoing,
	incoming input.AuxTapLeaves) AuxLeaves

NewAuxLeaves creates a new AuxLeaves record with the given local, remote, incoming, and outgoing auxiliary leaves.

func (*AuxLeaves) Bytes

func (o *AuxLeaves) Bytes() []byte

Bytes returns the serialized AuxLeaves record.

func (*AuxLeaves) Decode

func (o *AuxLeaves) Decode(r io.Reader) error

Decode deserializes the AuxLeaves from the given io.Reader.

func (*AuxLeaves) Encode

func (o *AuxLeaves) Encode(w io.Writer) error

Encode serializes the AuxLeaves to the given io.Writer.

func (*AuxLeaves) Record

func (o *AuxLeaves) Record() tlv.Record

Record creates a Record out of a AuxLeaves using the eHtlcAuxLeafMapRecord and dHtlcAuxLeafMapRecord functions.

NOTE: This is part of the tlv.RecordProducer interface.

type AuxShutdownMsg

type AuxShutdownMsg struct {
	// BtcInternalKey is the internal key that the sender will use in the
	// BTC shutdown addr. This is used to construct the final set of
	// proofs.
	BtcInternalKey tlv.RecordT[BtcKeyShutdownType, *btcec.PublicKey]

	// AssetInternalKey is the internal key to used to anchor the asset of
	// the sending party in the co-op close transaction.
	AssetInternalKey tlv.RecordT[AssetKeyShutdownType, *btcec.PublicKey]

	// ScriptKeys maps asset IDs to script keys to be used to send the
	// assets to the sending party in the co-op close transaction.
	ScriptKeys tlv.RecordT[ScriptKeysShutdownType, ScriptKeyMap]

	// ProofDeliveryAddr is an optional type that contains the delivery
	// address for the proofs of the co-op close outputs of the local node.
	ProofDeliveryAddr tlv.OptionalRecordT[
		ProofDeliveryAddrShutdownType, []byte,
	]
}

AuxShutdownMsg contains the additional records to be sent along with the shutdown message for co-op closes for an asset channel.

func DecodeAuxShutdownMsg

func DecodeAuxShutdownMsg(blob tlv.Blob) (*AuxShutdownMsg, error)

DecodeAuxShutdownMsg deserializes a AuxShutdownMsg from the given blob.

func NewAuxShutdownMsg

func NewAuxShutdownMsg(btcInternalKey, assetInternalKey *btcec.PublicKey,
	scriptKeys ScriptKeyMap, proofDeliveryAddr *url.URL) *AuxShutdownMsg

NewAuxShutdownMsg creates a new AuxShutdownMsg with the given internal key and script key map.

func (*AuxShutdownMsg) Decode

func (a *AuxShutdownMsg) Decode(r io.Reader) error

Decode deserializes the AuxShutdownMsg from the given io.Reader.

func (*AuxShutdownMsg) Encode

func (a *AuxShutdownMsg) Encode(w io.Writer) error

Encode serializes the AuxShutdownMsg to the given io.Writer.

func (*AuxShutdownMsg) EncodeRecords

func (a *AuxShutdownMsg) EncodeRecords() []tlv.Record

EncodeRecords returns the records that make up the AuxShutdownMsg for encoding.

type BalanceCustomData

type BalanceCustomData struct {
	OpenChannels    []*Commitment
	PendingChannels []*Commitment
}

BalanceCustomData represents the data that is returned in the CustomChannelData field of a lnrpc.ChannelBalanceResponse object.

func ReadBalanceCustomData

func ReadBalanceCustomData(balanceData []byte) (*BalanceCustomData, error)

ReadBalanceCustomData reads the content of a BalanceCustomData struct from a byte slice.

func (*BalanceCustomData) AsJson

func (b *BalanceCustomData) AsJson() ([]byte, error)

AsJson returns the JSON representation of the channel balance data.

type BtcKeyShutdownType

type BtcKeyShutdownType = tlv.TlvType65539

BtcKeyShutdownType is the type alias for the TLV type that is used to encode the BTC internal key of the shutdown record on the wire.

type ChannelCustomData

type ChannelCustomData struct {
	OpenChan    OpenChannel
	LocalCommit Commitment
}

ChannelCustomData represents the data that is returned in the CustomChannelData field of a lnrpc.Channel object.

func ReadChannelCustomData

func ReadChannelCustomData(chanData []byte) (*ChannelCustomData, error)

ReadChannelCustomData reads the content of a ChannelCustomData struct from a byte slice.

func (*ChannelCustomData) AsJson

func (c *ChannelCustomData) AsJson() ([]byte, error)

AsJson returns the JSON representation of the channel custom data.

type CommitSig

type CommitSig struct {
	// HtlcPartialSigs is a map of HTLC indices to partial signatures and
	// nonces for the HTLCs.
	HtlcPartialSigs tlv.RecordT[HtlcSigsRecordType, HtlcPartialSigsRecord]
}

CommitSig is a record that represents the commitment signatures for a certain commit height.

func DecodeCommitSig

func DecodeCommitSig(blob tlv.Blob) (*CommitSig, error)

DecodeCommitSig deserializes a CommitSig from the given blob.

func NewCommitSig

func NewCommitSig(htlcSigs [][]*AssetSig) *CommitSig

NewCommitSig creates a new CommitSig record with the given partial Sigs.

func (*CommitSig) Bytes

func (c *CommitSig) Bytes() []byte

Bytes returns the serialized CommitSig record.

func (*CommitSig) Decode

func (c *CommitSig) Decode(r io.Reader) error

Decode deserializes the CommitSig from the given io.Reader.

func (*CommitSig) Encode

func (c *CommitSig) Encode(w io.Writer) error

Encode serializes the CommitSig to the given io.Writer.

type Commitment

type Commitment struct {
	// LocalAssets is a list of all asset outputs that represent the current
	// local asset balance of the commitment.
	LocalAssets tlv.RecordT[tlv.TlvType0, AssetOutputListRecord]

	// RemoteAssets is a list of all asset outputs that represents the
	// current remote asset balance of the commitment.
	RemoteAssets tlv.RecordT[tlv.TlvType1, AssetOutputListRecord]

	// OutgoingHtlcAssets is a list of all outgoing in-flight HTLCs and the
	// asset balance change that they represent.
	OutgoingHtlcAssets tlv.RecordT[tlv.TlvType2, HtlcAssetOutput]

	// IncomingHtlcAssets is a list of all incoming in-flight HTLCs and the
	// asset balance change that they represent.
	IncomingHtlcAssets tlv.RecordT[tlv.TlvType3, HtlcAssetOutput]

	// AuxLeaves are the auxiliary leaves that correspond to the commitment.
	AuxLeaves tlv.RecordT[tlv.TlvType4, AuxLeaves]
}

Commitment is a record that represents the current state of a commitment. This entails all the (asset_id, amount, proof) tuples and other information that we may need to be able to sign the TAP portion of the commitment transaction.

func DecodeCommitment

func DecodeCommitment(blob tlv.Blob) (*Commitment, error)

DecodeCommitment deserializes a Commitment from the given blob.

func NewCommitment

func NewCommitment(localAssets, remoteAssets []*AssetOutput, outgoingHtlcs,
	incomingHtlcs map[input.HtlcIndex][]*AssetOutput,
	auxLeaves lnwallet.CommitAuxLeaves) *Commitment

NewCommitment creates a new Commitment record with the given local and remote assets, and incoming and outgoing HTLCs.

func ReadCommitment

func ReadCommitment(r io.Reader, maxReadSize uint32) (*Commitment, error)

ReadCommitment reads the content of a Commitment struct from a reader.

func (*Commitment) Bytes

func (c *Commitment) Bytes() []byte

Bytes returns the serialized Commitment record.

func (*Commitment) Decode

func (c *Commitment) Decode(r io.Reader) error

Decode deserializes the Commitment from the given io.Reader.

func (*Commitment) Encode

func (c *Commitment) Encode(w io.Writer) error

Encode serializes the Commitment to the given io.Writer.

func (*Commitment) Leaves

func (c *Commitment) Leaves() lnwallet.CommitAuxLeaves

Leaves returns the auxiliary leaves that correspond to the commitment.

func (*Commitment) LocalOutputs

func (c *Commitment) LocalOutputs() []*AssetOutput

LocalOutputs returns the local asset outputs that are committed to in the Commitment struct.

func (*Commitment) RemoteOutputs

func (c *Commitment) RemoteOutputs() []*AssetOutput

RemoteOutputs returns the remote asset outputs that are committed to in the Commitment struct.

type ContractResolution

type ContractResolution struct {
	// SweepVpkts is a list of pre-signed vPackets that can be anchored
	// into an output in a transaction where the refrnced previous inputs
	// are spent to sweep an asset.
	SweepVpkts tlv.RecordT[tlv.TlvType0, VpktList]
}

ContractResolution houses all the information we need to resolve a contract on chain. This includes a series of pre-populated and pre-signed vPackets. The internal key, and other on-chain anchor information may be missing from these packets.

func NewContractResolution

func NewContractResolution(pkts []*tappsbt.VPacket) ContractResolution

NewContractResolution creates a new ContractResolution with the given list of vpkts.

func (*ContractResolution) Decode

func (c *ContractResolution) Decode(r io.Reader) error

Decode deserializes the ContractResolution from the given io.Reader.

func (*ContractResolution) Encode

func (c *ContractResolution) Encode(w io.Writer) error

Encode serializes the ContractResolution to the given io.Writer.

func (*ContractResolution) Records

func (c *ContractResolution) Records() []tlv.Record

Records returns the records that make up the ContractResolution.

func (*ContractResolution) VPkts

func (c *ContractResolution) VPkts() []*tappsbt.VPacket

VPkts returns the list of vPkts in the ContractResolution.

type HtlcAmountRecordType

type HtlcAmountRecordType = tlv.TlvType65536

HtlcAmountRecordType is a type alias for the TLV type that is used to encode an asset ID and amount list within the custom records of an HTLC record on the wire.

type HtlcAssetOutput

type HtlcAssetOutput struct {
	HtlcOutputs map[input.HtlcIndex]AssetOutputListRecord
}

HtlcAssetOutput is a record that represents a list of asset outputs that are associated with a particular HTLC index.

func NewHtlcAssetOutput

func NewHtlcAssetOutput(
	htlcOutputs map[input.HtlcIndex][]*AssetOutput) HtlcAssetOutput

NewHtlcAssetOutput creates a new HtlcAssetOutput record with the given HTLC outputs.

func (*HtlcAssetOutput) Decode

func (h *HtlcAssetOutput) Decode(r io.Reader) error

Decode deserializes the HtlcAssetOutput from the given io.Reader.

func (*HtlcAssetOutput) Encode

func (h *HtlcAssetOutput) Encode(w io.Writer) error

Encode serializes the HtlcAssetOutput to the given io.Writer.

func (*HtlcAssetOutput) Record

func (h *HtlcAssetOutput) Record() tlv.Record

Record creates a Record out of a HtlcAssetOutput using the eHtlcAssetOutput and dHtlcAssetOutput functions.

NOTE: This is part of the tlv.RecordProducer interface.

type HtlcAuxLeaf

type HtlcAuxLeaf struct {
	// AuxLeaf is the auxiliary leaf that corresponds to the HTLC.
	AuxLeaf tlv.OptionalRecordT[tlv.TlvType0, TapLeafRecord]

	// SecondLevelLeaf is the auxiliary leaf that corresponds to the second
	// level HTLC. If this is not set, it means that the commitment
	// transaction isn't complete yet and the second level leaf couldn't yet
	// be created
	SecondLevelLeaf tlv.OptionalRecordT[tlv.TlvType1, TapLeafRecord]
}

HtlcAuxLeaf is a record that represents the auxiliary leaf of an HTLC and the optional second level leaf. The second level leaf is optional because it is not set in every case of the HTLC creation flow.

func DecodeHtlcAuxLeaf

func DecodeHtlcAuxLeaf(blob tlv.Blob) (*HtlcAuxLeaf, error)

DecodeHtlcAuxLeaf deserializes a HtlcAuxLeaf from the given blob.

func NewHtlcAuxLeaf

func NewHtlcAuxLeaf(leaf input.HtlcAuxLeaf) HtlcAuxLeaf

NewHtlcAuxLeaf creates a new HtlcAuxLeaf record with the given funded assets.

func (*HtlcAuxLeaf) Bytes

func (h *HtlcAuxLeaf) Bytes() []byte

Bytes returns the serialized HtlcAuxLeaf record.

func (*HtlcAuxLeaf) Decode

func (h *HtlcAuxLeaf) Decode(r io.Reader) error

Decode deserializes the HtlcAuxLeaf from the given io.Reader.

func (*HtlcAuxLeaf) Encode

func (h *HtlcAuxLeaf) Encode(w io.Writer) error

Encode serializes the HtlcAuxLeaf to the given io.Writer.

type HtlcAuxLeafMapRecord

type HtlcAuxLeafMapRecord struct {
	HtlcAuxLeaves map[input.HtlcIndex]HtlcAuxLeaf
}

HtlcAuxLeafMapRecord is a record that represents a map of HTLC indices to HtlcAuxLeaf records.

func NewHtlcAuxLeafMapRecord

func NewHtlcAuxLeafMapRecord(
	leaves map[input.HtlcIndex]input.HtlcAuxLeaf) HtlcAuxLeafMapRecord

NewHtlcAuxLeafMapRecord creates a new HtlcAuxLeafMapRecord record with the given HTLC aux leaves.

func (*HtlcAuxLeafMapRecord) Decode

func (l *HtlcAuxLeafMapRecord) Decode(r io.Reader) error

Decode deserializes the HtlcPartialSigsRecord from the given io.Reader.

func (*HtlcAuxLeafMapRecord) Encode

func (l *HtlcAuxLeafMapRecord) Encode(w io.Writer) error

Encode serializes the HtlcPartialSigsRecord to the given io.Writer.

func (*HtlcAuxLeafMapRecord) Record

func (l *HtlcAuxLeafMapRecord) Record() tlv.Record

Record creates a Record out of a HtlcAuxLeafMapRecord using the eHtlcAuxLeafMapRecord and dHtlcAuxLeafMapRecord functions.

NOTE: This is part of the tlv.RecordProducer interface.

type HtlcPartialSigsRecord

type HtlcPartialSigsRecord struct {
	HtlcPartialSigs []AssetSigListRecord
}

HtlcPartialSigsRecord is a record that represents a map of HTLC indices to partial signatures (with nonce).

func (*HtlcPartialSigsRecord) Decode

func (h *HtlcPartialSigsRecord) Decode(r io.Reader) error

Decode deserializes the HtlcPartialSigsRecord from the given io.Reader.

func (*HtlcPartialSigsRecord) Encode

func (h *HtlcPartialSigsRecord) Encode(w io.Writer) error

Encode serializes the HtlcPartialSigsRecord to the given io.Writer.

func (*HtlcPartialSigsRecord) Record

func (h *HtlcPartialSigsRecord) Record() tlv.Record

Record creates a Record out of a HtlcPartialSigsRecord using the eHtlcPartialSigsRecord and dHtlcPartialSigsRecord functions.

NOTE: This is part of the tlv.RecordProducer interface.

type HtlcRfqIDType

type HtlcRfqIDType = tlv.TlvType65538

HtlcRfqIDType is the type alias for the TLV type that is used to encode an RFQ id within the custom records of an HTLC record on the wire.

type HtlcSigsRecordType

type HtlcSigsRecordType = tlv.TlvType65537

HtlcSigsRecordType is a type alias for the TLV type that is used to encode the signatures of an HTLC record on the wire.

type OpenChannel

type OpenChannel struct {
	// FundedAssets is a list of asset outputs that was committed to the
	// funding output of a commitment.
	FundedAssets tlv.RecordT[tlv.TlvType0, AssetOutputListRecord]
}

OpenChannel is a record that represents the capacity information related to a commitment. This entails all the (asset_id, amount, proof) tuples and other information that we may need to be able to sign the TAP portion of the commitment transaction.

func DecodeOpenChannel

func DecodeOpenChannel(blob tlv.Blob) (*OpenChannel, error)

DecodeOpenChannel deserializes an OpenChannel from the given blob.

func NewOpenChannel

func NewOpenChannel(fundedAssets []*AssetOutput) *OpenChannel

NewOpenChannel creates a new OpenChannel record with the given funded assets.

func ReadOpenChannel

func ReadOpenChannel(r io.Reader, maxReadSize uint32) (*OpenChannel, error)

ReadOpenChannel reads the content of an OpenChannel struct from a reader.

func (*OpenChannel) Assets

func (o *OpenChannel) Assets() []*AssetOutput

Assets returns the list of asset outputs that are committed to in the OpenChannel struct.

func (*OpenChannel) Bytes

func (o *OpenChannel) Bytes() []byte

Bytes returns the serialized OpenChannel record.

func (*OpenChannel) Decode

func (o *OpenChannel) Decode(r io.Reader) error

Decode deserializes the OpenChannel from the given io.Reader.

func (*OpenChannel) Encode

func (o *OpenChannel) Encode(w io.Writer) error

Encode serializes the OpenChannel to the given io.Writer.

type ProofDeliveryAddrShutdownType

type ProofDeliveryAddrShutdownType = tlv.TlvType65542

ProofDeliveryAddrShutdownType is the type alias for the TLV type that is used to encode the proof delivery address of the shutdown record on the wire.

type ScriptKeyMap

type ScriptKeyMap map[asset.ID]btcec.PublicKey

ScriptKeyMap is a map of asset IDs to script keys.

func (*ScriptKeyMap) Record

func (s *ScriptKeyMap) Record() tlv.Record

Record creates a Record out of a ScriptKeyMap.

type ScriptKeysShutdownType

type ScriptKeysShutdownType = tlv.TlvType65541

ScriptKeysShutdownType is the type alias for the TLV type that is used to encode the script keys of the shutdown record on the wire.

type TapLeafRecord

type TapLeafRecord struct {
	Leaf txscript.TapLeaf
}

TapLeafRecord is a record that represents a TapLeaf.

func (*TapLeafRecord) Decode

func (l *TapLeafRecord) Decode(r io.Reader) error

Decode deserializes the TapLeafRecord from the given io.Reader.

func (*TapLeafRecord) Encode

func (l *TapLeafRecord) Encode(w io.Writer) error

Encode serializes the TapLeafRecord to the given io.Writer.

func (*TapLeafRecord) Record

func (l *TapLeafRecord) Record() tlv.Record

Record creates a Record out of a TapLeafRecord using the passed eTapLeafRecord and dTapLeafRecord functions.

NOTE: This is part of the tlv.RecordProducer interface.

type TxAssetInputProof

type TxAssetInputProof struct {
	// PendingChanID is the pending channel ID that was assigned to the
	// channel.
	PendingChanID tlv.RecordT[tlv.TlvType0, funding.PendingChanID]

	// AssetID is the ID of the asset that this output is associated with.
	AssetID tlv.RecordT[tlv.TlvType1, asset.ID]

	// Amount is the amount of the asset that this output represents.
	Amount tlv.RecordT[tlv.TlvType2, uint64]

	// Proof is the last transition proof that proves this output was
	// committed to in the Bitcoin transaction that anchors this asset
	// output.
	Proof tlv.RecordT[tlv.TlvType3, proof.Proof]
}

TxAssetInputProof is sent by the initiator of a channel funding request to prove to the upcoming responder that they are the owner of an asset input.

TODO(roasbeef): once we have fixed the asset ownership proof to sign a challenge value, we can use temp chan ID as the challenge.

func NewTxAssetInputProof

func NewTxAssetInputProof(pid funding.PendingChanID,
	p proof.Proof) *TxAssetInputProof

NewTxAssetInputProof creates a new TxAssetInputProof message.

func (*TxAssetInputProof) Amt

func (t *TxAssetInputProof) Amt() fn.Option[uint64]

Amt returns the amount of the asset that this output represents.

func (*TxAssetInputProof) Decode

func (t *TxAssetInputProof) Decode(r io.Reader, _ uint32) error

Decode reads the bytes stream and converts it to the object.

func (*TxAssetInputProof) Encode

func (t *TxAssetInputProof) Encode(w *bytes.Buffer, _ uint32) error

Encode converts object to the bytes stream and write it into the write buffer.

func (*TxAssetInputProof) FundingAssetID

func (t *TxAssetInputProof) FundingAssetID() fn.Option[asset.ID]

FundingAssetID returns the asset ID of the underlying asset.

func (*TxAssetInputProof) MsgType

func (t *TxAssetInputProof) MsgType() lnwire.MessageType

MsgType returns the type of the message.

func (*TxAssetInputProof) PID

PID returns the pending channel ID that was assigned to the channel.

type TxAssetOutputProof

type TxAssetOutputProof struct {
	// PendingChanID is the pending channel ID that was assigned to the
	// channel.
	PendingChanID tlv.RecordT[tlv.TlvType0, funding.PendingChanID]

	// AssetOutput is one of the funding UTXOs that'll be used in channel
	// funding.
	AssetOutput tlv.RecordT[tlv.TlvType1, asset.Asset]

	// Last indicates whether this is the last proof in the funding
	// process.
	Last tlv.RecordT[tlv.TlvType2, bool]
}

TxAssetOutputProof is sent by the initiator of the funding request *after* the inputs proofs. The proof contained in this message is the final signed asset funding output. Along with the input proofs, then the responder can verify the asset funding output witnesses in full.

func NewTxAssetOutputProof

func NewTxAssetOutputProof(pid funding.PendingChanID, a asset.Asset,
	last bool) *TxAssetOutputProof

NewTxAssetOutputProof creates a new TxAssetOutputProof message.

func (*TxAssetOutputProof) Amt

func (t *TxAssetOutputProof) Amt() fn.Option[uint64]

Amt returns the amount of the asset that this output represents.

func (*TxAssetOutputProof) Decode

func (t *TxAssetOutputProof) Decode(r io.Reader, _ uint32) error

Decode reads the bytes stream and converts it to the object.

func (*TxAssetOutputProof) Encode

func (t *TxAssetOutputProof) Encode(w *bytes.Buffer, _ uint32) error

Encode converts object to the bytes stream and write it into the write buffer.

func (*TxAssetOutputProof) MsgType

func (t *TxAssetOutputProof) MsgType() lnwire.MessageType

MsgType returns the type of the message.

func (*TxAssetOutputProof) PID

PID returns the pending channel ID that was assigned to the channel.

type VpktList

type VpktList struct {
	// Pkts is the list of vPkts.
	Pkts []*tappsbt.VPacket
}

VpktList is a record that represents a list of vPkts.

func NewVpktList

func NewVpktList(pkts []*tappsbt.VPacket) VpktList

NewVpktList creates a new VpktList record with the given list of vPkts.

func (*VpktList) Record

func (v *VpktList) Record() tlv.Record

Record returns a tlv.Record that represents the VpktList.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL