github.com/decred/dcrlnd@v0.7.6/lnwire/typed_delivery_addr.go (about) 1 package lnwire 2 3 import ( 4 "github.com/decred/dcrlnd/tlv" 5 ) 6 7 const ( 8 // DeliveryAddrType is the TLV record type for delivery addreses within 9 // the name space of the OpenChannel and AcceptChannel messages. 10 DeliveryAddrType = 0 11 12 // deliveryAddressMaxSize is the maximum expected size in bytes of a 13 // DeliveryAddress based on the types of scripts we know. 14 // Following are the known scripts and their sizes in bytes. 15 // - pay to witness script hash: 34 16 // - pay to pubkey hash: 25 17 // - pay to script hash: 22 18 // - pay to witness pubkey hash: 22. 19 deliveryAddressMaxSize = 34 20 ) 21 22 // DeliveryAddress is used to communicate the address to which funds from a 23 // closed channel should be sent. The address can be a p2wsh, p2pkh, p2sh or 24 // p2wpkh. 25 type DeliveryAddress []byte 26 27 // Record returns a TLV record that can be used to encode the delivery 28 // address within the ExtraData TLV stream. This was introduced in order to 29 // allow the OpenChannel/AcceptChannel messages to properly be extended with 30 // TLV types. 31 func (d *DeliveryAddress) Record() tlv.Record { 32 addrBytes := (*[]byte)(d) 33 34 return tlv.MakeDynamicRecord( 35 DeliveryAddrType, addrBytes, 36 func() uint64 { 37 return uint64(len(*addrBytes)) 38 }, 39 tlv.EVarBytes, tlv.DVarBytes, 40 ) 41 }