lnwire: add LeaseExpiry custom record for Open+AcceptChannel
This commit is contained in:
1 parent
6052a446dc
commit
6252563bc5
5 files changed
+119
-6
No files matched your search
+17
-2
@@ -135,6 +135,12 @@ type OpenChannel struct {
|
||||
// open.
|
||||
ChannelType *ChannelType
|
||||
|
||||
// LeaseExpiry represents the absolute expiration height of a channel
|
||||
// lease. This is a custom TLV record that will only apply when a leased
|
||||
// channel is being opened using the script enforced lease commitment
|
||||
// type.
|
||||
LeaseExpiry *LeaseExpiry
|
||||
|
||||
// ExtraData is the set of data that was appended to this message to
|
||||
// fill out the full maximum transport message size. These fields can
|
||||
// be used to specify optional data such as custom TLV fields.
|
||||
@@ -160,6 +166,9 @@ func (o *OpenChannel) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
if o.ChannelType != nil {
|
||||
recordProducers = append(recordProducers, o.ChannelType)
|
||||
}
|
||||
if o.LeaseExpiry != nil {
|
||||
recordProducers = append(recordProducers, o.LeaseExpiry)
|
||||
}
|
||||
err := EncodeMessageExtraData(&o.ExtraData, recordProducers...)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -282,9 +291,12 @@ func (o *OpenChannel) Decode(r io.Reader, pver uint32) error {
|
||||
|
||||
// Next we'll parse out the set of known records, keeping the raw tlv
|
||||
// bytes untouched to ensure we don't drop any bytes erroneously.
|
||||
var chanType ChannelType
|
||||
var (
|
||||
chanType ChannelType
|
||||
leaseExpiry LeaseExpiry
|
||||
)
|
||||
typeMap, err := tlvRecords.ExtractRecords(
|
||||
&o.UpfrontShutdownScript, &chanType,
|
||||
&o.UpfrontShutdownScript, &chanType, &leaseExpiry,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -294,6 +306,9 @@ func (o *OpenChannel) Decode(r io.Reader, pver uint32) error {
|
||||
if val, ok := typeMap[ChannelTypeRecordType]; ok && val == nil {
|
||||
o.ChannelType = &chanType
|
||||
}
|
||||
if val, ok := typeMap[LeaseExpiryRecordType]; ok && val == nil {
|
||||
o.LeaseExpiry = &leaseExpiry
|
||||
}
|
||||
|
||||
o.ExtraData = tlvRecords
|
||||
|
||||
|
||||
Reference in new issue
Block a user