mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-13 18:10:25 +02:00
lnwire: convert the delivery addr in [Open+Accept]Channel to a TLV type in ExtraData
In this commit, we convert the delivery address in the open and accept channel methods to be a TLV type. This works as an "empty" delivery address is encoded using a two zero bytes (uint16 length zero), and a tlv type of 0 is encoded in the same manner (byte for type, byte for zero length). This change allows us to easily extend these messages in the future, in a uniform manner. When decoding the message we snip the bytes from the read TLV data. Similarly, when encoding we concatenate the TLV record for the shutdown script with the rest of the TLV data.
This commit is contained in:
@@ -22,20 +22,6 @@ type Shutdown struct {
|
||||
ExtraData ExtraOpaqueData
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// 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.
|
||||
const deliveryAddressMaxSize = 34
|
||||
|
||||
// NewShutdown creates a new Shutdown message.
|
||||
func NewShutdown(cid ChannelID, addr DeliveryAddress) *Shutdown {
|
||||
return &Shutdown{
|
||||
|
Reference in New Issue
Block a user