You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
package lnwire |
|
|
|
import ( |
|
"github.com/lightningnetwork/lnd/tlv" |
|
) |
|
|
|
const ( |
|
// DeliveryAddrType is the TLV record type for delivery addreses within |
|
// the name space of the OpenChannel and AcceptChannel messages. |
|
DeliveryAddrType = 0 |
|
|
|
// deliveryAddressMaxSize is the maximum expected size in bytes of a |
|
// DeliveryAddress based on the types of scripts we know. |
|
// Following are the known scripts and their sizes in bytes. |
|
// - pay to witness script hash: 34 |
|
// - pay to pubkey hash: 25 |
|
// - pay to script hash: 22 |
|
// - pay to witness pubkey hash: 22. |
|
deliveryAddressMaxSize = 34 |
|
) |
|
|
|
// DeliveryAddress is used to communicate the address to which funds from a |
|
// closed channel should be sent. The address can be a p2wsh, p2pkh, p2sh or |
|
// p2wpkh. |
|
type DeliveryAddress []byte |
|
|
|
// NewRecord returns a TLV record that can be used to encode the delivery |
|
// address within the ExtraData TLV stream. This was intorudced in order to |
|
// allow the OpenChannel/AcceptChannel messages to properly be extended with |
|
// TLV types. |
|
func (d *DeliveryAddress) NewRecord() tlv.Record { |
|
addrBytes := (*[]byte)(d) |
|
|
|
return tlv.MakeDynamicRecord( |
|
DeliveryAddrType, addrBytes, |
|
func() uint64 { |
|
return uint64(len(*addrBytes)) |
|
}, |
|
tlv.EVarBytes, tlv.DVarBytes, |
|
) |
|
}
|
|
|